[llvm-commits] [llvm] r111252 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp
Benjamin Kramer
benny.kra at googlemail.com
Tue Aug 17 10:30:07 PDT 2010
Author: d0k
Date: Tue Aug 17 12:30:07 2010
New Revision: 111252
URL: http://llvm.org/viewvc/llvm-project?rev=111252&view=rev
Log:
Differentiate between RELA and REL relocations, from Roman Divacky.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=111252&r1=111251&r2=111252&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Tue Aug 17 12:30:07 2010
@@ -459,7 +459,7 @@
static_cast<const MCSectionELF&>(it->getSection());
// Leave out relocations so we don't have indexes within
// the relocations messed up
- if (Section.getType() == ELF::SHT_RELA)
+ if (Section.getType() == ELF::SHT_RELA || Section.getType() == ELF::SHT_REL)
continue;
if (Index == Asm.size())
continue;
@@ -747,12 +747,13 @@
static_cast<const MCSectionELF&>(SD.getSection());
const StringRef SectionName = Section.getSectionName();
- std::string RelaSectionName = ".rela";
+ std::string RelaSectionName = HasRelocationAddend ? ".rela" : ".rel";
RelaSectionName += SectionName;
unsigned EntrySize = Is64Bit ? ELF::SYMENTRY_SIZE64 : ELF::SYMENTRY_SIZE32;
- RelaSection = Ctx.getELFSection(RelaSectionName, ELF::SHT_RELA, 0,
+ RelaSection = Ctx.getELFSection(RelaSectionName, HasRelocationAddend ?
+ ELF::SHT_RELA : ELF::SHT_REL, 0,
SectionKind::getReadOnly(),
false, EntrySize);
@@ -945,7 +946,6 @@
case ELF::SHT_RELA: {
const MCSection *SymtabSection;
const MCSection *InfoSection;
- StringRef SectionName;
const MCSectionData *SymtabSD;
const MCSectionData *InfoSD;
@@ -956,8 +956,10 @@
// we have to count the empty section in too
sh_link = SymtabSD->getLayoutOrder() + 1;
- SectionName = Section.getSectionName();
- SectionName = SectionName.slice(5, SectionName.size());
+ // Remove ".rel" and ".rela" prefixes.
+ unsigned SecNameLen = (Section.getType() == ELF::SHT_REL) ? 4 : 5;
+ StringRef SectionName = Section.getSectionName().substr(SecNameLen);
+
InfoSection = Asm.getContext().getELFSection(SectionName,
ELF::SHT_PROGBITS, 0,
SectionKind::getReadOnly(),
More information about the llvm-commits
mailing list