aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2021-08-17 10:45:57 -0700
committerFangrui Song <maskray@google.com>2021-08-17 10:45:57 -0700
commitb37b75d269883a2c553bb7019a813094eb4e2dd1 (patch)
tree31b632b013008d61958678ee964fe2795db7f50f /sysdeps
parent33c50ef42878b07ee6ead8b3f1a81d8c2c74697c (diff)
downloadglibc-b37b75d269883a2c553bb7019a813094eb4e2dd1.tar
glibc-b37b75d269883a2c553bb7019a813094eb4e2dd1.tar.gz
glibc-b37b75d269883a2c553bb7019a813094eb4e2dd1.tar.bz2
glibc-b37b75d269883a2c553bb7019a813094eb4e2dd1.zip
x86_64: Simplify elf_machine_{load_address,dynamic}
and drop reliance on _GLOBAL_OFFSET_TABLE_[0] being the link-time address of _DYNAMIC. &__ehdr_start is a better way to get the load address. Reviewed-by: H.J. Lu <hjl.tools@gmail.com>
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/x86_64/dl-machine.h21
1 files changed, 7 insertions, 14 deletions
diff --git a/sysdeps/x86_64/dl-machine.h b/sysdeps/x86_64/dl-machine.h
index a8596aa3fa..ceee50734e 100644
--- a/sysdeps/x86_64/dl-machine.h
+++ b/sysdeps/x86_64/dl-machine.h
@@ -35,27 +35,20 @@ elf_machine_matches_host (const ElfW(Ehdr) *ehdr)
}
-/* 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 ElfW(Addr) __attribute__ ((unused))
-elf_machine_dynamic (void)
+elf_machine_load_address (void)
{
- /* This produces an IP-relative reloc which is resolved at link time. */
- extern const ElfW(Addr) _GLOBAL_OFFSET_TABLE_[] attribute_hidden;
- return _GLOBAL_OFFSET_TABLE_[0];
+ 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 ElfW(Addr) __attribute__ ((unused))
-elf_machine_load_address (void)
+elf_machine_dynamic (void)
{
- /* 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 ();
+ return (ElfW(Addr)) _DYNAMIC - elf_machine_load_address ();
}
/* Set up the loaded object described by L so its unrelocated PLT