summaryrefslogtreecommitdiff
path: root/gcc/acinclude.m4
diff options
context:
space:
mode:
authorhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-18 14:48:14 +0000
committerhjl <hjl@138bc75d-0d04-0410-961f-82ee72b054a4>2011-06-18 14:48:14 +0000
commit36267cc4921b2be00e6af68695f11f60b39f4891 (patch)
tree5cc8af97d1c0bdccd7a4ff87400e7f3b1970fb52 /gcc/acinclude.m4
parent3567a6ab69e9ef3828d56177b8b0edb9c3624dcc (diff)
downloadgcc-36267cc4921b2be00e6af68695f11f60b39f4891.tar.gz
Properly check if .init_array can be used with .ctors on targets.
2011-06-18 H.J. Lu <hongjiu.lu@intel.com> PR other/49325 * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Properly check if .init_array can be used with .ctors on targets. * configure: Regenerated. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@175181 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/acinclude.m4')
-rw-r--r--gcc/acinclude.m4108
1 files changed, 105 insertions, 3 deletions
diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4
index 3eec559e8f5..ff386825880 100644
--- a/gcc/acinclude.m4
+++ b/gcc/acinclude.m4
@@ -375,13 +375,115 @@ 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
+ AC_RUN_IFELSE([AC_LANG_SOURCE([
+#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 ()
+{
+ 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