OSDN Git Service

2012-01-30 Pascal Obry <obry@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / acinclude.m4
index 6f0f979..933f811 100644 (file)
@@ -1,4 +1,4 @@
-dnl Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
+dnl Copyright (C) 2005, 2006, 2007, 2008, 2011 Free Software Foundation, Inc.
 dnl
 dnl This file is part of GCC.
 dnl
@@ -375,13 +375,86 @@ AC_DEFUN([gcc_AC_INITFINI_ARRAY],
        [], [
 AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
                 gcc_cv_initfini_array, [dnl
-  AC_RUN_IFELSE([AC_LANG_SOURCE([
+  if test "x${build}" = "x${target}" && test "x${build}" = "x${host}"; then
+    case "${target}" in
+      ia64-*)
+       AC_RUN_IFELSE([AC_LANG_SOURCE([
+#ifndef __ELF__
+#error Not an ELF OS
+#endif
+/* 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;])],
+int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
+])],
             [gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
-            [gcc_cv_initfini_array=no])])
+            [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
+EOF
+         if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \
+            && $gcc_cv_ld -e 0 -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 <stdlib.h>
+#if defined __GLIBC_PREREQ && __GLIBC_PREREQ (2, 4)
+#else
+#error The C library not known to support .init_array/.fini_array
+#endif
+])],, [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
@@ -452,6 +525,10 @@ AC_DEFUN([gcc_GAS_FLAGS],
     dnl Always pass --32 to ia32 Linux assembler.
     gcc_cv_as_flags="--32"
     ;;
+  powerpc*-*-darwin*)
+    dnl Always pass -arch ppc to assembler.
+    gcc_cv_as_flags="-arch ppc"
+    ;;
   *)
     gcc_cv_as_flags=" "
     ;;
@@ -477,7 +554,7 @@ AC_CACHE_CHECK([assembler for $1], [$2],
   if test $in_tree_gas = yes; then
     gcc_GAS_VERSION_GTE_IFELSE($3, [[$2]=yes])
   el])if test x$gcc_cv_as != x; then
-    echo ifelse(m4_substr([$5],0,1),[$], "[$5]", '[$5]') > conftest.s
+    AS_ECHO([ifelse(m4_substr([$5],0,1),[$], "[$5]", '[$5]')]) > conftest.s
     if AC_TRY_COMMAND([$gcc_cv_as $gcc_cv_as_flags $4 -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD])
     then
        ifelse([$6],, [$2]=yes, [$6])