diff options
Diffstat (limited to 'llvm/lib/MC/MCELFStreamer.cpp')
-rw-r--r-- | llvm/lib/MC/MCELFStreamer.cpp | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/llvm/lib/MC/MCELFStreamer.cpp b/llvm/lib/MC/MCELFStreamer.cpp index 0286991c106..2e0d85a1e2d 100644 --- a/llvm/lib/MC/MCELFStreamer.cpp +++ b/llvm/lib/MC/MCELFStreamer.cpp @@ -189,13 +189,26 @@ void MCELFStreamer::InitSections() { } void MCELFStreamer::EmitLabel(MCSymbol *Symbol) { - MCObjectStreamer::EmitLabel(Symbol); + assert(Symbol->isUndefined() && "Cannot define a symbol twice!"); + + Symbol->setSection(*CurSection); + + MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); const MCSectionELF &Section = static_cast<const MCSectionELF&>(Symbol->getSection()); - MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol); if (Section.getFlags() & MCSectionELF::SHF_TLS) SetType(SD, ELF::STT_TLS); + + // FIXME: This is wasteful, we don't necessarily need to create a data + // fragment. Instead, we should mark the symbol as pointing into the data + // fragment if it exists, otherwise we should just queue the label and set its + // fragment pointer when we emit the next fragment. + MCDataFragment *F = getOrCreateDataFragment(); + + assert(!SD.getFragment() && "Unexpected fragment on symbol data!"); + SD.setFragment(F); + SD.setOffset(F->getContents().size()); } void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) { |