/// additional per symbol information which is not easily classified.
uint32_t Flags = 0;
- /// Index - Index field, for use by the object file implementation.
- uint64_t Index = 0;
-
public:
MCSymbolData() { Offset = 0; }
Flags = (Flags & ~Mask) | Value;
}
- /// getIndex - Get the (implementation defined) index.
- uint64_t getIndex() const { return Index; }
-
- /// setIndex - Set the (implementation defined) index.
- void setIndex(uint64_t Value) { Index = Value; }
-
/// @}
void dump() const;
mutable bool HasData : 1;
mutable MCSymbolData Data;
+ /// Index field, for use by the object file implementation.
+ mutable uint64_t Index = 0;
+
private: // MCContext creates and uniques these.
friend class MCExpr;
friend class MCContext;
/// @}
+ /// Get the (implementation defined) index.
+ uint64_t getIndex() const {
+ assert(HasData && "Uninitialized symbol data");
+ return Index;
+ }
+
+ /// Set the (implementation defined) index.
+ void setIndex(uint64_t Value) const {
+ assert(HasData && "Uninitialized symbol data");
+ Index = Value;
+ }
+
/// print - Print the value to the stream \p OS.
void print(raw_ostream &OS) const;
uint64_t
ELFObjectWriter::getSymbolIndexInSymbolTable(const MCAssembler &Asm,
const MCSymbol *S) {
- const MCSymbolData &SD = Asm.getSymbolData(*S);
- return SD.getIndex();
+ assert(S->hasData());
+ return S->getIndex();
}
bool ELFObjectWriter::isInSymtab(const MCAsmLayout &Layout,
// symbols with non-local bindings.
unsigned Index = FileSymbolData.size() + 1;
for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
- LocalSymbolData[i].Symbol->getData().setIndex(Index++);
+ LocalSymbolData[i].Symbol->setIndex(Index++);
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
- ExternalSymbolData[i].Symbol->getData().setIndex(Index++);
+ ExternalSymbolData[i].Symbol->setIndex(Index++);
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
- UndefinedSymbolData[i].Symbol->getData().setIndex(Index++);
+ UndefinedSymbolData[i].Symbol->setIndex(Index++);
}
MCSectionELF *
<< " Fragment:" << getFragment();
if (!isCommon())
OS << " Offset:" << getOffset();
- OS << " Flags:" << getFlags() << " Index:" << getIndex();
+ OS << " Flags:" << getFlags();
if (isCommon())
OS << " (common, size:" << getCommonSize()
<< " align: " << getCommonAlignment() << ")";
if (it != symbol_begin()) OS << ",\n ";
OS << "(";
it->dump();
- OS << ",";
+ OS << ", Index:" << it->getIndex() << ", ";
it->getData().dump();
OS << ")";
}
// Set the symbol indices.
Index = 0;
for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
- LocalSymbolData[i].Symbol->getData().setIndex(Index++);
+ LocalSymbolData[i].Symbol->setIndex(Index++);
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
- ExternalSymbolData[i].Symbol->getData().setIndex(Index++);
+ ExternalSymbolData[i].Symbol->setIndex(Index++);
for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
- UndefinedSymbolData[i].Symbol->getData().setIndex(Index++);
+ UndefinedSymbolData[i].Symbol->setIndex(Index++);
for (const MCSectionData &SD : Asm) {
std::vector<RelAndSymbol> &Relocs = Relocations[&SD];
continue;
// Set the Index and the IsExtern bit.
- unsigned Index = Rel.Sym->getData().getIndex();
+ unsigned Index = Rel.Sym->getIndex();
assert(isInt<24>(Index));
if (IsLittleEndian)
Rel.MRE.r_word1 = (Rel.MRE.r_word1 & (~0U << 24)) | Index | (1 << 27);
}
}
- Write32(Asm.getSymbolData(*it->Symbol).getIndex());
+ Write32(it->Symbol->getIndex());
}
// FIXME: Check that offsets match computed ones.