aboutsummaryrefslogtreecommitdiff
path: root/libsframe
diff options
context:
space:
mode:
authorIndu Bhagat <indu.bhagat@oracle.com>2025-07-11 23:32:58 -0700
committerIndu Bhagat <indu.bhagat@oracle.com>2025-07-11 23:32:58 -0700
commit6ab3f09a682adcb4e841faf7fc19dea2671debed (patch)
treec36fb7423de76579a8f44e10d842669a1f5a9ff6 /libsframe
parent7f8017add951c46959e54590c70cb2adcc1cede4 (diff)
downloadbinutils-6ab3f09a682adcb4e841faf7fc19dea2671debed.zip
binutils-6ab3f09a682adcb4e841faf7fc19dea2671debed.tar.gz
binutils-6ab3f09a682adcb4e841faf7fc19dea2671debed.tar.bz2
gas: elf: binutils: add new section type SHT_GNU_SFRAME
So far, SFrame sections were of type SHT_PROGBITS. As per ELF specification, SHT_PROGBITS indicates that the section holds information defined by the program, whose format and meaning are determined solely by the program. On the linker side, SHT_PROGBITS should be reserved for the simple "cat contents after applying relocs" semantics. Currently, the only way to know that a section contains SFrame stack trace data is if consumer checks for section name. Such a check for section name is not quite conformant to ELF principles. Some of this was discussed here https://sourceware.org/pipermail/binutils/2025-March/140181.html With this change, the SFrame sections generated by gas, ld will have section type set to SHT_GNU_SFRAME. The new section type is defined in the SHT_LOOS/SHT_HIOS space. The SFrame parsing routine _bfd_elf_parse_sframe () now admits sections only when the the section type is SHT_GNU_SFRAME. No special handling / validation is done at the moment for the case of manual creation of SFrame sections via obj_elf_section (). Add function level comments for now to add a note about this. Although the default handling for (sh_type >= SHT_LOOS && sh_type <= SHT_HIOS) is sufficient when SHT_GNU_SFRAME is in that range, it makes sense to add it as a case of its own. bfd/ * elf-sframe.c (_bfd_elf_parse_sframe): Check if section type is SHT_GNU_SFRAME. (_bfd_elf_set_section_sframe): Set SHT_GNU_SFRAME for output SFrame section. * elflink.c (obj_elf_section): Use section type for check instead of section name. * elfxx-x86.c: Set SHT_GNU_SFRAME for SFrame sections for .plt* sections. * elf.c (bfd_section_from_shdr): Add case for SHT_GNU_SFRAME. binutils/ * readelf.c (get_os_specific_section_type_name): Add SHT_GNU_SFRAME. gas/ * NEWS: Announce emitted SFrame sections have SHT_GNU_SFRAME set. * config/obj-elf.c (obj_elf_attach_to_group): Add comments to indicate no special handling for SFrame yet. * dw2gencfi.c (cfi_finish): Set SHT_GNU_SFRAME for emitted SFrame section. ld/ * NEWS: Announce emitted SFrame sections have SHT_GNU_SFRAME set. gas/testsuite/ * gas/cfi-sframe/cfi-sframe.exp: Add new test. * gas/cfi-sframe/cfi-sframe-common-1b.d: New test. * gas/cfi-sframe/cfi-sframe-common-1b.s: New test. include/ * elf/common.h (SHT_GNU_SFRAME): Add new section type for SFrame stack trace information. libsframe/doc/ * sframe-spec.texi: Add expected ELF section type.
Diffstat (limited to 'libsframe')
-rw-r--r--libsframe/doc/sframe-spec.texi7
1 files changed, 4 insertions, 3 deletions
diff --git a/libsframe/doc/sframe-spec.texi b/libsframe/doc/sframe-spec.texi
index ecc333d..7307789 100644
--- a/libsframe/doc/sframe-spec.texi
+++ b/libsframe/doc/sframe-spec.texi
@@ -77,9 +77,10 @@ Appendices
@section Overview
@cindex Overview
-The SFrame stack trace information is provided in a loaded section, known as the
-@code{.sframe} section. When available, the @code{.sframe} section appears in
-a new segment of its own, PT_GNU_SFRAME.
+The SFrame stack trace information is provided in a loaded section, known as
+the @code{.sframe} section. When available, the @code{.sframe} section appears
+in segment of type PT_GNU_SFRAME. An ELF SFrame section will have the type
+SHT_GNU_SFRAME.
The SFrame format is currently supported only for select ABIs, namely, AMD64,
AAPCS64, and s390x.