[all-commits] [llvm/llvm-project] 5ad010: [llvm-objcopy][ELF] Implement --only-keep-debug
Fangrui Song via All-commits
all-commits at lists.llvm.org
Tue Nov 5 08:57:58 PST 2019
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: 5ad0103d8a04cb066dfae4fc20b0dfcd9413f4d4
https://github.com/llvm/llvm-project/commit/5ad0103d8a04cb066dfae4fc20b0dfcd9413f4d4
Author: Fangrui Song <maskray at google.com>
Date: 2019-11-05 (Tue, 05 Nov 2019)
Changed paths:
M llvm/docs/CommandGuide/llvm-objcopy.rst
R llvm/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test
A llvm/test/tools/llvm-objcopy/ELF/only-keep-debug.test
M llvm/tools/llvm-objcopy/CommonOpts.td
M llvm/tools/llvm-objcopy/ELF/ELFObjcopy.cpp
M llvm/tools/llvm-objcopy/ELF/Object.cpp
M llvm/tools/llvm-objcopy/ELF/Object.h
Log Message:
-----------
[llvm-objcopy][ELF] Implement --only-keep-debug
--only-keep-debug produces a debug file as the output that only
preserves contents of sections useful for debugging purposes (the
binutils implementation preserves SHT_NOTE and non-SHF_ALLOC sections),
by changing their section types to SHT_NOBITS and rewritting file
offsets.
See https://sourceware.org/gdb/onlinedocs/gdb/Separate-Debug-Files.html
The intended use case is:
```
llvm-objcopy --only-keep-debug a a.dbg
llvm-objcopy --strip-debug a b
llvm-objcopy --add-gnu-debuglink=a.dbg b
```
The current layout algorithm is incapable of deleting contents and
shrinking segments, so it is not suitable for implementing the
functionality.
This patch adds a new algorithm which assigns sh_offset to sections
first, then modifies p_offset/p_filesz of program headers. It bears a
resemblance to lld/ELF/Writer.cpp.
Reviewed By: jhenderson, jakehehrlich
Differential Revision: https://reviews.llvm.org/D67137
More information about the All-commits
mailing list