[RTEMS Project] #2767: ARM PREL31 and TARGET2 relocation support

RTEMS trac trac at rtems.org
Fri Jul 29 05:11:15 UTC 2016


#2767: ARM PREL31 and TARGET2 relocation support
-------------------------+--------------------
 Reporter:  pggauvin     |      Owner:  chrisj
     Type:  enhancement  |     Status:  new
 Priority:  normal       |  Milestone:
Component:  libdl        |    Version:  4.11
 Severity:  normal       |   Keywords:
-------------------------+--------------------
 The PREL31 and TARGET2 relocation types are used in exception tables on
 ARM. `dlopen` on C++ code often fails because the loader does not
 recognize them. From what I've seen, PREL31 relocations are generally
 present in C++ object files, but if exceptions are used both will be
 present.

 Attached is a patch which implements them based on the references below.
 My understanding is not complete, however, so it may be incorrect. A test
 case which generates these relocations and uses libdl to load them is also
 attached. I have not been able to verify that the patch functions
 correctly because I am not sure how to trigger an operation that would
 fail if PREL31/TARGET2 relocations were not handled correctly.

 Something to note about the patch; PREL31 is not present in 64 bit ARM, so
 it may be possible to optimize the sign extension code.

 Expected outputs (with the patch applied to RTEMS):
 {{{
 $ qemu-system-arm -kernel libdl-prel31-target2-test.exe -m 256M -M xilinx-
 zynq-a9 -serial null -serial mon:stdio -nographic -no-reboot
 TEST BEGIN
 terminate called after throwing an instance of 'std::runtime_error'
   what():  func threw
 }}}
 {{{
 $ qemu-system-arm -kernel libdl-prel31-target2-test-builtin.exe -m 256M -M
 xilinx-zynq-a9 -serial null -serial mon:stdio -nographic -no-reboot
 TEST BEGIN
 func: Caught exception, e.what: "func threw"
 TEST END
 }}}
 Expected relocations:
 {{{
 $ arm-rtems4.11-objdump -r libfoo.o |env grep -e 'TARGET2\|PREL31' -a2
 RELOCATION RECORDS FOR [.ARM.extab]:
 OFFSET   TYPE              VALUE
 00000000 R_ARM_PREL31      __gxx_personality_v0
 00000040 R_ARM_TARGET2     _ZTISt13runtime_error


 RELOCATION RECORDS FOR [.ARM.exidx]:
 OFFSET   TYPE              VALUE
 00000000 R_ARM_PREL31      .text
 00000004 R_ARM_PREL31      .ARM.extab


 }}}

 References:
 - ELF for the ARM Architecture
 - Exception Handling ABI for the ARM Architecture

 Development Environment:
 - '''RTEMS Version''': 4.11 (Branch "4.11", commit
 3f72dda6ee518d3ea04341ad4df079ecb1895ef7) with the dlerror patches from
 #2747, and the object cache disable patch from #2754
 - '''System Type''': ARM Cortex-A9, xilinx_zynq_a9_qemu BSP
 - '''GCC Version''':

     arm-rtems4.11-gcc (GCC) 4.9.3 20150626 (RTEMS 4.11, RSB
 1675a733536d1aec2020011e5e522497a442561a (HEAD, origin/4.11, 4.11), Newlib
 2.2.0.20150423)
 - '''RTEMS Configure Options''':

     --target=arm-rtems4.11 --enable-rtemsbsp="xilinx_zynq_a9_qemu
 xilinx_zynq_zedboard xilinx_zynq_csp_cots xilinx_zynq_csp_hybrid"
 --enable-tests=samples --enable-posix
 --prefix=$HOME/development/rtems/4.11 --disable-networking

--
Ticket URL: <http://devel.rtems.org/ticket/2767>
RTEMS Project <http://www.rtems.org/>
RTEMS Project


More information about the bugs mailing list