[PATCH] D39550: [ELF] - Fix error reporting with --strip-debug/--strip-all.
George Rimar via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Nov 3 01:56:01 PDT 2017
grimar updated this revision to Diff 121443.
grimar added a comment.
- Changed implementation.
https://reviews.llvm.org/D39550
Files:
ELF/Driver.cpp
ELF/InputFiles.cpp
test/ELF/conflict-debug-variable.s
Index: test/ELF/conflict-debug-variable.s
===================================================================
--- test/ELF/conflict-debug-variable.s
+++ 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: ELF/InputFiles.cpp
===================================================================
--- ELF/InputFiles.cpp
+++ 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.
Index: ELF/Driver.cpp
===================================================================
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -1117,6 +1117,14 @@
for (InputSectionBase *S : F->getSections())
InputSections.push_back(cast<InputSection>(S));
+ // When --strip-debug/--strip-all is given we want to remove debug sections
+ // from output, but we can not just discard them because use debug information
+ // for building error messages.
+ 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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D39550.121443.patch
Type: text/x-patch
Size: 1894 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171103/08aa3d60/attachment.bin>
More information about the llvm-commits
mailing list