This is an archive of the discontinued LLVM Phabricator instance.

[BOLT] Handle broken .dynsym in stripped binaries
ClosedPublic

Authored by nhuhuan on Jul 19 2022, 3:50 AM.

Details

Summary

Strip tools cause a few symbols in .dynsym to have bad section index.
This update safely keeps such broken symbols intact.

Test Plan:

ninja check-bolt

Diff Detail

Event Timeline

nhuhuan created this revision.Jul 19 2022, 3:50 AM
Herald added a reviewer: Amir. · View Herald Transcript
Herald added a reviewer: maksfb. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: ayermolo. · View Herald Transcript
nhuhuan requested review of this revision.Jul 19 2022, 3:50 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2022, 3:50 AM

Looks good, but please add a test case.

Amir added a comment.Jul 19 2022, 11:36 AM

We need a test case for this fix: yaml2obj test with a dynamic symbol table with wrong (out of bounds) index. We should check that BOLT keeps this index intact.

nhuhuan updated this revision to Diff 445955.Jul 19 2022, 3:12 PM

Update test case.

nhuhuan updated this revision to Diff 446298.Jul 20 2022, 4:40 PM

Simplified test.

Amir accepted this revision.Jul 20 2022, 7:21 PM

Note for other reviewers: we were unable to get yaml input with a broken symbol section index (yaml2obj refuses to produce an object file). So this approach (yaml2obj + llvm-strip) is the closest we were able to get.

This revision is now accepted and ready to land.Jul 20 2022, 7:21 PM
This revision was automatically updated to reflect the committed changes.