configure.ac: Check for elf_getshdrstrndx or elf_getshstrndx separately.

toplevel:
	* configure.ac: Check for elf_getshdrstrndx or elf_getshstrndx
	separately.
	* configure: Regenerate.

	gcc:
	* configure.ac: Check for elf_getshdrstrndx or elf_getshstrndx
	flavor.
	* configure: Regenerate.
	* config.in: Regenerate.
	* doc/install.texi (Prerequisites): Document that Solaris 2 libelf
	works.

	gcc/lto:
	* lto-elf.c [!HAVE_ELF_GETSHDRSTRNDX] (elf_getshdrstrndx): New
	function.

From-SVN: r158423
This commit is contained in:
Rainer Orth 2010-04-16 13:45:25 +00:00 committed by Rainer Orth
parent bc9c331d43
commit 8ccb78f2d0
10 changed files with 202 additions and 5 deletions

View File

@ -1,3 +1,9 @@
2010-04-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* configure.ac: Check for elf_getshdrstrndx or elf_getshstrndx
separately.
* configure: Regenerate.
2010-04-16 Kevin Williams <kevin.williams@inria.fr> 2010-04-16 Kevin Williams <kevin.williams@inria.fr>
* MAINTAINERS (Write After Approval): Add myself. * MAINTAINERS (Write After Approval): Add myself.

56
configure vendored
View File

@ -6574,7 +6574,6 @@ main ()
elf_nextscn (0, 0); elf_nextscn (0, 0);
elf_strptr (0, 0, 0); elf_strptr (0, 0, 0);
elf_getident (0, 0); elf_getident (0, 0);
elf_getshdrstrndx (0, 0);
elf_begin (0, 0, 0); elf_begin (0, 0, 0);
elf_ndxscn (0); elf_ndxscn (0);
elf_end (0); elf_end (0);
@ -6594,6 +6593,61 @@ fi
rm -f core conftest.err conftest.$ac_objext \ rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext conftest$ac_exeext conftest.$ac_ext
# Check for elf_getshdrstrndx or elf_getshstrndx. The latter's flavor
# is determined in gcc/configure.ac.
if test x"$enable_lto" = x"yes" ; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_getshdrstrndx" >&5
$as_echo_n "checking for elf_getshdrstrndx... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <libelf.h>
int
main ()
{
elf_getshdrstrndx (0, 0);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; };
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; };
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for elf_getshstrndx" >&5
$as_echo_n "checking for elf_getshstrndx... " >&6; }
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <libelf.h>
int
main ()
{
elf_getshstrndx (0, 0);
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; };
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }; enable_lto=no; libelflibs= ; libelfinc=
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
fi
# If we couldn't enable LTO and the user forced it, emit an error. # If we couldn't enable LTO and the user forced it, emit an error.
if test x"$enable_lto" = x"no" \ if test x"$enable_lto" = x"no" \
&& test x"$default_enable_lto" != x"yes" ; then && test x"$default_enable_lto" != x"yes" ; then

View File

@ -1735,7 +1735,6 @@ if test x"$enable_lto" = x"yes" ; then
elf_nextscn (0, 0); elf_nextscn (0, 0);
elf_strptr (0, 0, 0); elf_strptr (0, 0, 0);
elf_getident (0, 0); elf_getident (0, 0);
elf_getshdrstrndx (0, 0);
elf_begin (0, 0, 0); elf_begin (0, 0, 0);
elf_ndxscn (0); elf_ndxscn (0);
elf_end (0); elf_end (0);
@ -1744,6 +1743,27 @@ if test x"$enable_lto" = x"yes" ; then
[AC_MSG_RESULT([no]); enable_lto=no; libelflibs= ; libelfinc= ] [AC_MSG_RESULT([no]); enable_lto=no; libelflibs= ; libelfinc= ]
) )
# Check for elf_getshdrstrndx or elf_getshstrndx. The latter's flavor
# is determined in gcc/configure.ac.
if test x"$enable_lto" = x"yes" ; then
AC_MSG_CHECKING([for elf_getshdrstrndx])
AC_TRY_LINK(
[#include <libelf.h>],[
elf_getshdrstrndx (0, 0);
],
[AC_MSG_RESULT([yes]);],
[AC_MSG_RESULT([no]);
AC_MSG_CHECKING([for elf_getshstrndx])
AC_TRY_LINK(
[#include <libelf.h>],[
elf_getshstrndx (0, 0);
],
[AC_MSG_RESULT([yes]);],
[AC_MSG_RESULT([no]); enable_lto=no; libelflibs= ; libelfinc= ]
)]
)
fi
# If we couldn't enable LTO and the user forced it, emit an error. # If we couldn't enable LTO and the user forced it, emit an error.
if test x"$enable_lto" = x"no" \ if test x"$enable_lto" = x"no" \
&& test x"$default_enable_lto" != x"yes" ; then && test x"$default_enable_lto" != x"yes" ; then

