]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld: generate SFrame stack trace info for .plt.got
authorIndu Bhagat <indu.bhagat@oracle.com>
Fri, 1 Nov 2024 22:36:35 +0000 (15:36 -0700)
committerIndu Bhagat <indu.bhagat@oracle.com>
Fri, 1 Nov 2024 22:36:35 +0000 (15:36 -0700)
commit47c88752f9adf3815566ae52731867a3bb87b044
tree1170642ee4e94e291ab2deff8ec528f63d87e88b
parent938fb512184d90d24b86c42ef53ef33c943cbe8b
ld: generate SFrame stack trace info for .plt.got

PR/32298 sframe: no SFrame stack trace info generated for .plt.got

Add support to generate SFrame stack trace info for .plt.got section.
Enhance the current definition of struct elf_x86_sframe_plt to include
initialized SFrame FDE/FREs applicable for .plt.got section.  There are
two variants of .plt.got entries: 16 byte and 8 byte.

8 byte:
    ff 25 00 00 00 00     jmpq  *name@GOTPCREL(%rip)
    66 90                 xchg  %ax,%ax

16 byte:
    f3 0f 1e fa           endbr64
    ff 25 66 2f 00 00     jmpq  *name@GOTPCREL(%rip)
    66 0f 1f 44 00 00     nopw   0x0(%rax,%rax,1)

For the testcase, define some application symbols such that their PLT
entry is placed in .plt.got and ensure SFrame information is generated
with and without -z ibtplt.

ChangeLog:
PR/32298
* bfd/elf64-x86-64.c (elf_x86_64_link_setup_gnu_properties):
PLT GOT entry size is different for IBT vs non IBT PLTs.
* bfd/elfxx-x86.c (enum dynobj_sframe_plt_type): New enum for
SFRAME_PLT_GOT.
(_bfd_x86_elf_create_sframe_plt): Handle SFRAME_PLT_GOT.
(_bfd_x86_elf_write_sframe_plt): Likewise.
(_bfd_x86_elf_late_size_sections): Likewise.
(_bfd_x86_elf_finish_dynamic_sections): Likewise.
* bfd/elfxx-x86.h (struct elf_x86_sframe_plt): Add new members
to keep information about PLT GOT entries.
(struct elf_x86_link_hash_table): Add support for creating
SFrame section for .plt.got.
* ld/testsuite/ld-x86-64/x86-64.exp: Add new tests.
* ld/testsuite/ld-x86-64/sframe-pltgot-1.d: New test.
* ld/testsuite/ld-x86-64/sframe-pltgot-1.s: New test.
* ld/testsuite/ld-x86-64/sframe-pltgot-2.d: New test.
bfd/elf64-x86-64.c
bfd/elfxx-x86.c
bfd/elfxx-x86.h
ld/testsuite/ld-x86-64/sframe-pltgot-1.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/sframe-pltgot-1.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/sframe-pltgot-2.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp