[PATCH RFC] bfd/ELF: restrict file alignment for object files
Jan Beulich
jbeulich@suse.com
Thu Sep 26 10:57:27 GMT 2024
On 09.09.2024 15:46, Nick Clifton wrote:
> Hi Jan,
>
>>>> yet then - any hint from where to take the two alignment values? Do they
>>>> need adding from scratch, for every architecture?
>>>
>>> Maybe bfd->xvec->section_alignment_power ?
>>>
>
>> I'm afraid I can't even spot a field of this name.
>
> Which would be because I was referencing the wrong structure. Doh.
> I meant the bfd_arch_info structure from bfd/archures.c:603...
>
> typedef struct bfd_arch_info
> {
> int bits_per_word;
> int bits_per_address;
> int bits_per_byte;
> enum bfd_architecture arch;
> unsigned long mach;
> const char *arch_name;
> const char *printable_name;
> unsigned int section_align_power;
> [...]
>
>> If there was one, it
>> also couldn't possibly express both minimal code and minimal data _file_
>> alignment (we're not really talking of in-memory alignment here, after
>> all).
>
> Hmm, since we are talking about sections rather than segments, I would
> think that we can assume that there would never be a need for a in-file
> alignment to be greater than an in-memory alignment. Hence we can use
> whatever in-memory section alignment fields we may have as a guide for
> the maximum file alignment needed.
>
> But for a minimum in-file works-for-all-sections alignment, I do not think
> that we have a structure field that we can use. We can always add one of
> course. Maybe just using a default value (eg 4) and allowing targets to
> override it if necessary would work ?
Just fyi that I think I found what I was after: struct elf_size_info's
log_file_align. That's used elsewhere for very similar purposes.
Jan
More information about the Binutils
mailing list