]> granicus.if.org Git - llvm/commitdiff
[llvm-objcopy] Make --strip-debug strip .gdb_index
authorFangrui Song <maskray@google.com>
Tue, 31 Jul 2018 21:26:35 +0000 (21:26 +0000)
committerFangrui Song <maskray@google.com>
Tue, 31 Jul 2018 21:26:35 +0000 (21:26 +0000)
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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@338443 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-objcopy/strip-debug.test
tools/llvm-objcopy/llvm-objcopy.cpp

index c8f90d9ca19eb1835481946a453caac46a735592..6c833f301c7fca947d68f12ed7e4b78e664e56e2 100644 (file)
@@ -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.
@@ -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 ]
index e903e57ad5f48e82efbb94d878261ca275ba697e..21a1622db7652659eb44837760ba903561d9b314 100644 (file)
@@ -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) {