mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-01-14 00:32:55 +00:00
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@234400 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
a7512d1d4a
commit
541279fdf9
@ -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(
|
||||
|
@ -42,7 +42,7 @@ barf: @ @barf
|
||||
@ OBJ-NEXT: Flags [ (0x0)
|
||||
@ OBJ-NEXT: ]
|
||||
@ OBJ-NEXT: Address: 0x0
|
||||
@ OBJ-NEXT: Offset: 0x22C
|
||||
@ OBJ-NEXT: Offset:
|
||||
@ OBJ-NEXT: Size: 16
|
||||
@ OBJ-NEXT: Link: 6
|
||||
@ OBJ-NEXT: Info: 1
|
||||
|
@ -53,7 +53,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x3C8
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 72
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -38,7 +38,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x490
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -40,7 +40,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x398
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -35,7 +35,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -35,7 +35,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -36,7 +36,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -35,7 +35,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -36,7 +36,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -44,7 +44,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x3A0
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -35,7 +35,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -38,7 +38,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -36,7 +36,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -36,7 +36,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -36,7 +36,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -38,7 +38,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x390
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -43,7 +43,7 @@ f:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x398
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -355,7 +355,7 @@ f37:
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0xE70
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 1752
|
||||
// CHECK-NEXT: Link: 7
|
||||
// CHECK-NEXT: Info: 4
|
||||
|
@ -19,7 +19,7 @@
|
||||
// CHECK-NEXT: Flags [
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x2E8
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 48
|
||||
// CHECK-NEXT: Link: 6
|
||||
// CHECK-NEXT: Info: 1
|
||||
|
@ -41,7 +41,7 @@ defined3:
|
||||
// CHECK-NEXT: Flags [ (0x0)
|
||||
// CHECK-NEXT: ]
|
||||
// CHECK-NEXT: Address: 0x0
|
||||
// CHECK-NEXT: Offset: 0x320
|
||||
// CHECK-NEXT: Offset:
|
||||
// CHECK-NEXT: Size: 24
|
||||
// CHECK-NEXT: Link: 6
|
||||
// CHECK-NEXT: Info: 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user