[llvm] r238979 - Record in a MCSymbolELF if it has been used in a relocation.
Rafael Espindola
rafael.espindola at gmail.com
Wed Jun 3 14:30:10 PDT 2015
Author: rafael
Date: Wed Jun 3 16:30:10 2015
New Revision: 238979
URL: http://llvm.org/viewvc/llvm-project?rev=238979&view=rev
Log:
Record in a MCSymbolELF if it has been used in a relocation.
No functionality change, just saves an on the side map.
Modified:
llvm/trunk/include/llvm/MC/MCSymbolELF.h
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/lib/MC/MCSymbolELF.cpp
Modified: llvm/trunk/include/llvm/MC/MCSymbolELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCSymbolELF.h?rev=238979&r1=238978&r2=238979&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCSymbolELF.h (original)
+++ llvm/trunk/include/llvm/MC/MCSymbolELF.h Wed Jun 3 16:30:10 2015
@@ -18,6 +18,7 @@ class MCSymbolELF : public MCSymbol {
const MCExpr *SymbolSize = nullptr;
mutable unsigned BindingSet : 1;
+ mutable unsigned UsedInReloc : 1;
public:
MCSymbolELF(const StringMapEntry<bool> *Name, bool isTemporary)
@@ -40,6 +41,9 @@ public:
bool isBindingSet() const { return BindingSet; }
+ void setUsedInReloc() const;
+ bool isUsedInReloc() const;
+
static bool classof(const MCSymbol *S) { return S->isELF(); }
};
}
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=238979&r1=238978&r2=238979&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed Jun 3 16:30:10 2015
@@ -74,8 +74,7 @@ class ELFObjectWriter : public MCObjectW
static uint64_t SymbolValue(const MCSymbol &Sym, const MCAsmLayout &Layout);
static bool isInSymtab(const MCAsmLayout &Layout, const MCSymbolELF &Symbol,
bool Used, bool Renamed);
- static bool isLocal(const MCSymbol &Symbol, bool IsUsedInReloc,
- bool IsSignature);
+ static bool isLocal(const MCSymbolELF &Symbol, bool IsSignature);
/// Helper struct for containing some precomputed information on symbols.
struct ELFSymbolData {
@@ -100,7 +99,6 @@ class ELFObjectWriter : public MCObjectW
/// The target specific ELF writer instance.
std::unique_ptr<MCELFObjectTargetWriter> TargetObjectWriter;
- SmallPtrSet<const MCSymbol *, 16> UsedInReloc;
SmallPtrSet<const MCSymbol *, 16> WeakrefUsedInReloc;
DenseMap<const MCSymbolELF *, const MCSymbolELF *> Renames;
@@ -144,7 +142,6 @@ class ELFObjectWriter : public MCObjectW
: MCObjectWriter(OS, IsLittleEndian), TargetObjectWriter(MOTW) {}
void reset() override {
- UsedInReloc.clear();
WeakrefUsedInReloc.clear();
Renames.clear();
Relocations.clear();
@@ -716,7 +713,7 @@ void ELFObjectWriter::RecordRelocation(M
if (const MCSymbol *WeakRef = getWeakRef(*RefA))
WeakrefUsedInReloc.insert(WeakRef);
else
- UsedInReloc.insert(SymA);
+ SymA->setUsedInReloc();
}
ELFRelocationEntry Rec(FixupOffset, SymA, Type, Addend);
Relocations[&FixupSection].push_back(Rec);
@@ -758,15 +755,14 @@ bool ELFObjectWriter::isInSymtab(const M
return true;
}
-bool ELFObjectWriter::isLocal(const MCSymbol &Symbol, bool IsUsedInReloc,
- bool IsSignature) {
+bool ELFObjectWriter::isLocal(const MCSymbolELF &Symbol, bool IsSignature) {
if (Symbol.isExternal())
return false;
if (Symbol.isDefined())
return true;
- if (IsUsedInReloc)
+ if (Symbol.isUsedInReloc())
return false;
return IsSignature;
@@ -802,7 +798,7 @@ void ELFObjectWriter::computeSymbolTable
bool HasLargeSectionIndex = false;
for (const MCSymbol &S : Asm.symbols()) {
const auto &Symbol = cast<MCSymbolELF>(S);
- bool Used = UsedInReloc.count(&Symbol);
+ bool Used = Symbol.isUsedInReloc();
bool WeakrefUsed = WeakrefUsedInReloc.count(&Symbol);
bool isSignature = RevGroupMap.count(&Symbol);
@@ -815,7 +811,7 @@ 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);
+ bool Local = isLocal(Symbol, isSignature);
if (!Local && Symbol.getBinding() == ELF::STB_LOCAL)
Symbol.setBinding(ELF::STB_GLOBAL);
Modified: llvm/trunk/lib/MC/MCSymbolELF.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCSymbolELF.cpp?rev=238979&r1=238978&r2=238979&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCSymbolELF.cpp (original)
+++ llvm/trunk/lib/MC/MCSymbolELF.cpp Wed Jun 3 16:30:10 2015
@@ -77,4 +77,13 @@ unsigned MCSymbolELF::getOther() const {
unsigned Other = (getFlags() & (0x3f << ELF_STO_Shift)) >> ELF_STO_Shift;
return Other;
}
+
+void MCSymbolELF::setUsedInReloc() const {
+ UsedInReloc = true;
+}
+
+bool MCSymbolELF::isUsedInReloc() const {
+ return UsedInReloc;
+}
+
}
More information about the llvm-commits
mailing list