[AARCH64] Rewrite elf_machine_load_address using _DYNAMIC symbol
commita68ba2f3cd3cbe32c1f31e13c20ed13487727b32
authorSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 18 Oct 2017 16:26:23 +0000 (18 17:26 +0100)
committerSzabolcs Nagy <szabolcs.nagy@arm.com>
Wed, 18 Oct 2017 16:35:16 +0000 (18 17:35 +0100)
tree41490ad1d5dd26a7fd4d4b0990c560158a3e9a44
parent346729f66b905344e4ce24045489d189e5b4a9b8
[AARCH64] Rewrite elf_machine_load_address using _DYNAMIC symbol

This patch rewrites aarch64 elf_machine_load_address to use special _DYNAMIC
symbol instead of _dl_start.

The static address of _DYNAMIC symbol is stored in the first GOT entry.
Here is the change which makes this solution work (part of binutils 2.24):
https://sourceware.org/ml/binutils/2013-06/msg00248.html

i386, x86_64 targets use the same method to do this as well.

The original implementation relies on a trick that R_AARCH64_ABS32 relocation
being resolved at link time and the static address fits in the 32bits.
However, in LP64, normally, the address is defined to be 64 bit.

Here is the C version one which should be portable in all cases.

* sysdeps/aarch64/dl-machine.h (elf_machine_load_address): Use
_DYNAMIC symbol to calculate load address.
ChangeLog
sysdeps/aarch64/dl-machine.h