From 2f9bdd8c9fffe4646d33a85349f55b43f795a253 Mon Sep 17 00:00:00 2001 From: Rafael Espindola Date: Wed, 27 May 2015 20:52:32 +0000 Subject: There is only one current section. Both MCStreamer and MCObjectStreamer were maintaining a current section variable and they were slightly out of sync. I don't think this was observable, but was inefficient and error prone. Changing this requires a few cascading changes: * SwitchSection has to call ChangeSection earlier for ChangeSection to see the old section. * With that change, ChangeSection cannot call EmitLabel, since during ChangeSection we are still in the old section. * When the object streamer requires a begin label, just reused the existing generic support for begin labels instead of calling EmitLabel directly. llvm-svn: 238357 --- llvm/lib/MC/ELFObjectWriter.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'llvm/lib/MC/ELFObjectWriter.cpp') diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp index 18746d1..8061f69 100644 --- a/llvm/lib/MC/ELFObjectWriter.cpp +++ b/llvm/lib/MC/ELFObjectWriter.cpp @@ -821,9 +821,7 @@ void ELFObjectWriter::RecordRelocation(MCAssembler &Asm, const MCSection *SecA = (SymA && !SymA->isUndefined()) ? &SymA->getSection() : nullptr; auto *ELFSec = cast_or_null(SecA); - MCSymbol *SectionSymbol = - ELFSec ? Asm.getContext().getOrCreateSectionSymbol(*ELFSec) - : nullptr; + const MCSymbol *SectionSymbol = ELFSec ? ELFSec->getBeginSymbol() : nullptr; ELFRelocationEntry Rec(FixupOffset, SectionSymbol, Type, Addend); Relocations[&FixupSection].push_back(Rec); return; @@ -882,6 +880,9 @@ bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout, if (!Symbol.isVariable() && Symbol.isUndefined() && !IsGlobal) return false; + if (MCELF::GetType(Data) == ELF::STT_SECTION) + return true; + if (Symbol.isTemporary()) return false; -- cgit v1.1