llvm-objcopy supports --strip-sections, while its alias llvm-strip does not. The option seems like a good fit for llvm-strip, so this patch adds support for it.
Details
Diff Detail
- Repository
- rL LLVM
Event Timeline
@jakehehrlich/@rupprecht, are you aware of any reason why we SHOULDN'T have this in llvm-strip? It seems odd to have it in llvm-objcopy when the original source was eu-strip!
llvm/test/tools/llvm-objcopy/ELF/strip-sections.test | ||
---|---|---|
15 ↗ | (On Diff #213508) | Better would be to do a cmp of %t2 and %t4. The two outputs should be byte-for-byte identical. |
I am on the fence. On one side, for extensions that binutils does not support, I think it is fine to just support them in llvm-objcopy, not in llvm-strip. On the other side, --strip-sections is a strip-* option, so it isn't a bad fit for llvm-strip.
Links: --strip-sections was implemented by D38335. In eu-strip, it was implemented by https://sourceware.org/git/?p=elfutils.git;a=commit;h=0b9d1fb534604a9ba19999cd8ce8e7efce28da24
We have a concrete use-case for this internally, so I'd like to have it if there isn't a good reason not to.
Then add this option.
The description should be changed to state that this is a strip option, so it seems a good fit for llvm-strip. We already have --strip-all --strip-all-gnu --strip-debug --strip-unneeded --strip-symbol so it seems natural to have another --strip-*.
The reasons for this are unclear, so this patch adds the option to llvm-strip.
I'm a bit unclear on what this means:
The description should be changed to state that this is a strip option, so it seems a good fit for llvm-strip. We already have --strip-all --strip-all-gnu --strip-debug --strip-unneeded --strip-symbol so it seems natural to have another --strip-*.
What description should be changed? The help text? Right now I see few distinctions between the 2 invocations in the *.td files for objcopy and strip respectively.
This sentence in the description:
The reasons for this are unclear, so this patch adds the option to llvm-strip.
We do not add options merely for "unclear" reasons. It is because the option is a good fit for llvm-strip.
CC'ing mmpozulp due to him writing the llvm-strip doc in D65384. This option will need adding, assuming this patch lands first.
This sentence in the description:
The reasons for this are unclear, so this patch adds the option to llvm-strip.
We do not add options merely for "unclear" reasons. It is because the option is a good fit for llvm-strip.
Well, of course! The unclear part was why it wasn't already supported in the first place. So I see we're in violent agreement.
Addressed review comments:
Use simple file comparison instead of performing the whole test again to verify support for --strip-sections with llvm-strip.
No, if we have the option already implemented, it should be available to both tools.
llvm/test/tools/llvm-objcopy/ELF/strip-sections.test | ||
---|---|---|
13–15 ↗ | (On Diff #213948) | You can create a separate output file with -o # RUN: llvm-strip --strip-sections %t -o %t4 # RUN: cmp %t2 %t4 |