[PATCH] D25082: [ELF] - Do not crash on invalid section alignment.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 30 06:51:28 PDT 2016


grimar added inline comments.


> evgeny777 wrote in InputSection.cpp:48
> Just checked: both gas and llvm-mc require alignment to be 32-bit value which is a power of 2. So better check for alignment can be:
> 
>   bool NotPower2 = Header->sh_addralign & (Header->sh_addralign - 1);
>   if (Header->sh_addralign > 0x80000000 || NotPower2)
>     error("...");

It is not just gas/llvm-mc, it is requirement for this field: "Only 0 and positive integral powers of 2 are currently allowed as values for this field. A value of 0 or 1 indicates no address alignment constraints.",

though I do not know do we want to check such details in linker or not. As far I understand main aim to fix wrong inputs is "just please do not crash" and not to verify if the ELF object is correct. As you mentioned, llvm-mc already do this check for us.

https://reviews.llvm.org/D25082





More information about the llvm-commits mailing list