summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2010-08-16 21:17:09 +0000
committerEli Friedman <eli.friedman@gmail.com>2010-08-16 21:17:09 +0000
commit1fe0d53aeca045d06bb4d86417eca7eeb34c74dc (patch)
tree940f6e3cea02e9764af8c6e749901a1569e99614 /llvm/lib/MC/ELFObjectWriter.cpp
parent51ec74550923ea27e43700df5110c002f48172da (diff)
downloadbcm5719-llvm-1fe0d53aeca045d06bb4d86417eca7eeb34c74dc.tar.gz
bcm5719-llvm-1fe0d53aeca045d06bb4d86417eca7eeb34c74dc.zip
Fixes for generation of ELF relocations. Patch by Roman Divacky.
llvm-svn: 111183
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index e692747de94..5f7ef1217d7 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -451,9 +451,23 @@ void ELFObjectWriterImpl::WriteSymbolTable(MCDataFragment *F,
}
// Write out a symbol table entry for each section.
- for (unsigned Index = 1; Index < Asm.size(); ++Index)
+ // leaving out the just added .symtab which is at
+ // the very end
+ unsigned Index = 1;
+ for (MCAssembler::const_iterator it = Asm.begin(),
+ ie = Asm.end(); it != ie; ++it, ++Index) {
+ const MCSectionData &SD = *it;
+ const MCSectionELF &Section =
+ static_cast<const MCSectionELF&>(SD.getSection());
+ // Leave out relocations so we don't have indexes within
+ // the relocations messed up
+ if (Section.getType() == ELF::SHT_RELA)
+ continue;
+ if (Index == Asm.size())
+ continue;
WriteSymbolEntry(F, 0, ELF::STT_SECTION, 0, 0, ELF::STV_DEFAULT, Index);
- LastLocalSymbolIndex += Asm.size() - 1;
+ LastLocalSymbolIndex++;
+ }
for (unsigned i = 0, e = ExternalSymbolData.size(); i != e; ++i) {
ELFSymbolData &MSD = ExternalSymbolData[i];
@@ -620,12 +634,10 @@ uint64_t ELFObjectWriterImpl::getSymbolIndexInSymbolTable(MCAssembler &Asm,
return i + /* empty symbol */ 1;
for (unsigned i = 0, e = External.size(); i != e; ++i)
if (&External[i].SymbolData->getSymbol() == S)
- return i + Local.size() + Asm.size() + /* empty symbol */ 1 +
- /* .rela.text + .rela.eh_frame */ + 2;
+ return i + Local.size() + Asm.size() + /* empty symbol */ 1;
for (unsigned i = 0, e = Undefined.size(); i != e; ++i)
if (&Undefined[i].SymbolData->getSymbol() == S)
- return i + Local.size() + External.size() + Asm.size() + /* empty symbol */ 1 +
- /* .rela.text + .rela.eh_frame */ + 2;
+ return i + Local.size() + External.size() + Asm.size() + /* empty symbol */ 1;
llvm_unreachable("Cannot find symbol which should exist!");
}
OpenPOWER on IntegriCloud