[llvm] r234400 - Write the section header in the end.
Rafael Espindola
rafael.espindola at gmail.com
Wed Apr 8 04:41:25 PDT 2015
Author: rafael
Date: Wed Apr 8 06:41:24 2015
New Revision: 234400
URL: http://llvm.org/viewvc/llvm-project?rev=234400&view=rev
Log:
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.
Modified:
llvm/trunk/lib/MC/ELFObjectWriter.cpp
llvm/trunk/test/MC/ARM/elf-movt.s
llvm/trunk/test/MC/ELF/cfi-adjust-cfa-offset.s
llvm/trunk/test/MC/ELF/cfi-advance-loc2.s
llvm/trunk/test/MC/ELF/cfi-def-cfa-offset.s
llvm/trunk/test/MC/ELF/cfi-def-cfa-register.s
llvm/trunk/test/MC/ELF/cfi-def-cfa.s
llvm/trunk/test/MC/ELF/cfi-escape.s
llvm/trunk/test/MC/ELF/cfi-offset.s
llvm/trunk/test/MC/ELF/cfi-register.s
llvm/trunk/test/MC/ELF/cfi-rel-offset.s
llvm/trunk/test/MC/ELF/cfi-rel-offset2.s
llvm/trunk/test/MC/ELF/cfi-remember.s
llvm/trunk/test/MC/ELF/cfi-restore.s
llvm/trunk/test/MC/ELF/cfi-same-value.s
llvm/trunk/test/MC/ELF/cfi-undefined.s
llvm/trunk/test/MC/ELF/cfi-window-save.s
llvm/trunk/test/MC/ELF/cfi-zero-addr-delta.s
llvm/trunk/test/MC/ELF/cfi.s
llvm/trunk/test/MC/ELF/relocation-pc.s
llvm/trunk/test/MC/ELF/rename.s
Modified: llvm/trunk/lib/MC/ELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/ELFObjectWriter.cpp?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/lib/MC/ELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/MC/ELFObjectWriter.cpp Wed Apr 8 06:41:24 2015
@@ -1676,8 +1676,6 @@ void ELFObjectWriter::WriteObject(MCAsse
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(MCAsse
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(MCAsse
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(MCAsse
// ... 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(
Modified: llvm/trunk/test/MC/ARM/elf-movt.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ARM/elf-movt.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ARM/elf-movt.s (original)
+++ llvm/trunk/test/MC/ARM/elf-movt.s Wed Apr 8 06:41:24 2015
@@ -42,7 +42,7 @@ 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
Modified: llvm/trunk/test/MC/ELF/cfi-adjust-cfa-offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-adjust-cfa-offset.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-adjust-cfa-offset.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-adjust-cfa-offset.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-advance-loc2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-advance-loc2.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-advance-loc2.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-advance-loc2.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-def-cfa-offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-def-cfa-offset.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-def-cfa-offset.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-def-cfa-offset.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-def-cfa-register.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-def-cfa-register.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-def-cfa-register.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-def-cfa-register.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-def-cfa.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-def-cfa.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-def-cfa.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-def-cfa.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-escape.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-escape.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-escape.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-escape.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-offset.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-offset.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-offset.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-register.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-register.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-register.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-register.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-rel-offset.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-rel-offset.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-rel-offset.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-rel-offset.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-rel-offset2.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-rel-offset2.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-rel-offset2.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-rel-offset2.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-remember.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-remember.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-remember.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-remember.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-restore.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-restore.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-restore.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-restore.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-same-value.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-same-value.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-same-value.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-same-value.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-undefined.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-undefined.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-undefined.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-undefined.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-window-save.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-window-save.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-window-save.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-window-save.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi-zero-addr-delta.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi-zero-addr-delta.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi-zero-addr-delta.s (original)
+++ llvm/trunk/test/MC/ELF/cfi-zero-addr-delta.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/cfi.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/cfi.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/cfi.s (original)
+++ llvm/trunk/test/MC/ELF/cfi.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/relocation-pc.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/relocation-pc.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/relocation-pc.s (original)
+++ llvm/trunk/test/MC/ELF/relocation-pc.s Wed Apr 8 06:41:24 2015
@@ -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
Modified: llvm/trunk/test/MC/ELF/rename.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/ELF/rename.s?rev=234400&r1=234399&r2=234400&view=diff
==============================================================================
--- llvm/trunk/test/MC/ELF/rename.s (original)
+++ llvm/trunk/test/MC/ELF/rename.s Wed Apr 8 06:41:24 2015
@@ -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
More information about the llvm-commits
mailing list