Skip to content
This repository was archived by the owner on Mar 28, 2020. It is now read-only.

Commit 644f4f6

Browse files
committed
llvm-symbolizer: Avoid infinite recursion walking dwos where the dwo contains a dwo_name attribute
The dwo_name was added to dwo files to improve diagnostics in dwp, but it confuses tools that attempt to load any dwo named by a dwo_name, even ones inside dwos. Avoid this by keeping track of whether a unit is already a dwo unit, and if so, not loading further dwos. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@267241 91177308-0d34-0410-b5e6-96231b3b80d8
1 parent 6c8569f commit 644f4f6

File tree

7 files changed

+30
-15
lines changed

7 files changed

+30
-15
lines changed

include/llvm/DebugInfo/DWARF/DWARFCompileUnit.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ class DWARFCompileUnit : public DWARFUnit {
1919
DWARFCompileUnit(DWARFContext &Context, const DWARFSection &Section,
2020
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
2121
StringRef SOS, StringRef AOS, StringRef LS, bool LE,
22-
const DWARFUnitSectionBase &UnitSection,
22+
bool IsDWO, const DWARFUnitSectionBase &UnitSection,
2323
const DWARFUnitIndex::Entry *Entry)
24-
: DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, UnitSection,
25-
Entry) {}
24+
: DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
25+
UnitSection, Entry) {}
2626
void dump(raw_ostream &OS);
2727
static const DWARFSectionKind Section = DW_SECT_INFO;
2828
// VTable anchor.

include/llvm/DebugInfo/DWARF/DWARFTypeUnit.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ class DWARFTypeUnit : public DWARFUnit {
2121
public:
2222
DWARFTypeUnit(DWARFContext &Context, const DWARFSection &Section,
2323
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
24-
StringRef SOS, StringRef AOS, StringRef LS, bool LE,
24+
StringRef SOS, StringRef AOS, StringRef LS, bool LE, bool IsDWO,
2525
const DWARFUnitSectionBase &UnitSection,
2626
const DWARFUnitIndex::Entry *Entry)
27-
: DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, UnitSection,
28-
Entry) {}
27+
: DWARFUnit(Context, Section, DA, RS, SS, SOS, AOS, LS, LE, IsDWO,
28+
UnitSection, Entry) {}
2929
uint32_t getHeaderSize() const override {
3030
return DWARFUnit::getHeaderSize() + 12;
3131
}

include/llvm/DebugInfo/DWARF/DWARFUnit.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class DWARFUnitSectionBase {
4747
virtual void parseImpl(DWARFContext &Context, const DWARFSection &Section,
4848
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
4949
StringRef SOS, StringRef AOS, StringRef LS,
50-
bool isLittleEndian) = 0;
50+
bool isLittleEndian, bool isDWO) = 0;
5151

