Skip to content

Commit

Permalink
[llvm-objcopy] Make --strip-debug strip .gdb_index
Browse files Browse the repository at this point in the history
Summary:
See binutils-gdb/bfd/elf.c, GNU objcopy also strips .stab* (STABS)
.line* (DWARF 1) .gnu.linkonce.wi.* (linkonce section for .debug_info) but
I'm not sure we need to be compatible with it.

Reviewers: dblaikie, alexshap, jakehehrlich, jhenderson

Reviewed By: alexshap, jakehehrlich

Subscribers: aprantl, JDevlieghere, jakehehrlich, llvm-commits

Differential Revision: https://reviews.llvm.org/D50100

llvm-svn: 338443
  • Loading branch information
MaskRay committed Jul 31, 2018
1 parent 497e8fa commit 87b4b8f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
8 changes: 7 additions & 1 deletion llvm/test/tools/llvm-objcopy/strip-debug.test
Expand Up @@ -67,7 +67,7 @@
# RUN: llvm-objcopy --strip-debug %t.thin.a %t2.thin.a
# RUN: cat %t.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE
# RUN: cat %t2.thin.a | FileCheck %s --check-prefix=VERIFY-THIN-ARCHIVE

# VERIFY-THIN-ARCHIVE: !<thin>

# Verify that the member of a thin archive was properly modified.
Expand All @@ -94,6 +94,12 @@ Sections:
- Name: .debugfoo
Type: SHT_PROGBITS
Content: "00000000"
- Name: .zdebugfoo
Type: SHT_PROGBITS
Content: "00000000"
- Name: .gdb_index
Type: SHT_PROGBITS
Content: "00000000"
- Name: .text
Type: SHT_PROGBITS
Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
Expand Down
3 changes: 2 additions & 1 deletion llvm/tools/llvm-objcopy/llvm-objcopy.cpp
Expand Up @@ -186,7 +186,8 @@ LLVM_ATTRIBUTE_NORETURN void reportError(StringRef File, Error E) {
} // end namespace llvm

static bool IsDebugSection(const SectionBase &Sec) {
return Sec.Name.startswith(".debug") || Sec.Name.startswith(".zdebug");
return Sec.Name.startswith(".debug") || Sec.Name.startswith(".zdebug") ||
Sec.Name == ".gdb_index";
}

static bool IsDWOSection(const SectionBase &Sec) {
Expand Down

0 comments on commit 87b4b8f

Please sign in to comment.