]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[SFrame-V3] gas: sframe: doc: testsuite: add new command line option --gsframe-3
authorIndu Bhagat <indu.bhagat@oracle.com>
Mon, 24 Nov 2025 20:16:05 +0000 (12:16 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Tue, 9 Dec 2025 08:26:15 +0000 (00:26 -0800)
This option will allow users to select emission of SFrame stack trace
information as per the SFrame version 3 specification.  Currenly, SFrame
version 3 is also the default.

In future, as SFrame evolves, similar command line args may be added for
future versions.

gas/
        * as.c (enum gen_sframe_version): New definition.
        (parse_args): Add option processing for --gsframe-3.
        * as.h (enum gen_sframe_version): New declaration.
        * doc/as.texi: Document the new option.
        * gen-sframe.c (sframe_set_version): Use enum gen_sframe_version
as version.
        (output_sframe): Likewise.
gas/testsuite/
        * gas/cfi-sframe/cfi-sframe.exp: New test.
        * gas/cfi-sframe/cfi-sframe-common-1d.d: Test new command line
option --gsframe-3.
        * gas/cfi-sframe/cfi-sframe-common-1d.s: Likewise.

gas/as.c
gas/as.h
gas/doc/as.texi
gas/gen-sframe.c
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1d.d [new file with mode: 0644]
gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1d.s [new file with mode: 0644]
gas/testsuite/gas/cfi-sframe/cfi-sframe.exp

index efcc80deef17dce1e26de33a6c25009de7f1625b..1491f6162fd4fdb90d20d0a86b8fc8250fe11ef7 100644 (file)
--- a/gas/as.c
+++ b/gas/as.c
@@ -118,6 +118,9 @@ bool flag_generate_build_notes = DEFAULT_GENERATE_BUILD_NOTES;
 #if DEFAULT_SFRAME
 enum gen_sframe_option flag_gen_sframe = GEN_SFRAME_CONFIG_ENABLED;
 #endif
+/* Version of SFrame stack trace info to generate.  Default version is
+   SFRAME_VERSION_3.  */
+enum gen_sframe_version flag_gen_sframe_version = GEN_SFRAME_VERSION_3;
 
 segT reg_section;
 segT expr_section;
@@ -318,7 +321,11 @@ 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: %s)\n"), DEFAULT_SFRAME ? "yes" : "no");
+                          (default: %s)\n\
+                         Default version emitted is V3\n"),
+          DEFAULT_SFRAME ? "yes" : "no");
+  fprintf (stream, _("\
+  --gsframe-<N>           generate SFrame version <N> information. 3 == <N>\n"));
 # if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
   fprintf (stream, _("\
   --scfi=experimental     Synthesize DWARF CFI for hand-written asm\n\
@@ -513,6 +520,7 @@ parse_args (int * pargc, char *** pargv)
       OPTION_NO_PAD_SECTIONS,
       OPTION_MULTIBYTE_HANDLING,  /* = STD_BASE + 40 */
       OPTION_SFRAME,
+      OPTION_SFRAME_3,
       OPTION_SCFI,
       OPTION_INFO,
       OPTION_NOINFO
@@ -547,6 +555,7 @@ parse_args (int * pargc, char *** pargv)
     ,{"sectname-subst", no_argument, NULL, OPTION_SECTNAME_SUBST}
     ,{"generate-missing-build-notes", required_argument, NULL, OPTION_ELF_BUILD_NOTES}
     ,{"gsframe", optional_argument, NULL, OPTION_SFRAME}
+    ,{"gsframe-3", no_argument, NULL, OPTION_SFRAME_3}
 # if defined (TARGET_USE_SCFI) && defined (TARGET_USE_GINSN)
     ,{"scfi", required_argument, NULL, OPTION_SCFI}
 # endif
@@ -1058,6 +1067,10 @@ This program has absolutely no warranty.\n"));
            flag_gen_sframe = GEN_SFRAME_ENABLED;
          break;
 
+       case OPTION_SFRAME_3:
+         flag_gen_sframe_version = GEN_SFRAME_VERSION_3;
+         break;
+
 #endif /* OBJ_ELF */
 
        case 'Z':
index b743ba95cc71dfd85aa70c12cb9dd99d0e16beb9..2455888bc3cde60a31dc4a6810b059775597b0cb 100644 (file)
--- a/gas/as.h
+++ b/gas/as.h
@@ -380,6 +380,13 @@ enum gen_sframe_option
 /* State of the setting for SFrame section creation.  */
 COMMON enum gen_sframe_option flag_gen_sframe;
 
+enum gen_sframe_version
+{
+  GEN_SFRAME_VERSION_3 = 3,
+};
+
+COMMON enum gen_sframe_version flag_gen_sframe_version;
+
 /* name of emitted object file */
 COMMON const char *out_file_name;
 
index 5c5f499c85c9c35947c9e9138bc9f3db70a62e88..743bd580d9cd5209fbdb02b7ba0ddd16be3aa0ab 100644 (file)
@@ -241,6 +241,7 @@ gcc(1), ld(1), and the Info entries for @file{binutils} and @file{ld}.
  [@b{--gdwarf-cie-version}=@var{VERSION}]
  [@b{--generate-missing-build-notes=[no|yes]}]
  [@b{--gsframe}] [@b{--gsframe=[no|yes]}]
+ [@b{--gsframe-3}]
  [@b{--hash-size}=@var{N}]
  [@b{--help}] [@b{--target-help}]
  [@b{--info}] [@b{--no-info}]
@@ -864,7 +865,11 @@ configure option.
 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}.  The default can be
-controlled by a configure option @option{--enable-default-sframe}.
+controlled by a configure option @option{--enable-default-sframe}.  The current
+version of the emitted SFrame stack trace data is SFRAME_VERSION_3.
+
+@item --gsframe-3
+Generate SFrame stack trace information as per Version 3 of the specification.
 
 @end ifset
 
index 664e62be1c9e0a929db5386db1703991982ee32d..f542e25c21a4c92a310a5e33f8265e61d22613df 100644 (file)
@@ -331,16 +331,17 @@ sframe_v3_set_func_info (unsigned int fde_type, unsigned int fre_type,
 /* SFrame version specific operations setup.  */
 
 static void
-sframe_set_version (uint32_t sframe_version ATTRIBUTE_UNUSED)
+sframe_set_version (enum gen_sframe_version flag_ver)
 {
-  sframe_ver_ops.format_version = SFRAME_VERSION_3;
-
-  /* These operations remain the same for SFRAME_VERSION_3 as fre_info and
-     func_info have not changed from SFRAME_VERSION_2 and SFRAME_VERSION_1.  */
-
-  sframe_ver_ops.set_fre_info = sframe_v1_set_fre_info;
-
-  sframe_ver_ops.set_func_info = sframe_v3_set_func_info;
+  if (flag_ver == GEN_SFRAME_VERSION_3)
+    {
+      sframe_ver_ops.format_version = SFRAME_VERSION_3;
+      /* These operations remain the same for SFRAME_VERSION_3 as fre_info and
+        func_info layout has not changed from SFRAME_VERSION_2 and
+        SFRAME_VERSION_1.  */
+      sframe_ver_ops.set_fre_info = sframe_v1_set_fre_info;
+      sframe_ver_ops.set_func_info = sframe_v3_set_func_info;
+    }
 }
 
 /* SFrame set FRE info.  */
@@ -2429,8 +2430,10 @@ output_sframe (segT sframe_seg)
 {
   (void) sframe_seg;
 
+  /* Currently only SFRAME_VERSION_3 can be emitted.  */
+  gas_assert (flag_gen_sframe_version == GEN_SFRAME_VERSION_3);
   /* Setup the version specific access functions.  */
-  sframe_set_version (SFRAME_VERSION_3);
+  sframe_set_version (flag_gen_sframe_version);
 
   /* Process all fdes and create SFrame stack trace information.  */
   create_sframe_all ();
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1d.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1d.d
new file mode 100644 (file)
index 0000000..2369041
--- /dev/null
@@ -0,0 +1,13 @@
+#as: --gsframe-3
+#readelf: --sframe
+#name: Generate SFrame V3 section
+Contents of the SFrame section .sframe:
+  Header :
+
+    Version: SFRAME_VERSION_3
+    Flags: SFRAME_F_FDE_FUNC_START_PCREL
+#...
+    Num FDEs: 1
+    Num FREs: 1
+
+#...
diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1d.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-common-1d.s
new file mode 100644 (file)
index 0000000..ac9c6ca
--- /dev/null
@@ -0,0 +1,3 @@
+       .cfi_sections .sframe
+       .cfi_startproc
+       .cfi_endproc
index d7a2afbaf3d2fcc50a67a5a9e1c9abc3c1ffe491..bb1cbbf3d71062f3a72cc978779720a9fdb90148 100644 (file)
@@ -37,6 +37,7 @@ if  { ([istarget "x86_64-*-*"] || [istarget "aarch64*-*-*"]
     run_dump_test "cfi-sframe-common-1"
     run_dump_test "cfi-sframe-common-1b"
     run_dump_test "cfi-sframe-common-1c"
+    run_dump_test "cfi-sframe-common-1d"
     run_dump_test "cfi-sframe-common-2"
     run_dump_test "cfi-sframe-common-3"
     run_dump_test "cfi-sframe-common-4"