X-Git-Url: http://git.sourceforge.jp/view?a=blobdiff_plain;f=gcc%2Facinclude.m4;h=a39484710486e281b6aebb6cb5166993bef35d56;hb=0b24c2581da7243b803e58b11bb1adc9fecac900;hp=a8ecd2d4f6ded40e7f42ae7ceb4f30cab0019aa6;hpb=dcad2431894108760a5351f5e668d1afa77c8344;p=pf3gnuchains%2Fgcc-fork.git diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 index a8ecd2d4f6d..a3948471048 100644 --- a/gcc/acinclude.m4 +++ b/gcc/acinclude.m4 @@ -1,4 +1,5 @@ -dnl Copyright (C) 2005, 2006, 2007, 2008, 2011 Free Software Foundation, Inc. +dnl Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 +dnl Free Software Foundation, Inc. dnl dnl This file is part of GCC. dnl @@ -370,127 +371,122 @@ fi fi]) AC_DEFUN([gcc_AC_INITFINI_ARRAY], -[AC_ARG_ENABLE(initfini-array, +[AC_REQUIRE([gcc_SUN_LD_VERSION])dnl +AC_ARG_ENABLE(initfini-array, [ --enable-initfini-array use .init_array/.fini_array sections], [], [ AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support, gcc_cv_initfini_array, [dnl if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then - AC_RUN_IFELSE([AC_LANG_SOURCE([ + case "${target}" in + ia64-*) + AC_RUN_IFELSE([AC_LANG_SOURCE([ #ifndef __ELF__ #error Not an ELF OS #endif -#ifdef __ia64__ /* We turn on .preinit_array/.init_array/.fini_array support for ia64 if it can be used. */ static int x = -1; int main (void) { return x; } int foo (void) { x = 0; } int (*fp) (void) __attribute__ ((section (".init_array"))) = foo; -#else -extern void abort (); -static int count; - -static void -init1005 () -{ - if (count != 0) - abort (); - count = 1005; -} -void (*const init_array1005[]) () - __attribute__ ((section (".init_array.01005"), aligned (sizeof (void *)))) - = { init1005 }; -static void -fini1005 () -{ - if (count != 1005) - abort (); -} -void (*const fini_array1005[]) () - __attribute__ ((section (".fini_array.01005"), aligned (sizeof (void *)))) - = { fini1005 }; - -static void -ctor1007 () -{ - if (count != 1005) - abort (); - count = 1007; -} -void (*const ctors1007[]) () - __attribute__ ((section (".ctors.64528"), aligned (sizeof (void *)))) - = { ctor1007 }; -static void -dtor1007 () -{ - if (count != 1007) - abort (); - count = 1005; -} -void (*const dtors1007[]) () - __attribute__ ((section (".dtors.64528"), aligned (sizeof (void *)))) - = { dtor1007 }; - -static void -init65530 () -{ - if (count != 1007) - abort (); - count = 65530; -} -void (*const init_array65530[]) () - __attribute__ ((section (".init_array.65530"), aligned (sizeof (void *)))) - = { init65530 }; -static void -fini65530 () -{ - if (count != 65530) - abort (); - count = 1007; -} -void (*const fini_array65530[]) () - __attribute__ ((section (".fini_array.65530"), aligned (sizeof (void *)))) - = { fini65530 }; - -static void -ctor65535 () -{ - if (count != 65530) - abort (); - count = 65535; -} -void (*const ctors65535[]) () - __attribute__ ((section (".ctors"), aligned (sizeof (void *)))) - = { ctor65535 }; -static void -dtor65535 () -{ - if (count != 65535) - abort (); - count = 65530; -} -void (*const dtors65535[]) () - __attribute__ ((section (".dtors"), aligned (sizeof (void *)))) - = { dtor65535 }; - -int -main () -{ - return 0; -} -#endif ])], [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no], - [gcc_cv_initfini_array=no]) - else - AC_MSG_CHECKING(cross compile... guessing) - gcc_cv_initfini_array=no - fi]) + [gcc_cv_initfini_array=no]);; + *) + gcc_cv_initfini_array=no + if test $in_tree_ld = yes ; then + if test "$gcc_cv_gld_major_version" -eq 2 \ + -a "$gcc_cv_gld_minor_version" -ge 22 \ + -o "$gcc_cv_gld_major_version" -gt 2 \ + && test $in_tree_ld_is_elf = yes; then + gcc_cv_initfini_array=yes + fi + elif test x$gcc_cv_as != x -a x$gcc_cv_ld != x -a x$gcc_cv_objdump != x ; then + cat > conftest.s <<\EOF +.section .dtors,"a",%progbits +.balign 4 +.byte 'A', 'A', 'A', 'A' +.section .ctors,"a",%progbits +.balign 4 +.byte 'B', 'B', 'B', 'B' +.section .fini_array.65530,"a",%progbits +.balign 4 +.byte 'C', 'C', 'C', 'C' +.section .init_array.65530,"a",%progbits +.balign 4 +.byte 'D', 'D', 'D', 'D' +.section .dtors.64528,"a",%progbits +.balign 4 +.byte 'E', 'E', 'E', 'E' +.section .ctors.64528,"a",%progbits +.balign 4 +.byte 'F', 'F', 'F', 'F' +.section .fini_array.01005,"a",%progbits +.balign 4 +.byte 'G', 'G', 'G', 'G' +.section .init_array.01005,"a",%progbits +.balign 4 +.byte 'H', 'H', 'H', 'H' +.text +.globl _start +_start: +EOF + if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \ + && $gcc_cv_ld -o conftest conftest.o > /dev/null 2>&1 \ + && $gcc_cv_objdump -s -j .init_array conftest \ + | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \ + && $gcc_cv_objdump -s -j .fini_array conftest \ + | grep GGGGEEEECCCCAAAA > /dev/null 2>&1; then + gcc_cv_initfini_array=yes + fi +changequote(,)dnl + rm -f conftest conftest.* +changequote([,])dnl + fi + AC_PREPROC_IFELSE([AC_LANG_SOURCE([ +#ifndef __ELF__ +# error Not an ELF OS +#endif +#include +#if defined __GLIBC_PREREQ +# if __GLIBC_PREREQ (2, 4) +# else +# error GLIBC 2.4 required +# endif +#else +# if defined __sun__ && defined __svr4__ + /* Solaris ld.so.1 supports .init_array/.fini_array since Solaris 8. */ +# else +# error The C library not known to support .init_array/.fini_array +# endif +#endif +])],[ + case "${target}" in + *-*-solaris2.8*) + # .init_array/.fini_array support was introduced in Solaris 8 + # patches 109147-08 (sparc) and 109148-08 (x86). Since ld.so.1 and + # ld are guaranteed to be updated in lockstep, we can check ld -V + # instead. Unfortunately, proper ld version numbers were only + # introduced in rev. -14, so we check for that. + if test "$gcc_cv_sun_ld_vers_minor" -lt 272; then + gcc_cv_initfini_array=no + fi + ;; + *-*-solaris2.9* | *-*-solaris2.1[[0-9]]*) + # .init_array/.fini_array support is present since Solaris 9 FCS. + ;; + esac +], [gcc_cv_initfini_array=no]);; + esac + else + AC_MSG_CHECKING(cross compile... guessing) + gcc_cv_initfini_array=no + fi]) enable_initfini_array=$gcc_cv_initfini_array ]) if test $enable_initfini_array = yes; then - AC_DEFINE(HAVE_INITFINI_ARRAY, 1, + AC_DEFINE(HAVE_INITFINI_ARRAY_SUPPORT, 1, [Define .init_array/.fini_array sections are available and working.]) fi]) @@ -601,6 +597,43 @@ if test $[$2] = yes; then $7 fi])]) +dnl gcc_SUN_LD_VERSION +dnl +dnl Determines Sun linker version numbers, setting gcc_cv_sun_ld_vers to +dnl the complete version number and gcc_cv_sun_ld_vers_{major, minor} to +dnl the corresponding fields. +dnl +dnl ld and ld.so.1 are guaranteed to be updated in lockstep, so ld version +dnl numbers can be used in ld.so.1 feature checks even if a different +dnl linker is configured. +dnl +AC_DEFUN([gcc_SUN_LD_VERSION], +[changequote(,)dnl +if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then + case "${target}" in + *-*-solaris2*) + # + # Solaris 2 ld -V output looks like this for a regular version: + # + # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1699 + # + # but test versions add stuff at the end: + # + # ld: Software Generation Utilities - Solaris Link Editors: 5.11-1.1701:onnv-ab196087-6931056-03/25/10 + # + gcc_cv_sun_ld_ver=`/usr/ccs/bin/ld -V 2>&1` + if echo "$gcc_cv_sun_ld_ver" | grep 'Solaris Link Editors' > /dev/null; then + gcc_cv_sun_ld_vers=`echo $gcc_cv_sun_ld_ver | sed -n \ + -e 's,^.*: 5\.[0-9][0-9]*-\([0-9]\.[0-9][0-9]*\).*$,\1,p'` + gcc_cv_sun_ld_vers_major=`expr "$gcc_cv_sun_ld_vers" : '\([0-9]*\)'` + gcc_cv_sun_ld_vers_minor=`expr "$gcc_cv_sun_ld_vers" : '[0-9]*\.\([0-9]*\)'` + fi + ;; + esac +fi +changequote([,])dnl +]) + dnl GCC_TARGET_TEMPLATE(KEY) dnl ------------------------ dnl Define KEY as a valid configure key on the target machine.