[PATCH] D39550: [ELF] - Fix error reporting with --strip-debug/--strip-all.

George Rimar via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 4 01:21:04 PDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rL317405: [ELF] - Fix error reporting with --strip-debug/--strip-all. (authored by grimar).

Changed prior to commit:
  https://reviews.llvm.org/D39550?vs=121443&id=121582#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39550

Files:
  lld/trunk/ELF/Driver.cpp
  lld/trunk/ELF/InputFiles.cpp
  lld/trunk/test/ELF/conflict-debug-variable.s


Index: lld/trunk/test/ELF/conflict-debug-variable.s
===================================================================
--- lld/trunk/test/ELF/conflict-debug-variable.s
+++ lld/trunk/test/ELF/conflict-debug-variable.s
@@ -30,6 +30,9 @@
 # CHECK-NEXT: >>> defined at 1.c:1
 # CHECK-NEXT: >>>            {{.*}}:(.bss+0x0)
 
+## Check that stripping debug sections does not break error reporting.
+# RUN: not ld.lld --strip-debug %t.o %t.o -o %t 2>&1 | FileCheck %s
+
 # Used reduced output from following code and gcc 7.1.0
 # to produce this input file:
 # Source (1.c):
Index: lld/trunk/ELF/Driver.cpp
===================================================================
--- lld/trunk/ELF/Driver.cpp
+++ lld/trunk/ELF/Driver.cpp
@@ -1106,6 +1106,13 @@
     for (InputSectionBase *S : F->getSections())
       InputSections.push_back(cast<InputSection>(S));
 
+  // We do not want to emit debug sections if --strip-all
+  // or -strip-debug are given.
+  if (Config->Strip != StripPolicy::None)
+    llvm::erase_if(InputSections, [](InputSectionBase *S) {
+      return S->Name.startswith(".debug") || S->Name.startswith(".zdebug");
+    });
+
   Config->EFlags = Target->calcEFlags();
 
   // This adds a .comment section containing a version string. We have to add it
Index: lld/trunk/ELF/InputFiles.cpp
===================================================================
--- lld/trunk/ELF/InputFiles.cpp
+++ lld/trunk/ELF/InputFiles.cpp
@@ -537,10 +537,6 @@
     return &InputSection::Discarded;
   }
 
-  if (Config->Strip != StripPolicy::None &&
-      (Name.startswith(".debug") || Name.startswith(".zdebug")))
-    return &InputSection::Discarded;
-
   // The linkonce feature is a sort of proto-comdat. Some glibc i386 object
   // files contain definitions of symbol "__x86.get_pc_thunk.bx" in linkonce
   // sections. Drop those sections to avoid duplicate symbol errors.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39550.121582.patch
Type: text/x-patch
Size: 1880 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171104/66b7f35c/attachment.bin>


More information about the llvm-commits mailing list