- // Add the data for local symbols.
- for (MCAssembler::symbol_iterator it = Asm.symbol_begin(),
- ie = Asm.symbol_end(); it != ie; ++it) {
- const MCSymbol &Symbol = it->getSymbol();
-
- if (!isInSymtab(Asm, *it, UsedInReloc.count(&Symbol)))
- continue;
-
- if (!isLocal(*it))
- continue;
-
- uint64_t &Entry = StringIndexMap[Symbol.getName()];
- if (!Entry) {
- Entry = StringTable.size();
- StringTable += Symbol.getName();
- StringTable += '\x00';
- }
-
- ELFSymbolData MSD;
- MSD.SymbolData = it;
- MSD.StringIndex = Entry;
-
- if (Symbol.isAbsolute()) {
- MSD.SectionIndex = ELF::SHN_ABS;
- LocalSymbolData.push_back(MSD);
- } else {
- const MCSymbol *SymbolP = &Symbol;
- if (Symbol.isVariable()) {
- const MCExpr *Value = Symbol.getVariableValue();
- assert (Value->getKind() == MCExpr::SymbolRef && "Unimplemented");
- const MCSymbolRefExpr *Ref = static_cast<const MCSymbolRefExpr*>(Value);
- SymbolP = &Ref->getSymbol();
- }
- MSD.SectionIndex = SectionIndexMap.lookup(&SymbolP->getSection());
- assert(MSD.SectionIndex && "Invalid section index!");
- LocalSymbolData.push_back(MSD);
- }
- }
-
- // Now add non-local symbols.