This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy/strip] Fix off-by-one error in SYMTAB_SHNDX need check
ClosedPublic

Authored by jhenderson on Mar 1 2021, 1:04 AM.

Details

Summary

The check for whether an extended symbol index table was required dropped the first SHN_LORESERVE sections from the sections array before checking whether the remaining sections had symbols. Unfortunately, the null section header is not present in this list, so the check was skipping the first section that might be important. If that section contained a symbol, and no subsequent ones did, the .symtab_shndx section would not be emitted, leading to a corrupt object.

Also consolidate and expand test coverage in the area to cover this bug and other aspects of the SYMTAB_SHNDX section.

Depends on D97660.

Diff Detail

Event Timeline

jhenderson created this revision.Mar 1 2021, 1:04 AM
jhenderson requested review of this revision.Mar 1 2021, 1:04 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2021, 1:04 AM
This revision is now accepted and ready to land.Mar 1 2021, 1:46 AM
MaskRay accepted this revision.Mar 1 2021, 2:02 PM

Thanks!

This revision was landed with ongoing or failed builds.Mar 4 2021, 2:24 AM
This revision was automatically updated to reflect the committed changes.
llvm/test/tools/llvm-objcopy/ELF/auto-remove-add-symtab-shndx.test