diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-08-25 20:09:43 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-08-25 20:09:43 +0000 |
commit | 7b83c26051b0474fb5f8b73ba6e74bd4f40324ba (patch) | |
tree | 7c8d49e70aff05de9dbe40315d8f238c6a3f1685 | |
parent | 2177a04e24b8ed8a922c5cd7ad27463de85a47d2 (diff) |
MCELF: Use precomputed symbol indices, patch by Roman Divacky.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@112079 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index 8fb6ff60f8..79bb52871d 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -567,18 +567,14 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm, uint64_t ELFObjectWriterImpl::getSymbolIndexInSymbolTable(const MCAssembler &Asm, const MCSymbol *S) { - for (unsigned i = 0, e = LocalSymbolData.size(); i != e; ++i) - if (&LocalSymbolData[i].SymbolData->getSymbol() == S) - return i + /* empty symbol */ 1; - for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i) - if (&ExternalSymbolData[i].SymbolData->getSymbol() == S) - return i + LocalSymbolData.size() + Asm.size() + /* empty symbol */ 1; - for (unsigned i = 0, e = UndefinedSymbolData.size(); i != e; ++i) - if (&UndefinedSymbolData[i].SymbolData->getSymbol() == S) - return i + LocalSymbolData.size() + ExternalSymbolData.size() + - Asm.size() + /* empty symbol */ 1; + MCSymbolData &SD = Asm.getSymbolData(*S); + + // Local symbol. + if (!SD.isExternal() && !S->isUndefined()) + return SD.getIndex() + /* empty symbol */ 1; - llvm_unreachable("Cannot find symbol which should exist!"); + // External or undefined symbol. + return SD.getIndex() + Asm.size() + /* empty symbol */ 1; } void ELFObjectWriterImpl::ComputeSymbolTable(MCAssembler &Asm) { |