[1/1] aarch64/dl-machine.h: Fix load-address for prelink support
Commit Message
Fix load-address for prelink support in aarch64,
reference from x86_64.
Existing code always use compiled address, whereas it should
use compiled address for non-prelinked binaries and prelinked
address for prelinked binaries, which it can get from .GOT first entry.
Signed-off-by: Vaneet Narang <v.narang@samsung.com>
Signed-off-by: Maninder Singh <maninder1.s@samsung.com>
---
sysdeps/aarch64/dl-machine.h | 28 +++++-----------------------
1 files changed, 5 insertions(+), 23 deletions(-)
Comments
On 16 Oct 2015 15:02, Maninder Singh wrote:
> + return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic ();
paren around ElfW(Addr) aren't really needed
-mike
Mike Frysinger <vapier@gentoo.org> writes:
> On 16 Oct 2015 15:02, Maninder Singh wrote:
>> + return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic ();
>
> paren around ElfW(Addr) aren't really needed
It's a cast.
Andreas.
@@ -46,29 +46,11 @@ elf_machine_dynamic (void)
static inline ElfW(Addr) __attribute__ ((unused))
elf_machine_load_address (void)
{
- /* To figure out the load address we use the definition that for any symbol:
- dynamic_addr(symbol) = static_addr(symbol) + load_addr
-
- The choice of symbol is arbitrary. The static address we obtain
- by constructing a non GOT reference to the symbol, the dynamic
- address of the symbol we compute using adrp/add to compute the
- symbol's address relative to the PC.
- This depends on 32bit relocations being resolved at link time
- and that the static address fits in the 32bits. */
-
- ElfW(Addr) static_addr;
- ElfW(Addr) dynamic_addr;
-
- asm (" \n"
-" adrp %1, _dl_start; \n"
-" add %1, %1, #:lo12:_dl_start \n"
-" ldr %w0, 1f \n"
-" b 2f \n"
-"1: \n"
-" .word _dl_start \n"
-"2: \n"
- : "=r" (static_addr), "=r" (dynamic_addr));
- return dynamic_addr - static_addr;
+ /* Compute the difference between the runtime address of _DYNAMIC as seen
+ by an IP-relative reference, and the link-time address found in the
+ special unrelocated first GOT entry. */
+ extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
+ return (ElfW(Addr)) &_DYNAMIC - elf_machine_dynamic ();
}
/* Set up the loaded object described by L so its unrelocated PLT