mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-10-29 08:16:51 +00:00
Store whether a symbol is a comdat signature in MCSymbolELF.
With this getBinging can now return the correct answer for all cases not involving a .symver and the elf writer doesn't need to patch it last minute. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@238980 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -58,7 +58,10 @@ private:
|
|||||||
MCSymbol *Begin, const MCSectionELF *Associated)
|
MCSymbol *Begin, const MCSectionELF *Associated)
|
||||||
: MCSection(SV_ELF, K, Begin), SectionName(Section), Type(type),
|
: MCSection(SV_ELF, K, Begin), SectionName(Section), Type(type),
|
||||||
Flags(flags), UniqueID(UniqueID), EntrySize(entrySize), Group(group),
|
Flags(flags), UniqueID(UniqueID), EntrySize(entrySize), Group(group),
|
||||||
Associated(Associated) {}
|
Associated(Associated) {
|
||||||
|
if (Group)
|
||||||
|
Group->setIsSignature();
|
||||||
|
}
|
||||||
~MCSectionELF() override;
|
~MCSectionELF() override;
|
||||||
|
|
||||||
void setSectionName(StringRef Name) { SectionName = Name; }
|
void setSectionName(StringRef Name) { SectionName = Name; }
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ class MCSymbolELF : public MCSymbol {
|
|||||||
|
|
||||||
mutable unsigned BindingSet : 1;
|
mutable unsigned BindingSet : 1;
|
||||||
mutable unsigned UsedInReloc : 1;
|
mutable unsigned UsedInReloc : 1;
|
||||||
|
mutable unsigned IsSignature : 1;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
MCSymbolELF(const StringMapEntry<bool> *Name, bool isTemporary)
|
MCSymbolELF(const StringMapEntry<bool> *Name, bool isTemporary)
|
||||||
@@ -44,6 +45,9 @@ public:
|
|||||||
void setUsedInReloc() const;
|
void setUsedInReloc() const;
|
||||||
bool isUsedInReloc() const;
|
bool isUsedInReloc() const;
|
||||||
|
|
||||||
|
void setIsSignature() const;
|
||||||
|
bool isSignature() const;
|
||||||
|
|
||||||
static bool classof(const MCSymbol *S) { return S->isELF(); }
|
static bool classof(const MCSymbol *S) { return S->isELF(); }
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -74,7 +74,6 @@ class ELFObjectWriter : public MCObjectWriter {
|
|||||||
static uint64_t SymbolValue(const MCSymbol &Sym, const MCAsmLayout &Layout);
|
static uint64_t SymbolValue(const MCSymbol &Sym, const MCAsmLayout &Layout);
|
||||||
static bool isInSymtab(const MCAsmLayout &Layout, const MCSymbolELF &Symbol,
|
static bool isInSymtab(const MCAsmLayout &Layout, const MCSymbolELF &Symbol,
|
||||||
bool Used, bool Renamed);
|
bool Used, bool Renamed);
|
||||||
static bool isLocal(const MCSymbolELF &Symbol, bool IsSignature);
|
|
||||||
|
|
||||||
/// Helper struct for containing some precomputed information on symbols.
|
/// Helper struct for containing some precomputed information on symbols.
|
||||||
struct ELFSymbolData {
|
struct ELFSymbolData {
|
||||||
@@ -755,19 +754,6 @@ bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ELFObjectWriter::isLocal(const MCSymbolELF &Symbol, bool IsSignature) {
|
|
||||||
if (Symbol.isExternal())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (Symbol.isDefined())
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if (Symbol.isUsedInReloc())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return IsSignature;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ELFObjectWriter::computeSymbolTable(
|
void ELFObjectWriter::computeSymbolTable(
|
||||||
MCAssembler &Asm, const MCAsmLayout &Layout,
|
MCAssembler &Asm, const MCAsmLayout &Layout,
|
||||||
const SectionIndexMapTy &SectionIndexMap, const RevGroupMapTy &RevGroupMap,
|
const SectionIndexMapTy &SectionIndexMap, const RevGroupMapTy &RevGroupMap,
|
||||||
@@ -800,7 +786,7 @@ void ELFObjectWriter::computeSymbolTable(
|
|||||||
const auto &Symbol = cast<MCSymbolELF>(S);
|
const auto &Symbol = cast<MCSymbolELF>(S);
|
||||||
bool Used = Symbol.isUsedInReloc();
|
bool Used = Symbol.isUsedInReloc();
|
||||||
bool WeakrefUsed = WeakrefUsedInReloc.count(&Symbol);
|
bool WeakrefUsed = WeakrefUsedInReloc.count(&Symbol);
|
||||||
bool isSignature = RevGroupMap.count(&Symbol);
|
bool isSignature = Symbol.isSignature();
|
||||||
|
|
||||||
if (!isInSymtab(Layout, Symbol, Used || WeakrefUsed || isSignature,
|
if (!isInSymtab(Layout, Symbol, Used || WeakrefUsed || isSignature,
|
||||||
Renames.count(&Symbol)))
|
Renames.count(&Symbol)))
|
||||||
@@ -809,12 +795,7 @@ void ELFObjectWriter::computeSymbolTable(
|
|||||||
ELFSymbolData MSD;
|
ELFSymbolData MSD;
|
||||||
MSD.Symbol = cast<MCSymbolELF>(&Symbol);
|
MSD.Symbol = cast<MCSymbolELF>(&Symbol);
|
||||||
|
|
||||||
// Undefined symbols are global, but this is the first place we
|
bool Local = Symbol.getBinding() == ELF::STB_LOCAL;
|
||||||
// are able to set it.
|
|
||||||
bool Local = isLocal(Symbol, isSignature);
|
|
||||||
if (!Local && Symbol.getBinding() == ELF::STB_LOCAL)
|
|
||||||
Symbol.setBinding(ELF::STB_GLOBAL);
|
|
||||||
|
|
||||||
if (Symbol.isAbsolute()) {
|
if (Symbol.isAbsolute()) {
|
||||||
MSD.SectionIndex = ELF::SHN_ABS;
|
MSD.SectionIndex = ELF::SHN_ABS;
|
||||||
} else if (Symbol.isCommon()) {
|
} else if (Symbol.isCommon()) {
|
||||||
|
|||||||
@@ -24,10 +24,20 @@ void MCSymbolELF::setBinding(unsigned Binding) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned MCSymbolELF::getBinding() const {
|
unsigned MCSymbolELF::getBinding() const {
|
||||||
uint32_t Binding = (getFlags() & (0xf << ELF_STB_Shift)) >> ELF_STB_Shift;
|
if (isBindingSet()) {
|
||||||
assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL ||
|
uint32_t Binding = (getFlags() & (0xf << ELF_STB_Shift)) >> ELF_STB_Shift;
|
||||||
Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE);
|
assert(Binding == ELF::STB_LOCAL || Binding == ELF::STB_GLOBAL ||
|
||||||
return Binding;
|
Binding == ELF::STB_WEAK || Binding == ELF::STB_GNU_UNIQUE);
|
||||||
|
return Binding;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDefined())
|
||||||
|
return ELF::STB_LOCAL;
|
||||||
|
if (isUsedInReloc())
|
||||||
|
return ELF::STB_GLOBAL;
|
||||||
|
if (isSignature())
|
||||||
|
return ELF::STB_LOCAL;
|
||||||
|
return ELF::STB_GLOBAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MCSymbolELF::setType(unsigned Type) const {
|
void MCSymbolELF::setType(unsigned Type) const {
|
||||||
@@ -86,4 +96,7 @@ bool MCSymbolELF::isUsedInReloc() const {
|
|||||||
return UsedInReloc;
|
return UsedInReloc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MCSymbolELF::setIsSignature() const { IsSignature = true; }
|
||||||
|
|
||||||
|
bool MCSymbolELF::isSignature() const { return IsSignature; }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user