From ff8f339f2315321c1dd8fb4af8b27d0f07ed8e17 Mon Sep 17 00:00:00 2001 From: Indu Bhagat Date: Wed, 3 Dec 2025 15:45:20 -0800 Subject: [PATCH] [SFrame-V3] ld: discard sframe sections when --no-sframe-info 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 | 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 217f8927936..72a4feb8b17 100644 --- a/bfd/elf-sframe.c +++ b/bfd/elf-sframe.c @@ -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 index 00000000000..dd1e645c5b7 --- /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 --no-sframe-info +#name: Command line option --no-sframe-info + +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 f04ae923ebc..45103ae1e4d 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.47.3