summaryrefslogtreecommitdiff
path: root/csu
diff options
context:
space:
mode:
authorThomas Schwinge <thomas@codesourcery.com>2013-05-26 16:07:10 +0200
committerThomas Schwinge <thomas@codesourcery.com>2013-05-26 16:07:10 +0200
commit12ccc71de7e6f111cb57ddb635847d704689ae4e (patch)
tree039aaee06dfaa25138e82ba33bb5d745f5a55057 /csu
parentcbb9d63bde7e060a2ae9cdf17a913a6e3f44446f (diff)
parent9a079e270a9bec7e1fe28aeda63e07c1bb808d44 (diff)
Merge commit 'refs/top-bases/t/tls' into t/tls
Conflicts: sysdeps/mach/hurd/i386/init-first.c Address glibc commits 3d3436ae68a907f656a07604eb7e10a50e1c8f85, dc0a02638583d8e7f7e1cc72643d1b26ec6042fd, 288f7d79fe2dcc8e62c539f57b25d7662a2cd5ff.
Diffstat (limited to 'csu')
-rw-r--r--csu/libc-start.c19
-rw-r--r--csu/libc-tls.c6
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)