# HG changeset patch
# Parent a3dd47adc9b6d81669be261d596e66b50d077111
Support init priority on Solaris
@@ -309,43 +309,96 @@ int (*fp) (void) __attribute__ ((section
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
+ case $target:$gas in
+ *:yes)
+ sh_flags='"a"'
+ sh_type='%progbits'
+ ;;
+ i?86-*-solaris2*:no | x86_64-*-solaris2*:no)
+ sh_flags='"a"'
+ sh_type='@progbits'
+ ;;
+ sparc*-*-solaris2*:no)
+ sh_flags='#alloc'
+ sh_type='#progbits'
+ sh_quote='"'
+ ;;
+ esac
+ case "$target:$gnu_ld" in
+ *:yes)
+ cat > conftest.s <<EOF
+.section .dtors,$sh_flags,$sh_type
.balign 4
.byte 'A', 'A', 'A', 'A'
-.section .ctors,"a",%progbits
+.section .ctors,$sh_flags,$sh_type
.balign 4
.byte 'B', 'B', 'B', 'B'
-.section .fini_array.65530,"a",%progbits
+.section .fini_array.65530,$sh_flags,$sh_type
.balign 4
.byte 'C', 'C', 'C', 'C'
-.section .init_array.65530,"a",%progbits
+.section .init_array.65530,$sh_flags,$sh_type
.balign 4
.byte 'D', 'D', 'D', 'D'
-.section .dtors.64528,"a",%progbits
+.section .dtors.64528,$sh_flags,$sh_type
.balign 4
.byte 'E', 'E', 'E', 'E'
-.section .ctors.64528,"a",%progbits
+.section .ctors.64528,$sh_flags,$sh_type
.balign 4
.byte 'F', 'F', 'F', 'F'
-.section .fini_array.01005,"a",%progbits
+.section .fini_array.01005,$sh_flags,$sh_type
.balign 4
.byte 'G', 'G', 'G', 'G'
-.section .init_array.01005,"a",%progbits
+.section .init_array.01005,$sh_flags,$sh_type
.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
+ 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
+ ;;
+ *-*-solaris2*:no)
+ # When Solaris ld added constructor priority support, it was
+ # decided to only handle .init_array.N/.fini_array.N since
+ # there was no need for backwards compatibility with
+ # .ctors.N/.dtors.N. .ctors/.dtors remain as separate
+ # sections with correct execution order resp. to
+ # .init_array/.fini_array, while gld merges them into
+ # .init_array/.fini_array.
+ cat > conftest.s <<EOF
+.section $sh_quote.fini_array.65530$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'C', 'C', 'C', 'C'
+.section $sh_quote.init_array.65530$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'D', 'D', 'D', 'D'
+.section $sh_quote.fini_array.01005$sh_quote,$sh_flags,$sh_type
+.align 4
+.byte 'G', 'G', 'G', 'G'
+.section $sh_quote.init_array.01005$sh_quote,$sh_flags,$sh_type
+.align 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 HHHHDDDD > /dev/null 2>&1 \
+ && $gcc_cv_objdump -s -j .fini_array conftest \
+ | grep GGGGCCCC > /dev/null 2>&1; then
+ gcc_cv_initfini_array=yes
+ fi
+ ;;
+ esac
changequote(,)dnl
rm -f conftest conftest.*
changequote([,])dnl
@@ -375,10 +428,10 @@ changequote([,])dnl
fi])
enable_initfini_array=$gcc_cv_initfini_array
])
-if test $enable_initfini_array = yes; then
- AC_DEFINE(HAVE_INITFINI_ARRAY_SUPPORT, 1,
- [Define .init_array/.fini_array sections are available and working.])
-fi])
+AC_DEFINE_UNQUOTED(HAVE_INITFINI_ARRAY_SUPPORT,
+ [`if test $enable_initfini_array = yes; then echo 1; else echo 0; fi`],
+ [Define 0/1 if .init_array/.fini_array sections are available and working.])
+])
dnl # _gcc_COMPUTE_GAS_VERSION
dnl # Used by gcc_GAS_VERSION_GTE_IFELSE
@@ -23,7 +23,7 @@
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
<http://www.gnu.org/licenses/>. */
-#ifdef HAVE_INITFINI_ARRAY_SUPPORT
+#if HAVE_INITFINI_ARRAY_SUPPORT
#define USE_INITFINI_ARRAY
@@ -398,11 +398,9 @@ along with GCC; see the file COPYING3.
#define NO_DBX_BNSYM_ENSYM 1
#endif
-#ifndef USE_GLD
-/* The Solaris linker doesn't understand constructor priorities. */
+/* Enable constructor priorities if the configured linker supports it. */
#undef SUPPORTS_INIT_PRIORITY
-#define SUPPORTS_INIT_PRIORITY 0
-#endif
+#define SUPPORTS_INIT_PRIORITY HAVE_INITFINI_ARRAY_SUPPORT
/* Solaris has an implementation of __enable_execute_stack. */
#define HAVE_ENABLE_EXECUTE_STACK
@@ -9885,14 +9885,12 @@ sparc_solaris_elf_asm_named_section (con
if (flags & SECTION_CODE)
fputs (",#execinstr", asm_out_file);
- /* Sun as only supports #nobits/#progbits since Solaris 10. */
- if (HAVE_AS_SPARC_NOBITS)
- {
- if (flags & SECTION_BSS)
- fputs (",#nobits", asm_out_file);
- else
- fputs (",#progbits", asm_out_file);
- }
+ if (flags & SECTION_NOTYPE)
+ ;
+ else if (flags & SECTION_BSS)
+ fputs (",#nobits", asm_out_file);
+ else
+ fputs (",#progbits", asm_out_file);
fputc ('\n', asm_out_file);
}
@@ -3742,13 +3742,6 @@ AS_HELP_STRING([--disable-fix-cortex-a53
[AC_DEFINE(HAVE_AS_REGISTER_PSEUDO_OP, 1,
[Define if your assembler supports .register.])])
- gcc_GAS_CHECK_FEATURE([@%:@nobits], gcc_cv_as_sparc_nobits,,,
- [.section "nobits",#alloc,#write,#nobits
- .section "progbits",#alloc,#write,#progbits])
- AC_DEFINE_UNQUOTED(HAVE_AS_SPARC_NOBITS,
- [`if test $gcc_cv_as_sparc_nobits = yes; then echo 1; else echo 0; fi`],
- [Define to 1 if your assembler supports #nobits, 0 otherwise.])
-
gcc_GAS_CHECK_FEATURE([-relax option], gcc_cv_as_sparc_relax,,
[-relax], [.text],,
[AC_DEFINE(HAVE_AS_RELAX_OPTION, 1,
@@ -61,7 +61,7 @@ dtor_ptr:
.hidden __dso_handle
-#ifdef HAVE_INITFINI_ARRAY_SUPPORT
+#if HAVE_INITFINI_ARRAY_SUPPORT
.section .fini_array, "a"
data8 @fptr(__do_global_dtors_aux)
@@ -39,7 +39,7 @@
__JCR_END__:
data8 0
-#ifdef HAVE_INITFINI_ARRAY_SUPPORT
+#if HAVE_INITFINI_ARRAY_SUPPORT
.global __do_global_ctors_aux
.hidden __do_global_ctors_aux
#else /* !HAVE_INITFINI_ARRAY_SUPPORT */