Implement --only-keep-debug for ELF
| Bugzilla Link | 41077 |
| Resolution | FIXED |
| Resolved on | Nov 05, 2019 13:02 |
| Version | trunk |
| OS | Linux |
| CC | @alexshap,@MaskRay,@jh7370,@m-gupta,@nickdesaulniers,@pawelsopensource,@rupprecht |
Extended Description
llvm-objcopy accepts the --only-keep-debug flag, but ignores it for ELF. (COFF implements it here: https://github.com/llvm/llvm-project/blob/master/llvm/tools/llvm-objcopy/COFF/COFFObjcopy.cpp#L112)
This supports a common workflow, e.g. as suggested by GNU man pages for objcopy:
- clang <...> -o foo
- llvm-objcopy --only-keep-debug foo foo.dbg
- llvm-objcopy --strip-debug foo
- llvm-objcopy --add-gnu-debuglink=foo.dbg foo
Thanks a lot Fangrui!
Implemented in D67137/llvmorg-10-init-9134-g5ad0103d8a0
New attempt https://reviews.llvm.org/D67090
It can make executables smaller and I've checked debuggability with several executables.
Jake/Jordan,
Chrome OS is currently relying on the current behavior of llvm-objcopy that it does not really strip the binary with -only-keep-debug as a workaround for a symbolization issue. As a favor, can you please notify us (manojgupta/aalexand) whenever a patch that implements " --only-keep-debug" is under review?
I'm not looking at this actively anymore. The latest attempt is in https://reviews.llvm.org/D63807, and previous attempts (with good discussions on the patch review threads) are https://reviews.llvm.org/D40523 and https://reviews.llvm.org/D43475.
I'm starting to look at this
This workflow is still supported by ignoring this flag. This would just make the debug files slightly smaller.
We would like to use this on Fuchsia as well.
assigned to @MaskRay