Commit e992fc2e by Rainer Orth Committed by Rainer Orth

Enable initfini array support on Solaris (PR target/50166)

	* acinclude.m4 (gcc_AC_INITFINI_ARRAY): Require gcc_SUN_LD_VERSION.
	Define _start.
	Remove -e 0 from $gcc_cv_ld invocation.
	Only use __GLIBC_PREREQ if defined.
	Enable on Solaris since Solaris 8 patch.
	(gcc_SUN_LD_VERSION): New macro.
	* configure.ac (ld_ver) <*-*-solaris2*>: Refer to
	gcc_SUN_LD_VERSION for version number format.
	* configure: Regenerate.
	* varasm.c (get_elf_initfini_array_priority_section): Set
	SECTION_NOTYPE for non-default priority.
	Use get_section instead of get_unnamed_section to emit
	.init_array/.fini_array with default priority.

From-SVN: r184390
parent d1503908
2012-02-20 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
PR target/50166
* acinclude.m4 (gcc_AC_INITFINI_ARRAY): Require gcc_SUN_LD_VERSION.
Define _start.
Remove -e 0 from $gcc_cv_ld invocation.
Only use __GLIBC_PREREQ if defined.
Enable on Solaris since Solaris 8 patch.
(gcc_SUN_LD_VERSION): New macro.
* configure.ac (ld_ver) <*-*-solaris2*>: Refer to
gcc_SUN_LD_VERSION for version number format.
* configure: Regenerate.
* varasm.c (get_elf_initfini_array_priority_section): Set
SECTION_NOTYPE for non-default priority.
Use get_section instead of get_unnamed_section to emit
.init_array/.fini_array with default priority.
2012-02-19 Richard Sandiford <rdsandiford@googlemail.com> 2012-02-19 Richard Sandiford <rdsandiford@googlemail.com>
* config/mips/mips.c (mips_need_mips16_rdhwr_p): New variable. * config/mips/mips.c (mips_need_mips16_rdhwr_p): New variable.
......
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
dnl This file is part of GCC. dnl This file is part of GCC.
dnl dnl
...@@ -370,7 +371,8 @@ fi ...@@ -370,7 +371,8 @@ fi
fi]) fi])
AC_DEFUN([gcc_AC_INITFINI_ARRAY], 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], [ --enable-initfini-array use .init_array/.fini_array sections],
[], [ [], [
AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support, AC_CACHE_CHECK(for .preinit_array/.init_array/.fini_array support,
...@@ -427,9 +429,11 @@ int (*fp) (void) __attribute__ ((section (".init_array"))) = foo; ...@@ -427,9 +429,11 @@ int (*fp) (void) __attribute__ ((section (".init_array"))) = foo;
.balign 4 .balign 4
.byte 'H', 'H', 'H', 'H' .byte 'H', 'H', 'H', 'H'
.text .text
.globl _start
_start:
EOF EOF
if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \ 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_ld -o conftest conftest.o > /dev/null 2>&1 \
&& $gcc_cv_objdump -s -j .init_array conftest \ && $gcc_cv_objdump -s -j .init_array conftest \
| grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \ | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \
&& $gcc_cv_objdump -s -j .fini_array conftest \ && $gcc_cv_objdump -s -j .fini_array conftest \
...@@ -442,14 +446,38 @@ changequote([,])dnl ...@@ -442,14 +446,38 @@ changequote([,])dnl
fi fi
AC_PREPROC_IFELSE([AC_LANG_SOURCE([ AC_PREPROC_IFELSE([AC_LANG_SOURCE([
#ifndef __ELF__ #ifndef __ELF__
#error Not an ELF OS # error Not an ELF OS
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#if defined __GLIBC_PREREQ && __GLIBC_PREREQ (2, 4) #if defined __GLIBC_PREREQ
# if __GLIBC_PREREQ (2, 4)
# else
# error GLIBC 2.4 required
# endif
#else #else
#error The C library not known to support .init_array/.fini_array # 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 #endif
])],, [gcc_cv_initfini_array=no]);; ])],[
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 esac
else else
AC_MSG_CHECKING(cross compile... guessing) AC_MSG_CHECKING(cross compile... guessing)
...@@ -569,6 +597,43 @@ if test $[$2] = yes; then ...@@ -569,6 +597,43 @@ if test $[$2] = yes; then
$7 $7
fi])]) 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 GCC_TARGET_TEMPLATE(KEY)
dnl ------------------------ dnl ------------------------
dnl Define KEY as a valid configure key on the target machine. dnl Define KEY as a valid configure key on the target machine.
......
...@@ -22214,15 +22214,11 @@ if test $in_tree_ld != yes ; then ...@@ -22214,15 +22214,11 @@ if test $in_tree_ld != yes ; then
else else
case "${target}" in case "${target}" in
*-*-solaris2*) *-*-solaris2*)
# See acinclude.m4 (gcc_SUN_LD_VERSION) for the version number
# format.
# #
# Solaris 2 ld -V output looks like this for a regular version: # Don't reuse gcc_gv_sun_ld_vers_* in case a linker other than
# # /usr/ccs/bin/ld has been configured.
# 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
#
ld_ver=`$gcc_cv_ld -V 2>&1` ld_ver=`$gcc_cv_ld -V 2>&1`
if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then
ld_vers=`echo $ld_ver | sed -n \ ld_vers=`echo $ld_ver | sed -n \
...@@ -22350,6 +22346,29 @@ fi ...@@ -22350,6 +22346,29 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_ro_rw_mix" >&5 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_ld_ro_rw_mix" >&5
$as_echo "$gcc_cv_ld_ro_rw_mix" >&6; } $as_echo "$gcc_cv_ld_ro_rw_mix" >&6; }
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
# Check whether --enable-initfini-array was given. # Check whether --enable-initfini-array was given.
if test "${enable_initfini_array+set}" = set; then : if test "${enable_initfini_array+set}" = set; then :
enableval=$enable_initfini_array; enableval=$enable_initfini_array;
...@@ -22425,9 +22444,11 @@ fi ...@@ -22425,9 +22444,11 @@ fi
.balign 4 .balign 4
.byte 'H', 'H', 'H', 'H' .byte 'H', 'H', 'H', 'H'
.text .text
.globl _start
_start:
EOF EOF
if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1 \ 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_ld -o conftest conftest.o > /dev/null 2>&1 \
&& $gcc_cv_objdump -s -j .init_array conftest \ && $gcc_cv_objdump -s -j .init_array conftest \
| grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \ | grep HHHHFFFFDDDDBBBB > /dev/null 2>&1 \
&& $gcc_cv_objdump -s -j .fini_array conftest \ && $gcc_cv_objdump -s -j .fini_array conftest \
...@@ -22440,17 +22461,41 @@ EOF ...@@ -22440,17 +22461,41 @@ EOF
/* end confdefs.h. */ /* end confdefs.h. */
#ifndef __ELF__ #ifndef __ELF__
#error Not an ELF OS # error Not an ELF OS
#endif #endif
#include <stdlib.h> #include <stdlib.h>
#if defined __GLIBC_PREREQ && __GLIBC_PREREQ (2, 4) #if defined __GLIBC_PREREQ
# if __GLIBC_PREREQ (2, 4)
# else
# error GLIBC 2.4 required
# endif
#else #else
#error The C library not known to support .init_array/.fini_array # 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 #endif
_ACEOF _ACEOF
if ac_fn_c_try_cpp "$LINENO"; then : if ac_fn_c_try_cpp "$LINENO"; then :
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
else else
gcc_cv_initfini_array=no gcc_cv_initfini_array=no
fi fi
......
...@@ -2296,15 +2296,11 @@ if test $in_tree_ld != yes ; then ...@@ -2296,15 +2296,11 @@ if test $in_tree_ld != yes ; then
else else
case "${target}" in case "${target}" in
*-*-solaris2*) *-*-solaris2*)
# See acinclude.m4 (gcc_SUN_LD_VERSION) for the version number
# format.
# #
# Solaris 2 ld -V output looks like this for a regular version: # Don't reuse gcc_gv_sun_ld_vers_* in case a linker other than
# # /usr/ccs/bin/ld has been configured.
# 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
#
ld_ver=`$gcc_cv_ld -V 2>&1` ld_ver=`$gcc_cv_ld -V 2>&1`
if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then if echo "$ld_ver" | grep 'Solaris Link Editors' > /dev/null; then
ld_vers=`echo $ld_ver | sed -n \ ld_vers=`echo $ld_ver | sed -n \
......
...@@ -7658,7 +7658,7 @@ get_elf_initfini_array_priority_section (int priority, ...@@ -7658,7 +7658,7 @@ get_elf_initfini_array_priority_section (int priority,
sprintf (buf, "%s.%.5u", sprintf (buf, "%s.%.5u",
constructor_p ? ".init_array" : ".fini_array", constructor_p ? ".init_array" : ".fini_array",
priority); priority);
sec = get_section (buf, SECTION_WRITE, NULL_TREE); sec = get_section (buf, SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
} }
else else
{ {
...@@ -7666,16 +7666,16 @@ get_elf_initfini_array_priority_section (int priority, ...@@ -7666,16 +7666,16 @@ get_elf_initfini_array_priority_section (int priority,
{ {
if (elf_init_array_section == NULL) if (elf_init_array_section == NULL)
elf_init_array_section elf_init_array_section
= get_unnamed_section (0, output_section_asm_op, = get_section (".init_array",
"\t.section\t.init_array"); SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
sec = elf_init_array_section; sec = elf_init_array_section;
} }
else else
{ {
if (elf_fini_array_section == NULL) if (elf_fini_array_section == NULL)
elf_fini_array_section elf_fini_array_section
= get_unnamed_section (0, output_section_asm_op, = get_section (".fini_array",
"\t.section\t.fini_array"); SECTION_WRITE | SECTION_NOTYPE, NULL_TREE);
sec = elf_fini_array_section; sec = elf_fini_array_section;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment