]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
elf: Properly set sh_offset for .tbss sections
authorH.J. Lu <hjl.tools@gmail.com>
Sun, 27 Apr 2025 23:12:48 +0000 (07:12 +0800)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 29 Apr 2025 07:39:54 +0000 (15:39 +0800)
commit5e247da8afb8b764cb111ce1a05e8cb8862a7f98
treefeeca18d6239b42756fb9b36d13b79c8a046b7ff
parentb1f0f5b31c414b3445cdcbc5bf9ca31638c7712a
elf: Properly set sh_offset for .tbss sections

Set sh_offset for .tbss sections to their nominal offset after aligning.
They are not loaded from disk so the value doesn't really matter, except
when the .tbss section is the first one in a PT_TLS segment.  In that
case, it sets the p_offset for the PT_TLS segment, which according to
the ELF gABI ought to satisfy p_offset % p_align == p_vaddr % p_align.

bfd/

PR ld/32896
* elf.c (assign_file_positions_for_load_sections): Properly set
sh_offset for .tbss sections.

ld/

PR ld/32896
* testsuite/ld-elf/tbss4.d: New file.
* testsuite/ld-elf/tbss4.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
bfd/elf.c
ld/testsuite/ld-elf/tbss4.d [new file with mode: 0644]
ld/testsuite/ld-elf/tbss4.s [new file with mode: 0644]