Use the correct entry size for relocation entries, from Roman Divacky.
authorBenjamin Kramer <benny.kra@googlemail.com>
Tue, 17 Aug 2010 17:56:13 +0000 (17:56 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Tue, 17 Aug 2010 17:56:13 +0000 (17:56 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111259 91177308-0d34-0410-b5e6-96231b3b80d8

lib/MC/ELFObjectWriter.cpp

index 9b399eb29eb503ed8b7e82ce33d6bab008b73a73..23c2dd5c20703c93140b37a3a561c7a7b5ee4a18 100644 (file)
@@ -748,9 +748,13 @@ void ELFObjectWriterImpl::WriteRelocation(MCAssembler &Asm, MCAsmLayout &Layout,
 
     const StringRef SectionName = Section.getSectionName();
     std::string RelaSectionName = HasRelocationAddend ? ".rela" : ".rel";
-
     RelaSectionName += SectionName;
-    unsigned EntrySize = Is64Bit ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32; 
+
+    unsigned EntrySize;
+    if (HasRelocationAddend)
+      EntrySize = Is64Bit ? sizeof(ELF::Elf64_Rela) : sizeof(ELF::Elf32_Rela);
+    else
+      EntrySize = Is64Bit ? sizeof(ELF::Elf64_Rel) : sizeof(ELF::Elf32_Rel);
 
     RelaSection = Ctx.getELFSection(RelaSectionName, HasRelocationAddend ?
                                     ELF::SHT_RELA : ELF::SHT_REL, 0,