]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
[SFrame-V3] ld: discard sframe sections when --no-sframe-info
authorIndu Bhagat <indu.bhagat@oracle.com>
Wed, 3 Dec 2025 23:45:20 +0000 (15:45 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Tue, 9 Dec 2025 08:26:15 +0000 (00:26 -0800)
Mark SFrame sections with SEC_EXCLUDE if --no-sframe-info is in effect.

TBD:
  - This does generate an empty .sframe section though!  A problem ? No
    segment marker PT_GNU_SFRAME is created, which is good

bfd/
        * elf-sframe.c (_bfd_elf_parse_sframe): Mark with SEC_EXCLUDE if
  --no-sframe-info is in effect.
ld/testsuite/
        * ld-x86-64/x86-64.exp: New test.
        * ld-x86-64/sframe-command-line-1.d: New test.

bfd/elf-sframe.c
ld/testsuite/ld-x86-64/sframe-command-line-1.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 217f892793605b55616f9b520b0fe77039a80987..72a4feb8b17a50e8bbb91bb8364891ac7ffb5f9c 100644 (file)
@@ -200,6 +200,9 @@ _bfd_elf_parse_sframe (bfd *abfd,
   bfd_size_type sf_size;
   int decerr = 0;
 
+  if (info->no_ld_sframe_info)
+    sec->flags |= SEC_EXCLUDE;
+
   /* Prior versions of assembler and ld were generating SFrame sections with
      section type SHT_PROGBITS.  Issue an error for lack of support for such
      objects now.  Even if section size is zero, a valid section type is
diff --git a/ld/testsuite/ld-x86-64/sframe-command-line-1.d b/ld/testsuite/ld-x86-64/sframe-command-line-1.d
new file mode 100644 (file)
index 0000000..dd1e645
--- /dev/null
@@ -0,0 +1,8 @@
+#as: --gsframe
+#source: sframe-foo.s
+#source: sframe-bar.s
+#readelf: --sframe
+#ld: -shared --no-rosegment -z separate-code --no-sframe-info
+#name: Command line option --no-sframe-info
+
+Section '.sframe' has no debugging data.
index f04ae923ebc983457cff618574954060d2066182..45103ae1e4d9a4cd8b7de6c026dbfaa9af67884e 100644 (file)
@@ -587,6 +587,7 @@ run_dump_test "tls-le-pic-3-x32"
 
 if { ![skip_sframe_tests] } {
     run_dump_test "sframe-simple-1"
+    run_dump_test "sframe-command-line-1"
     run_dump_test "sframe-reloc-1"
     run_dump_test "sframe-plt-1"
     run_dump_test "sframe-ibt-plt-1"