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

Nick Clifton nickc@redhat.com
Mon Sep 9 13:46:25 GMT 2024


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 ?

Cheers
   Nick




More information about the Binutils mailing list