[PATCH v3] elf: Don't set sh_offset of .tbss sections beyond EOF

Matthew Malcomson mmalcomson@nvidia.com
Wed Apr 30 07:53:58 GMT 2025



On 4/30/25 00:52, H.J. Lu wrote:
> External email: Use caution opening links or attachments
> 
> 
> On Wed, Apr 30, 2025 at 7:14 AM Alan Modra <amodra@gmail.com> wrote:
>>
>> On Wed, Apr 30, 2025 at 05:38:00AM +0800, H.J. Lu wrote:
>>> If there is no .tdata section, 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.
>>
>> 1) Do we have any real world binaries where .tbss alignment is such
>> that it places sh_offset for the section past all other following
>> sections?  (.tbss has a lot of section following it, in contrast with
>> .bss.)
>> 2) Even if such binaries exist, do tools that manipulate the binary
>> still have bugs in their SHT_NOBITS handling?
>>
>> ie. Is any of this necessary?
> 
> I don't know the answer.  Matthew, can you comment on these?
> 

Ah -- I don't know either -- for these points I was just going based on 
what I read in the code.

(Just to ensure clarity -- the original testcase was something we were 
hitting -- it's the extra testcases that I suggested based on what I 
read in the code).

>> I'm inclined to think we should consider going the opposite direction,
>> removing the hack trying to prevent p_offset from being past
>> end-of-file if (2) is no longer true.
>>
>> --
>> Alan Modra
> 
> 
> 
> --
> H.J.



More information about the Binutils mailing list