diff options
author | Benjamin Kramer <benny.kra@googlemail.com> | 2010-08-19 13:44:49 +0000 |
---|---|---|
committer | Benjamin Kramer <benny.kra@googlemail.com> | 2010-08-19 13:44:49 +0000 |
commit | 44cbde85badb60c7078e37e14575c15e671521b1 (patch) | |
tree | 9c9f0dfcf3caf0973fc296726788721fe5a0f8f4 /lib/MC/ELFObjectWriter.cpp | |
parent | 6e97e1d4be5caefe54133f14168c250be5010413 (diff) |
MCELF: Count the section orders properly. Patch by Roman Divacky.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@111517 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/ELFObjectWriter.cpp')
-rw-r--r-- | lib/MC/ELFObjectWriter.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/MC/ELFObjectWriter.cpp b/lib/MC/ELFObjectWriter.cpp index b7e19f1661..f4b68c4e48 100644 --- a/lib/MC/ELFObjectWriter.cpp +++ b/lib/MC/ELFObjectWriter.cpp @@ -932,11 +932,16 @@ void ELFObjectWriterImpl::WriteObject(const MCAssembler &Asm, // ... then all of the sections ... DenseMap<const MCSection*, uint64_t> SectionOffsetMap; + DenseMap<const MCSection*, uint8_t> SectionIndexMap; + + unsigned Index = 1; for (MCAssembler::const_iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it) { // Remember the offset into the file for this section. SectionOffsetMap[&it->getSection()] = FileOff; + SectionIndexMap[&it->getSection()] = Index++; + const MCSectionData &SD = *it; FileOff += Layout.getSectionFileSize(&SD); @@ -968,15 +973,11 @@ void ELFObjectWriterImpl::WriteObject(const MCAssembler &Asm, case ELF::SHT_RELA: { const MCSection *SymtabSection; const MCSection *InfoSection; - const MCSectionData *SymtabSD; - const MCSectionData *InfoSD; SymtabSection = Asm.getContext().getELFSection(".symtab", ELF::SHT_SYMTAB, 0, SectionKind::getReadOnly(), false); - SymtabSD = &Asm.getSectionData(*SymtabSection); - // we have to count the empty section in too - sh_link = SymtabSD->getLayoutOrder() + 1; + sh_link = SectionIndexMap[SymtabSection]; // Remove ".rel" and ".rela" prefixes. unsigned SecNameLen = (Section.getType() == ELF::SHT_REL) ? 4 : 5; @@ -986,8 +987,7 @@ void ELFObjectWriterImpl::WriteObject(const MCAssembler &Asm, ELF::SHT_PROGBITS, 0, SectionKind::getReadOnly(), false); - InfoSD = &Asm.getSectionData(*InfoSection); - sh_info = InfoSD->getLayoutOrder() + 1; + sh_info = SectionIndexMap[InfoSection]; break; } |