This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] - Strip sections before symbols.
ClosedPublic

Authored by grimar on Mar 25 2019, 5:16 AM.

Details

Summary

This is a fix for https://bugs.llvm.org/show_bug.cgi?id=40007.
It is rebased on top of D59762.

Idea is to swap the order of stripping. So that we strip sections before
symbols what allows us to strip relocation sections without emitting
the error about relative symbols.

Diff Detail

Repository
rL LLVM

Event Timeline

grimar created this revision.Mar 25 2019, 5:16 AM
grimar retitled this revision from [llvm-objcopy] - Strip sections before symbols, to [llvm-objcopy] - Strip sections before symbols..Mar 25 2019, 5:16 AM

I think another interesting test might be -N <sym> -R <relocation section referencing sym>. I'm assuming that this fails currently, based on the --strip-all symptoms.

test/tools/llvm-objcopy/ELF/strip-relocations.test
1 ↗(On Diff #192081)

Probably worth renaming this test strip-all-relocations.test, since it's not specifically about stripping relocations.

3 ↗(On Diff #192081)

Add "at the same time" to the end of this comment, as that's the important bit (it would have been possible to strip the relocation sections first, then the symbols as a workaround before).

grimar updated this revision to Diff 192096.Mar 25 2019, 6:51 AM
grimar marked 2 inline comments as done.
  • Addressed review comments.

I think another interesting test might be `-N <sym>

Something is wrong I guess here, as I do not see -N in llvm-objcopy help... I used --strip-symbol= instead.

jhenderson accepted this revision.Mar 25 2019, 8:47 AM

I think another interesting test might be `-N <sym>

Something is wrong I guess here, as I do not see -N in llvm-objcopy help... I used --strip-symbol= instead.

I'm guessing short aliases aren't in the help text, but --strip-symbol is fine.

LGTM, with a couple of minor comments. Maybe worth leaving it overnight before committing though, in case any of the US contributors have any comments.

test/tools/llvm-objcopy/ELF/strip-all-relocations.test
1 ↗(On Diff #192096)

Okay, since you've added the new test case to this test, this test is badly named again. Sorry! Perhaps "strip-symbol-and-relocation.test"?

29 ↗(On Diff #192096)

Nit: you can delete the Flags, as they aren't relevant to the test.

This revision is now accepted and ready to land.Mar 25 2019, 8:47 AM
rupprecht requested changes to this revision.Mar 25 2019, 9:04 AM

Just a couple test changes, otherwise LG and thanks for fixing this bug!

test/tools/llvm-objcopy/ELF/strip-all-relocations.test
14 ↗(On Diff #192096)

As a sanity check that this test is configured correctly, you might also want to run "not llvm-objcopy --strip-symbol=bar %t2" and make sure it prints the right error

14 ↗(On Diff #192096)

This is missing %t as the source, it should be "llvm-objcopy %t %t2". This is "copying" %t2 in place.

This revision now requires changes to proceed.Mar 25 2019, 9:04 AM
tools/llvm-objcopy/ELF/ELFObjcopy.cpp
545 ↗(On Diff #192096)

I think it's worth adding a comment here explaining that the order is really important here.

E5ten added a subscriber: E5ten.Mar 25 2019, 12:08 PM
grimar updated this revision to Diff 192254.Mar 26 2019, 3:55 AM
grimar marked 8 inline comments as done.
  • Addressed review comments.
test/tools/llvm-objcopy/ELF/strip-all-relocations.test
1 ↗(On Diff #192096)

NP, thanks for the help with the naming things!

14 ↗(On Diff #192096)

Done for both comments. Thanks!

29 ↗(On Diff #192096)

Done. (Honestly, I am not sure here, .text is "ax" traditionally, and it seems fine to me to keep it as it should be, just in case (given that non-alloc sections are often an exception for something usually in tools/linkers/etc), but I have no solid arguments for that atm).

rupprecht accepted this revision.Mar 26 2019, 10:29 AM

Thanks!

This revision is now accepted and ready to land.Mar 26 2019, 10:29 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptMar 26 2019, 11:41 AM