[PATCH] D38491: [ELF] Decompress debug info sections early
Shoaib Meenai via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 3 17:21:33 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL314866: [ELF] Decompress debug info sections early (authored by smeenai).
Changed prior to commit:
https://reviews.llvm.org/D38491?vs=117604&id=117606#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38491
Files:
lld/trunk/ELF/GdbIndex.cpp
lld/trunk/ELF/InputSection.cpp
lld/trunk/ELF/InputSection.h
lld/trunk/ELF/SyntheticSections.cpp
lld/trunk/test/ELF/compressed-debug-conflict.s
Index: lld/trunk/ELF/GdbIndex.cpp
===================================================================
--- lld/trunk/ELF/GdbIndex.cpp
+++ lld/trunk/ELF/GdbIndex.cpp
@@ -33,6 +33,7 @@
.Case(".debug_ranges", &RangeSection)
.Case(".debug_line", &LineSection)
.Default(nullptr)) {
+ Sec->maybeUncompress();
M->Data = toStringRef(Sec->Data);
M->Sec = Sec;
continue;
Index: lld/trunk/ELF/InputSection.cpp
===================================================================
--- lld/trunk/ELF/InputSection.cpp
+++ lld/trunk/ELF/InputSection.cpp
@@ -210,9 +210,15 @@
return Sec ? Sec->getParent() : nullptr;
}
-// Uncompress section contents. Note that this function is called
-// from parallelForEach, so it must be thread-safe.
-void InputSectionBase::uncompress() {
+// Uncompress section contents if required. Note that this function
+// is called from parallelForEach, so it must be thread-safe.
+void InputSectionBase::maybeUncompress() {
+ if (UncompressBuf)
+ return;
+
+ if (!Decompressor::isCompressedELFSection(Flags, Name))
+ return;
+
Decompressor Dec = check(Decompressor::create(Name, toStringRef(Data),
Config->IsLE, Config->Is64));
Index: lld/trunk/ELF/SyntheticSections.cpp
===================================================================
--- lld/trunk/ELF/SyntheticSections.cpp
+++ lld/trunk/ELF/SyntheticSections.cpp
@@ -2300,8 +2300,7 @@
parallelForEach(InputSections, [](InputSectionBase *S) {
if (!S->Live)
return;
- if (Decompressor::isCompressedELFSection(S->Flags, S->Name))
- S->uncompress();
+ S->maybeUncompress();
if (auto *MS = dyn_cast<MergeInputSection>(S))
MS->splitIntoPieces();
});
Index: lld/trunk/ELF/InputSection.h
===================================================================
--- lld/trunk/ELF/InputSection.h
+++ lld/trunk/ELF/InputSection.h
@@ -165,7 +165,7 @@
InputSection *getLinkOrderDep() const;
- void uncompress();
+ void maybeUncompress();
// Returns a source location string. Used to construct an error message.
template <class ELFT> std::string getLocation(uint64_t Offset);
Index: lld/trunk/test/ELF/compressed-debug-conflict.s
===================================================================
--- lld/trunk/test/ELF/compressed-debug-conflict.s
+++ lld/trunk/test/ELF/compressed-debug-conflict.s
@@ -0,0 +1,29 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple i686-linux-gnu -compress-debug-sections=zlib %s -o %t.o
+# RUN: llvm-readobj -sections %t.o | FileCheck -check-prefix=OBJ %s
+# RUN: not ld.lld %t.o %t.o -o %tout 2>&1 | FileCheck -check-prefix=ERROR %s
+
+# OBJ: Sections [
+# OBJ: Section {
+# OBJ: Index: 3
+# OBJ-NEXT: Name: .debug_line (16)
+# OBJ-NEXT: Type: SHT_PROGBITS (0x1)
+# OBJ-NEXT: Flags [ (0x800)
+# OBJ-NEXT: SHF_COMPRESSED (0x800)
+# OBJ-NEXT: ]
+
+# ERROR: error: duplicate symbol: main
+# ERROR-NEXT: >>> defined at reduced.c:2 (/tmp/reduced.c:2)
+# ERROR-NEXT: >>>
+# ERROR-NEXT: >>> defined at reduced.c:2 (/tmp/reduced.c:2)
+# ERROR-NEXT: >>>
+
+ .text
+ .file "reduced.c"
+ .globl main
+main:
+ .file 1 "/tmp" "reduced.c"
+ .loc 1 2 0
+ xorl %eax, %eax
+ retl
+ .file 2 "/tmp/repeat/repeat/repeat/repeat" "repeat.h"
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38491.117606.patch
Type: text/x-patch
Size: 3411 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171004/0293383c/attachment.bin>
More information about the llvm-commits
mailing list