View File

@ -1,3 +1,12 @@
2010-04-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* configure.ac: Check for elf_getshdrstrndx or elf_getshstrndx
flavor.
* configure: Regenerate.
* config.in: Regenerate.
* doc/install.texi (Prerequisites): Document that Solaris 2 libelf
works.
2010-04-16 Richard Guenther <rguenther@suse.de> 2010-04-16 Richard Guenther <rguenther@suse.de>
* tree.h (struct tree_decl_minimal): Move pt_uid ... * tree.h (struct tree_decl_minimal): Move pt_uid ...

View File

@ -814,6 +814,24 @@
#endif #endif
/* Define to 1 if you have the `elf_getshdrstrndx' function. */
#ifndef USED_FOR_TARGET
#undef HAVE_ELF_GETSHDRSTRNDX
#endif
/* Define to 1 if you have the `elf_getshstrndx' function. */
#ifndef USED_FOR_TARGET
#undef HAVE_ELF_GETSHSTRNDX
#endif
/* Define if elf_getshstrndx has gABI conformant return values. */
#ifndef USED_FOR_TARGET
#undef HAVE_ELF_GETSHSTRNDX_GABI
#endif
/* Define to 1 if you have the <fcntl.h> header file. */ /* Define to 1 if you have the <fcntl.h> header file. */
#ifndef USED_FOR_TARGET #ifndef USED_FOR_TARGET
#undef HAVE_FCNTL_H #undef HAVE_FCNTL_H

57
gcc/configure vendored
View File

