[PATCH] libdl/arm: Add support for ARM trampolines

chrisj at rtems.org chrisj at rtems.org
Wed Jul 31 09:52:58 UTC 2019


From: Chris Johns <chrisj at rtems.org>

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;
 }
-- 
2.19.1



More information about the devel mailing list