This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Allow sh_entsize to be unrelated to sh_addralign and not a power of 2
ClosedPublic

Authored by MaskRay on Mar 17 2019, 8:16 PM.

Details

Summary

This implements Rui Ueyama's idea in https://bugs.llvm.org/show_bug.cgi?id=39044#c3
I've checked that ld.bfd and gold do not have the power-of-2 requirement
and do not require sh_entsize to be a multiple of sh_align.

Now on the updated test merge-entsize.s, all the 3 linkers happily
create .rodata that is not 3-byte aligned.

This has a use case in Linux arch/x86/crypto/sha512-avx2-asm.S
It uses sh_entsize of 640, which is not a power of 2.
See https://github.com/ClangBuiltLinux/linux/issues/417

Diff Detail

Repository
rL LLVM

Event Timeline

MaskRay created this revision.Mar 17 2019, 8:16 PM
E5ten added a subscriber: E5ten.Mar 17 2019, 8:28 PM
MaskRay updated this revision to Diff 191054.Mar 17 2019, 9:42 PM
MaskRay retitled this revision from [ELF] Allow sh_entsize to be not a power of 2 to [ELF] Allow sh_entsize to be unrelated to sh_addralign and not a power of 2.
MaskRay removed a subscriber: E5ten.

Update title

E5ten added a subscriber: E5ten.Mar 17 2019, 9:51 PM

As a side note, sh_size%sh_entsize==0 is required and that is tested by test/ELF/invalid/merge-invalid-size.s

ruiu accepted this revision.Mar 18 2019, 10:57 AM

LGTM

This revision is now accepted and ready to land.Mar 18 2019, 10:57 AM
This revision was automatically updated to reflect the committed changes.