}
-/* Return the link-time address of _DYNAMIC. Conveniently, this is the
- first element of the GOT. This must be inlined in a function which
- uses global data. */
-
+/* Return the run-time load address of the shared object. */
static inline Elf32_Addr
-elf_machine_dynamic (void)
+elf_machine_load_address (void)
{
- register Elf32_Addr *got;
-
- __asm__( " bras %0,2f\n"
- "1: .long _GLOBAL_OFFSET_TABLE_-1b\n"
- "2: al %0,0(%0)"
- : "=&a" (got) : : "0" );
-
- return *got;
+ /* Starting from binutils-2.23, the linker will define the magic symbol
+ __ehdr_start to point to our own ELF header. */
+ extern const ElfW(Ehdr) __ehdr_start attribute_hidden;
+ return (ElfW(Addr)) &__ehdr_start;
}
-
-/* Return the run-time load address of the shared object. */
+/* Return the link-time address of _DYNAMIC. */
static inline Elf32_Addr
-elf_machine_load_address (void)
+elf_machine_dynamic (void)
{
- Elf32_Addr addr;
-
- __asm__( " bras 1,2f\n"
- "1: .long _GLOBAL_OFFSET_TABLE_ - 1b\n"
- " .long (_dl_start - 1b - 0x80000000) & 0x00000000ffffffff\n"
- "2: l %0,4(1)\n"
- " ar %0,1\n"
- " al 1,0(1)\n"
- " sl %0,_dl_start@GOT(1)"
- : "=&d" (addr) : : "1" );
- return addr;
+ extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
+ return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
}
/* Set up the loaded object described by L so its unrelocated PLT
&& ehdr->e_ident[EI_CLASS] == ELFCLASS64;
}
-/* Return the link-time address of _DYNAMIC. Conveniently, this is the
- first element of the GOT. This must be inlined in a function which
- uses global data. */
-
+/* Return the run-time load address of the shared object. */
static inline Elf64_Addr
-elf_machine_dynamic (void)
+elf_machine_load_address (void)
{
- register Elf64_Addr *got;
-
- __asm__ ( " larl %0,_GLOBAL_OFFSET_TABLE_\n"
- : "=&a" (got) : : "0" );
-
- return *got;
+ /* Starting from binutils-2.23, the linker will define the magic symbol
+ __ehdr_start to point to our own ELF header. */
+ extern const ElfW(Ehdr) __ehdr_start attribute_hidden;
+ return (ElfW(Addr)) &__ehdr_start;
}
-/* Return the run-time load address of the shared object. */
+/* Return the link-time address of _DYNAMIC. */
static inline Elf64_Addr
-elf_machine_load_address (void)
+elf_machine_dynamic (void)
{
- Elf64_Addr addr;
-
- __asm__( " larl %0,_dl_start\n"
- " larl 1,_GLOBAL_OFFSET_TABLE_\n"
- " lghi 2,_dl_start@GOT\n"
- " slg %0,0(2,1)"
- : "=&d" (addr) : : "1", "2" );
- return addr;
+ extern ElfW(Dyn) _DYNAMIC[] attribute_hidden;
+ return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
}
/* Set up the loaded object described by L so its unrelocated PLT