[PATCH] D13275: [lld][elf2] Sort output sections.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 30 17:00:32 PDT 2015


The patch can be simplified a bit (see attached).

Any reason you still had the SHT_NOBITS logic? If so it would need a
comment, and would be even better to have it in another patch, no?

In any case. The attached variation LGTM.

On 30 September 2015 at 19:14, Michael Spencer <bigcheesegs at gmail.com> wrote:
> Bigcheese updated this revision to Diff 36157.
> Bigcheese added a comment.
>
> Resolve comments.
>
>
> http://reviews.llvm.org/D13275
>
> Files:
>   ELF/OutputSections.cpp
>   ELF/Writer.cpp
>   test/elf2/basic-aarch64.s
>   test/elf2/basic-mips.s
>   test/elf2/basic.s
>   test/elf2/basic32.s
>   test/elf2/basic32be.s
>   test/elf2/basic64be.s
>   test/elf2/bss.s
>   test/elf2/discard-none.s
>   test/elf2/dynamic-reloc-index.s
>   test/elf2/dynamic-reloc.s
>   test/elf2/got.s
>   test/elf2/local-dynamic.s
>   test/elf2/plt-i686.s
>   test/elf2/plt.s
>   test/elf2/relocation-common.s
>   test/elf2/relocation-i686.s
>   test/elf2/relocation-local.s
>   test/elf2/relocation.s
>   test/elf2/section-layout.s
>   test/elf2/shared.s
>   test/elf2/symbols.s
>
-------------- next part --------------
diff --git a/ELF/OutputSections.cpp b/ELF/OutputSections.cpp
index 17bd9a6..13f599f 100644
--- a/ELF/OutputSections.cpp
+++ b/ELF/OutputSections.cpp
@@ -183,6 +183,9 @@ DynamicSection<ELFT>::DynamicSection(SymbolTable &SymTab,
 }
 
 template <class ELFT> void DynamicSection<ELFT>::finalize() {
+  if (this->Header.sh_size)
+    return; // Already finalized.
+
   typename Base::HeaderT &Header = this->Header;
   Header.sh_link = DynStrSec.getSectionIndex();
 
diff --git a/ELF/Writer.cpp b/ELF/Writer.cpp
index 3625934..b85f684 100644
--- a/ELF/Writer.cpp
+++ b/ELF/Writer.cpp
@@ -368,7 +368,6 @@ template <class ELFT> void Writer<ELFT>::createSections() {
   BssSec.setSize(Off);
 
   OutputSections.push_back(&SymTabSec);
-  OutputSections.push_back(&StrTabSec);
 
   if (needsDynamicSections()) {
     if (needsInterpSection())
@@ -389,12 +388,48 @@ template <class ELFT> void Writer<ELFT>::createSections() {
       OutputSections.begin(), OutputSections.end(),
       [](OutputSectionBase<ELFT::Is64Bits> *A,
          OutputSectionBase<ELFT::Is64Bits> *B) {
-        // Place SHF_ALLOC sections first.
-        return (A->getFlags() & SHF_ALLOC) && !(B->getFlags() & SHF_ALLOC);
+        // Non ALLOC goes last to reduce the total PT_LOAD size and so debug
+        // info doesn't change the layout of actual code.
+
+        // Read only (i.e., no SHF_EXECINSTR or SHF_WRITE) goes first to
+        // merge with the file header PT_LOAD.
+
+        // Other than that we just have to sort by matching SHF_EXECINSTR and
+        // SHF_WRITE to avoid creating too many PT_LOAD. The order between them
+        // is arbitrary, but generally matches what other linkers do.
+        auto ComputeRank = [](OutputSectionBase<ELFT::Is64Bits> *Sec) {
+          switch (Sec->getFlags() & (SHF_ALLOC | SHF_EXECINSTR | SHF_WRITE)) {
+          case SHF_ALLOC:
+            return 0;
+          case SHF_ALLOC | SHF_EXECINSTR:
+            return 1;
+          case SHF_ALLOC | SHF_EXECINSTR | SHF_WRITE:
+            return 2;
+          case SHF_ALLOC | SHF_WRITE:
+            return 3;
+          case 0:
+            return 4;
+          case SHF_EXECINSTR:
+          case SHF_WRITE:
+          case SHF_EXECINSTR | SHF_WRITE:
+            // These flags make no sense without ALLOC.
+            break;
+          }
+          error("Unexpected section flags");
+        };
+
+        return ComputeRank(A) < ComputeRank(B);
       });
 
+  // Always put StrTabSec last so that no section names are added to it after
+  // it's finalized.
+  OutputSections.push_back(&StrTabSec);
+
   for (unsigned I = 0, N = OutputSections.size(); I < N; ++I)
     OutputSections[I]->setSectionIndex(I + 1);
+
+  // Fill the DynStrSec early.
+  DynamicSec.finalize();
 }
 
 template <class ELFT>
diff --git a/test/elf2/basic-aarch64.s b/test/elf2/basic-aarch64.s
index 9eb2b5b..684cb4f 100644
--- a/test/elf2/basic-aarch64.s
+++ b/test/elf2/basic-aarch64.s
@@ -53,15 +53,15 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 1
-# CHECK-NEXT:     Name: .bss
-# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
-# CHECK-NEXT:     Flags [ (0x3)
+# CHECK-NEXT:     Name: .text
+# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
+# CHECK-NEXT:     Flags [ (0x6)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_WRITE (0x1)
+# CHECK-NEXT:       SHF_EXECINSTR (0x4)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Address: 0x11000
 # CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 0
+# CHECK-NEXT:     Size: 12
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
@@ -69,15 +69,15 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 2
-# CHECK-NEXT:     Name: .text
-# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT:     Flags [ (0x6)
+# CHECK-NEXT:     Name: .bss
+# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
+# CHECK-NEXT:     Flags [ (0x3)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_EXECINSTR (0x4)
+# CHECK-NEXT:       SHF_WRITE (0x1)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x11000
-# CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 12
+# CHECK-NEXT:     Address: 0x1100C
+# CHECK-NEXT:     Offset: 0x100C
+# CHECK-NEXT:     Size: 0
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
@@ -145,7 +145,7 @@ _start:
 # CHECK-NEXT:     Binding: Local (0x0)
 # CHECK-NEXT:     Type: None (0x0)
 # CHECK-NEXT:     Other: 0
-# CHECK-NEXT:     Section: .text (0x2)
+# CHECK-NEXT:     Section: .text
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Symbol {
 # CHECK-NEXT:     Name: _start (7)
diff --git a/test/elf2/basic-mips.s b/test/elf2/basic-mips.s
index 15a5b7c..6898264 100644
--- a/test/elf2/basic-mips.s
+++ b/test/elf2/basic-mips.s
@@ -25,14 +25,14 @@ __start:
 # CHECK-NEXT:   Type: Executable (0x2)
 # CHECK-NEXT:   Machine: EM_MIPS (0x8)
 # CHECK-NEXT:   Version: 1
-# CHECK-NEXT:   Entry: 0x11000
+# CHECK-NEXT:   Entry: 0x12000
 # CHECK-NEXT:   ProgramHeaderOffset: 0x34
-# CHECK-NEXT:   SectionHeaderOffset: 0x2094
+# CHECK-NEXT:   SectionHeaderOffset: 0x2074
 # CHECK-NEXT:   Flags [ (0x0)
 # CHECK-NEXT:   ]
 # CHECK-NEXT:   HeaderSize: 52
 # CHECK-NEXT:   ProgramHeaderEntrySize: 32
-# CHECK-NEXT:   ProgramHeaderCount: 3
+# CHECK-NEXT:   ProgramHeaderCount: 2
 # CHECK-NEXT:   SectionHeaderEntrySize: 40
 # CHECK-NEXT:   SectionHeaderCount: 8
 # CHECK-NEXT:   StringTableSectionIndex: 7
@@ -54,47 +54,45 @@ __start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 1
-# CHECK-NEXT:     Name: .bss (15)
-# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
-# CHECK-NEXT:     Flags [ (0x3)
+# CHECK-NEXT:     Name: .reginfo (35)
+# CHECK-NEXT:     Type: SHT_MIPS_REGINFO (0x70000006)
+# CHECK-NEXT:     Flags [ (0x2)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_WRITE (0x1)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Address: 0x11000
 # CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 0
+# CHECK-NEXT:     Size: 24
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
-# CHECK-NEXT:     AddressAlignment: 16
+# CHECK-NEXT:     AddressAlignment: 4
 # CHECK-NEXT:     EntrySize: 0
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 2
-# CHECK-NEXT:     Name: .text (1)
-# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT:     Flags [ (0x6)
+# CHECK-NEXT:     Name: .MIPS.abiflags (20)
+# CHECK-NEXT:     Type: SHT_MIPS_ABIFLAGS (0x7000002A)
+# CHECK-NEXT:     Flags [ (0x2)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_EXECINSTR (0x4)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x11000
-# CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 12
+# CHECK-NEXT:     Address: 0x11018
+# CHECK-NEXT:     Offset: 0x1018
+# CHECK-NEXT:     Size: 24
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
-# CHECK-NEXT:     AddressAlignment: 16
+# CHECK-NEXT:     AddressAlignment: 8
 # CHECK-NEXT:     EntrySize: 0
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 3
-# CHECK-NEXT:     Name: .data (60)
+# CHECK-NEXT:     Name: .text (1)
 # CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT:     Flags [ (0x3)
+# CHECK-NEXT:     Flags [ (0x6)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_WRITE (0x1)
+# CHECK-NEXT:       SHF_EXECINSTR (0x4)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x11010
-# CHECK-NEXT:     Offset: 0x1010
-# CHECK-NEXT:     Size: 0
+# CHECK-NEXT:     Address: 0x12000
+# CHECK-NEXT:     Offset: 0x2000
+# CHECK-NEXT:     Size: 12
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 16
@@ -102,32 +100,34 @@ __start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 4
-# CHECK-NEXT:     Name: .reginfo (35)
-# CHECK-NEXT:     Type: SHT_MIPS_REGINFO (0x70000006)
-# CHECK-NEXT:     Flags [ (0x2)
+# CHECK-NEXT:     Name: .bss (15)
+# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
+# CHECK-NEXT:     Flags [ (0x3)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
+# CHECK-NEXT:       SHF_WRITE (0x1)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x12000
-# CHECK-NEXT:     Offset: 0x2000
-# CHECK-NEXT:     Size: 24
+# CHECK-NEXT:     Address: 0x12010
+# CHECK-NEXT:     Offset: 0x2010
+# CHECK-NEXT:     Size: 0
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
-# CHECK-NEXT:     AddressAlignment: 4
+# CHECK-NEXT:     AddressAlignment: 16
 # CHECK-NEXT:     EntrySize: 0
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 5
-# CHECK-NEXT:     Name: .MIPS.abiflags (20)
-# CHECK-NEXT:     Type: SHT_MIPS_ABIFLAGS (0x7000002A)
-# CHECK-NEXT:     Flags [ (0x2)
+# CHECK-NEXT:     Name: .data (60)
+# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
+# CHECK-NEXT:     Flags [ (0x3)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
+# CHECK-NEXT:       SHF_WRITE (0x1)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x12018
-# CHECK-NEXT:     Offset: 0x2018
-# CHECK-NEXT:     Size: 24
+# CHECK-NEXT:     Address: 0x12010
+# CHECK-NEXT:     Offset: 0x2010
+# CHECK-NEXT:     Size: 0
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
-# CHECK-NEXT:     AddressAlignment: 8
+# CHECK-NEXT:     AddressAlignment: 16
 # CHECK-NEXT:     EntrySize: 0
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
@@ -137,7 +137,7 @@ __start:
 # CHECK-NEXT:     Flags [ (0x0)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Address: 0x0
-# CHECK-NEXT:     Offset: 0x2030
+# CHECK-NEXT:     Offset: 0x2010
 # CHECK-NEXT:     Size: 32
 # CHECK-NEXT:     Link: 7
 # CHECK-NEXT:     Info: 1
@@ -151,7 +151,7 @@ __start:
 # CHECK-NEXT:     Flags [ (0x0)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Address: 0x0
-# CHECK-NEXT:     Offset: 0x2050
+# CHECK-NEXT:     Offset: 0x2030
 # CHECK-NEXT:     Size: 66
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
@@ -171,12 +171,12 @@ __start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Symbol {
 # CHECK-NEXT:     Name: __start (7)
-# CHECK-NEXT:     Value: 0x11000
+# CHECK-NEXT:     Value: 0x12000
 # CHECK-NEXT:     Size: 0
 # CHECK-NEXT:     Binding: Global (0x1)
 # CHECK-NEXT:     Type: None (0x0)
 # CHECK-NEXT:     Other: 0
-# CHECK-NEXT:     Section: .text (0x2)
+# CHECK-NEXT:     Section: .text
 # CHECK-NEXT:   }
 # CHECK-NEXT: ]
 # CHECK-NEXT: ProgramHeaders [
@@ -185,8 +185,8 @@ __start:
 # CHECK-NEXT:     Offset: 0x0
 # CHECK-NEXT:     VirtualAddress: 0x10000
 # CHECK-NEXT:     PhysicalAddress: 0x10000
-# CHECK-NEXT:     FileSize: 148
-# CHECK-NEXT:     MemSize: 148
+# CHECK-NEXT:     FileSize: 4144
+# CHECK-NEXT:     MemSize: 4144
 # CHECK-NEXT:     Flags [ (0x4)
 # CHECK-NEXT:       PF_R (0x4)
 # CHECK-NEXT:     ]
@@ -194,9 +194,9 @@ __start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   ProgramHeader {
 # CHECK-NEXT:     Type: PT_LOAD (0x1)
-# CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     VirtualAddress: 0x11000
-# CHECK-NEXT:     PhysicalAddress: 0x11000
+# CHECK-NEXT:     Offset: 0x2000
+# CHECK-NEXT:     VirtualAddress: 0x12000
+# CHECK-NEXT:     PhysicalAddress: 0x12000
 # CHECK-NEXT:     FileSize: 16
 # CHECK-NEXT:     MemSize: 16
 # CHECK-NEXT:     Flags [ (0x5)
@@ -205,16 +205,4 @@ __start:
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Alignment: 4096
 # CHECK-NEXT:   }
-# CHECK-NEXT:   ProgramHeader {
-# CHECK-NEXT:     Type: PT_LOAD (0x1)
-# CHECK-NEXT:     Offset: 0x2000
-# CHECK-NEXT:     VirtualAddress: 0x12000
-# CHECK-NEXT:     PhysicalAddress: 0x12000
-# CHECK-NEXT:     FileSize: 48
-# CHECK-NEXT:     MemSize: 48
-# CHECK-NEXT:     Flags [ (0x4)
-# CHECK-NEXT:       PF_R (0x4)
-# CHECK-NEXT:     ]
-# CHECK-NEXT:     Alignment: 4096
-# CHECK-NEXT:   }
 # CHECK-NEXT: ]
diff --git a/test/elf2/basic.s b/test/elf2/basic.s
index 1504251..e872dff 100644
--- a/test/elf2/basic.s
+++ b/test/elf2/basic.s
@@ -54,15 +54,15 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 1
-# CHECK-NEXT:     Name: .bss
-# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
-# CHECK-NEXT:     Flags [ (0x3)
+# CHECK-NEXT:     Name: .text
+# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
+# CHECK-NEXT:     Flags [ (0x6)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_WRITE (0x1)
+# CHECK-NEXT:       SHF_EXECINSTR (0x4)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Address: 0x11000
 # CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 0
+# CHECK-NEXT:     Size: 16
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
@@ -70,15 +70,15 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 2
-# CHECK-NEXT:     Name: .text
-# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT:     Flags [ (0x6)
+# CHECK-NEXT:     Name: .bss
+# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
+# CHECK-NEXT:     Flags [ (0x3)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_EXECINSTR (0x4)
+# CHECK-NEXT:       SHF_WRITE (0x1)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x11000
-# CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 16
+# CHECK-NEXT:     Address: 0x11010
+# CHECK-NEXT:     Offset: 0x1010
+# CHECK-NEXT:     Size: 0
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
diff --git a/test/elf2/basic32.s b/test/elf2/basic32.s
index edafbe4..1de5d9d 100644
--- a/test/elf2/basic32.s
+++ b/test/elf2/basic32.s
@@ -52,15 +52,15 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 1
-# CHECK-NEXT:     Name: .bss
-# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
-# CHECK-NEXT:     Flags [ (0x3)
+# CHECK-NEXT:     Name: .text
+# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
+# CHECK-NEXT:     Flags [ (0x6)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_WRITE (0x1)
+# CHECK-NEXT:       SHF_EXECINSTR (0x4)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Address: 0x11000
 # CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 0
+# CHECK-NEXT:     Size: 12
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
@@ -68,15 +68,15 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 2
-# CHECK-NEXT:     Name: .text
-# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT:     Flags [ (0x6)
+# CHECK-NEXT:     Name: .bss
+# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
+# CHECK-NEXT:     Flags [ (0x3)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_EXECINSTR (0x4)
+# CHECK-NEXT:       SHF_WRITE (0x1)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x11000
-# CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 12
+# CHECK-NEXT:     Address: 0x1100C
+# CHECK-NEXT:     Offset: 0x100C
+# CHECK-NEXT:     Size: 0
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
diff --git a/test/elf2/basic32be.s b/test/elf2/basic32be.s
index 1f5e46a..2062ad8 100644
--- a/test/elf2/basic32be.s
+++ b/test/elf2/basic32be.s
@@ -52,15 +52,15 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 1
-# CHECK-NEXT:     Name: .bss
-# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
-# CHECK-NEXT:     Flags [ (0x3)
+# CHECK-NEXT:     Name: .text
+# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
+# CHECK-NEXT:     Flags [ (0x6)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_WRITE (0x1)
+# CHECK-NEXT:       SHF_EXECINSTR (0x4)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Address: 0x11000
 # CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 0
+# CHECK-NEXT:     Size: 12
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
@@ -68,15 +68,15 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 2
-# CHECK-NEXT:     Name: .text
-# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT:     Flags [ (0x6)
+# CHECK-NEXT:     Name: .bss
+# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
+# CHECK-NEXT:     Flags [ (0x3)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_EXECINSTR (0x4)
+# CHECK-NEXT:       SHF_WRITE (0x1)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x11000
-# CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 12
+# CHECK-NEXT:     Address: 0x1100C
+# CHECK-NEXT:     Offset: 0x100C
+# CHECK-NEXT:     Size: 0
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
diff --git a/test/elf2/basic64be.s b/test/elf2/basic64be.s
index 842312a..564b883 100644
--- a/test/elf2/basic64be.s
+++ b/test/elf2/basic64be.s
@@ -59,37 +59,37 @@ _start:
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 1
-# CHECK-NEXT:     Name: .bss
-# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
-# CHECK-NEXT:     Flags [ (0x3)
+# CHECK-NEXT:     Name: .text
+# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
+# CHECK-NEXT:     Flags [ (0x6)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_WRITE (0x1)
+# CHECK-NEXT:       SHF_EXECINSTR (0x4)
 # CHECK-NEXT:     ]
 # CHECK-NEXT:     Address: 0x11000
 # CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 0
+# CHECK-NEXT:     Size: 12
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
 # CHECK-NEXT:     EntrySize: 0
+# CHECK-NEXT:     SectionData (
+# CHECK:          )
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 2
-# CHECK-NEXT:     Name: .text
-# CHECK-NEXT:     Type: SHT_PROGBITS (0x1)
-# CHECK-NEXT:     Flags [ (0x6)
+# CHECK-NEXT:     Name: .bss
+# CHECK-NEXT:     Type: SHT_NOBITS (0x8)
+# CHECK-NEXT:     Flags [ (0x3)
 # CHECK-NEXT:       SHF_ALLOC (0x2)
-# CHECK-NEXT:       SHF_EXECINSTR (0x4)
+# CHECK-NEXT:       SHF_WRITE (0x1)
 # CHECK-NEXT:     ]
-# CHECK-NEXT:     Address: 0x11000
-# CHECK-NEXT:     Offset: 0x1000
-# CHECK-NEXT:     Size: 12
+# CHECK-NEXT:     Address: 0x1100C
+# CHECK-NEXT:     Offset: 0x100C
+# CHECK-NEXT:     Size: 0
 # CHECK-NEXT:     Link: 0
 # CHECK-NEXT:     Info: 0
 # CHECK-NEXT:     AddressAlignment: 4
 # CHECK-NEXT:     EntrySize: 0
-# CHECK-NEXT:     SectionData (
-# CHECK:          )
 # CHECK-NEXT:   }
 # CHECK-NEXT:   Section {
 # CHECK-NEXT:     Index: 3
diff --git a/test/elf2/bss.s b/test/elf2/bss.s
index e8ca6be..0fa8fe4 100644
--- a/test/elf2/bss.s
+++ b/test/elf2/bss.s
@@ -19,17 +19,6 @@
 // CHECK-NEXT:   AddressAlignment: 4
 // CHECK-NEXT:   EntrySize: 0
 // CHECK-NEXT: }
-// CHECK-NEXT: Section {
-// CHECK-NEXT:   Index:
-// CHECK-NEXT:   Name:
-// CHECK-NEXT:   Type:
-// CHECK-NEXT:   Flags [
-// CHECK-NEXT:     SHF_ALLOC
-// CHECK-NEXT:     SHF_EXECINSTR
-// CHECK-NEXT:   ]
-// CHECK-NEXT:   Address:
-// CHECK-NEXT:   Offset: 0x1000
-
 
         .global _start
 _start:
diff --git a/test/elf2/discard-none.s b/test/elf2/discard-none.s
index 2c3d798..7700534 100644
--- a/test/elf2/discard-none.s
+++ b/test/elf2/discard-none.s
@@ -40,7 +40,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: .Lmyothervar
-// CHECK-NEXT:     Value: 0x1000
+// CHECK-NEXT:     Value: 0x102C
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Local
 // CHECK-NEXT:     Type: None
@@ -49,7 +49,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: .Lmyvar
-// CHECK-NEXT:     Value: 0x1000
+// CHECK-NEXT:     Value: 0x102C
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Local
 // CHECK-NEXT:     Type: None
diff --git a/test/elf2/dynamic-reloc-index.s b/test/elf2/dynamic-reloc-index.s
index 294595b..da4df34 100644
--- a/test/elf2/dynamic-reloc-index.s
+++ b/test/elf2/dynamic-reloc-index.s
@@ -8,7 +8,7 @@
 
 // CHECK:      Relocations [
 // CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
-// CHECK-NEXT:     0x11000 R_X86_64_64 bar 0x0
+// CHECK-NEXT:     0x12000 R_X86_64_64 bar 0x0
 // CHECK-NEXT:   }
 // CHECK-NEXT: ]
 
diff --git a/test/elf2/dynamic-reloc.s b/test/elf2/dynamic-reloc.s
index 5a4b551..75cfde9 100644
--- a/test/elf2/dynamic-reloc.s
+++ b/test/elf2/dynamic-reloc.s
@@ -6,15 +6,7 @@
 // RUN: llvm-readobj -dynamic-table -r --expand-relocs -s %t | FileCheck %s
 // REQUIRES: x86
 
-// CHECK:      Name: .text
-// CHECK-NEXT: Type: SHT_PROGBITS
-// CHECK-NEXT: Flags [
-// CHECK-NEXT:   SHF_ALLOC
-// CHECK-NEXT:   SHF_EXECINSTR
-// CHECK-NEXT: ]
-// CHECK-NEXT: Address: [[ADDR:.*]]
-
-// CHECK:      Index: 4
+// CHECK:      Index: 1
 // CHECK-NEXT: Name: .dynsym
 
 // CHECK:      Name: .rela.dyn
@@ -25,11 +17,19 @@
 // CHECK-NEXT: Address: [[RELAADDR:.*]]
 // CHECK-NEXT: Offset:
 // CHECK-NEXT: Size: [[RELASIZE:.*]]
-// CHECK-NEXT: Link: 4
+// CHECK-NEXT: Link: 1
 // CHECK-NEXT: Info: 0
 // CHECK-NEXT: AddressAlignment: 8
 // CHECK-NEXT: EntrySize: 24
 
+// CHECK:      Name: .text
+// CHECK-NEXT: Type: SHT_PROGBITS
+// CHECK-NEXT: Flags [
+// CHECK-NEXT:   SHF_ALLOC
+// CHECK-NEXT:   SHF_EXECINSTR
+// CHECK-NEXT: ]
+// CHECK-NEXT: Address: [[ADDR:.*]]
+
 // CHECK:      Relocations [
 // CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
 // CHECK-NEXT:     Relocation {
diff --git a/test/elf2/got.s b/test/elf2/got.s
index aaff3a1..3e24891 100644
--- a/test/elf2/got.s
+++ b/test/elf2/got.s
@@ -12,7 +12,7 @@
 // CHECK-NEXT:   SHF_ALLOC
 // CHECK-NEXT:   SHF_WRITE
 // CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x15000
+// CHECK-NEXT: Address: 0x130A0
 // CHECK-NEXT: Offset:
 // CHECK-NEXT: Size: 16
 // CHECK-NEXT: Link: 0
@@ -21,22 +21,22 @@
 
 // CHECK:      Relocations [
 // CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
-// CHECK-NEXT:     0x15000 R_X86_64_GLOB_DAT bar 0x0
-// CHECK-NEXT:     0x15008 R_X86_64_GLOB_DAT zed 0x0
+// CHECK-NEXT:     0x130A0 R_X86_64_GLOB_DAT bar 0x0
+// CHECK-NEXT:     0x130A8 R_X86_64_GLOB_DAT zed 0x0
 // CHECK-NEXT:   }
 // CHECK-NEXT: ]
 
 
 // Unfortunately FileCheck can't do math, so we have to check for explicit
 // values:
-//  0x15000 - (0x11000 + 2) - 4 = 16378
-//  0x15000 - (0x11006 + 2) - 4 = 16372
-//  0x15008 - (0x1100c + 2) - 4 = 16374
+//  0x130A0 - (0x12000 + 2) - 4 = 4250
+//  0x130A0 - (0x12006 + 2) - 4 = 4244
+//  0x130A8 - (0x1200c + 2) - 4 = 4246
 
 // DISASM:      _start:
-// DISASM-NEXT:   11000:  ff 25 fa 3f 00 00  jmpq  *16378(%rip)
-// DISASM-NEXT:   11006:  ff 25 f4 3f 00 00  jmpq  *16372(%rip)
-// DISASM-NEXT:   1100c:  ff 25 f6 3f 00 00  jmpq  *16374(%rip)
+// DISASM-NEXT:   12000:  {{.*}}  jmpq  *4250(%rip)
+// DISASM-NEXT:   12006:  {{.*}}  jmpq  *4244(%rip)
+// DISASM-NEXT:   1200c:  {{.*}}  jmpq  *4246(%rip)
 
 .global _start
 _start:
diff --git a/test/elf2/local-dynamic.s b/test/elf2/local-dynamic.s
index d95909d..503f3aa 100644
--- a/test/elf2/local-dynamic.s
+++ b/test/elf2/local-dynamic.s
@@ -16,7 +16,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: blah
-// CHECK-NEXT:     Value: 0x1000
+// CHECK-NEXT:     Value: 0x1050
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Local
 // CHECK-NEXT:     Type: None
@@ -25,7 +25,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: foo
-// CHECK-NEXT:     Value: 0x1000
+// CHECK-NEXT:     Value: 0x1050
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Local
 // CHECK-NEXT:     Type: None
@@ -34,7 +34,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: goo
-// CHECK-NEXT:     Value: 0x1000
+// CHECK-NEXT:     Value: 0x1050
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Local
 // CHECK-NEXT:     Type: None
@@ -43,7 +43,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: _start
-// CHECK-NEXT:     Value: 0x1000
+// CHECK-NEXT:     Value: 0x1050
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Global
 // CHECK-NEXT:     Type: None
@@ -64,7 +64,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: _start@
-// CHECK-NEXT:     Value: 0x1000
+// CHECK-NEXT:     Value: 0x1050
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Global
 // CHECK-NEXT:     Type: None
diff --git a/test/elf2/plt-i686.s b/test/elf2/plt-i686.s
index 8891f9e..1fa1b60 100644
--- a/test/elf2/plt-i686.s
+++ b/test/elf2/plt-i686.s
@@ -12,7 +12,7 @@
 // CHECK-NEXT:   SHF_ALLOC
 // CHECK-NEXT:   SHF_EXECINSTR
 // CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x16000
+// CHECK-NEXT: Address: 0x12010
 // CHECK-NEXT: Offset:
 // CHECK-NEXT: Size: 16
 // CHECK-NEXT: Link: 0
@@ -21,34 +21,34 @@
 
 // CHECK:      Relocations [
 // CHECK-NEXT:   Section ({{.*}}) .rel.dyn {
-// CHECK-NEXT:     0x15000 R_386_GLOB_DAT bar 0x0
-// CHECK-NEXT:     0x15004 R_386_GLOB_DAT zed 0x0
+// CHECK-NEXT:     0x13050 R_386_GLOB_DAT bar 0x0
+// CHECK-NEXT:     0x13054 R_386_GLOB_DAT zed 0x0
 // CHECK-NEXT:   }
 // CHECK-NEXT: ]
 
 // Unfortunately FileCheck can't do math, so we have to check for explicit
 // values:
 
-// 0x16000 - (0x11000 + 1) - 4 = 20475
-// 0x16000 - (0x11005 + 1) - 4 = 20470
-// 0x16008 - (0x1100a + 1) - 4 = 20473
+// 0x12010 - (0x12000 + 1) - 4 = 11
+// 0x12010 - (0x12005 + 1) - 4 = 2
+// 0x12018 - (0x1200a + 1) - 4 = 9
 
 // DISASM:      _start:
-// DISASM-NEXT:   11000:  e9 fb 4f 00 00  jmp  20475
-// DISASM-NEXT:   11005:  e9 f6 4f 00 00  jmp  20470
-// DISASM-NEXT:   1100a:  e9 f9 4f 00 00  jmp  20473
+// DISASM-NEXT:   12000:  e9 0b 00 00 00  jmp  11
+// DISASM-NEXT:   12005:  e9 06 00 00 00  jmp  6
+// DISASM-NEXT:   1200a:  e9 09 00 00 00  jmp  9
 
-// 0x15000 = 86016
-// 0x15004 = 86020
+// 0x13050 = 77904
+// 0x13054 = 77908
 
 // DISASM:      Disassembly of section .plt:
 // DISASM-NEXT: .plt:
-// DISASM-NEXT:   16000:  ff 25 00 50 01 00  jmpl *86016
-// DISASM-NEXT:   16006:  90                 nop
-// DISASM-NEXT:   16007:  90                 nop
-// DISASM-NEXT:   16008:  ff 25 04 50 01 00  jmpl *86020
-// DISASM-NEXT:   1600e:  90                 nop
-// DISASM-NEXT:   1600f:  90                 nop
+// DISASM-NEXT:   12010:  ff 25 {{.*}}       jmpl *77904
+// DISASM-NEXT:   12016:  90                 nop
+// DISASM-NEXT:   12017:  90                 nop
+// DISASM-NEXT:   12018:  ff 25 {{.*}}       jmpl *77908
+// DISASM-NEXT:   1201e:  90                 nop
+// DISASM-NEXT:   1201f:  90                 nop
 
 .global _start
 _start:
diff --git a/test/elf2/plt.s b/test/elf2/plt.s
index 914b3e3..261ca9b 100644
--- a/test/elf2/plt.s
+++ b/test/elf2/plt.s
@@ -12,7 +12,7 @@
 // CHECK-NEXT:   SHF_ALLOC
 // CHECK-NEXT:   SHF_EXECINSTR
 // CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x16000
+// CHECK-NEXT: Address: 0x12020
 // CHECK-NEXT: Offset:
 // CHECK-NEXT: Size: 24
 // CHECK-NEXT: Link: 0
@@ -21,35 +21,35 @@
 
 // CHECK:      Relocations [
 // CHECK-NEXT:   Section ({{.*}}) .rela.dyn {
-// CHECK-NEXT:     0x15000 R_X86_64_GLOB_DAT bar 0x0
-// CHECK-NEXT:     0x15008 R_X86_64_GLOB_DAT zed 0x0
-// CHECK-NEXT:     0x15010 R_X86_64_GLOB_DAT _start 0x0
+// CHECK-NEXT:     0x130A0 R_X86_64_GLOB_DAT bar 0x0
+// CHECK-NEXT:     0x130A8 R_X86_64_GLOB_DAT zed 0x0
+// CHECK-NEXT:     0x130B0 R_X86_64_GLOB_DAT _start 0x0
 // CHECK-NEXT:   }
 // CHECK-NEXT: ]
 
 // Unfortunately FileCheck can't do math, so we have to check for explicit
 // values:
 
-// 0x16000 - (0x11000 + 1) - 4 = 20475
-// 0x16000 - (0x11005 + 1) - 4 = 20470
-// 0x16008 - (0x1100a + 1) - 4 = 20473
+// 0x12020 - (0x12000 + 1) - 4 = 27
+// 0x12020 - (0x12005 + 1) - 4 = 22
+// 0x12028 - (0x1200a + 1) - 4 = 25
 
 // DISASM:      _start:
-// DISASM-NEXT:   11000:  e9 fb 4f 00 00  jmp  20475
-// DISASM-NEXT:   11005:  e9 f6 4f 00 00  jmp  20470
-// DISASM-NEXT:   1100a:  e9 f9 4f 00 00  jmp  20473
+// DISASM-NEXT:   12000:  e9 {{.*}}       jmp  27
+// DISASM-NEXT:   12005:  e9 {{.*}}       jmp  22
+// DISASM-NEXT:   1200a:  e9 {{.*}}       jmp  25
 
-// 0x15000 - 0x16006  = -4102
-// 0x15008 - 0x1600e  = -4102
+// 0x130A0 - 0x12026  = 4218
+// 0x130A8 - 0x1202e  = 4218
 
 // DISASM:      Disassembly of section .plt:
 // DISASM-NEXT: .plt:
-// DISASM-NEXT:   16000:  ff 25 fa ef ff ff  jmpq *-4102(%rip)
-// DISASM-NEXT:   16006:  90                 nop
-// DISASM-NEXT:   16007:  90                 nop
-// DISASM-NEXT:   16008:  ff 25 fa ef ff ff  jmpq *-4102(%rip)
-// DISASM-NEXT:   1600e:  90                 nop
-// DISASM-NEXT:   1600f:  90                 nop
+// DISASM-NEXT:   12020:  ff 25 {{.*}}       jmpq *4218(%rip)
+// DISASM-NEXT:   12026:  90                 nop
+// DISASM-NEXT:   12027:  90                 nop
+// DISASM-NEXT:   12028:  ff 25 {{.*}}       jmpq *4218(%rip)
+// DISASM-NEXT:   1202e:  90                 nop
+// DISASM-NEXT:   1202f:  90                 nop
 
 .global _start
 _start:
diff --git a/test/elf2/relocation-common.s b/test/elf2/relocation-common.s
index 68eca01..8822ea7 100644
--- a/test/elf2/relocation-common.s
+++ b/test/elf2/relocation-common.s
@@ -10,5 +10,5 @@ _start:
 .global sym1
 .comm sym1,4,4
 
-// CHECK: 12000: {{.*}} movl    $1, -4106(%rip)
-// CHECK: 0000000000011000 g       .bss            00000004 sym1
+// CHECK: 11000: {{.*}} movl    $1, 4086(%rip)
+// CHECK: 0000000000012000 g       .bss            00000004 sym1
diff --git a/test/elf2/relocation-i686.s b/test/elf2/relocation-i686.s
index d028215..6208b82 100644
--- a/test/elf2/relocation-i686.s
+++ b/test/elf2/relocation-i686.s
@@ -27,14 +27,14 @@ R_386_PC32_2:
 
 // CHECK: Disassembly of section .R_386_32:
 // CHECK-NEXT: R_386_32:
-// CHECK-NEXT:  11000: {{.*}} movl $69633, %edx
+// CHECK-NEXT:  12000: {{.*}} movl $73729, %edx
 
 // CHECK: Disassembly of section .R_386_PC32:
 // CHECK-NEXT: R_386_PC32:
-// CHECK-NEXT:   11005:  e8 04 00 00 00  calll 4
+// CHECK-NEXT:   12005:  e8 04 00 00 00  calll 4
 
 // CHECK:      R_386_PC32_2:
-// CHECK-NEXT:   1100e:  90  nop
+// CHECK-NEXT:   1200e:  90  nop
 
 // Create a .got
 movl bar at GOT, %eax
@@ -46,23 +46,23 @@ movl bar at GOT, %eax
 // ADDR-NEXT:   SHF_ALLOC
 // ADDR-NEXT:   SHF_WRITE
 // ADDR-NEXT: ]
-// ADDR-NEXT: Address: 0x15000
+// ADDR-NEXT: Address: 0x13050
 
 .section .R_386_GOTPC,"ax", at progbits
 R_386_GOTPC:
  movl $_GLOBAL_OFFSET_TABLE_, %eax
 
-// 0x15000 - 0x11014 = 16364
+// 0x13050 - 0x12014 = 4156
 
 // CHECK:      Disassembly of section .R_386_GOTPC:
 // CHECK-NEXT: R_386_GOTPC:
-// CHECK-NEXT:   11014:  {{.*}} movl  $16364, %eax
+// CHECK-NEXT:   12014:  {{.*}} movl  $4156, %eax
 
 .section .dynamic_reloc, "ax", at progbits
         call bar+4
 // CHECK:      Disassembly of section .dynamic_reloc:
 // CHECK-NEXT: .dynamic_reloc:
-// CHECK-NEXT:   11019:  e8 00 00 00 00  calll  0
+// CHECK-NEXT:   12019:  e8 00 00 00 00  calll  0
 
 .section .R_386_GOT32,"ax", at progbits
 .global R_386_GOT32
@@ -71,4 +71,4 @@ R_386_GOT32:
 // This is the second symbol in the got, so the offset is 4.
 // CHECK:      Disassembly of section .R_386_GOT32:
 // CHECK-NEXT: R_386_GOT32:
-// CHECK-NEXT:   1101e:  {{.*}} movl 4, %eax
+// CHECK-NEXT:   1201e:  {{.*}} movl 4, %eax
diff --git a/test/elf2/relocation-local.s b/test/elf2/relocation-local.s
index 5042c79..3adba3d 100644
--- a/test/elf2/relocation-local.s
+++ b/test/elf2/relocation-local.s
@@ -20,7 +20,7 @@ R_X86_64_32:
 // constants in hex.
 // CHECK: Disassembly of section .text2:
 // CHECK-NEXT: R_X86_64_32:
-// CHECK-NEXT:  1100c: {{.*}} movl $69644, %edx
+// CHECK-NEXT:  12009: {{.*}} movl $73737, %edx
 
 .section .R_X86_64_32S,"ax", at progbits
 R_X86_64_32S:
@@ -28,11 +28,11 @@ R_X86_64_32S:
 
 // CHECK: Disassembly of section .R_X86_64_32S:
 // CHECK-NEXT: R_X86_64_32S:
-// CHECK-NEXT:  {{.*}}: {{.*}} movq -978935, %rdx
+// CHECK-NEXT:  {{.*}}: {{.*}} movq -974839, %rdx
 
 .section .R_X86_64_64,"a", at progbits
 R_X86_64_64:
  .quad R_X86_64_64
 
 // CHECK:      Contents of section .R_X86_64_64:
-// CHECK-NEXT:   12000 00200100 00000000
+// CHECK-NEXT:   11000 00100100 00000000
diff --git a/test/elf2/relocation.s b/test/elf2/relocation.s
index 4046f2b..b56dcd8 100644
--- a/test/elf2/relocation.s
+++ b/test/elf2/relocation.s
@@ -6,13 +6,23 @@
 // RUN: llvm-objdump -s -d %t3 | FileCheck %s
 // REQUIRES: x86
 
+// SEC:      Name: .plt
+// SEC-NEXT: Type: SHT_PROGBITS
+// SEC-NEXT: Flags [
+// SEC-NEXT:   SHF_ALLOC
+// SEC-NEXT:   SHF_EXECINSTR
+// SEC-NEXT: ]
+// SEC-NEXT: Address: 0x12020
+// SEC-NEXT: Offset: 0x2020
+// SEC-NEXT: Size: 8
+
 // SEC:         Name: .got
 // SEC-NEXT:   Type: SHT_PROGBITS
 // SEC-NEXT:   Flags [
 // SEC-NEXT:     SHF_ALLOC
 // SEC-NEXT:     SHF_WRITE
 // SEC-NEXT:   ]
-// SEC-NEXT:   Address: 0x15000
+// SEC-NEXT:   Address: 0x130A0
 // SEC-NEXT:   Offset:
 // SEC-NEXT:   Size: 16
 // SEC-NEXT:   Link: 0
@@ -21,16 +31,6 @@
 // SEC-NEXT:   EntrySize: 0
 // SEC-NEXT: }
 
-// SEC:      Name: .plt
-// SEC-NEXT: Type: SHT_PROGBITS
-// SEC-NEXT: Flags [
-// SEC-NEXT:   SHF_ALLOC
-// SEC-NEXT:   SHF_EXECINSTR
-// SEC-NEXT: ]
-// SEC-NEXT: Address: 0x16000
-// SEC-NEXT: Offset: 0x6000
-// SEC-NEXT: Size: 8
-
 .section       .text,"ax", at progbits,unique,1
 .global _start
 _start:
@@ -44,11 +44,11 @@ lulz:
 
 // CHECK: Disassembly of section .text:
 // CHECK-NEXT: _start:
-// CHECK-NEXT:   11000:  e8 04 00 00 00   callq 4
-// CHECK-NEXT:   11005:
+// CHECK-NEXT:   12000:  e8 04 00 00 00   callq 4
+// CHECK-NEXT:   12005:
 
 // CHECK:      lulz:
-// CHECK-NEXT:   11009:  90  nop
+// CHECK-NEXT:   12009:  90  nop
 
 
 .section       .text2,"ax", at progbits
@@ -60,7 +60,7 @@ R_X86_64_32:
 // constants in hex.
 // CHECK: Disassembly of section .text2:
 // CHECK-NEXT: R_X86_64_32:
-// CHECK-NEXT:  1100c: {{.*}} movl $69644, %edx
+// CHECK-NEXT:  1200a: {{.*}} movl $73738, %edx
 
 .section .R_X86_64_32S,"ax", at progbits
 .global R_X86_64_32S
@@ -69,16 +69,16 @@ R_X86_64_32S:
 
 // CHECK: Disassembly of section .R_X86_64_32S:
 // CHECK-NEXT: R_X86_64_32S:
-// CHECK-NEXT:  {{.*}}: {{.*}} movq -978935, %rdx
+// CHECK-NEXT:  {{.*}}: {{.*}} movq -974839, %rdx
 
 .section .R_X86_64_PC32,"ax", at progbits
 .global R_X86_64_PC32
 R_X86_64_PC32:
  call bar
-// 0x16000 - (0x11019 + 5) = 20450
+// 0x12020 - (0x12017 + 5) = 4
 // CHECK:      Disassembly of section .R_X86_64_PC32:
 // CHECK-NEXT: R_X86_64_PC32:
-// CHECK-NEXT:  11019:   e8 e2 4f 00 00  callq  20450
+// CHECK-NEXT:  12017:   e8 04 00 00 00  callq  4
 
 .section .R_X86_64_64,"a", at progbits
 .global R_X86_64_64
@@ -86,14 +86,14 @@ R_X86_64_64:
  .quad R_X86_64_64
 
 // CHECK:      Contents of section .R_X86_64_64:
-// CHECK-NEXT:   12000 00200100 00000000
+// CHECK-NEXT:   11000 00100100 00000000
 
 .section .R_X86_64_GOTPCREL,"a", at progbits
 .global R_X86_64_GOTPCREL
 R_X86_64_GOTPCREL:
  .long R_X86_64_GOTPCREL at gotpcrel
 
-// 0x15008 - 0x12008 = 12288
-// 12288 = 0x00300000   in little endian
+// 0x130A8 - 0x11008 = 8352
+// 8352 = 0x80200000   in little endian
 // CHECK:      Contents of section .R_X86_64_GOTPCREL
-// CHECK-NEXT:   12008 00300000
+// CHECK-NEXT:   11008 a0200000
diff --git a/test/elf2/shared.s b/test/elf2/shared.s
index dcda240..6d02249 100644
--- a/test/elf2/shared.s
+++ b/test/elf2/shared.s
@@ -14,7 +14,7 @@
 // SO-NEXT: Flags [
 // SO-NEXT: ]
 // SO-NEXT: Address:
-// SO-NEXT: Offset: 0x300C
+// SO-NEXT: Offset: 0x2030
 // SO-NEXT: Size:
 // SO-NEXT: Link:
 // SO-NEXT: Info:
@@ -39,14 +39,14 @@
 // CHECK-NEXT: }
 
 // test that .hash is linked to .dynsym
-// CHECK:        Index: 5
+// CHECK:        Index: 2
 // CHECK-NEXT:   Name: .dynsym
 // CHECK-NEXT:   Type: SHT_DYNSYM
 // CHECK-NEXT:   Flags [
 // CHECK-NEXT:     SHF_ALLOC
 // CHECK-NEXT:   ]
 // CHECK-NEXT:   Address: [[DYNSYMADDR:.*]]
-// CHECK-NEXT:   Offset: 0x201C
+// CHECK-NEXT:   Offset: 0x101C
 // CHECK-NEXT:   Size:
 // CHECK-NEXT:   Link: [[DYNSTR:.*]]
 // CHECK-NEXT:   Info: 1
@@ -60,7 +60,7 @@
 // CHECK-NEXT:   )
 // CHECK-NEXT: }
 // CHECK-NEXT: Section {
-// CHECK-NEXT:   Index: 6
+// CHECK-NEXT:   Index: 3
 // CHECK-NEXT:    Name: .hash
 // CHECK-NEXT:    Type: SHT_HASH
 // CHECK-NEXT:    Flags [
@@ -69,29 +69,11 @@
 // CHECK-NEXT:    Address: [[HASHADDR:.*]]
 // CHECK-NEXT:    Offset:
 // CHECK-NEXT:    Size:
-// CHECK-NEXT:    Link: 5
+// CHECK-NEXT:    Link: 2
 // CHECK-NEXT:    Info: 0
 // CHECK-NEXT:    AddressAlignment: 4
 // CHECK-NEXT:    EntrySize: 4
 
-
-// CHECK:        Name: .dynamic
-// CHECK-NEXT:   Type: SHT_DYNAMIC
-// CHECK-NEXT:   Flags [
-// CHECK-NEXT:     SHF_ALLOC
-// CHECK-NEXT:     SHF_WRITE
-// CHECK-NEXT:   ]
-// CHECK-NEXT:   Address: [[ADDR:.*]]
-// CHECK-NEXT:   Offset: [[OFFSET:.*]]
-// CHECK-NEXT:   Size: [[SIZE:.*]]
-// CHECK-NEXT:   Link: [[DYNSTR]]
-// CHECK-NEXT:   Info: 0
-// CHECK-NEXT:   AddressAlignment: [[ALIGN:.*]]
-// CHECK-NEXT:   EntrySize: 8
-// CHECK-NEXT:   SectionData (
-// CHECK:        )
-// CHECK-NEXT: }
-
 // CHECK:        Index: [[DYNSTR]]
 // CHECK-NEXT:   Name: .dynstr
 // CHECK-NEXT:   Type: SHT_STRTAB
@@ -122,6 +104,23 @@
 // CHECK-NEXT: AddressAlignment:
 // CHECK-NEXT: EntrySize: [[RELENT:.*]]
 
+// CHECK:        Name: .dynamic
+// CHECK-NEXT:   Type: SHT_DYNAMIC
+// CHECK-NEXT:   Flags [
+// CHECK-NEXT:     SHF_ALLOC
+// CHECK-NEXT:     SHF_WRITE
+// CHECK-NEXT:   ]
+// CHECK-NEXT:   Address: [[ADDR:.*]]
+// CHECK-NEXT:   Offset: [[OFFSET:.*]]
+// CHECK-NEXT:   Size: [[SIZE:.*]]
+// CHECK-NEXT:   Link: [[DYNSTR]]
+// CHECK-NEXT:   Info: 0
+// CHECK-NEXT:   AddressAlignment: [[ALIGN:.*]]
+// CHECK-NEXT:   EntrySize: 8
+// CHECK-NEXT:   SectionData (
+// CHECK:        )
+// CHECK-NEXT: }
+
 // CHECK:      Name: .symtab
 // CHECK-NEXT: Type: SHT_SYMTAB
 // CHECK-NEXT: Flags [
@@ -146,7 +145,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: _start
-// CHECK-NEXT:     Value: 0x11000
+// CHECK-NEXT:     Value: 0x12000
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Global
 // CHECK-NEXT:     Type: None
@@ -185,7 +184,7 @@
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: _start@
-// CHECK-NEXT:     Value: 0x11000
+// CHECK-NEXT:     Value: 0x12000
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Global
 // CHECK-NEXT:     Type: Non
diff --git a/test/elf2/symbols.s b/test/elf2/symbols.s
index 607048d..27e6fb7 100644
--- a/test/elf2/symbols.s
+++ b/test/elf2/symbols.s
@@ -45,15 +45,12 @@ hidden:
 .internal internal
 internal:
 
-// CHECK:      Name: .bss
+// CHECK:      Name: foobar
 // CHECK-NEXT: Type: SHT_NOBITS
 // CHECK-NEXT: Flags [
 // CHECK-NEXT:   SHF_ALLOC
-// CHECK-NEXT:   SHF_WRITE
 // CHECK-NEXT: ]
 // CHECK-NEXT: Address: 0x11000
-// CHECK-NEXT: Offset: 0x1000
-// CHECK-NEXT: Size: 4
 
 // CHECK:      Name: .text
 // CHECK-NEXT: Type: SHT_PROGBITS
@@ -63,12 +60,15 @@ internal:
 // CHECK-NEXT: ]
 // CHECK-NEXT: Address: 0x12000
 
-// CHECK:      Name: foobar
+// CHECK:      Name: .bss
 // CHECK-NEXT: Type: SHT_NOBITS
 // CHECK-NEXT: Flags [
 // CHECK-NEXT:   SHF_ALLOC
+// CHECK-NEXT:   SHF_WRITE
 // CHECK-NEXT: ]
 // CHECK-NEXT: Address: 0x13000
+// CHECK-NEXT: Offset: 0x2000
+// CHECK-NEXT: Size: 4
 
 // CHECK:      Symbols [
 // CHECK-NEXT:   Symbol {
@@ -109,7 +109,7 @@ internal:
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: common
-// CHECK-NEXT:     Value: 0x11000
+// CHECK-NEXT:     Value: 0x13000
 // CHECK-NEXT:     Size: 4
 // CHECK-NEXT:     Binding: Global
 // CHECK-NEXT:     Type: Object
@@ -127,7 +127,7 @@ internal:
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: protected
-// CHECK-NEXT:     Value: 0x13008
+// CHECK-NEXT:     Value: 0x11008
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Global
 // CHECK-NEXT:     Type: None
@@ -136,7 +136,7 @@ internal:
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: zed
-// CHECK-NEXT:     Value: 0x13000
+// CHECK-NEXT:     Value: 0x11000
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Global (0x1)
 // CHECK-NEXT:     Type: None
@@ -145,7 +145,7 @@ internal:
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: zed2
-// CHECK-NEXT:     Value: 0x13004
+// CHECK-NEXT:     Value: 0x11004
 // CHECK-NEXT:     Size: 0
 // CHECK-NEXT:     Binding: Global
 // CHECK-NEXT:     Type: None
@@ -154,7 +154,7 @@ internal:
 // CHECK-NEXT:   }
 // CHECK-NEXT:   Symbol {
 // CHECK-NEXT:     Name: zed3
-// CHECK-NEXT:     Value: 0x13008
+// CHECK-NEXT:     Value: 0x11008
 // CHECK-NEXT:     Size: 4
 // CHECK-NEXT:     Binding: Global
 // CHECK-NEXT:     Type: None


More information about the llvm-commits mailing list