Skip to content

Commit bf6a278

Browse files
committed
Use getFileNameEntry for retrieving FileNameEntry DWARF version agnositc way
1 parent 888ceac commit bf6a278

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

bolt/lib/Core/BinaryContext.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,23 +1568,19 @@ unsigned BinaryContext::addDebugFilenameToUnit(const uint32_t DestCUID,
15681568
DWARFCompileUnit *SrcUnit = DwCtx->getCompileUnitForOffset(SrcCUID);
15691569
const DWARFDebugLine::LineTable *LineTable =
15701570
DwCtx->getLineTableForUnit(SrcUnit);
1571-
const std::vector<DWARFDebugLine::FileNameEntry> &FileNames =
1572-
LineTable->Prologue.FileNames;
1573-
// Dir indexes start at 1, as DWARF file numbers, and a dir index 0
1571+
const DWARFDebugLine::FileNameEntry &FileNameEntry =
1572+
LineTable->Prologue.getFileNameEntry(FileIndex);
1573+
// Dir indexes start at 1 and a dir index 0
15741574
// means empty dir.
1575-
assert(FileIndex > 0 && FileIndex <= FileNames.size() &&
1576-
"FileIndex out of range for the compilation unit.");
15771575
StringRef Dir = "";
1578-
if (FileNames[FileIndex - 1].DirIdx != 0) {
1576+
if (FileNameEntry.DirIdx != 0) {
15791577
if (std::optional<const char *> DirName = dwarf::toString(
1580-
LineTable->Prologue
1581-
.IncludeDirectories[FileNames[FileIndex - 1].DirIdx - 1])) {
1578+
LineTable->Prologue.IncludeDirectories[FileNameEntry.DirIdx - 1])) {
15821579
Dir = *DirName;
15831580
}
15841581
}
15851582
StringRef FileName = "";
1586-
if (std::optional<const char *> FName =
1587-
dwarf::toString(FileNames[FileIndex - 1].Name))
1583+
if (std::optional<const char *> FName = dwarf::toString(FileNameEntry.Name))
15881584
FileName = *FName;
15891585
assert(FileName != "");
15901586
DWARFCompileUnit *DstUnit = DwCtx->getCompileUnitForOffset(DestCUID);
@@ -1925,7 +1921,7 @@ static void printDebugInfo(raw_ostream &OS, const MCInst &Instruction,
19251921
const DWARFDebugLine::Row &Row = LineTable->Rows[RowRef.RowIndex - 1];
19261922
StringRef FileName = "";
19271923
if (std::optional<const char *> FName =
1928-
dwarf::toString(LineTable->Prologue.FileNames[Row.File - 1].Name))
1924+
dwarf::toString(LineTable->Prologue.getFileNameEntry(Row.File).Name))
19291925
FileName = *FName;
19301926
OS << " # debug line " << FileName << ":" << Row.Line;
19311927
if (Row.Column)
Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
SECTIONS {
2-
. = SIZEOF_HEADERS;
2+
. = 0x400000 + SIZEOF_HEADERS;
33
.interp : { *(.interp) }
44
.note.gnu.build-id : { *(.note.gnu.build-id) }
5-
. = 0x212e8;
65
.dynsym : { *(.dynsym) }
7-
. = 0x31860;
6+
. = 0x801000;
87
.text : { *(.text*) }
9-
. = 0x41c20;
8+
. = 0x803000;
109
.fini_array : { *(.fini_array) }
11-
. = 0x54e18;
10+
. = 0x805000;
1211
.data : { *(.data) }
13-
}
12+
}

0 commit comments

Comments
 (0)