about summary refs log tree commit diff
path: root/elf
diff options
context:
space:
mode:
authorFangrui Song <maskray@google.com>2021-08-10 11:04:56 -0700
committerFangrui Song <maskray@google.com>2021-08-10 11:04:56 -0700
commit302247c89121e8d4c7629e589edbb4974fff6edb (patch)
treed0af2abbabc149fac1e598639652b60ea5221c8a /elf
parent13710e7e6af6c8965cc9a63a0660cb4ce1966557 (diff)
downloadglibc-302247c89121e8d4c7629e589edbb4974fff6edb.tar.gz
glibc-302247c89121e8d4c7629e589edbb4974fff6edb.tar.xz
glibc-302247c89121e8d4c7629e589edbb4974fff6edb.zip
elf: Unconditionally use __ehdr_start
We can consider __ehdr_start (from binutils 2.23 onwards)
unconditionally supported, since configure.ac requires binutils>=2.25.

The configure.ac check is related to an ia64 bug fixed by binutils 2.24.
See https://sourceware.org/pipermail/libc-alpha/2014-August/053503.html

Tested on x86_64-linux-gnu. Tested build-many-glibcs.py with
aarch64-linux-gnu and s390x-linux-gnu.

Reviewed-by: Szabolcs Nagy <szabolcs.nagy@arm.com>
Diffstat (limited to 'elf')
-rw-r--r--elf/rtld.c13
1 files changed, 4 insertions, 9 deletions
diff --git a/elf/rtld.c b/elf/rtld.c
index d733359eaf..878e6480f4 100644
--- a/elf/rtld.c
+++ b/elf/rtld.c
@@ -1684,21 +1684,16 @@ dl_main (const ElfW(Phdr) *phdr,
   if (GLRO(dl_use_load_bias) == (ElfW(Addr)) -2)
     GLRO(dl_use_load_bias) = main_map->l_addr == 0 ? -1 : 0;
 
-  /* Set up the program header information for the dynamic linker
-     itself.  It is needed in the dl_iterate_phdr callbacks.  */
-  const ElfW(Ehdr) *rtld_ehdr;
-
   /* Starting from binutils-2.23, the linker will define the magic symbol
      __ehdr_start to point to our own ELF header if it is visible in a
      segment that also includes the phdrs.  If that's not available, we use
      the old method that assumes the beginning of the file is part of the
      lowest-addressed PT_LOAD segment.  */
-#ifdef HAVE_EHDR_START
   extern const ElfW(Ehdr) __ehdr_start __attribute__ ((visibility ("hidden")));
-  rtld_ehdr = &__ehdr_start;
-#else
-  rtld_ehdr = (void *) GL(dl_rtld_map).l_map_start;
-#endif
+
+  /* Set up the program header information for the dynamic linker
+     itself.  It is needed in the dl_iterate_phdr callbacks.  */
+  const ElfW(Ehdr) *rtld_ehdr = &__ehdr_start;
   assert (rtld_ehdr->e_ehsize == sizeof *rtld_ehdr);
   assert (rtld_ehdr->e_phentsize == sizeof (ElfW(Phdr)));