diff --git a/gas/as.c b/gas/as.c index 58ed0a59e21..efcc80deef1 100644 --- a/gas/as.c +++ b/gas/as.c @@ -113,6 +113,12 @@ int flag_use_elf_stt_common = DEFAULT_GENERATE_ELF_STT_COMMON; bool flag_generate_build_notes = DEFAULT_GENERATE_BUILD_NOTES; #endif +/* If DEFAULT_SFRAME is 0 instead, flag_gen_sframe gets the default + enum value GEN_SFRAME_DEFAULT_NONE. */ +#if DEFAULT_SFRAME +enum gen_sframe_option flag_gen_sframe = GEN_SFRAME_CONFIG_ENABLED; +#endif + segT reg_section; segT expr_section; segT text_section; @@ -312,7 +318,7 @@ Options:\n\ generate GNU Build notes if none are present in the input\n")); fprintf (stream, _("\ --gsframe[={no|yes}] whether to generate SFrame stack trace information\n\ - (default: no)\n")); + (default: %s)\n"), DEFAULT_SFRAME ? "yes" : "no"); # if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN) fprintf (stream, _("\ --scfi=experimental Synthesize DWARF CFI for hand-written asm\n\ diff --git a/gas/config.in b/gas/config.in index bb896244640..ba042ca44eb 100644 --- a/gas/config.in +++ b/gas/config.in @@ -60,6 +60,9 @@ /* Define default value for RISC-V -mpriv-spec */ #undef DEFAULT_RISCV_PRIV_SPEC +/* Define to 1 if you want to emit SFrames by default. */ +#undef DEFAULT_SFRAME + /* Define to 1 if you want to check x86 TLS relocation by default. */ #undef DEFAULT_X86_TLS_CHECK diff --git a/gas/configure b/gas/configure index 97340444b72..12d96a5acd2 100755 --- a/gas/configure +++ b/gas/configure @@ -820,6 +820,7 @@ enable_default_compressed_debug_sections_algorithm enable_x86_relax_relocations enable_x86_tls_check enable_elf_stt_common +enable_default_sframe enable_generate_build_notes enable_mips_fix_loongson3_llsc enable_x86_used_note @@ -1497,6 +1498,7 @@ Optional Features: --enable-x86-tls-check check x86 TLS relocation by default --enable-elf-stt-common generate ELF common symbols with STT_COMMON type by default + --enable-default-sframe generate SFrame by default --enable-generate-build-notes generate GNU Build notes if none are provided by the input @@ -10777,7 +10779,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10780 "configure" +#line 10782 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -10883,7 +10885,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext <<_LT_EOF -#line 10886 "configure" +#line 10888 "configure" #include "confdefs.h" #if HAVE_DLFCN_H @@ -11599,6 +11601,15 @@ if test "${enable_elf_stt_common+set}" = set; then : esac fi +ac_default_sframe=unset +# Provide a configure time option to override our default. +# Check whether --enable-default-sframe was given. +if test "${enable_default_sframe+set}" = set; then : + enableval=$enable_default_sframe; case "${enableval}" in + yes) ac_default_sframe=1 ;; + no) ac_default_sframe=0 ;; +esac +fi # Decide if the ELF assembler should default to generating # GNU Build notes if none are provided by the input. @@ -12723,6 +12734,15 @@ cat >>confdefs.h <<_ACEOF _ACEOF +if test ${ac_default_sframe} = unset; then + ac_default_sframe=0 +fi + +cat >>confdefs.h <<_ACEOF +#define DEFAULT_SFRAME $ac_default_sframe +_ACEOF + + cat >>confdefs.h <<_ACEOF #define DEFAULT_GENERATE_BUILD_NOTES $ac_default_generate_build_notes diff --git a/gas/configure.ac b/gas/configure.ac index c65797fdf0a..78fe021bafd 100644 --- a/gas/configure.ac +++ b/gas/configure.ac @@ -117,6 +117,15 @@ AC_ARG_ENABLE(elf_stt_common, yes) ac_default_elf_stt_common=1 ;; esac])dnl +ac_default_sframe=unset +# Provide a configure time option to override our default. +AC_ARG_ENABLE(default-sframe, + AS_HELP_STRING([--enable-default-sframe], + [generate SFrame by default]), +[case "${enableval}" in + yes) ac_default_sframe=1 ;; + no) ac_default_sframe=0 ;; +esac])dnl # Decide if the ELF assembler should default to generating # GNU Build notes if none are provided by the input. @@ -757,6 +766,13 @@ AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_ELF_STT_COMMON, [Define to 1 if you want to generate ELF common symbols with the STT_COMMON type by default.]) +if test ${ac_default_sframe} = unset; then + ac_default_sframe=0 +fi +AC_DEFINE_UNQUOTED(DEFAULT_SFRAME, + $ac_default_sframe, + [Define to 1 if you want to emit SFrames by default.]) + AC_DEFINE_UNQUOTED(DEFAULT_GENERATE_BUILD_NOTES, $ac_default_generate_build_notes, [Define to 1 if you want to generate GNU Build attribute notes diff --git a/gas/doc/as.texi b/gas/doc/as.texi index 2db5f4896ee..28fb6a6a97b 100644 --- a/gas/doc/as.texi +++ b/gas/doc/as.texi @@ -864,7 +864,8 @@ configure option. @itemx --gsframe=yes Create @var{.sframe} section from CFI directives. The explicit @option{--gsframe=yes} option behaves the same as @option{--gsframe}. -Generation can be suppressed with @option{--gsframe=no}. +Generation can be suppressed with @option{--gsframe=no}. The default can be +controlled by a configure option @option{--enable-default-sframe}. @end ifset diff --git a/gas/dw2gencfi.c b/gas/dw2gencfi.c index c28856cdf24..186dfa667c8 100644 --- a/gas/dw2gencfi.c +++ b/gas/dw2gencfi.c @@ -2598,9 +2598,11 @@ cfi_finish (void) /* Generate SFrame section if the user: - enables via the command line option, or + - default-enabled at configure-time via --enable-default-sframe, or - specifies .sframe in the .cfi_sections directive and does not disable via the command line. */ if (flag_gen_sframe == GEN_SFRAME_ENABLED + || flag_gen_sframe == GEN_SFRAME_CONFIG_ENABLED || ((all_cfi_sections & CFI_EMIT_sframe) != 0 && flag_gen_sframe != GEN_SFRAME_DISABLED)) { @@ -2619,7 +2621,9 @@ cfi_finish (void) } else #endif - as_bad (_(".sframe not supported for target")); + /* Avoid erroring with DEFAULT_SFRAME for non-default options, like + -32 on x86_64. */ + sframe_as_bad (_(".sframe not supported for target")); } if ((all_cfi_sections & CFI_EMIT_debug_frame) != 0) diff --git a/gas/gen-sframe.h b/gas/gen-sframe.h index e4a4c6ea0ce..8ad521b5cbe 100644 --- a/gas/gen-sframe.h +++ b/gas/gen-sframe.h @@ -21,6 +21,16 @@ #ifndef GENSFRAME_H #define GENSFRAME_H +/* Errors shouldn't be emitted either if SFrames are default-enabled, as + we interpret default-enabled as "opportunistic SFrames". Users don't + want to be bothered by something preventing emission of SFrames in + such a case. */ +#define sframe_as_bad(format, ...) \ + do { \ + if (flag_gen_sframe == GEN_SFRAME_ENABLED) \ + as_bad (format, ##__VA_ARGS__); \ + } while (0) + #define SFRAME_FRE_ELEM_LOC_REG 0 #define SFRAME_FRE_ELEM_LOC_STACK 1