[PATCH] D50100: [llvm-objcopy] Make --strip-debug strip .gdb_index

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 31 13:33:48 PDT 2018


MaskRay updated this revision to Diff 158374.
MaskRay added a comment.

Add test


Repository:
  rL LLVM

https://reviews.llvm.org/D50100

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


Index: tools/llvm-objcopy/llvm-objcopy.cpp
===================================================================
--- tools/llvm-objcopy/llvm-objcopy.cpp
+++ tools/llvm-objcopy/llvm-objcopy.cpp
@@ -186,7 +186,8 @@
 } // 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) {
Index: test/tools/llvm-objcopy/strip-debug.test
===================================================================
--- test/tools/llvm-objcopy/strip-debug.test
+++ test/tools/llvm-objcopy/strip-debug.test
@@ -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.
@@ -91,7 +91,13 @@
   Type:            ET_REL
   Machine:         EM_X86_64
 Sections:
-  - Name:            .debugfoo
+  - Name:            .debug_info
+    Type:            SHT_PROGBITS
+    Content:         "00000000"
+  - Name:            .zdebug_info
+    Type:            SHT_PROGBITS
+    Content:         "00000000"
+  - Name:            .gdb_index
     Type:            SHT_PROGBITS
     Content:         "00000000"
   - Name:            .text
@@ -103,8 +109,8 @@
   Global:
     - Name: foo
       Section: .text
-    - Name: debugfoo
-      Section: .debugfoo
+    - Name: debug_info
+      Section: .debug_info
 
 # CHECK: SectionHeaderCount: 5
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D50100.158374.patch
Type: text/x-patch
Size: 1727 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180731/e0379aee/attachment.bin>


More information about the llvm-commits mailing list