llvm-project icon indicating copy to clipboard operation
llvm-project copied to clipboard

Implement --only-keep-debug for ELF

Open rupprecht opened this issue 7 years ago • 8 comments

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:

  1. clang <...> -o foo
  2. llvm-objcopy --only-keep-debug foo foo.dbg
  3. llvm-objcopy --strip-debug foo
  4. llvm-objcopy --add-gnu-debuglink=foo.dbg foo

rupprecht avatar Mar 14 '19 21:03 rupprecht

Thanks a lot Fangrui!

m-gupta avatar Nov 05 '19 21:11 m-gupta

Implemented in D67137/llvmorg-10-init-9134-g5ad0103d8a0

MaskRay avatar Nov 05 '19 20:11 MaskRay

New attempt https://reviews.llvm.org/D67090

It can make executables smaller and I've checked debuggability with several executables.

MaskRay avatar Sep 04 '19 06:09 MaskRay

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?

m-gupta avatar Aug 01 '19 18:08 m-gupta

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.

rupprecht avatar Jun 28 '19 18:06 rupprecht

I'm starting to look at this

rupprecht avatar Mar 22 '19 23:03 rupprecht

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.

llvmbot avatar Mar 14 '19 21:03 llvmbot

assigned to @MaskRay

rupprecht avatar Mar 14 '19 21:03 rupprecht