[llvm-commits] [llvm] r111517 - /llvm/trunk/lib/MC/ELFObjectWriter.cpp
Benjamin Kramer
benny.kra at googlemail.com
Thu Aug 19 06:44:49 PDT 2010
Author: d0k
Date: Thu Aug 19 08:44:49 2010
New Revision: 111517
URL: http://llvm.org/viewvc/llvm-project?rev=111517&view=rev
Log:
MCELF: Count the section orders properly. Patch by 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=111517&r1=111516&r2=111517&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Thu Aug 19 08:44:49 2010
@@ -932,11 +932,16 @@
// ... 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 @@
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 @@
ELF::SHT_PROGBITS, 0,
SectionKind::getReadOnly(),
false);
- InfoSD = &Asm.getSectionData(*InfoSection);
- sh_info = InfoSD->getLayoutOrder() + 1;
+ sh_info = SectionIndexMap[InfoSection];
break;
}
More information about the llvm-commits
mailing list