From e6b6bf09dd34ed9a35cbc7d37d0fde1849450aad Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Mon, 9 Nov 2015 11:33:30 +0000 Subject: [PATCH] Support init priority on Solaris libgcc: * config/ia64/crtbegin.S: Check HAVE_INITFINI_ARRAY_SUPPORT value. * config/ia64/crtend.S: Likewise. gcc: * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Allow for differences in assembler syntax. Support Solaris ld. Define HAVE_INITFINI_ARRAY_SUPPORT as 0/1. * config/sol2.h (SUPPORTS_INIT_PRIORITY): Define to HAVE_INITFINI_ARRAY_SUPPORT. * config/initfini-array.h: Check HAVE_INITFINI_ARRAY_SUPPORT value. * configure.ac (gcc_cv_as_sparc_nobits): Remove. * config/sparc/sparc.c (sparc_solaris_elf_asm_named_section): Don't check HAVE_AS_SPARC_NOBITS. Heed SECTION_NOTYPE. * configure: Regenerate. * config.in: Regenerate. From-SVN: r230013 --- gcc/ChangeLog | 20 ++++++ gcc/acinclude.m4 | 95 +++++++++++++++++++------ gcc/config.in | 9 +-- gcc/config/initfini-array.h | 2 +- gcc/config/sol2.h | 6 +- gcc/config/sparc/sparc.c | 14 ++-- gcc/configure | 127 ++++++++++++++++++++-------------- gcc/configure.ac | 7 -- libgcc/ChangeLog | 6 ++ libgcc/config/ia64/crtbegin.S | 2 +- libgcc/config/ia64/crtend.S | 2 +- 11 files changed, 187 insertions(+), 103 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 510f5ee5df9..4ebfc523546 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,23 @@ +2015-11-09 Rainer Orth + + * acinclude.m4 (gcc_AC_INITFINI_ARRAY): Allow for differences in + assembler syntax. + Support Solaris ld. + Define HAVE_INITFINI_ARRAY_SUPPORT as 0/1. + + * config/sol2.h (SUPPORTS_INIT_PRIORITY): Define to + HAVE_INITFINI_ARRAY_SUPPORT. + * config/initfini-array.h: Check HAVE_INITFINI_ARRAY_SUPPORT + value. + + * configure.ac (gcc_cv_as_sparc_nobits): Remove. + * config/sparc/sparc.c (sparc_solaris_elf_asm_named_section): + Don't check HAVE_AS_SPARC_NOBITS. + Heed SECTION_NOTYPE. + + * configure: Regenerate. + * config.in: Regenerate. + 2015-11-09 Eric Botcazou PR middle-end/68253 diff --git a/gcc/acinclude.m4 b/gcc/acinclude.m4 index 0bcd844fac6..b8a4c28424d 100644 --- a/gcc/acinclude.m4 +++ b/gcc/acinclude.m4 @@ -309,43 +309,96 @@ int (*fp) (void) __attribute__ ((section (".init_array"))) = foo; 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 < /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 < /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 diff --git a/gcc/config.in b/gcc/config.in index 6f46f7039bd..eb1ea106031 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -598,12 +598,6 @@ #endif -/* Define to 1 if your assembler supports #nobits, 0 otherwise. */ -#ifndef USED_FOR_TARGET -#undef HAVE_AS_SPARC_NOBITS -#endif - - /* Define if your assembler and linker support unaligned PC relative relocs. */ #ifndef USED_FOR_TARGET @@ -1329,7 +1323,8 @@ #endif -/* Define .init_array/.fini_array sections are available and working. */ +/* Define 0/1 if .init_array/.fini_array sections are available and working. + */ #ifndef USED_FOR_TARGET #undef HAVE_INITFINI_ARRAY_SUPPORT #endif diff --git a/gcc/config/initfini-array.h b/gcc/config/initfini-array.h index 06da397404a..59adedebf00 100644 --- a/gcc/config/initfini-array.h +++ b/gcc/config/initfini-array.h @@ -23,7 +23,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see . */ -#ifdef HAVE_INITFINI_ARRAY_SUPPORT +#if HAVE_INITFINI_ARRAY_SUPPORT #define USE_INITFINI_ARRAY diff --git a/gcc/config/sol2.h b/gcc/config/sol2.h index f444e48659d..6bf0599feaa 100644 --- a/gcc/config/sol2.h +++ b/gcc/config/sol2.h @@ -398,11 +398,9 @@ along with GCC; see the file COPYING3. If not see #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 diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 6d877d6fb95..28c2c63b683 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -9868,14 +9868,12 @@ sparc_solaris_elf_asm_named_section (const char *name, unsigned int flags, 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); } diff --git a/gcc/configure b/gcc/configure index 1d2e8f2644d..de6cf13569f 100755 --- a/gcc/configure +++ b/gcc/configure @@ -22930,43 +22930,96 @@ fi 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 < /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 < /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 rm -f conftest conftest.* fi cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -23009,11 +23062,12 @@ $as_echo "$gcc_cv_initfini_array" >&6; } fi -if test $enable_initfini_array = yes; then -$as_echo "#define HAVE_INITFINI_ARRAY_SUPPORT 1" >>confdefs.h +cat >>confdefs.h <<_ACEOF +#define HAVE_INITFINI_ARRAY_SUPPORT `if test $enable_initfini_array = yes; then echo 1; else echo 0; fi` +_ACEOF + -fi # Check if we have .[us]leb128, and support symbol arithmetic with it. { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .sleb128 and .uleb128" >&5 @@ -24667,39 +24721,6 @@ $as_echo "#define HAVE_AS_REGISTER_PSEUDO_OP 1" >>confdefs.h fi - { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for #nobits" >&5 -$as_echo_n "checking assembler for #nobits... " >&6; } -if test "${gcc_cv_as_sparc_nobits+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - gcc_cv_as_sparc_nobits=no - if test x$gcc_cv_as != x; then - $as_echo '.section "nobits",#alloc,#write,#nobits - .section "progbits",#alloc,#write,#progbits' > conftest.s - if { ac_try='$gcc_cv_as $gcc_cv_as_flags -o conftest.o conftest.s >&5' - { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 - (eval $ac_try) 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; } - then - gcc_cv_as_sparc_nobits=yes - else - echo "configure: failed program was" >&5 - cat conftest.s >&5 - fi - rm -f conftest.o conftest.s - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_sparc_nobits" >&5 -$as_echo "$gcc_cv_as_sparc_nobits" >&6; } - - -cat >>confdefs.h <<_ACEOF -#define HAVE_AS_SPARC_NOBITS `if test $gcc_cv_as_sparc_nobits = yes; then echo 1; else echo 0; fi` -_ACEOF - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -relax option" >&5 $as_echo_n "checking assembler for -relax option... " >&6; } if test "${gcc_cv_as_sparc_relax+set}" = set; then : diff --git a/gcc/configure.ac b/gcc/configure.ac index d03a0bd1c17..7670824e5a4 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -3754,13 +3754,6 @@ AS_HELP_STRING([--disable-fix-cortex-a53-843419], [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, diff --git a/libgcc/ChangeLog b/libgcc/ChangeLog index e4fb81bad0b..13ed8133857 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,9 @@ +2015-11-09 Rainer Orth + + * config/ia64/crtbegin.S: Check HAVE_INITFINI_ARRAY_SUPPORT + value. + * config/ia64/crtend.S: Likewise. + 2015-11-07 Trevor Saunders * config/visium/lib2funcs.c (__set_trampoline_parity): Use diff --git a/libgcc/config/ia64/crtbegin.S b/libgcc/config/ia64/crtbegin.S index ec8ed7b5bb3..477b383f112 100644 --- a/libgcc/config/ia64/crtbegin.S +++ b/libgcc/config/ia64/crtbegin.S @@ -61,7 +61,7 @@ __dso_handle: .hidden __dso_handle -#ifdef HAVE_INITFINI_ARRAY_SUPPORT +#if HAVE_INITFINI_ARRAY_SUPPORT .section .fini_array, "a" data8 @fptr(__do_global_dtors_aux) diff --git a/libgcc/config/ia64/crtend.S b/libgcc/config/ia64/crtend.S index a1a559560d1..d9c65c0765d 100644 --- a/libgcc/config/ia64/crtend.S +++ b/libgcc/config/ia64/crtend.S @@ -39,7 +39,7 @@ __DTOR_END__: __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 */ -- 2.30.2