]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
ld: bfd: sframe: fix incorrect offset in RELA entries users/ibhagat/try-pr32589-pr32666
authorIndu Bhagat <indu.bhagat@oracle.com>
Thu, 6 Feb 2025 21:38:04 +0000 (13:38 -0800)
committerIndu Bhagat <indu.bhagat@oracle.com>
Wed, 26 Feb 2025 00:00:43 +0000 (16:00 -0800)
commitbdbbe876990c3414aaaba7e80413f2ac13cffb12
tree8dc19e79d686c3e2eabafbac87162c0602766357
parent83329bd4ddad3a1503555d43231e0322868a1f01
ld: bfd: sframe: fix incorrect offset in RELA entries

PR/32666  Incorrect .rela.sframe when using ld -r

Input SFrame sections are merged using _bfd_elf_merge_section_sframe (),
which clubs all SFrame FDEs together in one blob and all SFrame FREs in
another.  This, of course, means the offset of an FDE in the output
section cannot be simply derived from the output_offset of the sections.

Fix this by providing _bfd_elf_sframe_section_offset () which returns
the new offset of the SFrame FDE in the merged SFrame section.

TBD:
  - Q: The _bfd_elf_sframe_section_offset () function does assume that
    _bfd_elf_merge_section_sframe () has not been called on the
    associated .sframe section yet.  Is this an OK assumption ?

bfd/
        * elf-bfd.h: New declaration.
        * elf-sframe.c (_bfd_elf_sframe_section_offset): New definition.
        * elf.c (_bfd_elf_section_offset): Adjust offset if SFrame
section.
        * elflink.c (elf_link_input_bfd): RELA offset adjust be done
conditionally.

ld/testsuite/
        * ld-x86-64/x86-64.exp: New test.
        * ld-x86-64/sframe-reloc-1.d: New test.
bfd/elf-bfd.h
bfd/elf-sframe.c
bfd/elf.c
bfd/elflink.c
ld/testsuite/ld-x86-64/sframe-reloc-1.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp