Pass MCSymbols to the helper functions in MCELF.h.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238596 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Rafael Espindola 2015-05-29 18:47:23 +00:00
parent 09681051e6
commit 5b68a837c7
14 changed files with 108 additions and 114 deletions

View File

@ -16,18 +16,18 @@
#define LLVM_MC_MCELF_H
namespace llvm {
class MCSymbolData;
class MCSymbol;
class MCELF {
public:
static void SetBinding(MCSymbolData &SD, unsigned Binding);
static unsigned GetBinding(const MCSymbolData &SD);
static void SetType(MCSymbolData &SD, unsigned Type);
static unsigned GetType(const MCSymbolData &SD);
static void SetVisibility(MCSymbolData &SD, unsigned Visibility);
static unsigned GetVisibility(const MCSymbolData &SD);
static void setOther(MCSymbolData &SD, unsigned Other);
static unsigned getOther(const MCSymbolData &SD);
static void SetBinding(const MCSymbol &Sym, unsigned Binding);
static unsigned GetBinding(const MCSymbol &Sym);
static void SetType(const MCSymbol &Sym, unsigned Type);
static unsigned GetType(const MCSymbol &Sym);
static void SetVisibility(MCSymbol &Sym, unsigned Visibility);
static unsigned GetVisibility(const MCSymbol &Sym);
static void setOther(MCSymbol &Sym, unsigned Other);
static unsigned getOther(const MCSymbol &Sym);
};
}

View File

@ -85,8 +85,8 @@ class ELFObjectWriter : public MCObjectWriter {
// Support lexicographic sorting.
bool operator<(const ELFSymbolData &RHS) const {
unsigned LHSType = MCELF::GetType(Symbol->getData());
unsigned RHSType = MCELF::GetType(RHS.Symbol->getData());
unsigned LHSType = MCELF::GetType(*Symbol);
unsigned RHSType = MCELF::GetType(*RHS.Symbol);
if (LHSType == ELF::STT_SECTION && RHSType != ELF::STT_SECTION)
return false;
if (LHSType != ELF::STT_SECTION && RHSType == ELF::STT_SECTION)
@ -398,7 +398,7 @@ void ELFObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
// Aliases defined with .symvar copy the binding from the symbol they alias.
// This is the first place we are able to copy this information.
OriginalData.setExternal(SD.isExternal());
MCELF::SetBinding(OriginalData, MCELF::GetBinding(SD));
MCELF::SetBinding(Alias, MCELF::GetBinding(Symbol));
StringRef Rest = AliasName.substr(Pos);
if (!Symbol.isUndefined() && !Rest.startswith("@@@"))
@ -462,19 +462,20 @@ void ELFObjectWriter::writeSymbol(SymbolTableWriter &Writer,
bool IsReserved = !Base || MSD.Symbol->isCommon();
// Binding and Type share the same byte as upper and lower nibbles
uint8_t Binding = MCELF::GetBinding(OrigData);
uint8_t Type = MCELF::GetType(OrigData);
uint8_t Binding = MCELF::GetBinding(*MSD.Symbol);
uint8_t Type = MCELF::GetType(*MSD.Symbol);
MCSymbolData *BaseSD = nullptr;
if (Base) {
BaseSD = &Base->getData();
Type = mergeTypeForSet(Type, MCELF::GetType(*BaseSD));
Type = mergeTypeForSet(Type, MCELF::GetType(*Base));
}
uint8_t Info = (Binding << ELF_STB_Shift) | (Type << ELF_STT_Shift);
// Other and Visibility share the same byte with Visibility using the lower
// 2 bits
uint8_t Visibility = MCELF::GetVisibility(OrigData);
uint8_t Other = MCELF::getOther(OrigData) << (ELF_STO_Shift - ELF_STV_Shift);
uint8_t Visibility = MCELF::GetVisibility(*MSD.Symbol);
uint8_t Other = MCELF::getOther(*MSD.Symbol)
<< (ELF_STO_Shift - ELF_STV_Shift);
Other |= Visibility;
uint64_t Value = SymbolValue(*MSD.Symbol, Layout);
@ -503,8 +504,6 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm,
const MCSymbolRefExpr *RefA,
const MCSymbol *Sym, uint64_t C,
unsigned Type) const {
MCSymbolData *SD = Sym ? &Sym->getData() : nullptr;
// A PCRel relocation to an absolute value has no symbol (or section). We
// represent that with a relocation to a null section.
if (!RefA)
@ -543,7 +542,7 @@ bool ELFObjectWriter::shouldRelocateWithSymbol(const MCAssembler &Asm,
if (Sym->isUndefined())
return true;
unsigned Binding = MCELF::GetBinding(*SD);
unsigned Binding = MCELF::GetBinding(*Sym);
switch(Binding) {
default:
llvm_unreachable("Invalid Binding");
@ -620,11 +619,11 @@ static const MCSymbol *getWeakRef(const MCSymbolRefExpr &Ref) {
// True if the assembler knows nothing about the final value of the symbol.
// This doesn't cover the comdat issues, since in those cases the assembler
// can at least know that all symbols in the section will move together.
static bool isWeak(const MCSymbolData &D) {
if (MCELF::GetType(D) == ELF::STT_GNU_IFUNC)
static bool isWeak(const MCSymbol &Sym) {
if (MCELF::GetType(Sym) == ELF::STT_GNU_IFUNC)
return true;
switch (MCELF::GetBinding(D)) {
switch (MCELF::GetBinding(Sym)) {
default:
llvm_unreachable("Unknown binding");
case ELF::STB_LOCAL:
@ -676,7 +675,7 @@ void ELFObjectWriter::RecordRelocation(MCAssembler &Asm,
Asm.getContext().reportFatalError(
Fixup.getLoc(), "Cannot represent a difference across sections");
if (::isWeak(SymB.getData()))
if (::isWeak(SymB))
Asm.getContext().reportFatalError(
Fixup.getLoc(), "Cannot represent a subtraction with a weak symbol");
@ -730,7 +729,6 @@ void ELFObjectWriter::RecordRelocation(MCAssembler &Asm,
bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
const MCSymbol &Symbol, bool Used,
bool Renamed) {
const MCSymbolData &Data = Symbol.getData();
if (Symbol.isVariable()) {
const MCExpr *Expr = Symbol.getVariableValue();
if (const MCSymbolRefExpr *Ref = dyn_cast<MCSymbolRefExpr>(Expr)) {
@ -754,11 +752,11 @@ bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
return false;
}
bool IsGlobal = MCELF::GetBinding(Data) == ELF::STB_GLOBAL;
bool IsGlobal = MCELF::GetBinding(Symbol) == ELF::STB_GLOBAL;
if (!Symbol.isVariable() && Symbol.isUndefined() && !IsGlobal)
return false;
if (MCELF::GetType(Data) == ELF::STT_SECTION)
if (MCELF::GetType(Symbol) == ELF::STT_SECTION)
return true;
if (Symbol.isTemporary())
@ -811,8 +809,6 @@ void ELFObjectWriter::computeSymbolTable(
// Add the data for the symbols.
bool HasLargeSectionIndex = false;
for (const MCSymbol &Symbol : Asm.symbols()) {
MCSymbolData &SD = Symbol.getData();
bool Used = UsedInReloc.count(&Symbol);
bool WeakrefUsed = WeakrefUsedInReloc.count(&Symbol);
bool isSignature = RevGroupMap.count(&Symbol);
@ -827,8 +823,8 @@ void ELFObjectWriter::computeSymbolTable(
// Undefined symbols are global, but this is the first place we
// are able to set it.
bool Local = isLocal(Symbol, Used, isSignature);
if (!Local && MCELF::GetBinding(SD) == ELF::STB_LOCAL)
MCELF::SetBinding(SD, ELF::STB_GLOBAL);
if (!Local && MCELF::GetBinding(Symbol) == ELF::STB_LOCAL)
MCELF::SetBinding(Symbol, ELF::STB_GLOBAL);
if (Symbol.isAbsolute()) {
MSD.SectionIndex = ELF::SHN_ABS;
@ -844,7 +840,7 @@ void ELFObjectWriter::computeSymbolTable(
MSD.SectionIndex = ELF::SHN_UNDEF;
}
if (!Used && WeakrefUsed)
MCELF::SetBinding(SD, ELF::STB_WEAK);
MCELF::SetBinding(Symbol, ELF::STB_WEAK);
} else {
const MCSectionELF &Section =
static_cast<const MCSectionELF &>(Symbol.getSection());
@ -894,7 +890,7 @@ void ELFObjectWriter::computeSymbolTable(
}
// Sections have their own string table
if (MCELF::GetType(SD) != ELF::STT_SECTION)
if (MCELF::GetType(Symbol) != ELF::STT_SECTION)
MSD.Name = StrTabBuilder.add(Name);
if (Local)
@ -930,10 +926,9 @@ void ELFObjectWriter::computeSymbolTable(
unsigned Index = FileNames.size() + 1;
for (ELFSymbolData &MSD : LocalSymbolData) {
unsigned StringIndex =
MCELF::GetType(MSD.Symbol->getData()) == ELF::STT_SECTION
? 0
: StrTabBuilder.getOffset(MSD.Name);
unsigned StringIndex = MCELF::GetType(*MSD.Symbol) == ELF::STT_SECTION
? 0
: StrTabBuilder.getOffset(MSD.Name);
MSD.Symbol->setIndex(Index++);
writeSymbol(Writer, StringIndex, MSD, Layout);
}
@ -945,7 +940,7 @@ void ELFObjectWriter::computeSymbolTable(
unsigned StringIndex = StrTabBuilder.getOffset(MSD.Name);
MSD.Symbol->setIndex(Index++);
writeSymbol(Writer, StringIndex, MSD, Layout);
assert(MCELF::GetBinding(MSD.Symbol->getData()) != ELF::STB_LOCAL);
assert(MCELF::GetBinding(*MSD.Symbol) != ELF::STB_LOCAL);
}
uint64_t SecEnd = OS.tell();
@ -1361,7 +1356,7 @@ bool ELFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
bool InSet, bool IsPCRel) const {
if (IsPCRel) {
assert(!InSet);
if (::isWeak(SymA.getData()))
if (::isWeak(SymA))
return false;
}
return MCObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(Asm, SymA, FB,
@ -1369,8 +1364,7 @@ bool ELFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
}
bool ELFObjectWriter::isWeak(const MCSymbol &Sym) const {
const MCSymbolData &SD = Sym.getData();
if (::isWeak(SD))
if (::isWeak(Sym))
return true;
// It is invalid to replace a reference to a global in a comdat
@ -1379,7 +1373,7 @@ bool ELFObjectWriter::isWeak(const MCSymbol &Sym) const {
// We could try to return false for more cases, like the reference
// being in the same comdat or Sym being an alias to another global,
// but it is not clear if it is worth the effort.
if (MCELF::GetBinding(SD) != ELF::STB_GLOBAL)
if (MCELF::GetBinding(Sym) != ELF::STB_GLOBAL)
return false;
if (!Sym.isInSection())

View File

@ -19,21 +19,24 @@
namespace llvm {
void MCELF::SetBinding(MCSymbolData &SD, unsigned Binding) {
void MCELF::SetBinding(const MCSymbol &Sym, unsigned Binding) {
MCSymbolData &SD = Sym.getData();
assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL ||
Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE);
uint32_t OtherFlags = SD.getFlags() & ~(0xf << ELF_STB_Shift);
SD.setFlags(OtherFlags | (Binding << ELF_STB_Shift));
}
unsigned MCELF::GetBinding(const MCSymbolData &SD) {
unsigned MCELF::GetBinding(const MCSymbol &Sym) {
MCSymbolData &SD = Sym.getData();
uint32_t Binding = (SD.getFlags() & (0xf << ELF_STB_Shift)) >> ELF_STB_Shift;
assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL ||
Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE);
return Binding;
}
void MCELF::SetType(MCSymbolData &SD, unsigned Type) {
void MCELF::SetType(const MCSymbol &Sym, unsigned Type) {
MCSymbolData &SD = Sym.getData();
assert(Type == ELF::STT_NOTYPE || Type == ELF::STT_OBJECT ||
Type == ELF::STT_FUNC || Type == ELF::STT_SECTION ||
Type == ELF::STT_COMMON || Type == ELF::STT_TLS ||
@ -43,7 +46,8 @@ void MCELF::SetType(MCSymbolData &SD, unsigned Type) {
SD.setFlags(OtherFlags | (Type << ELF_STT_Shift));
}
unsigned MCELF::GetType(const MCSymbolData &SD) {
unsigned MCELF::GetType(const MCSymbol &Sym) {
MCSymbolData &SD = Sym.getData();
uint32_t Type = (SD.getFlags() & (0xf << ELF_STT_Shift)) >> ELF_STT_Shift;
assert(Type == ELF::STT_NOTYPE || Type == ELF::STT_OBJECT ||
Type == ELF::STT_FUNC || Type == ELF::STT_SECTION ||
@ -53,7 +57,8 @@ unsigned MCELF::GetType(const MCSymbolData &SD) {
// Visibility is stored in the first two bits of st_other
// st_other values are stored in the second byte of get/setFlags
void MCELF::SetVisibility(MCSymbolData &SD, unsigned Visibility) {
void MCELF::SetVisibility(MCSymbol &Sym, unsigned Visibility) {
MCSymbolData &SD = Sym.getData();
assert(Visibility == ELF::STV_DEFAULT || Visibility == ELF::STV_INTERNAL ||
Visibility == ELF::STV_HIDDEN || Visibility == ELF::STV_PROTECTED);
@ -61,7 +66,8 @@ void MCELF::SetVisibility(MCSymbolData &SD, unsigned Visibility) {
SD.setFlags(OtherFlags | (Visibility << ELF_STV_Shift));
}
unsigned MCELF::GetVisibility(const MCSymbolData &SD) {
unsigned MCELF::GetVisibility(const MCSymbol &Sym) {
MCSymbolData &SD = Sym.getData();
unsigned Visibility =
(SD.getFlags() & (0x3 << ELF_STV_Shift)) >> ELF_STV_Shift;
assert(Visibility == ELF::STV_DEFAULT || Visibility == ELF::STV_INTERNAL ||
@ -71,12 +77,14 @@ unsigned MCELF::GetVisibility(const MCSymbolData &SD) {
// Other is stored in the last six bits of st_other
// st_other values are stored in the second byte of get/setFlags
void MCELF::setOther(MCSymbolData &SD, unsigned Other) {
void MCELF::setOther(MCSymbol &Sym, unsigned Other) {
MCSymbolData &SD = Sym.getData();
uint32_t OtherFlags = SD.getFlags() & ~(0x3f << ELF_STO_Shift);
SD.setFlags(OtherFlags | (Other << ELF_STO_Shift));
}
unsigned MCELF::getOther(const MCSymbolData &SD) {
unsigned MCELF::getOther(const MCSymbol &Sym) {
MCSymbolData &SD = Sym.getData();
unsigned Other =
(SD.getFlags() & (0x3f << ELF_STO_Shift)) >> ELF_STO_Shift;
return Other;

View File

@ -113,9 +113,8 @@ void MCELFStreamer::EmitLabel(MCSymbol *Symbol) {
const MCSectionELF &Section =
static_cast<const MCSectionELF&>(Symbol->getSection());
MCSymbolData &SD = Symbol->getData();
if (Section.getFlags() & ELF::SHF_TLS)
MCELF::SetType(SD, ELF::STT_TLS);
MCELF::SetType(*Symbol, ELF::STT_TLS);
}
void MCELFStreamer::EmitAssemblerFlag(MCAssemblerFlag Flag) {
@ -165,8 +164,10 @@ void MCELFStreamer::ChangeSection(MCSection *Section,
Begin = Ctx.getOrCreateSectionSymbol(*SectionELF);
Section->setBeginSymbol(Begin);
}
if (Begin->isUndefined())
MCELF::SetType(Asm.getOrCreateSymbolData(*Begin), ELF::STT_SECTION);
if (Begin->isUndefined()) {
Asm.getOrCreateSymbolData(*Begin);
MCELF::SetType(*Begin, ELF::STT_SECTION);
}
}
void MCELFStreamer::EmitWeakReference(MCSymbol *Alias, const MCSymbol *Symbol) {
@ -236,72 +237,73 @@ bool MCELFStreamer::EmitSymbolAttribute(MCSymbol *Symbol,
break;
case MCSA_ELF_TypeGnuUniqueObject:
MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD), ELF::STT_OBJECT));
MCELF::SetBinding(SD, ELF::STB_GNU_UNIQUE);
MCELF::SetType(
*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT));
MCELF::SetBinding(*Symbol, ELF::STB_GNU_UNIQUE);
SD.setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_Global:
MCELF::SetBinding(SD, ELF::STB_GLOBAL);
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
SD.setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_WeakReference:
case MCSA_Weak:
MCELF::SetBinding(SD, ELF::STB_WEAK);
MCELF::SetBinding(*Symbol, ELF::STB_WEAK);
SD.setExternal(true);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_Local:
MCELF::SetBinding(SD, ELF::STB_LOCAL);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
BindingExplicitlySet.insert(Symbol);
break;
case MCSA_ELF_TypeFunction:
MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
ELF::STT_FUNC));
MCELF::SetType(*Symbol,
CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_FUNC));
break;
case MCSA_ELF_TypeIndFunction:
MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
ELF::STT_GNU_IFUNC));
MCELF::SetType(*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol),
ELF::STT_GNU_IFUNC));
break;
case MCSA_ELF_TypeObject:
MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
ELF::STT_OBJECT));
MCELF::SetType(
*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT));
break;
case MCSA_ELF_TypeTLS:
MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
ELF::STT_TLS));
MCELF::SetType(*Symbol,
CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_TLS));
break;
case MCSA_ELF_TypeCommon:
// TODO: Emit these as a common symbol.
MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
ELF::STT_OBJECT));
MCELF::SetType(
*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_OBJECT));
break;
case MCSA_ELF_TypeNoType:
MCELF::SetType(SD, CombineSymbolTypes(MCELF::GetType(SD),
ELF::STT_NOTYPE));
MCELF::SetType(
*Symbol, CombineSymbolTypes(MCELF::GetType(*Symbol), ELF::STT_NOTYPE));
break;
case MCSA_Protected:
MCELF::SetVisibility(SD, ELF::STV_PROTECTED);
MCELF::SetVisibility(*Symbol, ELF::STV_PROTECTED);
break;
case MCSA_Hidden:
MCELF::SetVisibility(SD, ELF::STV_HIDDEN);
MCELF::SetVisibility(*Symbol, ELF::STV_HIDDEN);
break;
case MCSA_Internal:
MCELF::SetVisibility(SD, ELF::STV_INTERNAL);
MCELF::SetVisibility(*Symbol, ELF::STV_INTERNAL);
break;
}
@ -313,13 +315,13 @@ void MCELFStreamer::EmitCommonSymbol(MCSymbol *Symbol, uint64_t Size,
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
if (!BindingExplicitlySet.count(Symbol)) {
MCELF::SetBinding(SD, ELF::STB_GLOBAL);
MCELF::SetBinding(*Symbol, ELF::STB_GLOBAL);
SD.setExternal(true);
}
MCELF::SetType(SD, ELF::STT_OBJECT);
MCELF::SetType(*Symbol, ELF::STT_OBJECT);
if (MCELF::GetBinding(SD) == ELF_STB_Local) {
if (MCELF::GetBinding(*Symbol) == ELF_STB_Local) {
MCSection *Section = getAssembler().getContext().getELFSection(
".bss", ELF::SHT_NOBITS, ELF::SHF_WRITE | ELF::SHF_ALLOC);
@ -342,7 +344,7 @@ void MCELFStreamer::EmitLocalCommonSymbol(MCSymbol *Symbol, uint64_t Size,
unsigned ByteAlignment) {
// FIXME: Should this be caught and done earlier?
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
MCELF::SetBinding(SD, ELF::STB_LOCAL);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
BindingExplicitlySet.insert(Symbol);
EmitCommonSymbol(Symbol, Size, ByteAlignment);
@ -458,8 +460,8 @@ void MCELFStreamer::fixSymbolsInTLSFixups(const MCExpr *expr) {
case MCSymbolRefExpr::VK_PPC_TLSLD:
break;
}
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(symRef.getSymbol());
MCELF::SetType(SD, ELF::STT_TLS);
getAssembler().getOrCreateSymbolData(symRef.getSymbol());
MCELF::SetType(symRef.getSymbol(), ELF::STT_TLS);
break;
}

View File

@ -165,8 +165,8 @@ private:
Name + "." + Twine(MappingSymbolCounter++));
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
MCELF::SetType(SD, ELF::STT_NOTYPE);
MCELF::SetBinding(SD, ELF::STB_LOCAL);
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
auto Sec = getCurrentSection().first;
assert(Sec && "need a section");

View File

@ -121,8 +121,7 @@ static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
// We're known to be under a TLS fixup, so any symbol should be
// modified. There should be only one.
const MCSymbolRefExpr &SymRef = *cast<MCSymbolRefExpr>(Expr);
MCSymbolData &SD = Asm.getOrCreateSymbolData(SymRef.getSymbol());
MCELF::SetType(SD, ELF::STT_TLS);
MCELF::SetType(SymRef.getSymbol(), ELF::STT_TLS);
break;
}

View File

@ -567,8 +567,8 @@ private:
Twine(MappingSymbolCounter++));
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(*Symbol);
MCELF::SetType(SD, ELF::STT_NOTYPE);
MCELF::SetBinding(SD, ELF::STB_LOCAL);
MCELF::SetType(*Symbol, ELF::STT_NOTYPE);
MCELF::SetBinding(*Symbol, ELF::STB_LOCAL);
SD.setExternal(false);
AssignSection(Symbol, getCurrentSection().first);
@ -972,8 +972,8 @@ void ARMTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
if (!Streamer.IsThumb)
return;
const MCSymbolData &SD = Streamer.getOrCreateSymbolData(Symbol);
unsigned Type = MCELF::GetType(SD);
Streamer.getOrCreateSymbolData(Symbol);
unsigned Type = MCELF::GetType(*Symbol);
if (Type == ELF_STT_Func || Type == ELF_STT_GnuIFunc)
Streamer.EmitThumbFunc(Symbol);
}

View File

@ -271,9 +271,7 @@ static unsigned getMatchingLoType(const MCAssembler &Asm,
if (Type == ELF::R_MIPS16_HI16)
return ELF::R_MIPS16_LO16;
const MCSymbolData &SD = Reloc.Symbol->getData();
if (MCELF::GetBinding(SD) != ELF::STB_LOCAL)
if (MCELF::GetBinding(*Reloc.Symbol) != ELF::STB_LOCAL)
return ELF::R_MIPS_NONE;
if (Type == ELF::R_MIPS_GOT16)
@ -433,7 +431,7 @@ bool MipsELFObjectWriter::needsRelocateWithSymbol(const MCSymbol &Sym,
return true;
case ELF::R_MIPS_32:
if (MCELF::getOther(Sym.getData()) & (ELF::STO_MIPS_MICROMIPS >> 2))
if (MCELF::getOther(Sym) & (ELF::STO_MIPS_MICROMIPS >> 2))
return true;
// falltrough
case ELF::R_MIPS_26:

View File

@ -42,11 +42,11 @@ void MipsELFStreamer::createPendingLabelRelocs() {
// FIXME: Also mark labels when in MIPS16 mode.
if (ELFTargetStreamer->isMicroMipsEnabled()) {
for (auto Label : Labels) {
MCSymbolData &Data = getOrCreateSymbolData(Label);
getOrCreateSymbolData(Label);
// The "other" values are stored in the last 6 bits of the second byte.
// The traditional defines for STO values assume the full byte and thus
// the shift to pack it.
MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
MCELF::setOther(*Label, ELF::STO_MIPS_MICROMIPS >> 2);
}
}

View File

@ -441,15 +441,15 @@ MipsTargetELFStreamer::MipsTargetELFStreamer(MCStreamer &S,
void MipsTargetELFStreamer::emitLabel(MCSymbol *Symbol) {
if (!isMicroMipsEnabled())
return;
MCSymbolData &Data = getStreamer().getOrCreateSymbolData(Symbol);
uint8_t Type = MCELF::GetType(Data);
getStreamer().getOrCreateSymbolData(Symbol);
uint8_t Type = MCELF::GetType(*Symbol);
if (Type != ELF::STT_FUNC)
return;
// The "other" values are stored in the last 6 bits of the second byte
// The traditional defines for STO values assume the full byte and thus
// the shift to pack it.
MCELF::setOther(Data, ELF::STO_MIPS_MICROMIPS >> 2);
MCELF::setOther(*Symbol, ELF::STO_MIPS_MICROMIPS >> 2);
}
void MipsTargetELFStreamer::finish() {
@ -510,16 +510,14 @@ void MipsTargetELFStreamer::emitAssignment(MCSymbol *Symbol,
return;
const MCSymbol &RhsSym =
static_cast<const MCSymbolRefExpr *>(Value)->getSymbol();
MCSymbolData &Data = getStreamer().getOrCreateSymbolData(&RhsSym);
if (!(MCELF::getOther(Data) & (ELF::STO_MIPS_MICROMIPS >> 2)))
if (!(MCELF::getOther(RhsSym) & (ELF::STO_MIPS_MICROMIPS >> 2)))
return;
MCSymbolData &SymbolData = getStreamer().getOrCreateSymbolData(Symbol);
// The "other" values are stored in the last 6 bits of the second byte.
// The traditional defines for STO values assume the full byte and thus
// the shift to pack it.
MCELF::setOther(SymbolData, ELF::STO_MIPS_MICROMIPS >> 2);
MCELF::setOther(*Symbol, ELF::STO_MIPS_MICROMIPS >> 2);
}
MCELFStreamer &MipsTargetELFStreamer::getStreamer() {

View File

@ -142,11 +142,10 @@ public:
// to resolve the fixup directly. Emit a relocation and leave
// resolution of the final target address to the linker.
if (const MCSymbolRefExpr *A = Target.getSymA()) {
const MCSymbolData &Data = A->getSymbol().getData();
// The "other" values are stored in the last 6 bits of the second byte.
// The traditional defines for STO values assume the full byte and thus
// the shift to pack it.
unsigned Other = MCELF::getOther(Data) << 2;
unsigned Other = MCELF::getOther(A->getSymbol()) << 2;
if ((Other & ELF::STO_PPC64_LOCAL_MASK) != 0)
IsResolved = false;
}

View File

@ -407,7 +407,7 @@ bool PPCELFObjectWriter::needsRelocateWithSymbol(const MCSymbol &Sym,
// The "other" values are stored in the last 6 bits of the second byte.
// The traditional defines for STO values assume the full byte and thus
// the shift to pack it.
unsigned Other = MCELF::getOther(Sym.getData()) << 2;
unsigned Other = MCELF::getOther(Sym) << 2;
return (Other & ELF::STO_PPC64_LOCAL_MASK) != 0;
}
}

View File

@ -161,7 +161,6 @@ public:
}
void emitLocalEntry(MCSymbol *S, const MCExpr *LocalOffset) override {
MCAssembler &MCA = getStreamer().getAssembler();
MCSymbolData &Data = getStreamer().getOrCreateSymbolData(S);
int64_t Res;
if (!LocalOffset->EvaluateAsAbsolute(Res, MCA))
@ -174,10 +173,10 @@ public:
// The "other" values are stored in the last 6 bits of the second byte.
// The traditional defines for STO values assume the full byte and thus
// the shift to pack it.
unsigned Other = MCELF::getOther(Data) << 2;
unsigned Other = MCELF::getOther(*S) << 2;
Other &= ~ELF::STO_PPC64_LOCAL_MASK;
Other |= Encoded;
MCELF::setOther(Data, Other >> 2);
MCELF::setOther(*S, Other >> 2);
// For GAS compatibility, unless we already saw a .abiversion directive,
// set e_flags to indicate ELFv2 ABI.
@ -192,15 +191,13 @@ public:
return;
const MCSymbol &RhsSym =
static_cast<const MCSymbolRefExpr *>(Value)->getSymbol();
MCSymbolData &Data = getStreamer().getOrCreateSymbolData(&RhsSym);
MCSymbolData &SymbolData = getStreamer().getOrCreateSymbolData(Symbol);
// The "other" values are stored in the last 6 bits of the second byte.
// The traditional defines for STO values assume the full byte and thus
// the shift to pack it.
unsigned Other = MCELF::getOther(SymbolData) << 2;
unsigned Other = MCELF::getOther(*Symbol) << 2;
Other &= ~ELF::STO_PPC64_LOCAL_MASK;
Other |= (MCELF::getOther(Data) << 2) & ELF::STO_PPC64_LOCAL_MASK;
MCELF::setOther(SymbolData, Other >> 2);
Other |= (MCELF::getOther(RhsSym) << 2) & ELF::STO_PPC64_LOCAL_MASK;
MCELF::setOther(*Symbol, Other >> 2);
}
};

View File

@ -184,8 +184,7 @@ static void fixELFSymbolsInTLSFixupsImpl(const MCExpr *Expr, MCAssembler &Asm) {
case MCExpr::SymbolRef: {
const MCSymbolRefExpr &SymRef = *cast<MCSymbolRefExpr>(Expr);
MCSymbolData &SD = Asm.getOrCreateSymbolData(SymRef.getSymbol());
MCELF::SetType(SD, ELF::STT_TLS);
MCELF::SetType(SymRef.getSymbol(), ELF::STT_TLS);
break;
}