This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Allow invalid sh_size%sh_entsize!=0 for non-SHF_MERGE sections
ClosedPublic

Authored by MaskRay on Apr 2 2020, 10:22 PM.

Details

Summary

Fixes https://bugs.llvm.org/show_bug.cgi?id=45370
Fixes https://github.com/Clozure/ccl/issues/273

.stab holds a table of 12-byte entries. GNU as before 2.35 incorrectly
sets sh_entsize(.stab) to 20 on 64-bit architectures:
https://sourceware.org/bugzilla/show_bug.cgi?id=25768

We should not emit the confusing error:
"SHF_MERGE section size (...) must be a multiple of sh_entsize (20)

Diff Detail

Event Timeline

MaskRay created this revision.Apr 2 2020, 10:22 PM
psmith accepted this revision.Apr 3 2020, 12:54 AM

LGTM, thanks for fixing. A minor stylistic comment that me might want to put the check for SHF_MERGE as the first item as I don't think we'd create a merge section for anything else.

This revision is now accepted and ready to land.Apr 3 2020, 12:54 AM
grimar accepted this revision.Apr 3 2020, 2:36 AM

A minor stylistic comment that me might want to put the check for SHF_MERGE as the first item as I don't think we'd create a merge section for anything else.

Yeah, sounds like a bit more natural behavior for a function called shouldMerge.

lld/ELF/InputFiles.cpp
452

nit: Perhaps no need to have flags variable? sec.sh_flags should look good when inlined.

lld/test/ELF/invalid/entsize.yaml
2

Perhaps add a bit of information abut why we even care about this case, e.g. link to a GNU as bug?

MaskRay updated this revision to Diff 254826.Apr 3 2020, 8:42 AM
MaskRay marked 2 inline comments as done.

Address comments

MaskRay updated this revision to Diff 254829.Apr 3 2020, 8:47 AM
MaskRay edited the summary of this revision. (Show Details)

Update description

This revision was automatically updated to reflect the committed changes.