This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objcopy] Implement --set-section-flags.
ClosedPublic

Authored by rupprecht on Jan 24 2019, 3:28 PM.

Details

Summary

--set-section-flags is used to change the section flags (e.g. SHF_ALLOC) for given sections. The flags allowed are the same from the existing --rename-section=.old=.new[,flags] feature.

Additionally, make sure that --set-section-flag cannot be used with --rename-section (either the source or destination), since --rename-section accepts flags. This avoids ambiguity for something like "--rename-section=.foo=.bar,alloc --set-section-flag=.bar,code".

Diff Detail

Repository
rL LLVM

Event Timeline

rupprecht created this revision.Jan 24 2019, 3:28 PM
rupprecht updated this revision to Diff 183416.Jan 24 2019, 3:30 PM
  • Add --set-section-flags to the list of unimplemented COFF methods
rupprecht set the repository for this revision to rL LLVM.Jan 25 2019, 10:41 AM
jhenderson added inline comments.Jan 28 2019, 2:36 AM
llvm/test/tools/llvm-objcopy/ELF/set-section-flags-and-rename.test
16 ↗(On Diff #183416)

Nit: get rid of the content. It's not needed. Can you get rid of the Type and Flags fields too, or are they required?

llvm/test/tools/llvm-objcopy/ELF/set-section-flags-multiple.test
16 ↗(On Diff #183416)

Ditto, here and below.

llvm/test/tools/llvm-objcopy/ELF/set-section-flags.test
54 ↗(On Diff #183416)

Ditto.

llvm/tools/llvm-objcopy/CopyConfig.cpp
341–344 ↗(On Diff #183416)

This should look almost the same as the --rename-section code above, i.e. where the error checking for bad format etc is done.

rupprecht marked 5 inline comments as done.
  • Remove unnecessary portions from tests
  • Make --set-section-flags arg parsing more similar to --rename-section
rupprecht marked an inline comment as done.Jan 28 2019, 12:07 PM
rupprecht added inline comments.
llvm/test/tools/llvm-objcopy/ELF/set-section-flags-and-rename.test
16 ↗(On Diff #183416)

This flag checking is done during argument parsing, so no section is needed at all.

llvm/test/tools/llvm-objcopy/ELF/set-section-flags-multiple.test
16 ↗(On Diff #183416)

Removed content here, but I'd prefer to leave flags explicitly empty here (even though the test passes w/o it). Type is a required yaml field here.

jakehehrlich accepted this revision.Jan 28 2019, 3:27 PM

Even though this is a large change I think I'm happy with it. Everything was either factoring out common code or handling error messages. I didn't see anything about how error messages were handled that was objectionable.

Please wait on someone else but this LGTM.

This revision is now accepted and ready to land.Jan 28 2019, 3:27 PM
  • Add --set-section-flags to the list of unimplemented COFF methods

Crap I guess we have to remember to do that for all new flags. I should have asked for this to be a white list instead of a black list. It doesn't make sense for ELF and eventually MachO to have to update flags when one or the other doesn't support this.

This revision was automatically updated to reflect the committed changes.