summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeng Fan <van.freenix@gmail.com>2013-07-22 00:36:24 +0800
committerPeng Fan <van.freenix@gmail.com>2013-07-24 15:47:59 +0800
commitb25aaa867154306e0cfa6308e1a2b2dfbebb110a (patch)
tree211992ec5e74f4fe81e9b8c56a843f6be0c60469
parentf21aa4dbcab097e6972f2a50461b96312c269084 (diff)
Sparc testcase
Signed-off-by: Peng Fan <van.freenix@gmail.com>
-rw-r--r--rtl-mdreloc-sparc.c6
-rw-r--r--testcase/1.c57
-rw-r--r--testcase/2.c8
-rw-r--r--testcase/wscript11
4 files changed, 82 insertions, 0 deletions
diff --git a/rtl-mdreloc-sparc.c b/rtl-mdreloc-sparc.c
index 268d4bf..a96a5ae 100644
--- a/rtl-mdreloc-sparc.c
+++ b/rtl-mdreloc-sparc.c
@@ -97,6 +97,7 @@ static const uint32_t reloc_target_flags[] = {
_RF_S|_RF_A| _RF_U|_RF_SZ(32) | _RF_RS(0), /* UA_32 */
};
+#define NOT_CURRENTLY_USED_BUT_MAYBE_USEFUL
#ifdef NOT_CURRENTLY_USED_BUT_MAYBE_USEFUL
static const char *reloc_names[] = {
"NONE", "RELOC_8", "RELOC_16", "RELOC_32", "DISP_8",
@@ -244,6 +245,11 @@ rtems_rtl_elf_relocate_rela (const rtems_rtl_obj_t* obj,
*where |= value;
}
+ if (rtems_rtl_trace (RTEMS_RTL_TRACE_RELOC))
+ printf ("rtl: %s %p @ %p in %s\n",
+ reloc_names[type], (void *)*where, where, rtems_rtl_obj_oname (obj));
+
+
return true;
}
diff --git a/testcase/1.c b/testcase/1.c
index bfb8d24..91cae0f 100644
--- a/testcase/1.c
+++ b/testcase/1.c
@@ -20,6 +20,15 @@ void hello(int arg)
case 15:
printf("PPC ADDR14 'beqa cr7, hello' jump\n");
break;
+#elif defined (__sparc__)
+ case 22:
+ printf("SPARC WDISP22 'b hello'\n");
+ break;
+ case 13:
+ printf("SPARC 13 'mov hello, %%l4'\n");
+ break;
+#else
+
#endif
default:
printf("no arg in hello\n");
@@ -169,6 +178,54 @@ int rtems(int argc, char **argv)
"nop\n\t"
);
+#elif defined (__sparc__)
+ __asm__ volatile (
+ "sethi %%hi(1f), %%l5\n\t"
+ "ld [%%l5 + %%lo(1f)], %%l4\n\t"
+ "mov 32, %%l5\n\t"
+ "st %%l5, [%%l4]\n\t"
+ "b 2f\n\t"
+ "nop\n\t"
+ "nop\n\t"
+ "1:\n\t"
+ ".word global\n\t" /* R_SPARC_32 */
+ "2:\n\t"
+ "nop\n\t"
+ "nop\n\t" : : : "l4", "l5");
+
+ if (global == 32)
+ printf("R_SPARC_32: '.word global' pass\n");
+
+ __asm__ volatile (
+ "mov %%o0, %%l4\n\t"
+ "mov 22, %%o0\n\t"
+ "sethi %%hi(3f), %%o7\n\t"
+ "or %%o7, %%lo(3f), %%o7\n\t"
+ "b hello\n\t" /* R_SPARC_WDISP22 */
+ "nop\n\t"
+ "3:\t\n"
+ "nop\n\t"
+ "mov %%l4, %%o0\n\t"
+ "nop\n\t" : : : "o0", "o7"
+ );
+
+ /* R_SPARC_13: Overflow are not checked, Thus
+ * should use assemble language to handle this
+ * to avoid overflow.
+ */
+ __asm__ volatile (
+ "mov hello, %%l4\n\t"
+ "and %%l4, 0x3ff, %%l4\n\t"
+ "sethi %%hi(hello), %%l5\n\t"
+ "or %%l4, %%l5, %%l4\n\t"
+ "mov %%o0, %%l5\n\t"
+ "mov 13, %%o0\n\t"
+ "call hello\n\t"
+ "nop\n\t"
+ "mov %%l5, %%o0\n\t"
+ "nop\n\t": : :
+ );
+
#else
/* other archs */
#endif
diff --git a/testcase/2.c b/testcase/2.c
index cac20fa..84efea1 100644
--- a/testcase/2.c
+++ b/testcase/2.c
@@ -9,6 +9,14 @@ void tst_pc16(void)
}
#endif
+#if defined (__sparc__)
+void tst_wdisp(void)
+{
+ printf("R_SPARC_DISP22: pass\n");
+ return;
+}
+#endif
+
int test(int argc, char **argv)
{
global = 1; //inter-module data access
diff --git a/testcase/wscript b/testcase/wscript
index 8ece186..2064bb6 100644
--- a/testcase/wscript
+++ b/testcase/wscript
@@ -50,6 +50,17 @@ def build(bld):
'--entry', 'my_main', '-a', 'mips'],
source = ['1.c', '2.c'])
+ elif arch == 'sparc':
+ bld(target = 'test.rap',
+ features = 'c rap',
+ xxxx = 'hello',
+
+ cflags = '-fno-common',
+
+ rtems_linkflags = ['--base', 'rtld.prelink',
+ '--entry', 'my_main'],
+ source = ['1.c', '2.c'])
+
bld(target = '../test.rap',
source = ['test.rap'],