Add a `--verbose` option for `llvm-strip`
Hi, it appears llvm-strip has no --verbose option https://llvm.org/docs/CommandGuide/llvm-strip.html.
strip utility has it and it proves handy. It would be nice to have a verbose option for llvm-strip to see which sections/symbols are removed. In my case, trying to use llvm-objdump --syms or llvm-objdump -TC I am unable to see a difference although the file size is reduced.
Thank you!
@llvm/issue-subscribers-tools-llvm-objcopy-strip
Author: None (fxmarty-amd)
strip utility has it and it proves handy. It would be nice to have a verbose option for llvm-strip to see which sections/symbols are removed. In my case, trying to use llvm-objdump --syms or llvm-objdump -TC I am unable to see a difference although the file size is reduced.
Thank you!
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor has already been assigned to this issue. If you believe that no one is actually working on it despite an assignment, ping the person. After one week without a response, the assignee may be changed.
- In the comments of this issue, request for it to be assigned to you, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: None (fxmarty-amd)
strip utility has it and it proves handy. It would be nice to have a verbose option for llvm-strip to see which sections/symbols are removed. In my case, trying to use llvm-objdump --syms or llvm-objdump -TC I am unable to see a difference although the file size is reduced.
Thank you!
I think this seems very reasonable to add. I also don't think it'd be especially complicated, so I've added the "good-first-issue" label.
To whomever picks this up: note that llvm-objcopy and llvm-strip share the same codebase and it seems reasonable for them both to gain this option. Please also make sure the output looks similar to the GNU version.
@fxmarty-amd, if you fancy tackling this yourself, by all means do so. With regards to identifying why your size changed, two comments:
- Try using
llvm-readelf --allto dump everything. This will either directly (missing sections/symbols/etc) or indirectly (adjusted file offsets etc) show the issue. - Keep in mind that even if llvm-strip does not remove anything, the object file is still potentially rebuilt, i.e. gaps in the file might be removed, depending on the alignment constraints of the sections in the file.
I want to work. Can you assign it to me? Thanks!
@fxmarty-amd, were you planning on implementing this yourself, or are you happy for @kshitijvp to do so? I've assigned it to @kshitijvp for now, but would like @fxmarty-amd to confirm they're not planning on tackling it themselves first, as if they'd like to, it'd make sense for them to do so, since they opened the issue in the first place.
Thank you! For sure @kshitijvp, feel free to give it a go!
I have created a PR for this issue I know it's incomplete but could you tell me if I am going in the right direction?
https://github.com/llvm/llvm-project/pull/124692
The --verbose option in GNU objcopy/strip just prints a copy from message without mentioning symbol/section removal. Mentioning the removed symbols/sections seems fine as an extention. For llvm-strip --strip-all clang -o clang.stripped that removes .symtab/.strtab, there is potentially a huge output.
% strip a -o a6 --verbose
copy from `a' [elf64-x86-64] to `a6' [elf64-x86-64]
I've been considering what @MaskRay said and compatibility with the GNU tools. I think adding the functionality of printing information about removed symbols and sections may not belong under the --verbose option. I expect it would not be uncommon for existing users of the --verbose option to be using it within a script that is parsing the output, but in that case, changing the output will cause them issues if they try to migrate to the LLVM tools.
That being said, I suspect there is some benefit to the functionality.
@fxmarty-amd, as MaskRay points out, the behaviour you're requesting (printing information about removed symbols and sections) is different to what GNU objcopy does. Could I confirm you're wanting brand new behaviour to list the information? Could you describe your use-case in more detail?
It might be more appropriate to add this behaviour under a new option, which implies the --verbose option (since we'd need the names of the input object to disambiguate the cases where the same-named symbol/section is present in multiple inputs).
Hi, I’d like to work on this issue if it’s still open.
@fxmarty-amd, as MaskRay points out, the behaviour you're requesting (printing information about removed symbols and sections) is different to what GNU objcopy does. Could I confirm you're wanting brand new behaviour to list the information? Could you describe your use-case in more detail?
Hi @fxmarty-amd, I was just wondering if you have any response to this?
@iamaayushrivastava, I'd suggest breaking this into two parts. The first PR would implement --verbose, matching GNU-strip style. The second step would add a new option (name to be determined) that fulfils @fxmarty-amd's original needs. Whether we actually accept the second step is still an open discussion and requires a concrete use-case.
Hi @MaskRay and @kshitijvp,
I've been working on this issue and have opened a PR implementing the --verbose option for llvm-strip and llvm-objcopy, matching the GNU strip output format.
PR: 196611
Please review and share your feedback. @kshitijvp @MaskRay
Thanks!