[PATCH RFC] bfd/ELF: restrict file alignment for object files

Jan Beulich jbeulich@suse.com
Mon Sep 9 09:39:37 GMT 2024


On 09.09.2024 11:29, Nick Clifton wrote:
>    [I am just back from two weeks of PTO and I am now reading through my
>    email, so if this issue has already been resolved then please ignore
>    this message]

It hasn't, so thanks a lot for replying.

>> While for executables properly aligning sections within the file can be
>> quite relevant, the same is of pretty little importance for relocatable
>> object files. However, compensate this a little for sections with fixed
>> entry sizes, such that they're at least aligned to what conceivably is
>> the granularity within those elements (allowing e.g. REL/RELA sections
>> to still be mmap()-ed and then accessed without needing to deal with
>> mis-alignment of fields).
>> ---
>> RFC: Question is whether some minimal alignment (e.g. the architecture's
>>       word size) should still be retained, then perhaps replacing the
>>       sh_entsize special treatment. Else question is whether e.g. the
>>       symbol tables can also be written at misaligned file positions
>>       (assuming the sh_entsize-based alignment then also would be left
>>       out).
> 
> For architectures with fixed instruction size(s) I think that we should
> keep executable sections at least aligned to the correct size.  There are
> cases where object files are loaded and executed without ever being fully
> linked.  (I am thinking of kernel object files here - .ko - but there are
> probably others as well).

I actually considered this as an option. Just that I found nowhere that
this particular alignment was announced (for e.g. ia64 I take it that it
would want to be 16, due to fixed-size insns being grouped into bundles
of [typically] three insns, who individually have no sensible alignment
at all).

Considering your kernel modules example, the concern might easily extend
to data sections then as well, I guess. Hence my mentioning of "word
size".

Jan


More information about the Binutils mailing list