zig icon indicating copy to clipboard operation
zig copied to clipboard

objcopy: add some support for --strip-debug and --strip-all

Open xxxbxxx opened this issue 1 year ago • 0 comments

Support for the use case: zig objcopy --strip-all program stripped --extract-to stripped.dbg to separate the debug & symbols sections out to a companion file, with a corresponding .gnu_debuglink.

note: this is "a minimal effort implementation"

  • It doesn't support all possible elf files: some section types or the program header may need fix up, ...
  • It was written for a specific use case (strip debug info to a seperate file, for linux 64-bits executable built with zig or zig c++ )
  • It doesn't support non-native endianess.
  • it isn't as thorough as standalone objcopy: it doesn't rewrite string tables, and probably many other things..

It was written separately from the existing objcopy.zig, so there is some de-duplication left to to with the hex and raw cases.

--extract-to is a made-up options that doesn't seem to exist in other objcopy programs. (only eu-strip has -f for this use), but it is more convenient.

xxxbxxx avatar Mar 11 '23 15:03 xxxbxxx