Use the proper relocation section + cleanup, from Roman Divacky.
authorBenjamin Kramer <benny.kra@googlemail.com>
Mon, 23 Aug 2010 18:24:20 +0000 (18:24 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Mon, 23 Aug 2010 18:24:20 +0000 (18:24 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111819 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/ELFObjectWriter.cpp

index f4b68c4e481778722672d6bea4dcb322c7528c8c..573453fc86fcccb464a1daa7eab2f742deac73e5 100644 (file)
@@ -511,7 +511,10 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
     const MCSymbolData *Base = Asm.getAtom(Layout, &SD);
 
     if (Base) {
-      Index = getSymbolIndexInSymbolTable(const_cast<MCAssembler &>(Asm), &Base->getSymbol());
+      if (MCFragment *F = SD.getFragment())
+        Index = F->getParent()->getOrdinal() + getNumOfLocalSymbols(Asm) + 1;
+      else
+        Index = getSymbolIndexInSymbolTable(const_cast<MCAssembler &>(Asm), Symbol);
       if (Base != &SD)
         Value += Layout.getSymbolAddress(&SD) - Layout.getSymbolAddress(Base);
       Addend = Value;
@@ -521,8 +524,7 @@ void ELFObjectWriterImpl::RecordRelocation(const MCAssembler &Asm,
       if (F) {
         // Index of the section in .symtab against this symbol
         // is being relocated + 2 (empty section + abs. symbols).
-        Index = SD.getFragment()->getParent()->getOrdinal() +
-          getNumOfLocalSymbols(Asm) + 1;
+        Index = F->getParent()->getOrdinal() + getNumOfLocalSymbols(Asm) + 1;
 
         MCSectionData *FSD = F->getParent();
         // Offset of the symbol in the section