diff options
author | Thomas Schwinge <thomas@codesourcery.com> | 2013-05-26 16:21:10 +0200 |
---|---|---|
committer | Thomas Schwinge <thomas@codesourcery.com> | 2013-05-26 16:21:10 +0200 |
commit | d9e11d0c51182483d30760f3c66000a0e9b8c922 (patch) | |
tree | e1d147b2d9d270f8cec60e499bc5fd738144d4c2 /csu | |
parent | d5ce2d1c5dfae01688cad679b2fbd071e70a1f3a (diff) | |
parent | 9a079e270a9bec7e1fe28aeda63e07c1bb808d44 (diff) |
Merge branch 'baseline' into refs/top-bases/tschwinge/Roger_Whittaker
Conflicts:
sysdeps/mach/hurd/i386/init-first.c
Diffstat (limited to 'csu')
-rw-r--r-- | csu/libc-start.c | 19 | ||||
-rw-r--r-- | csu/libc-tls.c | 6 |
2 files changed, 20 insertions, 5 deletions
diff --git a/csu/libc-start.c b/csu/libc-start.c index 736f30c9c5..04b013b770 100644 --- a/csu/libc-start.c +++ b/csu/libc-start.c @@ -15,6 +15,7 @@ License along with the GNU C Library; if not, see <http://www.gnu.org/licenses/>. */ +#include <assert.h> #include <stdlib.h> #include <stdio.h> #include <unistd.h> @@ -151,7 +152,25 @@ LIBC_START_MAIN (int (*main) (int, char **, char ** MAIN_AUXVEC_DECL), } # endif _dl_aux_init (auxvec); + if (GL(dl_phdr) == NULL) # endif + { + /* 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. + So we can set up _dl_phdr and _dl_phnum even without any + information from auxv. */ + + extern const ElfW(Ehdr) __ehdr_start + __attribute__ ((weak, visibility ("hidden"))); + if (&__ehdr_start != NULL) + { + assert (__ehdr_start.e_phentsize == sizeof *GL(dl_phdr)); + GL(dl_phdr) = (const void *) &__ehdr_start + __ehdr_start.e_phoff; + GL(dl_phnum) = __ehdr_start.e_phnum; + } + } + # ifdef DL_SYSDEP_OSCHECK if (!__libc_multiple_libcs) { diff --git a/csu/libc-tls.c b/csu/libc-tls.c index 5fa39eb8d1..c37df67e6c 100644 --- a/csu/libc-tls.c +++ b/csu/libc-tls.c @@ -28,10 +28,6 @@ #error makefile bug, this file is for static only #endif -extern ElfW(Phdr) *_dl_phdr; -extern size_t _dl_phnum; - - dtv_t _dl_static_dtv[2 + TLS_SLOTINFO_SURPLUS]; @@ -118,7 +114,7 @@ __libc_setup_tls (size_t tcbsize, size_t tcbalign) size_t align = 0; size_t max_align = tcbalign; size_t tcb_offset; - ElfW(Phdr) *phdr; + const ElfW(Phdr) *phdr; /* Look through the TLS segment if there is any. */ if (_dl_phdr != NULL) |