[PATCH v3] gas: support --gsframe=no

H.J. Lu hjl.tools@gmail.com
Tue Jul 15 01:52:24 GMT 2025


On Tue, Jul 15, 2025 at 9:00 AM Sam James <sam@gentoo.org> wrote:
>
> Being able to explicitly disable SFrames on the command line is useful,
> especially when looking at a gas that enables SFrames by default. The
> binutils testsuite will benefit from this as there's testcases that don't
> expect their presence.
>
> In summary:
> * Nothing is passed       => no SFrames (no change from before)
> * --gsframe is passed     => SFrames    (no change from before)
> * --gsframe=yes is passed => SFrames    (previously rejected)
> * --gsframe-no  is passed => no SFrames (previously rejected)
>
>         PR gas/33125
>         * gas/as.c (parse_args): Accept --gsframe=no, --gsframe=yes.
> ---
> I've pushed this after discussing with Indu off-list and reaching
> consensus. Thanks.
>
>  gas/as.c | 17 ++++++++++++++---
>  1 file changed, 14 insertions(+), 3 deletions(-)
>
> diff --git a/gas/as.c b/gas/as.c
> index 78970ff2714..ce89d6f5aa7 100644
> --- a/gas/as.c
> +++ b/gas/as.c
> @@ -311,7 +311,8 @@ Options:\n\
>    fprintf (stream, _("\
>                            generate GNU Build notes if none are present in the input\n"));
>    fprintf (stream, _("\
> -  --gsframe               generate SFrame stack trace information\n"));
> +  --gsframe=[no|yes]      whether to generate SFrame stack trace information\n\
> +                          (default: no)\n"));
>  # if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
>    fprintf (stream, _("\
>    --scfi=experimental     Synthesize DWARF CFI for hand-written asm\n\
> @@ -539,7 +540,7 @@ parse_args (int * pargc, char *** pargv)
>      ,{"elf-stt-common", required_argument, NULL, OPTION_ELF_STT_COMMON}
>      ,{"sectname-subst", no_argument, NULL, OPTION_SECTNAME_SUBST}
>      ,{"generate-missing-build-notes", required_argument, NULL, OPTION_ELF_BUILD_NOTES}
> -    ,{"gsframe", no_argument, NULL, OPTION_SFRAME}
> +    ,{"gsframe", optional_argument, NULL, OPTION_SFRAME}
>  # if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
>      ,{"scfi", required_argument, NULL, OPTION_SCFI}
>  # endif
> @@ -1038,7 +1039,17 @@ This program has absolutely no warranty.\n"));
>           break;
>
>         case OPTION_SFRAME:
> -         flag_gen_sframe = 1;
> +         if (optarg)
> +           {
> +           if (strcasecmp (optarg, "no") == 0)
> +             flag_gen_sframe = 0;
> +           else if (strcasecmp (optarg, "yes") == 0)
> +             flag_gen_sframe = 1;
> +           else
> +             as_fatal (_("Invalid --gsframe option: `%s'"), optarg);
> +           }
> +         else
> +           flag_gen_sframe = 1;
>           break;
>
>  #endif /* OBJ_ELF */
> --
> 2.50.1
>

Should we apply this patch to properly indent the newly added lines?

-- 
H.J.
-------------- next part --------------
diff --git a/gas/as.c b/gas/as.c
index ce89d6f5aa7..acdf6bb74fd 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -1041,12 +1041,12 @@ This program has absolutely no warranty.\n"));
 	case OPTION_SFRAME:
 	  if (optarg)
 	    {
-	    if (strcasecmp (optarg, "no") == 0)
-	      flag_gen_sframe = 0;
-	    else if (strcasecmp (optarg, "yes") == 0)
-	      flag_gen_sframe = 1;
-	    else
-	      as_fatal (_("Invalid --gsframe option: `%s'"), optarg);
+	      if (strcasecmp (optarg, "no") == 0)
+		flag_gen_sframe = 0;
+	      else if (strcasecmp (optarg, "yes") == 0)
+		flag_gen_sframe = 1;
+	      else
+		as_fatal (_("Invalid --gsframe option: `%s'"), optarg);
 	    }
 	  else
 	    flag_gen_sframe = 1;


More information about the Binutils mailing list