[PATCH] elf: Properly set sh_offset for .tbss sections

Jan Beulich jbeulich@suse.com
Mon Apr 28 06:08:56 GMT 2025


On 28.04.2025 04:47, H.J. Lu wrote:
> 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.

Why does the order of checks (PT_LOAD then SHT_NOBITS) need changing here?
While pre-existing, I'm also having a hard time seeing why among SHT_NOBITS
sections SHF_TLS ones would need special casing here. While I agree that
the usual requirements have to be met by PT_TLS, the entire change feels
like it's papering over an issue elsewhere (presumably in the laying out of
load segments).

Jan



More information about the Binutils mailing list