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

Nick Clifton nickc@redhat.com
Mon Sep 9 09:29:57 GMT 2024


Hi Jan,

   [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]

> 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).

Cheers
   Nick



More information about the Binutils mailing list