@ -8426,6 +8426,59 @@ fi
done done
save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
LIBS="$LIBS $LIBELFLIBS"
for ac_func in elf_getshdrstrndx
do :
ac_fn_c_check_func "$LINENO" "elf_getshdrstrndx" "ac_cv_func_elf_getshdrstrndx"
if test "x$ac_cv_func_elf_getshdrstrndx" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_ELF_GETSHDRSTRNDX 1
_ACEOF
else
for ac_func in elf_getshstrndx
do :
ac_fn_c_check_func "$LINENO" "elf_getshstrndx" "ac_cv_func_elf_getshstrndx"
if test "x$ac_cv_func_elf_getshstrndx" = x""yes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_ELF_GETSHSTRNDX 1
_ACEOF
if test "$cross_compiling" = yes; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
as_fn_error "cannot run test program while cross compiling
See \`config.log' for more details." "$LINENO" 5; }
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <stdlib.h>
#include <libelf.h>
int main()
{
return elf_getshstrndx (NULL, 0) == 0;
},
$as_echo "#define HAVE_ELF_GETSHSTRNDX_GABI 1" >>confdefs.h
_ACEOF
if ac_fn_c_try_run "$LINENO"; then :
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
fi
done
fi
done
LIBS="$save_LIBS"
CPPFLAGS="$save_CPPFLAGS"
if test x$ac_cv_func_mbstowcs = xyes; then if test x$ac_cv_func_mbstowcs = xyes; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbstowcs works" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether mbstowcs works" >&5
$as_echo_n "checking whether mbstowcs works... " >&6; } $as_echo_n "checking whether mbstowcs works... " >&6; }
@ -17039,7 +17092,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 17042 "configure" #line 17095 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H
@ -17145,7 +17198,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF cat > conftest.$ac_ext <<_LT_EOF
#line 17148 "configure" #line 17201 "configure"
#include "confdefs.h" #include "confdefs.h"
#if HAVE_DLFCN_H #if HAVE_DLFCN_H

View File

@ -1024,6 +1024,22 @@ AC_CHECK_FUNCS(times clock kill getrlimit setrlimit atoll atoq \
gettimeofday mbstowcs wcswidth mmap mincore setlocale \ gettimeofday mbstowcs wcswidth mmap mincore setlocale \
gcc_UNLOCKED_FUNCS) gcc_UNLOCKED_FUNCS)
save_CPPFLAGS="$CPPFLAGS"
save_LIBS="$LIBS"
LIBS="$LIBS $LIBELFLIBS"
AC_CHECK_FUNCS(elf_getshdrstrndx,,
[AC_CHECK_FUNCS(elf_getshstrndx,
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>
#include <libelf.h>
int main()
{
return elf_getshstrndx (NULL, 0) == 0;
}]]), AC_DEFINE(HAVE_ELF_GETSHSTRNDX_GABI, 1,
[Define if elf_getshstrndx has gABI conformant return values.])])])]
)
LIBS="$save_LIBS"
CPPFLAGS="$save_CPPFLAGS"
if test x$ac_cv_func_mbstowcs = xyes; then if test x$ac_cv_func_mbstowcs = xyes; then
AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works, AC_CACHE_CHECK(whether mbstowcs works, gcc_cv_func_mbstowcs_works,
[ AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h> [ AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdlib.h>

View File

@ -361,7 +361,7 @@ Necessary to build link-time optimization (LTO) support. It can be
downloaded from @uref{http://www.mr511.de/software/libelf-0.8.12.tar.gz}, downloaded from @uref{http://www.mr511.de/software/libelf-0.8.12.tar.gz},
though it is commonly available in several systems. The versions in though it is commonly available in several systems. The versions in
IRIX 5 and 6 don't work since they lack @file{gelf.h}. The version in IRIX 5 and 6 don't work since they lack @file{gelf.h}. The version in
recent releases of Solaris 11 does work, previous ones don't yet. Solaris 2 does work.
The @option{--with-libelf} configure option should be used if libelf is The @option{--with-libelf} configure option should be used if libelf is
not installed in your default library search patch. not installed in your default library search patch.

View File

@ -1,3 +1,8 @@
2010-04-16 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
* lto-elf.c [!HAVE_ELF_GETSHDRSTRNDX] (elf_getshdrstrndx): New
function.
2010-03-09 Eric Botcazou <ebotcazou@adacore.com> 2010-03-09 Eric Botcazou <ebotcazou@adacore.com>
PR bootstrap/43276 PR bootstrap/43276

View File

@ -455,6 +455,22 @@ DEFINE_VALIDATE_EHDR (32)
DEFINE_VALIDATE_EHDR (64) DEFINE_VALIDATE_EHDR (64)
#ifndef HAVE_ELF_GETSHDRSTRNDX
/* elf_getshdrstrndx replacement for systems that lack it, but provide
either the gABI conformant or Solaris 2 variant of elf_getshstrndx
instead. */
static int
elf_getshdrstrndx (Elf *elf, size_t *dst)
{
#ifdef HAVE_ELF_GETSHSTRNDX_GABI
return elf_getshstrndx (elf, dst);
#else
return elf_getshstrndx (elf, dst) ? 0 : -1;
#endif
}
#endif
/* Validate's ELF_FILE's executable header and, if cached_file_attrs is /* Validate's ELF_FILE's executable header and, if cached_file_attrs is
uninitialized, caches the results. Also records the section header string uninitialized, caches the results. Also records the section header string
table's section index. Returns true on success or false on failure. */ table's section index. Returns true on success or false on failure. */