mirror of
https://sourceware.org/git/glibc.git
synced 2024-12-12 06:10:10 +00:00
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>
(cherry picked from commit 302247c891
)
This commit is contained in:
parent
6056776143
commit
ec38ea9597
@ -171,9 +171,6 @@
|
||||
/* Define if gcc supports attribute ifunc. */
|
||||
#undef HAVE_GCC_IFUNC
|
||||
|
||||
/* Define if the linker defines __ehdr_start. */
|
||||
#undef HAVE_EHDR_START
|
||||
|
||||
#define WANT_FLOAT128 0
|
||||
|
||||
/*
|
||||
|
52
configure
vendored
52
configure
vendored
@ -6569,58 +6569,6 @@ if test $libc_cv_predef_fortify_source = yes; then
|
||||
fi
|
||||
|
||||
|
||||
# Some linkers on some architectures support __ehdr_start but with
|
||||
# bugs. Make sure usage of it does not create relocations in the
|
||||
# output (as the linker should resolve them all for us).
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the linker provides working __ehdr_start" >&5
|
||||
$as_echo_n "checking whether the linker provides working __ehdr_start... " >&6; }
|
||||
if ${libc_cv_ehdr_start+:} false; then :
|
||||
$as_echo_n "(cached) " >&6
|
||||
else
|
||||
|
||||
old_CFLAGS="$CFLAGS"
|
||||
old_LDFLAGS="$LDFLAGS"
|
||||
old_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS -fPIC"
|
||||
LDFLAGS="$LDFLAGS -nostdlib -nostartfiles -shared $no_ssp"
|
||||
LIBS=
|
||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||
/* end confdefs.h. */
|
||||
|
||||
typedef struct {
|
||||
char foo;
|
||||
long val;
|
||||
} Ehdr;
|
||||
extern const Ehdr __ehdr_start __attribute__ ((visibility ("hidden")));
|
||||
long ehdr (void) { return __ehdr_start.val; }
|
||||
|
||||
_ACEOF
|
||||
if ac_fn_c_try_link "$LINENO"; then :
|
||||
if $READELF -r conftest | grep -F __ehdr_start >/dev/null; then
|
||||
libc_cv_ehdr_start=broken
|
||||
else
|
||||
libc_cv_ehdr_start=yes
|
||||
fi
|
||||
else
|
||||
libc_cv_ehdr_start=no
|
||||
fi
|
||||
rm -f core conftest.err conftest.$ac_objext \
|
||||
conftest$ac_exeext conftest.$ac_ext
|
||||
CFLAGS="$old_CFLAGS"
|
||||
LDFLAGS="$old_LDFLAGS"
|
||||
LIBS="$old_LIBS"
|
||||
|
||||
fi
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ehdr_start" >&5
|
||||
$as_echo "$libc_cv_ehdr_start" >&6; }
|
||||
if test "$libc_cv_ehdr_start" = yes; then
|
||||
$as_echo "#define HAVE_EHDR_START 1" >>confdefs.h
|
||||
|
||||
elif test "$libc_cv_ehdr_start" = broken; then
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: linker is broken -- you should upgrade" >&5
|
||||
$as_echo "$as_me: WARNING: linker is broken -- you should upgrade" >&2;}
|
||||
fi
|
||||
|
||||
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __builtin_trap with no external dependencies" >&5
|
||||
$as_echo_n "checking for __builtin_trap with no external dependencies... " >&6; }
|
||||
if ${libc_cv_builtin_trap+:} false; then :
|
||||
|
34
configure.ac
34
configure.ac
@ -1665,40 +1665,6 @@ if test $libc_cv_predef_fortify_source = yes; then
|
||||
fi
|
||||
AC_SUBST(CPPUNDEFS)
|
||||
|
||||
# Some linkers on some architectures support __ehdr_start but with
|
||||
# bugs. Make sure usage of it does not create relocations in the
|
||||
# output (as the linker should resolve them all for us).
|
||||
AC_CACHE_CHECK([whether the linker provides working __ehdr_start],
|
||||
libc_cv_ehdr_start, [
|
||||
old_CFLAGS="$CFLAGS"
|
||||
old_LDFLAGS="$LDFLAGS"
|
||||
old_LIBS="$LIBS"
|
||||
CFLAGS="$CFLAGS -fPIC"
|
||||
LDFLAGS="$LDFLAGS -nostdlib -nostartfiles -shared $no_ssp"
|
||||
LIBS=
|
||||
AC_LINK_IFELSE([AC_LANG_SOURCE([
|
||||
typedef struct {
|
||||
char foo;
|
||||
long val;
|
||||
} Ehdr;
|
||||
extern const Ehdr __ehdr_start __attribute__ ((visibility ("hidden")));
|
||||
long ehdr (void) { return __ehdr_start.val; }
|
||||
])],
|
||||
[if $READELF -r conftest | grep -F __ehdr_start >/dev/null; then
|
||||
libc_cv_ehdr_start=broken
|
||||
else
|
||||
libc_cv_ehdr_start=yes
|
||||
fi], [libc_cv_ehdr_start=no])
|
||||
CFLAGS="$old_CFLAGS"
|
||||
LDFLAGS="$old_LDFLAGS"
|
||||
LIBS="$old_LIBS"
|
||||
])
|
||||
if test "$libc_cv_ehdr_start" = yes; then
|
||||
AC_DEFINE([HAVE_EHDR_START])
|
||||
elif test "$libc_cv_ehdr_start" = broken; then
|
||||
AC_MSG_WARN([linker is broken -- you should upgrade])
|
||||
fi
|
||||
|
||||
AC_CACHE_CHECK(for __builtin_trap with no external dependencies,
|
||||
libc_cv_builtin_trap, [dnl
|
||||
libc_cv_builtin_trap=no
|
||||
|
13
elf/rtld.c
13
elf/rtld.c
@ -1385,21 +1385,16 @@ of this helper program; chances are you did not intend to run this program.\n\
|
||||
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)));
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user