diff options
author | Fangrui Song <maskray@google.com> | 2019-10-24 15:48:32 -0700 |
---|---|---|
committer | Fangrui Song <maskray@google.com> | 2019-11-05 08:56:15 -0800 |
commit | 5ad0103d8a04cb066dfae4fc20b0dfcd9413f4d4 (patch) | |
tree | 65dcbcfccb35bf5353a1bfac0b665bbf7421e1e4 /llvm/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test | |
parent | ade55d07871040d0e75b94e3d3a1eaecbd704d36 (diff) | |
download | bcm5719-llvm-5ad0103d8a04cb066dfae4fc20b0dfcd9413f4d4.tar.gz bcm5719-llvm-5ad0103d8a04cb066dfae4fc20b0dfcd9413f4d4.zip |
[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
Diffstat (limited to 'llvm/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test')
-rw-r--r-- | llvm/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test | 22 |
1 files changed, 0 insertions, 22 deletions
diff --git a/llvm/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test b/llvm/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test deleted file mode 100644 index 95cd07d0c26..00000000000 --- a/llvm/test/tools/llvm-objcopy/ELF/basic-only-keep-debug.test +++ /dev/null @@ -1,22 +0,0 @@ -# NOTE: This test is only intended to be valid as long as --only-keep-debug is -# implemented as a NOP. This test should fail when that changes and you -# will need to update this test. - -# RUN: yaml2obj %s > %t -# RUN: llvm-objcopy %t %t2 -# RUN: llvm-objcopy --only-keep-debug %t %t3 -# RUN: cmp %t2 %t3 -# RUN: llvm-strip --only-keep-debug --no-strip-all %t -o %t4 -# RUN: cmp %t2 %t4 - -!ELF -FileHeader: - Class: ELFCLASS64 - Data: ELFDATA2LSB - Type: ET_EXEC - Machine: EM_X86_64 -Sections: - - Name: .text - Type: SHT_PROGBITS - Flags: [ SHF_ALLOC, SHF_EXECINSTR ] - Content: "DEADBEEF" |