From f8d704048f0900b88a459a60c5fed0e9b7ed8658 Mon Sep 17 00:00:00 2001 From: Rainer Orth Date: Fri, 25 May 2018 07:57:10 +0000 Subject: [PATCH] Support SHF_EXCLUDE on non-x86 and with Solaris as * configure.ac (gcc_cv_as_section_has_e): Move to common section. Rename to... (gcc_cv_as_section_exclude): ... this. Try Solaris as #exclude syntax. * configure: Regenerate. * config.in: Regenerate. * config/i386/i386.c (i386_solaris_elf_named_section): Handle SECTION_EXCLUDE. * config/sparc/sparc.c (sparc_solaris_elf_asm_named_section) [HAVE_GAS_SECTION_EXCLUDE]: Handle SECTION_EXCLUDE. * varasm.c (default_elf_asm_named_section): Don't check if HAVE_GAS_SECTION_EXCLUDE is defined. From-SVN: r260708 --- gcc/ChangeLog | 16 +++++ gcc/config.in | 2 +- gcc/config/i386/i386.c | 9 +++ gcc/config/sparc/sparc.c | 4 ++ gcc/configure | 123 ++++++++++++++++++++++++++------------- gcc/configure.ac | 38 ++++++++---- gcc/varasm.c | 2 +- 7 files changed, 142 insertions(+), 52 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c258af3d255..9dd687ad8ab 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,19 @@ +2018-05-25 Rainer Orth + + * configure.ac (gcc_cv_as_section_has_e): Move to common section. + Rename to... + (gcc_cv_as_section_exclude): ... this. + Try Solaris as #exclude syntax. + * configure: Regenerate. + * config.in: Regenerate. + * config/i386/i386.c (i386_solaris_elf_named_section): Handle + SECTION_EXCLUDE. + * config/sparc/sparc.c (sparc_solaris_elf_asm_named_section) + [HAVE_GAS_SECTION_EXCLUDE]: Handle SECTION_EXCLUDE. + + * varasm.c (default_elf_asm_named_section): Don't check if + HAVE_GAS_SECTION_EXCLUDE is defined. + 2018-05-25 Richard Sandiford * doc/md.texi: Update the documentation of the cond_* optabs diff --git a/gcc/config.in b/gcc/config.in index 5bccb408016..2856e72d627 100644 --- a/gcc/config.in +++ b/gcc/config.in @@ -1323,7 +1323,7 @@ #endif -/* Define if your assembler supports specifying the section flag e. */ +/* Define if your assembler supports specifying the exclude section flag. */ #ifndef USED_FOR_TARGET #undef HAVE_GAS_SECTION_EXCLUDE #endif diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 184b721dbf3..637c10565d5 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -45905,6 +45905,15 @@ i386_solaris_elf_named_section (const char *name, unsigned int flags, solaris_elf_asm_comdat_section (name, flags, decl); return; } + + /* Solaris/x86 as uses the same syntax for the SHF_EXCLUDE flags as the + SPARC assembler. One cannot mix single-letter flags and #exclude, so + only emit the latter here. */ + if (flags & SECTION_EXCLUDE) + { + fprintf (asm_out_file, "\t.section\t%s,#exclude\n", name); + return; + } #endif default_elf_asm_named_section (name, flags, decl); diff --git a/gcc/config/sparc/sparc.c b/gcc/config/sparc/sparc.c index 768ee2b829c..6b6f155f49f 100644 --- a/gcc/config/sparc/sparc.c +++ b/gcc/config/sparc/sparc.c @@ -10502,6 +10502,10 @@ sparc_solaris_elf_asm_named_section (const char *name, unsigned int flags, if (!(flags & SECTION_DEBUG)) fputs (",#alloc", asm_out_file); +#if HAVE_GAS_SECTION_EXCLUDE + if (flags & SECTION_EXCLUDE) + fputs (",#exclude", asm_out_file); +#endif if (flags & SECTION_WRITE) fputs (",#write", asm_out_file); if (flags & SECTION_TLS) diff --git a/gcc/configure b/gcc/configure index 7d69faf549d..60d373982fd 100755 --- a/gcc/configure +++ b/gcc/configure @@ -23514,6 +23514,89 @@ $as_echo "#define USE_AS_TRADITIONAL_FORMAT 1" >>confdefs.h fi +# Test if the assembler supports the section flag 'e' or #exclude for +# specifying an excluded section. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section exclude flag" >&5 +$as_echo_n "checking assembler for section exclude flag... " >&6; } +if test "${gcc_cv_as_section_exclude_e+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_section_exclude_e=no + if test $in_tree_gas = yes; then + if test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 22 \) \* 1000 + 51` + then gcc_cv_as_section_exclude_e=yes +fi + elif test x$gcc_cv_as != x; then + $as_echo '.section foo1,"e" + .byte 0,0,0,0' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags --fatal-warnings -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_section_exclude_e=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_section_exclude_e" >&5 +$as_echo "$gcc_cv_as_section_exclude_e" >&6; } + + +if test $gcc_cv_as_section_exclude_e = no; then + case "${target}" in + # Solaris as uses #exclude instead. + *-*-solaris2*) + case "${target}" in + sparc*-*-solaris2*) + conftest_s='.section "foo1", #exclude' + ;; + i?86-*-solaris2* | x86_64-*-solaris2*) + conftest_s='.section foo1, #exclude' + ;; + esac + ;; + esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section exclude flag" >&5 +$as_echo_n "checking assembler for section exclude flag... " >&6; } +if test "${gcc_cv_as_section_exclude_hash+set}" = set; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_section_exclude_hash=no + if test x$gcc_cv_as != x; then + $as_echo "$conftest_s + .byte 0,0,0,0" > 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_section_exclude_hash=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_section_exclude_hash" >&5 +$as_echo "$gcc_cv_as_section_exclude_hash" >&6; } + + +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_GAS_SECTION_EXCLUDE `if test $gcc_cv_as_section_exclude_e = yes || test $gcc_cv_as_section_exclude_hash = yes; then echo 1; else echo 0; fi` +_ACEOF + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for section merging support" >&5 $as_echo_n "checking assembler for section merging support... " >&6; } if test "${gcc_cv_as_shf_merge+set}" = set; then : @@ -25671,46 +25754,6 @@ $as_echo "#define HAVE_AS_XBRACE_COMMENT_OPTION 1" >>confdefs.h fi - # Test if the assembler supports the section flag 'e' for specifying - # an excluded section. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for .section with e" >&5 -$as_echo_n "checking assembler for .section with e... " >&6; } -if test "${gcc_cv_as_section_has_e+set}" = set; then : - $as_echo_n "(cached) " >&6 -else - gcc_cv_as_section_has_e=no - if test $in_tree_gas = yes; then - if test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 22 \) \* 1000 + 51` - then gcc_cv_as_section_has_e=yes -fi - elif test x$gcc_cv_as != x; then - $as_echo '.section foo1,"e" -.byte 0,0,0,0' > conftest.s - if { ac_try='$gcc_cv_as $gcc_cv_as_flags --fatal-warnings -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_section_has_e=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_section_has_e" >&5 -$as_echo "$gcc_cv_as_section_has_e" >&6; } - - - -cat >>confdefs.h <<_ACEOF -#define HAVE_GAS_SECTION_EXCLUDE `if test $gcc_cv_as_section_has_e = yes; then echo 1; else echo 0; fi` -_ACEOF - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for filds and fists mnemonics" >&5 $as_echo_n "checking assembler for filds and fists mnemonics... " >&6; } if test "${gcc_cv_as_ix86_filds+set}" = set; then : diff --git a/gcc/configure.ac b/gcc/configure.ac index 36124b8ce90..010ecd2ccf6 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -2953,6 +2953,34 @@ if test $gcc_cv_as_eh_frame = buggy; then [Define if your assembler mis-optimizes .eh_frame data.]) fi +# Test if the assembler supports the section flag 'e' or #exclude for +# specifying an excluded section. +gcc_GAS_CHECK_FEATURE([section exclude flag], gcc_cv_as_section_exclude_e, + [2,22,51], [--fatal-warnings], + [.section foo1,"e" + .byte 0,0,0,0]) +if test $gcc_cv_as_section_exclude_e = no; then + case "${target}" in + # Solaris as uses #exclude instead. + *-*-solaris2*) + case "${target}" in + sparc*-*-solaris2*) + conftest_s='.section "foo1", #exclude' + ;; + i?86-*-solaris2* | x86_64-*-solaris2*) + conftest_s='.section foo1, #exclude' + ;; + esac + ;; + esac + gcc_GAS_CHECK_FEATURE([section exclude flag], gcc_cv_as_section_exclude_hash,,, + [$conftest_s + .byte 0,0,0,0]) +fi +AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_EXCLUDE, + [`if test $gcc_cv_as_section_exclude_e = yes || test $gcc_cv_as_section_exclude_hash = yes; then echo 1; else echo 0; fi`], +[Define if your assembler supports specifying the exclude section flag.]) + gcc_GAS_CHECK_FEATURE(section merging support, gcc_cv_as_shf_merge, [elf,2,12,0], [--fatal-warnings], [.section .rodata.str, "aMS", @progbits, 1]) @@ -4202,16 +4230,6 @@ foo: nop [AC_DEFINE(HAVE_AS_XBRACE_COMMENT_OPTION, 1, [Define if your assembler supports -xbrace_comment option.])]) - # Test if the assembler supports the section flag 'e' for specifying - # an excluded section. - gcc_GAS_CHECK_FEATURE([.section with e], gcc_cv_as_section_has_e, - [2,22,51], [--fatal-warnings], -[.section foo1,"e" -.byte 0,0,0,0]) - AC_DEFINE_UNQUOTED(HAVE_GAS_SECTION_EXCLUDE, - [`if test $gcc_cv_as_section_has_e = yes; then echo 1; else echo 0; fi`], - [Define if your assembler supports specifying the section flag e.]) - gcc_GAS_CHECK_FEATURE([filds and fists mnemonics], gcc_cv_as_ix86_filds,,, [filds (%ebp); fists (%ebp)],, diff --git a/gcc/varasm.c b/gcc/varasm.c index bff43450a91..6b9f87b203f 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -6449,7 +6449,7 @@ default_elf_asm_named_section (const char *name, unsigned int flags, { if (!(flags & SECTION_DEBUG)) *f++ = 'a'; -#if defined (HAVE_GAS_SECTION_EXCLUDE) && HAVE_GAS_SECTION_EXCLUDE == 1 +#if HAVE_GAS_SECTION_EXCLUDE if (flags & SECTION_EXCLUDE) *f++ = 'e'; #endif -- 2.30.2