unsigned getAlignment() const { return Alignment; }
void setAlignment(unsigned Value) { Alignment = Value; }
- /// @name Section List Access
+ /// @name Fragment Access
/// @{
const FragmentListType &getFragmentList() const { return Fragments; }
assert(FileSize != ~UINT64_C(0) && "File size not set!");
return FileSize;
}
- void setFileSize(uint64_t Value) { FileSize = Value; }
+ void setFileSize(uint64_t Value) { FileSize = Value; }
/// @}
};
/// additional per symbol information which is not easily classified.
uint32_t Flags;
+ /// Index - Index field, for use by the object file implementation.
+ uint64_t Index;
+
public:
// Only for use as sentinel.
MCSymbolData();
/// setFlags - Set the (implementation defined) symbol flags.
void setFlags(uint32_t Value) { Flags = 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 BindIndirectSymbols(MCAssembler &Asm,
- DenseMap<MCSymbol*, MCSymbolData*> &SymbolMap) {
+ DenseMap<const MCSymbol*,MCSymbolData*> &SymbolMap) {
// This is the point where 'as' creates actual symbols for indirect symbols
// (in the following two passes). It would be easier for us to do this
// sooner when we see the attribute, but that makes getting the order in the
std::sort(ExternalSymbolData.begin(), ExternalSymbolData.end());
std::sort(UndefinedSymbolData.begin(), UndefinedSymbolData.end());
+ // Set the symbol indices.
+ Index = 0;
+ for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i)
+ LocalSymbolData[i].SymbolData->setIndex(Index++);
+ for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i)
+ ExternalSymbolData[i].SymbolData->setIndex(Index++);
+ for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i)
+ UndefinedSymbolData[i].SymbolData->setIndex(Index++);
+
// The string table is padded to a multiple of 4.
//
// FIXME: Check to see if this varies per arch.
// Compute the symbol -> symbol data map.
//
// FIXME: This should not be here.
- DenseMap<MCSymbol*, MCSymbolData *> SymbolMap;
+ DenseMap<const MCSymbol*, MCSymbolData *> SymbolMap;
for (MCAssembler::symbol_iterator it = Asm.symbol_begin(),
ie = Asm.symbol_end(); it != ie; ++it)
SymbolMap[&it->getSymbol()] = it;
// Write the symbol table data, if used.
if (NumSymbols) {
- // FIXME: We shouldn't need this index table.
- DenseMap<MCSymbol*, unsigned> SymbolIndexMap;
- for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i) {
- MCSymbol &Symbol = LocalSymbolData[i].SymbolData->getSymbol();
- SymbolIndexMap.insert(std::make_pair(&Symbol, SymbolIndexMap.size()));
- }
- for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i) {
- MCSymbol &Symbol = ExternalSymbolData[i].SymbolData->getSymbol();
- SymbolIndexMap.insert(std::make_pair(&Symbol, SymbolIndexMap.size()));
- }
- for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i) {
- MCSymbol &Symbol = UndefinedSymbolData[i].SymbolData->getSymbol();
- SymbolIndexMap.insert(std::make_pair(&Symbol, SymbolIndexMap.size()));
- }
-
// Write the indirect symbol entries.
- //
- // FIXME: We need the symbol index map for this.
for (MCAssembler::indirect_symbol_iterator
it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it) {
}
}
- Write32(SymbolIndexMap[it->Symbol]);
+ Write32(SymbolMap[it->Symbol]->getIndex());
}
// FIXME: Check that offsets match computed ones.
MCSymbolData::MCSymbolData(MCSymbol &_Symbol, MCFragment *_Fragment,
uint64_t _Offset, MCAssembler *A)
: Symbol(_Symbol), Fragment(_Fragment), Offset(_Offset),
- IsExternal(false), IsPrivateExtern(false), Flags(0)
+ IsExternal(false), IsPrivateExtern(false), Flags(0), Index(0)
{
if (A)
A->getSymbolList().push_back(this);