[V2 31/36] [SFrame-V3] ld: discard sframe sections when --discard-sframe
Indu Bhagat
indu.bhagat@oracle.com
Wed Jan 7 08:42:22 GMT 2026
Mark SFrame sections with SEC_EXCLUDE if --discard-sframe 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
--discard-sframe is in effect.
ld/testsuite/
* ld-x86-64/x86-64.exp: New test.
* ld-x86-64/sframe-command-line-1.d: New test.
---
[Changes in V1]
- Rename to --discard-sframe-sections [Jan].
[End of changes in V1]
[Changes in V2]
- Rename to --discard-sframe [Jan, Indu].
[End of changes in V2]
---
bfd/elf-sframe.c | 3 +++
ld/testsuite/ld-x86-64/sframe-command-line-1.d | 8 ++++++++
ld/testsuite/ld-x86-64/x86-64.exp | 1 +
3 files changed, 12 insertions(+)
create mode 100644 ld/testsuite/ld-x86-64/sframe-command-line-1.d
diff --git a/bfd/elf-sframe.c b/bfd/elf-sframe.c
index 511a297054b..33e4df5b1c7 100644
--- a/bfd/elf-sframe.c
+++ b/bfd/elf-sframe.c
@@ -211,6 +211,9 @@ _bfd_elf_parse_sframe (bfd *abfd,
bfd_size_type sf_size;
int decerr = 0;
+ if (info->discard_sframe)
+ 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
index 00000000000..3f54ff9f83a
--- /dev/null
+++ b/ld/testsuite/ld-x86-64/sframe-command-line-1.d
@@ -0,0 +1,8 @@
+#as: --gsframe
+#source: sframe-foo.s
+#source: sframe-bar.s
+#readelf: --sframe
+#ld: -shared --no-rosegment -z separate-code --discard-sframe
+#name: Command line option --discard-sframe
+
+Section '.sframe' has no debugging data.
diff --git a/ld/testsuite/ld-x86-64/x86-64.exp b/ld/testsuite/ld-x86-64/x86-64.exp
index f80f718c15b..df2bb5ea1bd 100644
--- a/ld/testsuite/ld-x86-64/x86-64.exp
+++ b/ld/testsuite/ld-x86-64/x86-64.exp
@@ -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"
--
2.43.0
More information about the Binutils
mailing list