[PATCH] D25324: [ELF] - Check that section alignment is a power of 2.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 6 11:31:10 PDT 2016


Since we are talking alignment:

We use alignTo quite often and that causes a divq. That is
surprisingly fast on modern cpus, but I wonder if we should normalize
the alignment to its log2. That would also have the advantage of
requiring far fewer bits to store.

If we do that it should definitely be another patch.

Cheers,
Rafael


On 6 October 2016 at 14:25, Rui Ueyama <ruiu at google.com> wrote:
> ruiu added inline comments.
>
>
>> InputSection.cpp:48
>>    // no alignment constraits.
>> -  if (Header->sh_addralign > UINT32_MAX)
>> -    fatal(getFilename(File) + ": section sh_addralign is too large");
>> +  if (Header->sh_addralign > UINT32_MAX ||
>> +      (Header->sh_addralign && !isPowerOf2_32(Header->sh_addralign)))
>
> Also, please leave a comment here to say that we reject object files having insanely large alignment requirements and may want to relax this limitation in the future.
>
> binutils-ish tools have incredible long lifetime -- GNU ld has been used for decades now for example. We want to leave a hint why we are doing this, so that people who look at this code 10 years later won't have to wonder why we reject 4GB-aligned sections when they are creating 10 terabyte executable.
>
> https://reviews.llvm.org/D25324
>
>
>


More information about the llvm-commits mailing list