[llvm] r336688 - [MC] Add interface to finish pending labels.
Jonas Devlieghere via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 10 08:32:17 PDT 2018
Author: jdevlieghere
Date: Tue Jul 10 08:32:17 2018
New Revision: 336688
URL: http://llvm.org/viewvc/llvm-project?rev=336688&view=rev
Log:
[MC] Add interface to finish pending labels.
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.
Differential revision: https://reviews.llvm.org/D49131
Modified:
llvm/trunk/include/llvm/MC/MCObjectStreamer.h
llvm/trunk/lib/MC/MCObjectStreamer.cpp
llvm/trunk/tools/dsymutil/MachOUtils.cpp
Modified: llvm/trunk/include/llvm/MC/MCObjectStreamer.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectStreamer.h?rev=336688&r1=336687&r2=336688&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCObjectStreamer.h (original)
+++ llvm/trunk/include/llvm/MC/MCObjectStreamer.h Tue Jul 10 08:32:17 2018
@@ -90,6 +90,9 @@ protected:
public:
void visitUsedSymbol(const MCSymbol &Sym) override;
+ /// Create a dummy fragment to assign any pending labels.
+ void flushPendingLabels() { flushPendingLabels(nullptr); }
+
MCAssembler &getAssembler() { return *Assembler; }
MCAssembler *getAssemblerPtr() override;
/// \name MCStreamer Interface
Modified: llvm/trunk/lib/MC/MCObjectStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectStreamer.cpp?rev=336688&r1=336687&r2=336688&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCObjectStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCObjectStreamer.cpp Tue Jul 10 08:32:17 2018
@@ -671,6 +671,6 @@ void MCObjectStreamer::FinishImpl() {
// Dump out the dwarf file & directory tables and line tables.
MCDwarfLineTable::Emit(this, getAssembler().getDWARFLinetableParams());
- flushPendingLabels(nullptr);
+ flushPendingLabels();
getAssembler().Finish();
}
Modified: llvm/trunk/tools/dsymutil/MachOUtils.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/MachOUtils.cpp?rev=336688&r1=336687&r2=336688&view=diff
==============================================================================
--- llvm/trunk/tools/dsymutil/MachOUtils.cpp (original)
+++ llvm/trunk/tools/dsymutil/MachOUtils.cpp Tue Jul 10 08:32:17 2018
@@ -322,8 +322,10 @@ bool generateDsymCompanion(const DebugMa
auto &ObjectStreamer = static_cast<MCObjectStreamer &>(MS);
MCAssembler &MCAsm = ObjectStreamer.getAssembler();
auto &Writer = static_cast<MachObjectWriter &>(MCAsm.getWriter());
- MCAsmLayout Layout(MCAsm);
+ // Layout but don't emit.
+ ObjectStreamer.flushPendingLabels();
+ MCAsmLayout Layout(MCAsm);
MCAsm.layout(Layout);
BinaryHolder InputBinaryHolder(false);
More information about the llvm-commits
mailing list