This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy][test] Fix test that could have passed spuriously
ClosedPublic

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

Details

Summary

The test was showing that when --strip-unneeded is specified for an executable, all the symbols are stripped. However, the set of symbols used in the test would be stripped by --strip-unneeded for an ET_REL object too. Fix this by adding additional symbols that aren't normally stripped by --strip-unneeded.

Diff Detail

Event Timeline

jhenderson created this revision.Mar 1 2021, 1:12 AM
jhenderson requested review of this revision.Mar 1 2021, 1:12 AM
Herald added a project: Restricted Project. · View Herald TranscriptMar 1 2021, 1:12 AM
MaskRay added inline comments.Mar 1 2021, 11:27 AM
llvm/test/tools/llvm-objcopy/ELF/strip-unneeded-all-symbols.test
14

If I change ET_EXEC to ET_REL, the test fails as intended.

Adding more tests is fine. Perhaps we need two tests (use something like Type: [[type]]).

MaskRay accepted this revision.Mar 1 2021, 11:27 AM
This revision is now accepted and ready to land.Mar 1 2021, 11:27 AM
jhenderson added inline comments.Mar 4 2021, 2:59 AM
llvm/test/tools/llvm-objcopy/ELF/strip-unneeded-all-symbols.test
14

I can add a test case here that shows the same input (but ET_REL instead) does produce a symbol table, if you want, to act as a validity test, but that overlaps other tests (see for example strip-unneeded.test). I think there is some benefit still, because it ensures the CHECK-NOT with no other checks is somewhat safe.

jhenderson updated this revision to Diff 328103.Mar 4 2021, 3:35 AM

Add second test case to show the check fails if the input object is ET_REL.

@MaskRay, can you confirm you are happy with the updated test?

MaskRay accepted this revision.Mar 4 2021, 2:01 PM

LGTM.

This revision was landed with ongoing or failed builds.Mar 5 2021, 1:03 AM
This revision was automatically updated to reflect the committed changes.