summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2010-08-17 17:30:07 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2010-08-17 17:30:07 +0000
commit377a572d9b92304a0fde4371d726721586c1a5bd (patch)
treee0a7259a6709a258aec25be8354da46a28a14abb /lib
parentf955f290c949ff0df7d23cec055efcc4ffeb35d1 (diff)
downloadllvm-377a572d9b92304a0fde4371d726721586c1a5bd.tar.gz
llvm-377a572d9b92304a0fde4371d726721586c1a5bd.tar.bz2
llvm-377a572d9b92304a0fde4371d726721586c1a5bd.tar.xz
Differentiate between RELA and REL relocations, from Roman Divacky.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111252 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/MC/ELFObjectWriter.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp
index 610f685606..9b399eb29e 100644
--- a/lib/MC/ELFObjectWriter.cpp
+++ b/lib/MC/ELFObjectWriter.cpp
@@ -459,7 +459,7 @@ void ELFObjectWriterImpl::WriteSymbolTable(MCDataFragment *F,
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 @@ void ELFObjectWriterImpl::WriteRelocation(MCAssembler &Asm, MCAsmLayout &Layout,
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 @@ void ELFObjectWriterImpl::WriteObject(const MCAssembler &Asm,
case ELF::SHT_RELA: {
const MCSection *SymtabSection;
const MCSection *InfoSection;
- StringRef SectionName;
const MCSectionData *SymtabSD;
const MCSectionData *InfoSD;
@@ -956,8 +956,10 @@ void ELFObjectWriterImpl::WriteObject(const MCAssembler &Asm,
// 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(),