From 288f7d79fe2dcc8e62c539f57b25d7662a2cd5ff Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 28 Mar 2013 16:15:48 -0700 Subject: Use __ehdr_start, if available, as fallback for AT_PHDR. --- sysdeps/mach/hurd/i386/init-first.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'sysdeps/mach/hurd/i386') diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c index 59253db539..fc3330c1fc 100644 --- a/sysdeps/mach/hurd/i386/init-first.c +++ b/sysdeps/mach/hurd/i386/init-first.c @@ -117,14 +117,20 @@ init1 (int argc, char *arg0, ...) if ((void *) d == argv[0]) { #ifndef SHARED - /* We may need to see our own phdrs, e.g. for TLS setup. - Try the usual kludge to find the headers without help from - the exec server. */ - extern const void _start; - const ElfW(Ehdr) *const ehdr = &_start; - _dl_phdr = (const void *) ehdr + ehdr->e_phoff; - _dl_phnum = ehdr->e_phnum; - assert (ehdr->e_phentsize == sizeof (ElfW(Phdr))); + /* With a new enough linker (binutils-2.23 or better), + the magic __ehdr_start symbol will be available and + __libc_start_main will have done this that way already. */ + if (_dl_phdr == NULL) + { + /* We may need to see our own phdrs, e.g. for TLS setup. + Try the usual kludge to find the headers without help from + the exec server. */ + extern const void _start; + const ElfW(Ehdr) *const ehdr = &_start; + _dl_phdr = (const void *) ehdr + ehdr->e_phoff; + _dl_phnum = ehdr->e_phnum; + assert (ehdr->e_phentsize == sizeof (ElfW(Phdr))); + } #endif return; } -- cgit 1.4.1