This is an archive of the discontinued LLVM Phabricator instance.

[llvm-strip] Support stripping multiple input files
ClosedPublic

Authored by rupprecht on Sep 4 2018, 3:24 PM.

Details

Summary

Allow strip to be called on multiple input files, which is interpreted as stripping N files in place. Using multiple input files is incompatible with -o.

To allow this, create a DriverConfig struct which just wraps a list of CopyConfigs. objcopy will only ever have a single CopyConfig, but strip will have N (where N >= 1) CopyConfigs.

Diff Detail

Repository
rL LLVM

Event Timeline

rupprecht created this revision.Sep 4 2018, 3:24 PM
rupprecht updated this revision to Diff 163935.Sep 4 2018, 3:28 PM
  • Add test case for -o flag error
rupprecht added a subscriber: MaskRay.
tools/llvm-objcopy/llvm-objcopy.cpp
185 ↗(On Diff #163935)

nit: SmallVector<CopyConfig, 1>

rupprecht updated this revision to Diff 163941.Sep 4 2018, 4:17 PM
  • Use SmallVector for CopyConfigs
rupprecht marked an inline comment as done.Sep 4 2018, 4:18 PM
test/tools/llvm-objcopy/strip-multiple-files.test
9 ↗(On Diff #163941)

not sure if these checks are particularly useful,
i'd probably reorganize and simplify (and, actually, speed up) this test a little bit:

  1. run llvm-strip on one .o
  2. run llvm-readobj on the output and verify that the output is correct (via FileCheck)
  3. run llvm-strip on 3 .o and verify that the outputs are correct (via cmp ) (compare them with the result of (2))

What would you say to this approach ?

rupprecht updated this revision to Diff 163954.Sep 4 2018, 5:13 PM
  • Simplify test
rupprecht added inline comments.Sep 4 2018, 5:15 PM
test/tools/llvm-objcopy/strip-multiple-files.test
9 ↗(On Diff #163941)

Thanks, that makes it look nicer than what I have here.

I left in the case where we just have two files, since I want to make sure that edge case is tested (e.g. "llvm-strip a b" isn't somehow interpreted as "llvm-strip a -o b")

To me looks good, but please wait for Jake.

This revision is now accepted and ready to land.Sep 4 2018, 7:42 PM
jakehehrlich accepted this revision.Sep 4 2018, 8:10 PM

Whoops...I meant to say the following already. I was confused why it was missing my LGTM.

Below no longer relevant:
I like the change, I'm quite satisfied with the coverage given by your test. You're welcome to optimize the test a bit as Alex has outlined (I would be satisfied with that testing strategy as well).

This revision was automatically updated to reflect the committed changes.