From b25aaa867154306e0cfa6308e1a2b2dfbebb110a Mon Sep 17 00:00:00 2001 From: Peng Fan Date: Mon, 22 Jul 2013 00:36:24 +0800 Subject: Sparc testcase Signed-off-by: Peng Fan --- rtl-mdreloc-sparc.c | 6 ++++++ testcase/1.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++ testcase/2.c | 8 ++++++++ testcase/wscript | 11 +++++++++++ 4 files changed, 82 insertions(+) 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'], -- cgit v1.2.3