[PATCH v2] elf: Don't set sh_offset of .tbss sections beyond EOF
H.J. Lu
hjl.tools@gmail.com
Tue Apr 29 12:56:23 GMT 2025
On Tue, Apr 29, 2025 at 4:36 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> 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?
Here is the v2 patch which works with any .tdata
sections before .tbss section.
> 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.
--
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-elf-Don-t-set-sh_offset-of-.tbss-sections-beyond-.patch
Type: text/x-patch
Size: 6167 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20250429/d8ae35ea/attachment.bin>
More information about the Binutils
mailing list