From 8c66acc8dcb4d459c1f61f2d5f62a23d14e3af46 Mon Sep 17 00:00:00 2001 From: Chris Johns Date: Tue, 30 Jul 2019 20:43:15 +1000 Subject: libdl/arm: Add support for ARM trampolines Closes #3776 --- cpukit/libdl/rtl-mdreloc-arm.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/cpukit/libdl/rtl-mdreloc-arm.c b/cpukit/libdl/rtl-mdreloc-arm.c index 9e5d66ee1f..4950dcdab1 100644 --- a/cpukit/libdl/rtl-mdreloc-arm.c +++ b/cpukit/libdl/rtl-mdreloc-arm.c @@ -78,10 +78,27 @@ set_veneer(void* tramopline, Elf_Addr target) /* * http://shell-storm.org/online/Online-Assembler-and-Disassembler/ * - * ldr.w pc, [pc] + * Thumb mode: + * ldr.w pc, [pc] + * + * ARM mode: + * ldr pc, [pc, #-4] + * */ uint32_t* tramp = (uint32_t*) tramopline; +#if defined(__thumb__) + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ *tramp++ = 0xf000f8df; + #else + *tramp++ = 0xf8dff000; /* not tested */ + #endif +#else + #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ + *tramp++ = 0xe51ff004; + #else + *tramp++ = 0xe51ff004; /* not tested */ + #endif +#endif *tramp++ = (uint32_t) target; return tramp; } -- cgit v1.2.3