[PATCH] D49131: [MC] Add interface to finish pending labels.
Jonas Devlieghere via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 10 06:59:40 PDT 2018
JDevlieghere created this revision.
JDevlieghere added a reviewer: thegameg.
Herald added a subscriber: hiraditya.
When manually finishing the object writer in dsymutil, it's possible
that there are pending labels that haven't been resolved. This results
in an assertion when the assembler tries to fixup a label that doesn't
have an address yet.
Repository:
rL LLVM
https://reviews.llvm.org/D49131
Files:
llvm/include/llvm/MC/MCObjectStreamer.h
llvm/lib/MC/MCObjectStreamer.cpp
llvm/tools/dsymutil/MachOUtils.cpp
Index: llvm/tools/dsymutil/MachOUtils.cpp
===================================================================
--- llvm/tools/dsymutil/MachOUtils.cpp
+++ llvm/tools/dsymutil/MachOUtils.cpp
@@ -322,8 +322,10 @@
auto &ObjectStreamer = static_cast<MCObjectStreamer &>(MS);
MCAssembler &MCAsm = ObjectStreamer.getAssembler();
auto &Writer = static_cast<MachObjectWriter &>(MCAsm.getWriter());
- MCAsmLayout Layout(MCAsm);
+ // Finish but don't emit.
+ ObjectStreamer.finishPendingLabels();
+ MCAsmLayout Layout(MCAsm);
MCAsm.layout(Layout);
BinaryHolder InputBinaryHolder(false);
Index: llvm/lib/MC/MCObjectStreamer.cpp
===================================================================
--- llvm/lib/MC/MCObjectStreamer.cpp
+++ llvm/lib/MC/MCObjectStreamer.cpp
@@ -660,14 +660,16 @@
getAssembler().addFileName(Filename);
}
+void MCObjectStreamer::finishPendingLabels() { flushPendingLabels(nullptr); }
+
void MCObjectStreamer::FinishImpl() {
// If we are generating dwarf for assembly source files dump out the sections.
if (getContext().getGenDwarfForAssembly())
MCGenDwarfInfo::Emit(this);
// Dump out the dwarf file & directory tables and line tables.
MCDwarfLineTable::Emit(this, getAssembler().getDWARFLinetableParams());
- flushPendingLabels(nullptr);
+ finishPendingLabels();
getAssembler().Finish();
}
Index: llvm/include/llvm/MC/MCObjectStreamer.h
===================================================================
--- llvm/include/llvm/MC/MCObjectStreamer.h
+++ llvm/include/llvm/MC/MCObjectStreamer.h
@@ -89,6 +89,7 @@
public:
void visitUsedSymbol(const MCSymbol &Sym) override;
+ void finishPendingLabels();
MCAssembler &getAssembler() { return *Assembler; }
MCAssembler *getAssemblerPtr() override;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49131.154795.patch
Type: text/x-patch
Size: 1781 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180710/249ab9e7/attachment.bin>
More information about the llvm-commits
mailing list