-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
[], [
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
+ 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;])],
+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 ()
+{
+ if (count != 65535)
+ abort ();
+ return 0;
+}
+#endif
+])],
[gcc_cv_initfini_array=yes], [gcc_cv_initfini_array=no],
- [gcc_cv_initfini_array=no])])
+ [gcc_cv_initfini_array=no])
+ 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
ifelse([$1], elf, [_gcc_GAS_VERSION_GTE_IFELSE($@)],
[_gcc_GAS_VERSION_GTE_IFELSE(,$@)])])
+dnl # gcc_GAS_FLAGS
+dnl # Used by gcc_GAS_CHECK_FEATURE
+dnl #
+AC_DEFUN([gcc_GAS_FLAGS],
+[AC_CACHE_CHECK([assembler flags], gcc_cv_as_flags,
+[ case "$target" in
+ i[[34567]]86-*-linux*)
+ 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=" "
+ ;;
+ esac])
+])
+
dnl gcc_GAS_CHECK_FEATURE(description, cv, [[elf,]major,minor,patchlevel],
dnl [extra switches to as], [assembler input],
dnl [extra testing logic], [command if feature available])
dnl then it is run instead of simply setting CV to "yes" - it is responsible
dnl for doing so, if appropriate.
AC_DEFUN([gcc_GAS_CHECK_FEATURE],
-[AC_CACHE_CHECK([assembler for $1], [$2],
+[AC_REQUIRE([gcc_GAS_FLAGS])dnl
+AC_CACHE_CHECK([assembler for $1], [$2],
[[$2]=no
ifelse([$3],,,[dnl
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
- if AC_TRY_COMMAND([$gcc_cv_as $4 -o conftest.o conftest.s >&AS_MESSAGE_LOG_FD])
+ 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])
else