summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/ELFObjectWriter.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-04-08 11:41:24 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-04-08 11:41:24 +0000
commit7230f80e3bf6523abf826c1d034f5a82b0f12513 (patch)
tree1d1b4129048a281eaeb2b2279fc1554ed1285b8d /llvm/lib/MC/ELFObjectWriter.cpp
parent3cc62b371502c973309f72268063e94bc627082d (diff)
downloadbcm5719-llvm-7230f80e3bf6523abf826c1d034f5a82b0f12513.tar.gz
bcm5719-llvm-7230f80e3bf6523abf826c1d034f5a82b0f12513.zip
Write the section header in the end.
One could make the argument for writing it immediately after the ELF header, but writing it in the middle of the sections like we were doing just makes it harder for no reason. llvm-svn: 234400
Diffstat (limited to 'llvm/lib/MC/ELFObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/ELFObjectWriter.cpp31
1 files changed, 4 insertions, 27 deletions
diff --git a/llvm/lib/MC/ELFObjectWriter.cpp b/llvm/lib/MC/ELFObjectWriter.cpp
index b3ae4a545f1..f6b20900911 100644
--- a/llvm/lib/MC/ELFObjectWriter.cpp
+++ b/llvm/lib/MC/ELFObjectWriter.cpp
@@ -1676,8 +1676,6 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
createIndexedSections(Asm, const_cast<MCAsmLayout &>(Layout), GroupMap,
RevGroupMap, SectionIndexMap);
- unsigned NumRegularSections = Asm.size();
-
// Compute symbol table information.
computeSymbolTable(Asm, Layout, SectionIndexMap, RevGroupMap);
@@ -1696,7 +1694,8 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
ComputeSectionOrder(Asm, Sections);
unsigned NumSections = Sections.size();
SectionOffsetMapTy SectionOffsetMap;
- for (unsigned i = 0; i < NumRegularSections + 1; ++i) {
+ for (unsigned i = 0; i < NumSections; ++i) {
+
const MCSectionELF &Section = *Sections[i];
const MCSectionData &SD = Asm.getOrCreateSectionData(Section);
@@ -1713,29 +1712,11 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
const unsigned SectionHeaderOffset = FileOff;
- uint64_t SectionHeaderEntrySize = is64Bit() ?
- sizeof(ELF::Elf64_Shdr) : sizeof(ELF::Elf32_Shdr);
- FileOff += (NumSections + 1) * SectionHeaderEntrySize;
-
- for (unsigned i = NumRegularSections + 1; i < NumSections; ++i) {
- const MCSectionELF &Section = *Sections[i];
- const MCSectionData &SD = Asm.getOrCreateSectionData(Section);
-
- FileOff = RoundUpToAlignment(FileOff, SD.getAlignment());
-
- // Remember the offset into the file for this section.
- SectionOffsetMap[&Section] = FileOff;
-
- // Get the size of the section in the output file (including padding).
- FileOff += GetSectionFileSize(Layout, SD);
- }
-
// Write out the ELF header ...
WriteHeader(Asm, SectionHeaderOffset, NumSections + 1);
- // ... then the regular sections ...
- // + because of .shstrtab
- for (unsigned i = 0; i < NumRegularSections + 1; ++i)
+ // ... then the sections ...
+ for (unsigned i = 0; i < NumSections; ++i)
WriteDataSectionData(Asm, Layout, *Sections[i]);
uint64_t Padding = OffsetToAlignment(OS.tell(), NaturalAlignment);
@@ -1743,10 +1724,6 @@ void ELFObjectWriter::WriteObject(MCAssembler &Asm,
// ... then the section header table ...
writeSectionHeader(Asm, GroupMap, Layout, SectionIndexMap, SectionOffsetMap);
-
- // ... and then the remaining sections ...
- for (unsigned i = NumRegularSections + 1; i < NumSections; ++i)
- WriteDataSectionData(Asm, Layout, *Sections[i]);
}
bool ELFObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
OpenPOWER on IntegriCloud