5252
~DWARFUnitSectionBase() = default;
5353
};
@@ -80,15 +80,16 @@ class DWARFUnitSection final : public SmallVector<std::unique_ptr<UnitType>, 1>,
8080
private:
8181
void parseImpl(DWARFContext &Context, const DWARFSection &Section,
8282
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
83-
StringRef SOS, StringRef AOS, StringRef LS, bool LE) override {
83+
StringRef SOS, StringRef AOS, StringRef LS, bool LE,
84+
bool IsDWO) override {
8485
if (Parsed)
8586
return;
8687
const auto &Index = getDWARFUnitIndex(Context, UnitType::Section);
8788
DataExtractor Data(Section.Data, LE, 0);
8889
uint32_t Offset = 0;
8990
while (Data.isValidOffset(Offset)) {
9091
auto U = llvm::make_unique<UnitType>(Context, Section, DA, RS, SS, SOS,
91-
AOS, LS, LE, *this,
92+
AOS, LS, LE, IsDWO, *this,
9293
Index.getFromOffset(Offset));
9394
if (!U->extract(Data, &Offset))
9495
break;
@@ -113,6 +114,7 @@ class DWARFUnit {
113114
StringRef AddrOffsetSection;
114115
uint32_t AddrOffsetSectionBase;
115116
bool isLittleEndian;
117+
bool isDWO;
116118
const DWARFUnitSectionBase &UnitSection;
117119

118120
uint32_t Offset;
@@ -144,7 +146,7 @@ class DWARFUnit {
144146
public:
145147
DWARFUnit(DWARFContext &Context, const DWARFSection &Section,
146148
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
147-
StringRef SOS, StringRef AOS, StringRef LS, bool LE,
149+
StringRef SOS, StringRef AOS, StringRef LS, bool LE, bool IsDWO,
148150
const DWARFUnitSectionBase &UnitSection,
149151
const DWARFUnitIndex::Entry *IndexEntry = nullptr);
150152

lib/DebugInfo/DWARF/DWARFUnit.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,22 @@ using namespace dwarf;
2020
void DWARFUnitSectionBase::parse(DWARFContext &C, const DWARFSection &Section) {
2121
parseImpl(C, Section, C.getDebugAbbrev(), C.getRangeSection(),
2222
C.getStringSection(), StringRef(), C.getAddrSection(),
23-
C.getLineSection().Data, C.isLittleEndian());
23+
C.getLineSection().Data, C.isLittleEndian(), false);
2424
}
2525

2626
void DWARFUnitSectionBase::parseDWO(DWARFContext &C,
2727
const DWARFSection &DWOSection,
2828
DWARFUnitIndex *Index) {
2929
parseImpl(C, DWOSection, C.getDebugAbbrevDWO(), C.getRangeDWOSection(),
3030
C.getStringDWOSection(), C.getStringOffsetDWOSection(),
31-
C.getAddrSection(), C.getLineDWOSection().Data, C.isLittleEndian());
31+
C.getAddrSection(), C.getLineDWOSection().Data, C.isLittleEndian(),
32+
true);
3233
}
3334

3435
DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
3536
const DWARFDebugAbbrev *DA, StringRef RS, StringRef SS,
3637
StringRef SOS, StringRef AOS, StringRef LS, bool LE,
37-
const DWARFUnitSectionBase &UnitSection,
38+
bool IsDWO, const DWARFUnitSectionBase &UnitSection,
3839
const DWARFUnitIndex::Entry *IndexEntry)
3940
: Context(DC), InfoSection(Section), Abbrev(DA), RangeSection(RS),
4041
LineSection(LS), StringSection(SS), StringOffsetSection([&]() {
@@ -43,8 +44,8 @@ DWARFUnit::DWARFUnit(DWARFContext &DC, const DWARFSection &Section,
4344
return SOS.slice(C->Offset, C->Offset + C->Length);
4445
return SOS;
4546
}()),
46-
AddrOffsetSection(AOS), isLittleEndian(LE), UnitSection(UnitSection),
47-
IndexEntry(IndexEntry) {
47+
AddrOffsetSection(AOS), isLittleEndian(LE), isDWO(IsDWO),
48+
UnitSection(UnitSection), IndexEntry(IndexEntry) {
4849
clear();
4950
}
5051

@@ -281,6 +282,8 @@ DWARFUnit::DWOHolder::DWOHolder(StringRef DWOPath)
281282
}
282283

283284
bool DWARFUnit::parseDWO() {
285+
if (isDWO)
286+
return false;
284287
if (DWO.get())
285288
return false;
286289
extractDIEsIfNeeded(true);
1.15 KB
Binary file not shown.
1.61 KB
Binary file not shown.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
REQUIRES: shell
2+
RUN: cd Output
3+
RUN: cp %p/Inputs/split-dwarf-empty.dwo %T
4+
RUN: echo "%p/Inputs/split-dwarf-empty.o 0xdeadbeef" > %t.input
5+
6+
RUN: llvm-symbolizer --functions=linkage --inlining --demangle=false \
7+
RUN: --default-arch=i386 < %t.input | FileCheck %s
8+
9+
CHECK: ??
10+
CHECK: ??:0:0

0 commit comments

Comments
 (0)