[PATCH] elf: Don't set sh_offset of .tbss sections beyond EOF
H.J. Lu
hjl.tools@gmail.com
Tue Apr 29 08:36:31 GMT 2025
On Tue, Apr 29, 2025 at 3:42 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> > I'd rather you committed v1. This one might make a TLS segment with
> > both .tdata and .tbss look a little wierd.
> >
>
> I pushed v1. I will keep the bug open and see if I can find a solution for
> a TLS segment with both .tdata and .tbss without looking weird.
>
Here is the patch. We clamp the .tbss sh_offset within the first page
only if there are no prior .tdata nor .tbss sections.
OK for master?
Thanks.
--
H.J.
---
If there are no prior .tdata nor .tbss sections, put meaningless sh_offset
of .tbss sections without file contents somewhere within the first page,
in an attempt to not point past EOF and avoid sh_offset of zero.
bfd/
PR ld/32896
* elf.c (IS_TDATA): New.
(assign_file_positions_for_load_sections): Don't set sh_offset
of .tbss sections beyond EOF.
ld/
PR ld/32896
* testsuite/ld-elf/tbss4.d: Updated.
* testsuite/ld-elf/tbss5.d: New file.
* testsuite/ld-elf/tbss5.s: Likewise.
* testsuite/ld-elf/tbss6.d: Likewise.
* testsuite/ld-elf/tbss6.s: Likewise.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-elf-Don-t-set-sh_offset-of-.tbss-sections-beyond-EOF.patch
Type: text/x-patch
Size: 5950 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20250429/f454330e/attachment.bin>
More information about the Binutils
mailing list