aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCDwarf.cpp
diff options
context:
space:
mode:
authorAlexander Yermolovich <ayermolo@meta.com>2023-07-06 11:34:18 -0700
committerAlexander Yermolovich <ayermolo@meta.com>2023-07-06 11:37:08 -0700
commit66e943b1a9751db1611f6ba07e4c46899455d686 (patch)
tree87d01d9e536712c9ac8e9a93c3510e62abdf234f /llvm/lib/MC/MCDwarf.cpp
parentade8db573ed200c562f81c4a8d81eaf6ae48bb35 (diff)
downloadllvm-66e943b1a9751db1611f6ba07e4c46899455d686.zip
llvm-66e943b1a9751db1611f6ba07e4c46899455d686.tar.gz
llvm-66e943b1a9751db1611f6ba07e4c46899455d686.tar.bz2
[BOLT][DWARF] Fix for .debug_line with DWARF5
There was a bug in a code that pre-populated line string for a case where parts of .debug_line are not processed by BOLT, but copied as raw data. We were not switching sections. This resulted in parts of the binary being over-written with debug data. Reviewed By: maksfb Differential Revision: https://reviews.llvm.org/D154544
Diffstat (limited to 'llvm/lib/MC/MCDwarf.cpp')
-rw-r--r--llvm/lib/MC/MCDwarf.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/MC/MCDwarf.cpp b/llvm/lib/MC/MCDwarf.cpp
index 177f957..55632f2 100644
--- a/llvm/lib/MC/MCDwarf.cpp
+++ b/llvm/lib/MC/MCDwarf.cpp
@@ -350,10 +350,14 @@ SmallString<0> MCDwarfLineStr::getFinalizedData() {
return Data;
}
+size_t MCDwarfLineStr::addString(StringRef Path) {
+ return LineStrings.add(Path);
+}
+
void MCDwarfLineStr::emitRef(MCStreamer *MCOS, StringRef Path) {
int RefSize =
dwarf::getDwarfOffsetByteSize(MCOS->getContext().getDwarfFormat());
- size_t Offset = LineStrings.add(Path);
+ size_t Offset = addString(Path);
if (UseRelocs) {
MCContext &Ctx = MCOS->getContext();
MCOS->emitValue(makeStartPlusIntExpr(Ctx, *LineStrLabel, Offset), RefSize);