[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 10:55:06 PDT 2016
LGTM since the spec says "Currently, only 0 and positive integral
powers of two are allowed". But instead of
> - 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)))
> + fatal(getFilename(File) + ": section sh_addralign is invalid");
> Alignment = std::max<uintX_t>(Header->sh_addralign, 1);
I think it is simpler to write
uintX_t V = std::max<uintX_t>(Header->sh_addralign, 1);
if (V > UINT32_MAX || !isPowerOf2_32(V))
fatal
Alignment = V;
Cheers,
Rafael
More information about the llvm-commits
mailing list