]> granicus.if.org Git - llvm/commitdiff
Revert "[Tests] Output of od can be lower or upper case (llvm-objcopy/yaml2obj)."
authorDmitri Gribenko <gribozavr@gmail.com>
Thu, 10 Oct 2019 14:26:54 +0000 (14:26 +0000)
committerDmitri Gribenko <gribozavr@gmail.com>
Thu, 10 Oct 2019 14:26:54 +0000 (14:26 +0000)
This reverts commit r374343. It broke tests:
http://lab.llvm.org:8011/builders/clang-x86_64-debian-fast/builds/19066

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@374358 91177308-0d34-0410-b5e6-96231b3b80d8

test/tools/llvm-objcopy/ELF/basic-binary-copy.test
test/tools/llvm-objcopy/ELF/binary-no-paddr.test
test/tools/llvm-objcopy/ELF/binary-paddr.test
test/tools/llvm-objcopy/ELF/binary-segment-layout.test
test/tools/llvm-objcopy/ELF/check-addr-offset-align-binary.test
test/tools/llvm-objcopy/ELF/dump-section.test
test/tools/llvm-objcopy/ELF/preserve-segment-contents.test
test/tools/llvm-objcopy/ELF/strip-all-gnu.test
test/tools/llvm-objcopy/ELF/strip-sections.test
test/tools/yaml2obj/elf-override-shoffset.yaml
test/tools/yaml2obj/elf-override-shsize.yaml

index d6659e1fb368ac9f442e5a9b576bfd4576bc1b4c..5808f1aadf3fb2669b8adc7c0a3c55bf87e0e74c 100644 (file)
@@ -1,25 +1,25 @@
-# RUN: yaml2obj %s -o %t\r
-# RUN: llvm-objcopy -O binary %t %t2\r
-# RUN: od -t x2 -v %t2 | FileCheck %s --ignore-case\r
-# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE\r
-\r
-!ELF\r
-FileHeader:\r
-  Class:           ELFCLASS64\r
-  Data:            ELFDATA2LSB\r
-  Type:            ET_EXEC\r
-  Machine:         EM_X86_64\r
-Sections:\r
-  - Name:            .text\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    AddressAlign:    0x0000000000001000\r
-    Content:         "c3c3c3c3"\r
-ProgramHeaders:\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_X, PF_R ]\r
-    Sections:\r
-      - Section: .text\r
-\r
-# CHECK: 0000000 c3c3 c3c3\r
-# SIZE:  4\r
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy -O binary %t %t2
+# RUN: od -t x2 -v %t2 | FileCheck %s
+# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x0000000000001000
+    Content:         "c3c3c3c3"
+ProgramHeaders:
+  - Type: PT_LOAD
+    Flags: [ PF_X, PF_R ]
+    Sections:
+      - Section: .text
+
+# CHECK: 0000000 c3c3 c3c3
+# SIZE:  4
index 065861df9f2ba99e686ed6f99af952bc5bc49590..4d2fba889c965f77a6dbbda2f99298b40ec6ab98 100644 (file)
@@ -1,42 +1,42 @@
-# RUN: yaml2obj %s -o %t\r
-# RUN: llvm-objcopy -O binary %t %t2\r
-# RUN: od -t x2 -v %t2 | FileCheck %s --ignore-case\r
-# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE\r
-\r
-!ELF\r
-FileHeader:\r
-  Class:           ELFCLASS64\r
-  Data:            ELFDATA2LSB\r
-  Type:            ET_EXEC\r
-  Machine:         EM_X86_64\r
-Sections:\r
-  - Name:            .text\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    Address:         0x1000\r
-    AddressAlign:    0x0000000000001000\r
-    Content:         "c3c3c3c3"\r
-  - Name:            .data\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC ]\r
-    Address:         0x1004\r
-    AddressAlign:    0x0000000000000004\r
-    Content:         "3232"\r
-ProgramHeaders:\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_X, PF_R ]\r
-    VAddr: 0x1000\r
-    PAddr: 0x0000\r
-    Align: 0x1000\r
-    Sections:\r
-      - Section: .text\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_R, PF_W ]\r
-    VAddr: 0x1004\r
-    PAddr: 0x0000\r
-    Align: 0x1000\r
-    Sections:\r
-      - Section: .data\r
-\r
-# CHECK: 0000000 c3c3 c3c3 3232\r
-# SIZE:  6\r
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy -O binary %t %t2
+# RUN: od -t x2 -v %t2 | FileCheck %s
+# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x1000
+    AddressAlign:    0x0000000000001000
+    Content:         "c3c3c3c3"
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x1004
+    AddressAlign:    0x0000000000000004
+    Content:         "3232"
+ProgramHeaders:
+  - Type: PT_LOAD
+    Flags: [ PF_X, PF_R ]
+    VAddr: 0x1000
+    PAddr: 0x0000
+    Align: 0x1000
+    Sections:
+      - Section: .text
+  - Type: PT_LOAD
+    Flags: [ PF_R, PF_W ]
+    VAddr: 0x1004
+    PAddr: 0x0000
+    Align: 0x1000
+    Sections:
+      - Section: .data
+
+# CHECK: 0000000 c3c3 c3c3 3232
+# SIZE:  6
index 377cc96fda8ebb6e6c2f0e734f65e061fc837701..8bd7c1867a006b38f8fafe201a9df392da65b85f 100644 (file)
@@ -1,45 +1,45 @@
-# RUN: yaml2obj %s -o %t\r
-# RUN: llvm-objcopy -O binary %t %t2\r
-# RUN: od -t x2 %t2 | FileCheck %s --ignore-case\r
-# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE\r
-\r
-!ELF\r
-FileHeader:\r
-  Class:           ELFCLASS64\r
-  Data:            ELFDATA2LSB\r
-  Type:            ET_EXEC\r
-  Machine:         EM_X86_64\r
-Sections:\r
-  - Name:            .text\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    Address:         0x1000\r
-    AddressAlign:    0x0000000000001000\r
-    Content:         "c3c3c3c3"\r
-  - Name:            .data\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC ]\r
-    Address:         0x2000\r
-    AddressAlign:    0x0000000000001000\r
-    Content:         "3232"\r
-ProgramHeaders:\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_X, PF_R ]\r
-    VAddr: 0x1000\r
-    PAddr: 0x1000\r
-    Align: 0x1000\r
-    Sections:\r
-      - Section: .text\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_R, PF_W ]\r
-    VAddr: 0x2000\r
-    PAddr: 0x4000\r
-    Align: 0x1000\r
-    Sections:\r
-      - Section: .data\r
-\r
-# CHECK:       0000000 c3c3 c3c3 0000 0000 0000 0000 0000 0000\r
-# CHECK-NEXT:  0000020 0000 0000 0000 0000 0000 0000 0000 0000\r
-# CHECK-NEXT:  *\r
-# CHECK-NEXT:  0030000 3232\r
-# SIZE:        12290\r
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy -O binary %t %t2
+# RUN: od -t x2 %t2 | FileCheck %s
+# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x1000
+    AddressAlign:    0x0000000000001000
+    Content:         "c3c3c3c3"
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x2000
+    AddressAlign:    0x0000000000001000
+    Content:         "3232"
+ProgramHeaders:
+  - Type: PT_LOAD
+    Flags: [ PF_X, PF_R ]
+    VAddr: 0x1000
+    PAddr: 0x1000
+    Align: 0x1000
+    Sections:
+      - Section: .text
+  - Type: PT_LOAD
+    Flags: [ PF_R, PF_W ]
+    VAddr: 0x2000
+    PAddr: 0x4000
+    Align: 0x1000
+    Sections:
+      - Section: .data
+
+# CHECK:       0000000 c3c3 c3c3 0000 0000 0000 0000 0000 0000
+# CHECK-NEXT:  0000020 0000 0000 0000 0000 0000 0000 0000 0000
+# CHECK-NEXT:  *
+# CHECK-NEXT:  0030000 3232
+# SIZE:        12290
index 9687ba57a3b2fc9a163f9ca82b026c7bf23a4ea4..f38215f7d5e6aed41c185604731238c5080415e7 100644 (file)
@@ -1,38 +1,38 @@
-# RUN: yaml2obj %s -o %t\r
-# RUN: llvm-objcopy -O binary %t %t2\r
-# RUN: od -t x2 %t2 | FileCheck %s --ignore-case\r
-# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE\r
-\r
-!ELF\r
-FileHeader:\r
-  Class:           ELFCLASS64\r
-  Data:            ELFDATA2LSB\r
-  Type:            ET_EXEC\r
-  Machine:         EM_X86_64\r
-Sections:\r
-  - Name:            .text\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    AddressAlign:    0x0000000000001000\r
-    Address:         0x00\r
-    Content:         "c3c3c3c3"\r
-  - Name:            .data\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    AddressAlign:    0x0000000000000008\r
-    Address:         0x08\r
-    Content:         "3232"\r
-ProgramHeaders:\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_X, PF_R ]\r
-    VAddr: 0x00\r
-    Sections:\r
-      - Section: .text\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_R ]\r
-    VAddr: 0x08\r
-    Sections:\r
-      - Section: .data\r
-\r
-# CHECK:       0000000 c3c3 c3c3 0000 0000 3232\r
-# SIZE:        10\r
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy -O binary %t %t2
+# RUN: od -t x2 %t2 | FileCheck %s
+# RUN: wc -c < %t2 | FileCheck %s --check-prefix=SIZE
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x0000000000001000
+    Address:         0x00
+    Content:         "c3c3c3c3"
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x0000000000000008
+    Address:         0x08
+    Content:         "3232"
+ProgramHeaders:
+  - Type: PT_LOAD
+    Flags: [ PF_X, PF_R ]
+    VAddr: 0x00
+    Sections:
+      - Section: .text
+  - Type: PT_LOAD
+    Flags: [ PF_R ]
+    VAddr: 0x08
+    Sections:
+      - Section: .data
+
+# CHECK:       0000000 c3c3 c3c3 0000 0000 3232
+# SIZE:        10
index 6bc9ccd40fca6ac1d74cd99bbcad38e714e10ac6..755acceeda2ce8a213e8801a9c0133dc37d7d950 100644 (file)
@@ -1,40 +1,40 @@
-# RUN: yaml2obj %s -o %t\r
-# RUN: llvm-objcopy -O binary %t %t2\r
-# RUN: od -t x1 %t2 | FileCheck %s --ignore-case\r
-\r
-!ELF\r
-FileHeader:\r
-  Class:           ELFCLASS64\r
-  Data:            ELFDATA2LSB\r
-  Type:            ET_EXEC\r
-  Machine:         EM_X86_64\r
-Sections:\r
-  - Name:            .text\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    Address:         0x1000\r
-    AddressAlign:    0x0000000000001000\r
-    Content:         "c3c3c3c3"\r
-  - Name:            .data\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC ]\r
-    Address:         0x1008\r
-    AddressAlign:    0x0000000000000008\r
-    Content:         "3232"\r
-ProgramHeaders:\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_X, PF_R ]\r
-    VAddr: 0x1000\r
-    PAddr: 0x1000\r
-    Align: 0x1000\r
-    Sections:\r
-      - Section: .text\r
-  - Type: PT_LOAD\r
-    Flags: [ PF_R, PF_W ]\r
-    VAddr: 0x1008\r
-    PAddr: 0x1008\r
-    Align: 0x1000\r
-    Sections:\r
-      - Section: .data\r
-\r
-# CHECK: 0000000 c3 c3 c3 c3 00 00 00 00 32 32\r
+# RUN: yaml2obj %s -o %t
+# RUN: llvm-objcopy -O binary %t %t2
+# RUN: od -t x1 %t2 | FileCheck %s
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Address:         0x1000
+    AddressAlign:    0x0000000000001000
+    Content:         "c3c3c3c3"
+  - Name:            .data
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    Address:         0x1008
+    AddressAlign:    0x0000000000000008
+    Content:         "3232"
+ProgramHeaders:
+  - Type: PT_LOAD
+    Flags: [ PF_X, PF_R ]
+    VAddr: 0x1000
+    PAddr: 0x1000
+    Align: 0x1000
+    Sections:
+      - Section: .text
+  - Type: PT_LOAD
+    Flags: [ PF_R, PF_W ]
+    VAddr: 0x1008
+    PAddr: 0x1008
+    Align: 0x1000
+    Sections:
+      - Section: .data
+
+# CHECK: 0000000 c3 c3 c3 c3 00 00 00 00 32 32
index 941ea03bb4e3a4c709ef597e52ae828312fbe528..ed46c3061ddda2aa54a4483957812a452eb3aaa8 100644 (file)
@@ -1,44 +1,44 @@
-# RUN: yaml2obj %s > %t\r
-# RUN: llvm-objcopy -O binary -j .text %t %t2\r
-# RUN: llvm-objcopy -O binary --only-section .text %t %t3\r
-# RUN: llvm-objcopy --dump-section .text=%t4 %t %t5\r
-# RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7\r
-# RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS -DINPUT=%t\r
-# RUN: od -t x1 %t2 | FileCheck %s --ignore-case\r
-# RUN: od -t x1 %t6 | FileCheck %s --ignore-case --check-prefix=NON-ALLOC\r
-# RUN: wc -c %t2 | FileCheck %s --check-prefix=SIZE\r
-# RUN: diff %t2 %t3\r
-# RUN: diff %t4 %t3\r
-\r
-!ELF\r
-FileHeader:\r
-  Class:           ELFCLASS64\r
-  Data:            ELFDATA2LSB\r
-  Type:            ET_EXEC\r
-  Machine:         EM_X86_64\r
-Sections:\r
-  - Name:            .text\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    AddressAlign:    0x0000000000001000\r
-    Content:         "DEADBEEF"\r
-  - Name:            .foo\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_WRITE ]\r
-    Content:         "CAFE"\r
-  - Name:            .bar\r
-    Type:            SHT_NOBITS\r
-    Flags:           [ SHF_WRITE ]\r
-ProgramHeaders:\r
-- Type: PT_LOAD\r
-  Flags: [ PF_X, PF_R ]\r
-  Sections:\r
-    - Section: .text\r
-\r
-#CHECK: 0000000 de ad be ef\r
-\r
-#NON-ALLOC: 0000000 ca fe\r
-\r
-#SIZE: 4\r
-\r
-#NOBITS: error: '[[INPUT]]': cannot dump section '.bar': it has no contents\r
+# RUN: yaml2obj %s > %t
+# RUN: llvm-objcopy -O binary -j .text %t %t2
+# RUN: llvm-objcopy -O binary --only-section .text %t %t3
+# RUN: llvm-objcopy --dump-section .text=%t4 %t %t5
+# RUN: llvm-objcopy --dump-section .foo=%t6 %t %t7
+# RUN: not llvm-objcopy --dump-section .bar=%t8 %t %t9 2>&1 | FileCheck %s --check-prefix=NOBITS -DINPUT=%t
+# RUN: od -t x1 %t2 | FileCheck %s
+# RUN: od -t x1 %t6 | FileCheck %s --check-prefix=NON-ALLOC
+# RUN: wc -c %t2 | FileCheck %s --check-prefix=SIZE
+# RUN: diff %t2 %t3
+# RUN: diff %t4 %t3
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x0000000000001000
+    Content:         "DEADBEEF"
+  - Name:            .foo
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_WRITE ]
+    Content:         "CAFE"
+  - Name:            .bar
+    Type:            SHT_NOBITS
+    Flags:           [ SHF_WRITE ]
+ProgramHeaders:
+- Type: PT_LOAD
+  Flags: [ PF_X, PF_R ]
+  Sections:
+    - Section: .text
+
+#CHECK: 0000000 de ad be ef
+
+#NON-ALLOC: 0000000 ca fe
+
+#SIZE: 4
+
+#NOBITS: error: '[[INPUT]]': cannot dump section '.bar': it has no contents
index d110d4d26f234e18cee94026b195c06a59bd7aa9..2f9b2f3c7db7cedd05dfffb79199aef477cdf609 100644 (file)
-# We want to preserve areas in segments that are not covered by section headers.\r
-# This test shows that we do this for areas at the start of a segment, between\r
-# sections in a segment, and after all sections in a segment.\r
-# To create inputs with arbitrary data in segments, not covered by sections, we\r
-# use yaml2obj to create segments with sections covering all areas, then remove\r
-# some sections in those segments, and finally write over the areas of the\r
-# removed sections using python.\r
-\r
-# blob* sections are the sections that will be removed to create unlabelled\r
-# areas and then overwritten with data to show we preserve the data.\r
-\r
-# RUN: yaml2obj %s -o %t.base\r
-# RUN: llvm-objcopy %t.base %t.stripped --regex -R blob.*\r
-# Show that the removal leaves the bytes as zeroes, as desired, for all our\r
-# test cases.\r
-# RUN: od -t x1 -j 0x2000 -N 24 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK1 -DPATTERN="00 00 00 00"\r
-# RUN: od -t x1 -j 0x2100 -N 12 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK2 -DPATTERN="00 00 00 00"\r
-# RUN: od -t x1 -j 0x2200 -N 4  %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK3 -DPATTERN="00 00 00 00"\r
-# RUN: od -t x1 -j 0x2300 -N 12 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK4 -DPATTERN="00 00 00 00"\r
-# RUN: od -t x1 -j 0x3000 -N 68 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK5 -DPATTERN="00 00 00 00"\r
-# RUN: od -t x1 -j 0x4000 -N 60 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK6 -DPATTERN="00 00 00 00"\r
-# RUN: od -t x1 -j 0x5000 -N 60 %t.stripped | FileCheck %s --ignore-case --check-prefix=CHECK7 -DPATTERN="00 00 00 00"\r
-\r
-# RUN: cp %t.stripped %t.in\r
-# RUN: echo "with open('%/t.in', 'rb+') as input:"                                 > %t.py\r
-# RUN: echo "  for offset in ["                                                   >> %t.py\r
-# RUN: echo "   0x2000, 0x2008, 0x200C, 0x2014, 0x2104, 0x2300,"                  >> %t.py\r
-# RUN: echo "   0x3008, 0x3010, 0x3018, 0x3020, 0x3028, 0x302C, 0x3034, 0x303C,"  >> %t.py\r
-# RUN: echo "   0x4000, 0x4008, 0x4010, 0x4014, 0x401C, 0x4024, 0x4034,"          >> %t.py\r
-# RUN: echo "   0x5000, 0x5008, 0x5010, 0x501C, 0x5024, 0x502C, 0x5030, 0x5038]:" >> %t.py\r
-# RUN: echo "    input.seek(offset)"                                              >> %t.py\r
-# RUN: echo "    input.write(bytearray.fromhex('DEADBEEF'))"                      >> %t.py\r
-# RUN: %python %t.py\r
-# RUN: llvm-objcopy %t.in %t.out\r
-# RUN: od -t x1 -j 0x2000 -N 24 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK1 -DPATTERN="de ad be ef"\r
-# RUN: od -t x1 -j 0x2100 -N 12 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK2 -DPATTERN="de ad be ef"\r
-# RUN: od -t x1 -j 0x2200 -N 4  %t.out | FileCheck %s --ignore-case --check-prefix=CHECK3 -DPATTERN="de ad be ef"\r
-# RUN: od -t x1 -j 0x2300 -N 12 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK4 -DPATTERN="de ad be ef"\r
-# RUN: od -t x1 -j 0x3000 -N 68 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK5 -DPATTERN="de ad be ef"\r
-# RUN: od -t x1 -j 0x4000 -N 60 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK6 -DPATTERN="de ad be ef"\r
-# RUN: od -t x1 -j 0x5000 -N 60 %t.out | FileCheck %s --ignore-case --check-prefix=CHECK7 -DPATTERN="de ad be ef"\r
-\r
-# CHECK1:      [[PATTERN]] 11 22 33 44 [[PATTERN]] [[PATTERN]]\r
-# CHECK1-NEXT: 55 66 77 88 [[PATTERN]]\r
-# CHECK2:      99 00 aa bb [[PATTERN]] cc dd ee ff\r
-# CHECK3:      fe fe fe fe\r
-# CHECK4:      [[PATTERN]] 00 00 00 00 00 00 00 00\r
-# CHECK5:      ff ff ee ee dd dd cc cc [[PATTERN]] bb bb aa aa\r
-# CHECK5-NEXT: [[PATTERN]] 00 00 99 99 [[PATTERN]] 88 88 77 77\r
-# CHECK5-NEXT: [[PATTERN]] 66 66 55 55 [[PATTERN]] [[PATTERN]]\r
-# CHECK5-NEXT: 44 44 33 33 [[PATTERN]] 22 22 11 11 [[PATTERN]]\r
-# CHECK5-NEXT: 00 11 22 33\r
-# CHECK6:      [[PATTERN]] 44 55 66 77 [[PATTERN]] 88 99 aa bb\r
-# CHECK6-NEXT: [[PATTERN]] [[PATTERN]] cc dd ee ff [[PATTERN]]\r
-# CHECK6-NEXT: ff ee dd cc [[PATTERN]] bb aa 99 88 77 66 55 44\r
-# CHECK6-NEXT: 33 22 11 00 [[PATTERN]] 11 11 11 11\r
-# CHECK7:      [[PATTERN]] 12 34 56 78 [[PATTERN]] 90 ab cd ef\r
-# CHECK7-NEXT: [[PATTERN]] fe dc ba 09 87 65 43 21 [[PATTERN]]\r
-# CHECK7-NEXT: 22 22 22 22 [[PATTERN]] 33 33 33 33 [[PATTERN]]\r
-# CHECK7-NEXT: [[PATTERN]] 44 44 44 44 [[PATTERN]]\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_EXEC\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: blob1\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x2000\r
-    AddressAlign: 0x2000\r
-  - Name: section1\r
-    Type: SHT_PROGBITS\r
-    Address: 0x2004\r
-    Content: '11223344'\r
-  - Name: blob2\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x2008\r
-  - Name: section2\r
-    Type: SHT_NOBITS\r
-    Size: 4\r
-    Address: 0x200C\r
-  - Name: blob3\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x2010\r
-  - Name: section3\r
-    Type: SHT_PROGBITS\r
-    Content: '55667788'\r
-    Address: 0x2014\r
-  - Name: blob4\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x2018\r
-  - Name: section4\r
-    Type: SHT_PROGBITS\r
-    Content: '9900aabb'\r
-    Address: 0x2100\r
-    AddressAlign: 0x100\r
-  - Name: blob5\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x2104\r
-  - Name: section5\r
-    Type: SHT_PROGBITS\r
-    Address: 0x2108\r
-    Content: 'ccddeeff'\r
-  - Name: section6\r
-    Type: SHT_PROGBITS\r
-    Content: 'fefefefe'\r
-    Address: 0x2200\r
-    AddressAlign: 0x100\r
-  - Name: blob6\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x2300\r
-    AddressAlign: 0x100\r
-  - Name: sectionA\r
-    Type: SHT_PROGBITS\r
-    Content: 'ffffeeee'\r
-    Address: 0x3000\r
-    AddressAlign: 0x1000\r
-  - Name: sectionB\r
-    Type: SHT_PROGBITS\r
-    Content: 'ddddcccc'\r
-    Address: 0x3004\r
-  - Name: blobA\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x3008\r
-  - Name: sectionC\r
-    Type: SHT_PROGBITS\r
-    Content: 'bbbbaaaa'\r
-    Address: 0x300C\r
-  - Name: blobB\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x3010\r
-  - Name: sectionD\r
-    Type: SHT_PROGBITS\r
-    Content: '00009999'\r
-    Address: 0x3014\r
-  - Name: blobC\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x3018\r
-  - Name: sectionE\r
-    Type: SHT_PROGBITS\r
-    Content: '88887777'\r
-    Address: 0x301C\r
-  - Name: blobD\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x3020\r
-  - Name: sectionF\r
-    Type: SHT_PROGBITS\r
-    Content: '66665555'\r
-    Address: 0x3024\r
-  - Name: blobE\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x3028\r
-  - Name: blobF\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x302C\r
-  - Name: sectionG\r
-    Type: SHT_PROGBITS\r
-    Content: '44443333'\r
-    Address: 0x3030\r
-  - Name: blobG\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x3034\r
-  - Name: sectionH\r
-    Type: SHT_PROGBITS\r
-    Content: '22221111'\r
-    Address: 0x3038\r
-  - Name: blobH\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x303C\r
-  - Name: sectionI\r
-    Type: SHT_PROGBITS\r
-    Content: '00112233'\r
-    Address: 0x3040\r
-  - Name: blobz\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x4000\r
-    AddressAlign: 0x1000\r
-  - Name: sectionz\r
-    Type: SHT_PROGBITS\r
-    Content: '44556677'\r
-    Address: 0x4004\r
-  - Name: bloby\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x4008\r
-  - Name: sectiony\r
-    Type: SHT_PROGBITS\r
-    Content: '8899aabb'\r
-    Address: 0x400C\r
-  - Name: blobx\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x4010\r
-  - Name: blobw\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x4014\r
-  - Name: sectionx\r
-    Type: SHT_PROGBITS\r
-    Content: 'ccddeeff'\r
-    Address: 0x4018\r
-  - Name: blobv\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x401C\r
-  - Name: sectionw\r
-    Type: SHT_PROGBITS\r
-    Content: 'ffeeddcc'\r
-    Address: 0x4020\r
-  - Name: blobu\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x4024\r
-  - Name: sectionv\r
-    Type: SHT_PROGBITS\r
-    Content: 'bbaa9988'\r
-    Address: 0x4028\r
-  - Name: sectionu\r
-    Type: SHT_PROGBITS\r
-    Content: '77665544'\r
-    Address: 0x402C\r
-  - Name: sectiont\r
-    Type: SHT_PROGBITS\r
-    Content: '33221100'\r
-    Address: 0x4030\r
-  - Name: blobt\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x4034\r
-  - Name: sections\r
-    Type: SHT_PROGBITS\r
-    Content: '11111111'\r
-    Address: 0x4038\r
-  - Name: bloba\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x5000\r
-    AddressAlign: 0x1000\r
-  - Name: sectiona\r
-    Type: SHT_PROGBITS\r
-    Content: '12345678'\r
-    Address: 0x5004\r
-  - Name: blobb\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x5008\r
-  - Name: sectionb\r
-    Type: SHT_PROGBITS\r
-    Content: '90abcdef'\r
-    Address: 0x500C\r
-  - Name: blobc\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x5010\r
-  - Name: sectionc\r
-    Type: SHT_PROGBITS\r
-    Content: 'fedcba09'\r
-    Address: 0x5014\r
-  - Name: sectiond\r
-    Type: SHT_PROGBITS\r
-    Content: '87654321'\r
-    Address: 0x5018\r
-  - Name: blobd\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x501C\r
-  - Name: sectione\r
-    Type: SHT_PROGBITS\r
-    Content: '22222222'\r
-    Address: 0x5020\r
-  - Name: blobe\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x5024\r
-  - Name: sectionf\r
-    Type: SHT_PROGBITS\r
-    Content: '33333333'\r
-    Address: 0x5028\r
-  - Name: blobf\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x502C\r
-  - Name: blobg\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x5030\r
-  - Name: sectiong\r
-    Type: SHT_PROGBITS\r
-    Content: '44444444'\r
-    Address: 0x5034\r
-  - Name: blobh\r
-    Type: SHT_PROGBITS\r
-    Content: 'abbababa'\r
-    Address: 0x5038\r
-ProgramHeaders:\r
-  # First segment has unlabelled space at start and end.\r
-  - Type:  0x6ABCDEF0 # Non-specific segment type.\r
-    VAddr: 0x2000\r
-    PAddr: 0x2000\r
-    Align: 0x2000\r
-    Sections:\r
-      - Section: blob1\r
-      - Section: section1\r
-      - Section: blob2\r
-      - Section: section2 # nobits\r
-      - Section: blob3\r
-      - Section: section3\r
-      - Section: blob4\r
-  # Second segment has sections at start and end.\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x2100\r
-    PAddr: 0x2100\r
-    Align: 0x100\r
-    Sections:\r
-      - Section: section4\r
-      - Section: blob5\r
-      - Section: section5\r
-  # Third segment is all covered by a section.\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x2200\r
-    PAddr: 0x2200\r
-    Align: 0x100\r
-    Sections:\r
-      - Section: section6\r
-  # Fourth segment has no sections (after removing blob headers).\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x2300\r
-    PAddr: 0x2300\r
-    Align: 0x100\r
-    Sections:\r
-      - Section: blob6\r
-  # Fifth segment is empty.\r
-  - Type:   0x6ABCDEF0\r
-    VAddr:  0x2308\r
-    PAddr:  0x2308\r
-    Offset: 0x2308\r
-\r
-  # The next few segments test behaviour of fully nested segments.\r
-  # Sixth segment is the "parent" segment.\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x3000\r
-    PAddr: 0x3000\r
-    Align: 0x1000\r
-    Sections:\r
-      - Section: sectionA\r
-      - Section: sectionB\r
-      - Section: blobA\r
-      - Section: sectionC\r
-      - Section: blobB\r
-      - Section: sectionD\r
-      - Section: blobC\r
-      - Section: sectionE\r
-      - Section: blobD\r
-      - Section: sectionF\r
-      - Section: blobE\r
-      - Section: blobF\r
-      - Section: sectionG\r
-      - Section: blobG\r
-      - Section: sectionH\r
-      - Section: blobH\r
-      - Section: sectionI\r
-  # Seventh segment is empty and nested.\r
-  - Type:   0x6ABCDEF0\r
-    VAddr:  0x3002\r
-    PAddr:  0x3002\r
-    Offset: 0x3002\r
-  # Eighth segment contains only a section and is nested.\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x3004\r
-    PAddr: 0x3004\r
-    Sections:\r
-      - Section: sectionB\r
-  # Ninth segment contains only unlabelled space and is nested.\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x3008\r
-    PAddr: 0x3008\r
-    Sections:\r
-      - Section: blobA\r
-  # Tenth segment contains two sections with space between and is nested.\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x300C\r
-    PAddr: 0x300C\r
-    Sections:\r
-      - Section: sectionC\r
-      - Section: blobB\r
-      - Section: sectionD\r
-  # Eleventh segment contains two sections with space between and at ends and is nested.\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x3018\r
-    PAddr: 0x3018\r
-    Sections:\r
-      - Section: blobC\r
-      - Section: sectionE\r
-      - Section: blobD\r
-      - Section: sectionF\r
-      - Section: blobE\r
-  # Twelfth segment contains one section with space at ends adjacent to space in parent segment.\r
-  - Type:     0x6ABCDEF0\r
-    VAddr:    0x302E\r
-    PAddr:    0x302E\r
-    Offset:   0x302E\r
-    FileSize: 8\r
-    Sections:\r
-      - Section: sectionG\r
-  # Thirteenth segment contains overlaps sections at either end in parent segment.\r
-  - Type:     0x6ABCDEF0\r
-    VAddr:    0x303A\r
-    PAddr:    0x303A\r
-    Offset:   0x303A\r
-    FileSize: 0x8\r
-    Sections:\r
-      - Section: blobH\r
-\r
-  # The next batch of segments are segments that only partially overlap other segments.\r
-\r
-  # Segment14: |-unlabelled-|-Sec-|\r
-  # Segment15:           |--|-Sec-|-unlabelled-|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x4000\r
-    PAddr: 0x4000\r
-    Sections:\r
-      - Section: blobz\r
-      - Section: sectionz\r
-  - Type:   0x6ABCDEF0\r
-    VAddr:  0x4002\r
-    PAddr:  0x4002\r
-    Offset: 0x4002\r
-    Sections:\r
-      - Section: sectionz\r
-      - Section: bloby\r
-\r
-  # Segment16: |-Sec-|--|\r
-  # Segment17:    |--|----unlabelled---|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x400C\r
-    PAddr: 0x400C\r
-    FileSize: 6\r
-    Sections:\r
-      - Section: sectiony\r
-  - Type:   0x6ABCDEF0\r
-    VAddr:  0x400E\r
-    PAddr:  0x400E\r
-    Offset: 0x400E\r
-    Sections:\r
-      - Section: blobx\r
-\r
-  # Segment18: |-unlabelled-|-Sec-|\r
-  # Segment19:              |-Sec-|-unlabelled-|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x4014\r
-    PAddr: 0x4014\r
-    Sections:\r
-      - Section: blobw\r
-      - Section: sectionx\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x4018\r
-    PAddr: 0x4018\r
-    Sections:\r
-      - Section: sectionx\r
-      - Section: blobv\r
-\r
-  # Segment20: |-Sec-|\r
-  # Segment21:    |--|-unlabelled-|-Sec-|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x4020\r
-    PAddr: 0x4020\r
-    Sections:\r
-      - Section: sectionw\r
-  - Type:   0x6ABCDEF0\r
-    VAddr:  0x4022\r
-    PAddr:  0x4022\r
-    Offset: 0x4022\r
-    Sections:\r
-      - Section: blobu\r
-      - Section: sectionv\r
-\r
-  # Segment22: |-Sec-|\r
-  # Segment23:    |--|-Sec-|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x402C\r
-    PAddr: 0x402C\r
-    Sections:\r
-      - Section: sectionu\r
-  - Type:   0x6ABCDEF0\r
-    VAddr:  0x402E\r
-    PAddr:  0x402E\r
-    Offset: 0x402E\r
-    Sections:\r
-      - Section: sectiont\r
-\r
-  # Segment24: |-unlabelled-|--|\r
-  # Segment25:              |--Sec--|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x4034\r
-    PAddr: 0x4034\r
-    FileSize: 6\r
-    Sections:\r
-      - Section: blobt\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x4038\r
-    PAddr: 0x4038\r
-    Sections:\r
-      - Section: sections\r
-\r
-  # The next batch of segments represent groups of three nested/overlapping segments,\r
-  # with one parent segment containing two overlapping segments.\r
-\r
-  # Segment26: |-unlabelled-|-Sec-|-unlabelled-|\r
-  # Segment27: |------------|--|\r
-  # Segment28:              |-Sec-|------------|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5000\r
-    PAddr: 0x5000\r
-    Align: 0x1000\r
-    Sections:\r
-      - Section: bloba\r
-      - Section: sectiona\r
-      - Section: blobb\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5000\r
-    PAddr: 0x5000\r
-    FileSize: 6\r
-    Sections:\r
-      - Section: bloba\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5004\r
-    PAddr: 0x5004\r
-    Sections:\r
-      - Section: sectiona\r
-      - Section: blobb\r
-\r
-  # Segment29: |-Sec-|-unlabelled-|-Sec-|\r
-  # Segment30: |-Sec-|--------|\r
-  # Segment31:          |---------|-Sec-|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x500C\r
-    PAddr: 0x500C\r
-    Sections:\r
-      - Section: sectionb\r
-      - Section: blobc\r
-      - Section: sectionc\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x500C\r
-    PAddr: 0x500C\r
-    FileSize: 7\r
-    Sections:\r
-      - Section: sectionb\r
-  - Type:   0x6ABCDEF0\r
-    VAddr:  0x5011\r
-    PAddr:  0x5011\r
-    Offset: 0x5011\r
-    Sections:\r
-      - Section: sectionc\r
-\r
-  # Segment32: |-Sec-|-unlabelled-|-Sec-|\r
-  # Segment33: |-Sec-|------------|\r
-  # Segment34:       |------------|-Sec-|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5018\r
-    PAddr: 0x5018\r
-    Sections:\r
-      - Section: sectiond\r
-      - Section: blobd\r
-      - Section: sectione\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5018\r
-    PAddr: 0x5018\r
-    Sections:\r
-      - Section: sectiond\r
-      - Section: blobd\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x501C\r
-    PAddr: 0x501C\r
-    Sections:\r
-      - Section: blobd\r
-      - Section: sectione\r
-\r
-  # Segment35: |-unlabelled-|-Sec-|-unlabelled-|\r
-  # Segment36: |------------|-Sec-|\r
-  # Segment37:              |-Sec-|------------|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5024\r
-    PAddr: 0x5024\r
-    Sections:\r
-      - Section: blobe\r
-      - Section: sectionf\r
-      - Section: blobf\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5024\r
-    PAddr: 0x5024\r
-    Sections:\r
-      - Section: blobe\r
-      - Section: sectionf\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5028\r
-    PAddr: 0x5028\r
-    Sections:\r
-      - Section: sectionf\r
-      - Section: blobf\r
-\r
-  # Segment38: |-unlabelled-|-Sec-|-unlabelled-|\r
-  # Segment39: |------------|---|\r
-  # Segment40:                |---|------------|\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5030\r
-    PAddr: 0x5030\r
-    Sections:\r
-      - Section: blobg\r
-      - Section: sectiong\r
-      - Section: blobh\r
-  - Type:  0x6ABCDEF0\r
-    VAddr: 0x5030\r
-    PAddr: 0x5030\r
-    FileSize: 7\r
-    Sections:\r
-      - Section: blobg\r
-  - Type:   0x6ABCDEF0\r
-    VAddr:  0x5035\r
-    PAddr:  0x5035\r
-    Offset: 0x5035\r
-    Sections:\r
-      - Section: blobh\r
+# We want to preserve areas in segments that are not covered by section headers.
+# This test shows that we do this for areas at the start of a segment, between
+# sections in a segment, and after all sections in a segment.
+# To create inputs with arbitrary data in segments, not covered by sections, we
+# use yaml2obj to create segments with sections covering all areas, then remove
+# some sections in those segments, and finally write over the areas of the
+# removed sections using python.
+
+# blob* sections are the sections that will be removed to create unlabelled
+# areas and then overwritten with data to show we preserve the data.
+
+# RUN: yaml2obj %s -o %t.base
+# RUN: llvm-objcopy %t.base %t.stripped --regex -R blob.*
+# Show that the removal leaves the bytes as zeroes, as desired, for all our
+# test cases.
+# RUN: od -t x1 -j 0x2000 -N 24 %t.stripped | FileCheck %s --check-prefix=CHECK1 -DPATTERN="00 00 00 00"
+# RUN: od -t x1 -j 0x2100 -N 12 %t.stripped | FileCheck %s --check-prefix=CHECK2 -DPATTERN="00 00 00 00"
+# RUN: od -t x1 -j 0x2200 -N 4  %t.stripped | FileCheck %s --check-prefix=CHECK3 -DPATTERN="00 00 00 00"
+# RUN: od -t x1 -j 0x2300 -N 12 %t.stripped | FileCheck %s --check-prefix=CHECK4 -DPATTERN="00 00 00 00"
+# RUN: od -t x1 -j 0x3000 -N 68 %t.stripped | FileCheck %s --check-prefix=CHECK5 -DPATTERN="00 00 00 00"
+# RUN: od -t x1 -j 0x4000 -N 60 %t.stripped | FileCheck %s --check-prefix=CHECK6 -DPATTERN="00 00 00 00"
+# RUN: od -t x1 -j 0x5000 -N 60 %t.stripped | FileCheck %s --check-prefix=CHECK7 -DPATTERN="00 00 00 00"
+
+# RUN: cp %t.stripped %t.in
+# RUN: echo "with open('%/t.in', 'rb+') as input:"                                 > %t.py
+# RUN: echo "  for offset in ["                                                   >> %t.py
+# RUN: echo "   0x2000, 0x2008, 0x200C, 0x2014, 0x2104, 0x2300,"                  >> %t.py
+# RUN: echo "   0x3008, 0x3010, 0x3018, 0x3020, 0x3028, 0x302C, 0x3034, 0x303C,"  >> %t.py
+# RUN: echo "   0x4000, 0x4008, 0x4010, 0x4014, 0x401C, 0x4024, 0x4034,"          >> %t.py
+# RUN: echo "   0x5000, 0x5008, 0x5010, 0x501C, 0x5024, 0x502C, 0x5030, 0x5038]:" >> %t.py
+# RUN: echo "    input.seek(offset)"                                              >> %t.py
+# RUN: echo "    input.write(bytearray.fromhex('DEADBEEF'))"                      >> %t.py
+# RUN: %python %t.py
+# RUN: llvm-objcopy %t.in %t.out
+# RUN: od -t x1 -j 0x2000 -N 24 %t.out | FileCheck %s --check-prefix=CHECK1 -DPATTERN="de ad be ef"
+# RUN: od -t x1 -j 0x2100 -N 12 %t.out | FileCheck %s --check-prefix=CHECK2 -DPATTERN="de ad be ef"
+# RUN: od -t x1 -j 0x2200 -N 4  %t.out | FileCheck %s --check-prefix=CHECK3 -DPATTERN="de ad be ef"
+# RUN: od -t x1 -j 0x2300 -N 12 %t.out | FileCheck %s --check-prefix=CHECK4 -DPATTERN="de ad be ef"
+# RUN: od -t x1 -j 0x3000 -N 68 %t.out | FileCheck %s --check-prefix=CHECK5 -DPATTERN="de ad be ef"
+# RUN: od -t x1 -j 0x4000 -N 60 %t.out | FileCheck %s --check-prefix=CHECK6 -DPATTERN="de ad be ef"
+# RUN: od -t x1 -j 0x5000 -N 60 %t.out | FileCheck %s --check-prefix=CHECK7 -DPATTERN="de ad be ef"
+
+# CHECK1:      [[PATTERN]] 11 22 33 44 [[PATTERN]] [[PATTERN]]
+# CHECK1-NEXT: 55 66 77 88 [[PATTERN]]
+# CHECK2:      99 00 aa bb [[PATTERN]] cc dd ee ff
+# CHECK3:      fe fe fe fe
+# CHECK4:      [[PATTERN]] 00 00 00 00 00 00 00 00
+# CHECK5:      ff ff ee ee dd dd cc cc [[PATTERN]] bb bb aa aa
+# CHECK5-NEXT: [[PATTERN]] 00 00 99 99 [[PATTERN]] 88 88 77 77
+# CHECK5-NEXT: [[PATTERN]] 66 66 55 55 [[PATTERN]] [[PATTERN]]
+# CHECK5-NEXT: 44 44 33 33 [[PATTERN]] 22 22 11 11 [[PATTERN]]
+# CHECK5-NEXT: 00 11 22 33
+# CHECK6:      [[PATTERN]] 44 55 66 77 [[PATTERN]] 88 99 aa bb
+# CHECK6-NEXT: [[PATTERN]] [[PATTERN]] cc dd ee ff [[PATTERN]]
+# CHECK6-NEXT: ff ee dd cc [[PATTERN]] bb aa 99 88 77 66 55 44
+# CHECK6-NEXT: 33 22 11 00 [[PATTERN]] 11 11 11 11
+# CHECK7:      [[PATTERN]] 12 34 56 78 [[PATTERN]] 90 ab cd ef
+# CHECK7-NEXT: [[PATTERN]] fe dc ba 09 87 65 43 21 [[PATTERN]]
+# CHECK7-NEXT: 22 22 22 22 [[PATTERN]] 33 33 33 33 [[PATTERN]]
+# CHECK7-NEXT: [[PATTERN]] 44 44 44 44 [[PATTERN]]
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_EXEC
+  Machine: EM_X86_64
+Sections:
+  - Name: blob1
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x2000
+    AddressAlign: 0x2000
+  - Name: section1
+    Type: SHT_PROGBITS
+    Address: 0x2004
+    Content: '11223344'
+  - Name: blob2
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x2008
+  - Name: section2
+    Type: SHT_NOBITS
+    Size: 4
+    Address: 0x200C
+  - Name: blob3
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x2010
+  - Name: section3
+    Type: SHT_PROGBITS
+    Content: '55667788'
+    Address: 0x2014
+  - Name: blob4
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x2018
+  - Name: section4
+    Type: SHT_PROGBITS
+    Content: '9900aabb'
+    Address: 0x2100
+    AddressAlign: 0x100
+  - Name: blob5
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x2104
+  - Name: section5
+    Type: SHT_PROGBITS
+    Address: 0x2108
+    Content: 'ccddeeff'
+  - Name: section6
+    Type: SHT_PROGBITS
+    Content: 'fefefefe'
+    Address: 0x2200
+    AddressAlign: 0x100
+  - Name: blob6
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x2300
+    AddressAlign: 0x100
+  - Name: sectionA
+    Type: SHT_PROGBITS
+    Content: 'ffffeeee'
+    Address: 0x3000
+    AddressAlign: 0x1000
+  - Name: sectionB
+    Type: SHT_PROGBITS
+    Content: 'ddddcccc'
+    Address: 0x3004
+  - Name: blobA
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x3008
+  - Name: sectionC
+    Type: SHT_PROGBITS
+    Content: 'bbbbaaaa'
+    Address: 0x300C
+  - Name: blobB
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x3010
+  - Name: sectionD
+    Type: SHT_PROGBITS
+    Content: '00009999'
+    Address: 0x3014
+  - Name: blobC
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x3018
+  - Name: sectionE
+    Type: SHT_PROGBITS
+    Content: '88887777'
+    Address: 0x301C
+  - Name: blobD
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x3020
+  - Name: sectionF
+    Type: SHT_PROGBITS
+    Content: '66665555'
+    Address: 0x3024
+  - Name: blobE
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x3028
+  - Name: blobF
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x302C
+  - Name: sectionG
+    Type: SHT_PROGBITS
+    Content: '44443333'
+    Address: 0x3030
+  - Name: blobG
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x3034
+  - Name: sectionH
+    Type: SHT_PROGBITS
+    Content: '22221111'
+    Address: 0x3038
+  - Name: blobH
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x303C
+  - Name: sectionI
+    Type: SHT_PROGBITS
+    Content: '00112233'
+    Address: 0x3040
+  - Name: blobz
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x4000
+    AddressAlign: 0x1000
+  - Name: sectionz
+    Type: SHT_PROGBITS
+    Content: '44556677'
+    Address: 0x4004
+  - Name: bloby
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x4008
+  - Name: sectiony
+    Type: SHT_PROGBITS
+    Content: '8899aabb'
+    Address: 0x400C
+  - Name: blobx
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x4010
+  - Name: blobw
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x4014
+  - Name: sectionx
+    Type: SHT_PROGBITS
+    Content: 'ccddeeff'
+    Address: 0x4018
+  - Name: blobv
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x401C
+  - Name: sectionw
+    Type: SHT_PROGBITS
+    Content: 'ffeeddcc'
+    Address: 0x4020
+  - Name: blobu
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x4024
+  - Name: sectionv
+    Type: SHT_PROGBITS
+    Content: 'bbaa9988'
+    Address: 0x4028
+  - Name: sectionu
+    Type: SHT_PROGBITS
+    Content: '77665544'
+    Address: 0x402C
+  - Name: sectiont
+    Type: SHT_PROGBITS
+    Content: '33221100'
+    Address: 0x4030
+  - Name: blobt
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x4034
+  - Name: sections
+    Type: SHT_PROGBITS
+    Content: '11111111'
+    Address: 0x4038
+  - Name: bloba
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x5000
+    AddressAlign: 0x1000
+  - Name: sectiona
+    Type: SHT_PROGBITS
+    Content: '12345678'
+    Address: 0x5004
+  - Name: blobb
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x5008
+  - Name: sectionb
+    Type: SHT_PROGBITS
+    Content: '90abcdef'
+    Address: 0x500C
+  - Name: blobc
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x5010
+  - Name: sectionc
+    Type: SHT_PROGBITS
+    Content: 'fedcba09'
+    Address: 0x5014
+  - Name: sectiond
+    Type: SHT_PROGBITS
+    Content: '87654321'
+    Address: 0x5018
+  - Name: blobd
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x501C
+  - Name: sectione
+    Type: SHT_PROGBITS
+    Content: '22222222'
+    Address: 0x5020
+  - Name: blobe
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x5024
+  - Name: sectionf
+    Type: SHT_PROGBITS
+    Content: '33333333'
+    Address: 0x5028
+  - Name: blobf
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x502C
+  - Name: blobg
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x5030
+  - Name: sectiong
+    Type: SHT_PROGBITS
+    Content: '44444444'
+    Address: 0x5034
+  - Name: blobh
+    Type: SHT_PROGBITS
+    Content: 'abbababa'
+    Address: 0x5038
+ProgramHeaders:
+  # First segment has unlabelled space at start and end.
+  - Type:  0x6ABCDEF0 # Non-specific segment type.
+    VAddr: 0x2000
+    PAddr: 0x2000
+    Align: 0x2000
+    Sections:
+      - Section: blob1
+      - Section: section1
+      - Section: blob2
+      - Section: section2 # nobits
+      - Section: blob3
+      - Section: section3
+      - Section: blob4
+  # Second segment has sections at start and end.
+  - Type:  0x6ABCDEF0
+    VAddr: 0x2100
+    PAddr: 0x2100
+    Align: 0x100
+    Sections:
+      - Section: section4
+      - Section: blob5
+      - Section: section5
+  # Third segment is all covered by a section.
+  - Type:  0x6ABCDEF0
+    VAddr: 0x2200
+    PAddr: 0x2200
+    Align: 0x100
+    Sections:
+      - Section: section6
+  # Fourth segment has no sections (after removing blob headers).
+  - Type:  0x6ABCDEF0
+    VAddr: 0x2300
+    PAddr: 0x2300
+    Align: 0x100
+    Sections:
+      - Section: blob6
+  # Fifth segment is empty.
+  - Type:   0x6ABCDEF0
+    VAddr:  0x2308
+    PAddr:  0x2308
+    Offset: 0x2308
+
+  # The next few segments test behaviour of fully nested segments.
+  # Sixth segment is the "parent" segment.
+  - Type:  0x6ABCDEF0
+    VAddr: 0x3000
+    PAddr: 0x3000
+    Align: 0x1000
+    Sections:
+      - Section: sectionA
+      - Section: sectionB
+      - Section: blobA
+      - Section: sectionC
+      - Section: blobB
+      - Section: sectionD
+      - Section: blobC
+      - Section: sectionE
+      - Section: blobD
+      - Section: sectionF
+      - Section: blobE
+      - Section: blobF
+      - Section: sectionG
+      - Section: blobG
+      - Section: sectionH
+      - Section: blobH
+      - Section: sectionI
+  # Seventh segment is empty and nested.
+  - Type:   0x6ABCDEF0
+    VAddr:  0x3002
+    PAddr:  0x3002
+    Offset: 0x3002
+  # Eighth segment contains only a section and is nested.
+  - Type:  0x6ABCDEF0
+    VAddr: 0x3004
+    PAddr: 0x3004
+    Sections:
+      - Section: sectionB
+  # Ninth segment contains only unlabelled space and is nested.
+  - Type:  0x6ABCDEF0
+    VAddr: 0x3008
+    PAddr: 0x3008
+    Sections:
+      - Section: blobA
+  # Tenth segment contains two sections with space between and is nested.
+  - Type:  0x6ABCDEF0
+    VAddr: 0x300C
+    PAddr: 0x300C
+    Sections:
+      - Section: sectionC
+      - Section: blobB
+      - Section: sectionD
+  # Eleventh segment contains two sections with space between and at ends and is nested.
+  - Type:  0x6ABCDEF0
+    VAddr: 0x3018
+    PAddr: 0x3018
+    Sections:
+      - Section: blobC
+      - Section: sectionE
+      - Section: blobD
+      - Section: sectionF
+      - Section: blobE
+  # Twelfth segment contains one section with space at ends adjacent to space in parent segment.
+  - Type:     0x6ABCDEF0
+    VAddr:    0x302E
+    PAddr:    0x302E
+    Offset:   0x302E
+    FileSize: 8
+    Sections:
+      - Section: sectionG
+  # Thirteenth segment contains overlaps sections at either end in parent segment.
+  - Type:     0x6ABCDEF0
+    VAddr:    0x303A
+    PAddr:    0x303A
+    Offset:   0x303A
+    FileSize: 0x8
+    Sections:
+      - Section: blobH
+
+  # The next batch of segments are segments that only partially overlap other segments.
+
+  # Segment14: |-unlabelled-|-Sec-|
+  # Segment15:           |--|-Sec-|-unlabelled-|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x4000
+    PAddr: 0x4000
+    Sections:
+      - Section: blobz
+      - Section: sectionz
+  - Type:   0x6ABCDEF0
+    VAddr:  0x4002
+    PAddr:  0x4002
+    Offset: 0x4002
+    Sections:
+      - Section: sectionz
+      - Section: bloby
+
+  # Segment16: |-Sec-|--|
+  # Segment17:    |--|----unlabelled---|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x400C
+    PAddr: 0x400C
+    FileSize: 6
+    Sections:
+      - Section: sectiony
+  - Type:   0x6ABCDEF0
+    VAddr:  0x400E
+    PAddr:  0x400E
+    Offset: 0x400E
+    Sections:
+      - Section: blobx
+
+  # Segment18: |-unlabelled-|-Sec-|
+  # Segment19:              |-Sec-|-unlabelled-|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x4014
+    PAddr: 0x4014
+    Sections:
+      - Section: blobw
+      - Section: sectionx
+  - Type:  0x6ABCDEF0
+    VAddr: 0x4018
+    PAddr: 0x4018
+    Sections:
+      - Section: sectionx
+      - Section: blobv
+
+  # Segment20: |-Sec-|
+  # Segment21:    |--|-unlabelled-|-Sec-|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x4020
+    PAddr: 0x4020
+    Sections:
+      - Section: sectionw
+  - Type:   0x6ABCDEF0
+    VAddr:  0x4022
+    PAddr:  0x4022
+    Offset: 0x4022
+    Sections:
+      - Section: blobu
+      - Section: sectionv
+
+  # Segment22: |-Sec-|
+  # Segment23:    |--|-Sec-|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x402C
+    PAddr: 0x402C
+    Sections:
+      - Section: sectionu
+  - Type:   0x6ABCDEF0
+    VAddr:  0x402E
+    PAddr:  0x402E
+    Offset: 0x402E
+    Sections:
+      - Section: sectiont
+
+  # Segment24: |-unlabelled-|--|
+  # Segment25:              |--Sec--|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x4034
+    PAddr: 0x4034
+    FileSize: 6
+    Sections:
+      - Section: blobt
+  - Type:  0x6ABCDEF0
+    VAddr: 0x4038
+    PAddr: 0x4038
+    Sections:
+      - Section: sections
+
+  # The next batch of segments represent groups of three nested/overlapping segments,
+  # with one parent segment containing two overlapping segments.
+
+  # Segment26: |-unlabelled-|-Sec-|-unlabelled-|
+  # Segment27: |------------|--|
+  # Segment28:              |-Sec-|------------|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5000
+    PAddr: 0x5000
+    Align: 0x1000
+    Sections:
+      - Section: bloba
+      - Section: sectiona
+      - Section: blobb
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5000
+    PAddr: 0x5000
+    FileSize: 6
+    Sections:
+      - Section: bloba
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5004
+    PAddr: 0x5004
+    Sections:
+      - Section: sectiona
+      - Section: blobb
+
+  # Segment29: |-Sec-|-unlabelled-|-Sec-|
+  # Segment30: |-Sec-|--------|
+  # Segment31:          |---------|-Sec-|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x500C
+    PAddr: 0x500C
+    Sections:
+      - Section: sectionb
+      - Section: blobc
+      - Section: sectionc
+  - Type:  0x6ABCDEF0
+    VAddr: 0x500C
+    PAddr: 0x500C
+    FileSize: 7
+    Sections:
+      - Section: sectionb
+  - Type:   0x6ABCDEF0
+    VAddr:  0x5011
+    PAddr:  0x5011
+    Offset: 0x5011
+    Sections:
+      - Section: sectionc
+
+  # Segment32: |-Sec-|-unlabelled-|-Sec-|
+  # Segment33: |-Sec-|------------|
+  # Segment34:       |------------|-Sec-|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5018
+    PAddr: 0x5018
+    Sections:
+      - Section: sectiond
+      - Section: blobd
+      - Section: sectione
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5018
+    PAddr: 0x5018
+    Sections:
+      - Section: sectiond
+      - Section: blobd
+  - Type:  0x6ABCDEF0
+    VAddr: 0x501C
+    PAddr: 0x501C
+    Sections:
+      - Section: blobd
+      - Section: sectione
+
+  # Segment35: |-unlabelled-|-Sec-|-unlabelled-|
+  # Segment36: |------------|-Sec-|
+  # Segment37:              |-Sec-|------------|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5024
+    PAddr: 0x5024
+    Sections:
+      - Section: blobe
+      - Section: sectionf
+      - Section: blobf
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5024
+    PAddr: 0x5024
+    Sections:
+      - Section: blobe
+      - Section: sectionf
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5028
+    PAddr: 0x5028
+    Sections:
+      - Section: sectionf
+      - Section: blobf
+
+  # Segment38: |-unlabelled-|-Sec-|-unlabelled-|
+  # Segment39: |------------|---|
+  # Segment40:                |---|------------|
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5030
+    PAddr: 0x5030
+    Sections:
+      - Section: blobg
+      - Section: sectiong
+      - Section: blobh
+  - Type:  0x6ABCDEF0
+    VAddr: 0x5030
+    PAddr: 0x5030
+    FileSize: 7
+    Sections:
+      - Section: blobg
+  - Type:   0x6ABCDEF0
+    VAddr:  0x5035
+    PAddr:  0x5035
+    Offset: 0x5035
+    Sections:
+      - Section: blobh
index 2cf94c077129911680a1284e635b6396f01d7af9..ea2cb635aec50efec0fb2770d08039a45324e3b8 100644 (file)
@@ -1,74 +1,74 @@
-# RUN: yaml2obj %s > %t\r
-# RUN: llvm-objcopy --strip-all-gnu %t %t2\r
-# RUN: llvm-strip --strip-all-gnu %t -o %t3\r
-# RUN: llvm-readobj --file-headers --sections %t2 | FileCheck %s\r
-# RUN: cmp %t2 %t3\r
-\r
-# Show that the debug section in a segment was removed, to match GNU.\r
-# First validate that the offset in use is correct.\r
-# RUN: llvm-objcopy %t %t4\r
-# RUN: od -t x1 -N 4 -j 120 %t4 | FileCheck %s --ignore-case --check-prefix=COPY-BYTES\r
-# RUN: od -t x1 -N 4 -j 120 %t2 | FileCheck %s --ignore-case --check-prefix=STRIP-BYTES\r
-\r
-!ELF\r
-FileHeader:\r
-  Class:           ELFCLASS64\r
-  Data:            ELFDATA2LSB\r
-  Type:            ET_REL\r
-  Machine:         EM_X86_64\r
-Sections:\r
-  - Name:            .debug_in_segment\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ ]\r
-    Content:         "deadbeef"\r
-  - Name:            .dynstr\r
-    Type:            SHT_STRTAB\r
-    Flags:           [ SHF_ALLOC ]\r
-  - Name:            .symtab.dyn\r
-    Type:            SHT_SYMTAB\r
-    Flags:           [ SHF_ALLOC ]\r
-    Type:            SHT_NOBITS\r
-  - Name:            .text\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    Size:            4\r
-  - Name:            .debug_info\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ ]\r
-    AddressAlign:    0x1\r
-    Size:            4\r
-  - Name:            .debug_loc\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC ]\r
-    AddressAlign:    0x1\r
-    Size:            4\r
-  - Name:            .comment\r
-    Type:            SHT_PROGBITS\r
-  - Name:            .random_section_name\r
-    Type:            SHT_PROGBITS\r
-  - Name:            .debug_not_a_real_debug_section\r
-    Type:            SHT_PROGBITS\r
-  - Name:            .rel.text\r
-    Type:            SHT_REL\r
-    Info:            .text\r
-  - Name:            .rela.text\r
-    Type:            SHT_RELA\r
-    Info:            .text\r
-ProgramHeaders:\r
-  # Use an arbitrary segment type to show that the segment type is unimportant.\r
-  - Type: 0x61234567\r
-    Sections:\r
-      - Section: .debug_in_segment\r
-\r
-# CHECK: SectionHeaderCount: 8\r
-\r
-# CHECK:      Name: .dynstr\r
-# CHECK:      Name: .symtab.dyn\r
-# CHECK:      Name: .text\r
-# CHECK:      Name: .debug_loc\r
-# CHECK:      Name: .comment\r
-# CHECK:      Name: .random_section_name\r
-# CHECK:      Name: .shstrtab\r
-\r
-# COPY-BYTES:  de ad be ef\r
-# STRIP-BYTES: 00 00 00 00\r
+# RUN: yaml2obj %s > %t
+# RUN: llvm-objcopy --strip-all-gnu %t %t2
+# RUN: llvm-strip --strip-all-gnu %t -o %t3
+# RUN: llvm-readobj --file-headers --sections %t2 | FileCheck %s
+# RUN: cmp %t2 %t3
+
+# Show that the debug section in a segment was removed, to match GNU.
+# First validate that the offset in use is correct.
+# RUN: llvm-objcopy %t %t4
+# RUN: od -t x1 -N 4 -j 120 %t4 | FileCheck %s --check-prefix=COPY-BYTES
+# RUN: od -t x1 -N 4 -j 120 %t2 | FileCheck %s --check-prefix=STRIP-BYTES
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_REL
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .debug_in_segment
+    Type:            SHT_PROGBITS
+    Flags:           [ ]
+    Content:         "deadbeef"
+  - Name:            .dynstr
+    Type:            SHT_STRTAB
+    Flags:           [ SHF_ALLOC ]
+  - Name:            .symtab.dyn
+    Type:            SHT_SYMTAB
+    Flags:           [ SHF_ALLOC ]
+    Type:            SHT_NOBITS
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    Size:            4
+  - Name:            .debug_info
+    Type:            SHT_PROGBITS
+    Flags:           [ ]
+    AddressAlign:    0x1
+    Size:            4
+  - Name:            .debug_loc
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC ]
+    AddressAlign:    0x1
+    Size:            4
+  - Name:            .comment
+    Type:            SHT_PROGBITS
+  - Name:            .random_section_name
+    Type:            SHT_PROGBITS
+  - Name:            .debug_not_a_real_debug_section
+    Type:            SHT_PROGBITS
+  - Name:            .rel.text
+    Type:            SHT_REL
+    Info:            .text
+  - Name:            .rela.text
+    Type:            SHT_RELA
+    Info:            .text
+ProgramHeaders:
+  # Use an arbitrary segment type to show that the segment type is unimportant.
+  - Type: 0x61234567
+    Sections:
+      - Section: .debug_in_segment
+
+# CHECK: SectionHeaderCount: 8
+
+# CHECK:      Name: .dynstr
+# CHECK:      Name: .symtab.dyn
+# CHECK:      Name: .text
+# CHECK:      Name: .debug_loc
+# CHECK:      Name: .comment
+# CHECK:      Name: .random_section_name
+# CHECK:      Name: .shstrtab
+
+# COPY-BYTES:  de ad be ef
+# STRIP-BYTES: 00 00 00 00
index 3a9edec0b5994464cbead23f9f8cd88337045b42..40032d93a3dd156422cdc784e329174573e97ddd 100644 (file)
@@ -1,88 +1,88 @@
-# RUN: yaml2obj %s > %t\r
-# RUN: llvm-objcopy --strip-sections %t %t2\r
-# RUN: llvm-readobj --file-headers --program-headers %t2 | FileCheck %s\r
-# RUN: od -t x1 -j 4096 -N 12 %t2 | FileCheck %s --ignore-case --check-prefix=DATA\r
-\r
-## Sanity check the DATA-NOT line by showing that "fe ed fa ce" appears\r
-## if --strip-sections is not specified.\r
-# RUN: llvm-objcopy %t %t3\r
-# RUN: od -t x1 -j 4096 -N 12 %t3 | FileCheck %s --ignore-case --check-prefix=VALIDATE\r
-\r
-## Check that llvm-strip --strip-sections is equivalent to\r
-## llvm-objcopy --strip-sections. \r
-# RUN: llvm-strip --strip-sections %t -o %t4\r
-# RUN: cmp %t2 %t4\r
-\r
-!ELF\r
-FileHeader:\r
-  Class:           ELFCLASS64\r
-  Data:            ELFDATA2LSB\r
-  Type:            ET_EXEC\r
-  Machine:         EM_X86_64\r
-Sections:\r
-  - Name:            .text\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]\r
-    AddressAlign:    0x0000000000001000\r
-    Content:         "DEADBEEF"\r
-  - Name:            .non_alloc_in_segment\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ ]\r
-    Content:         "CAFEBABE"\r
-  - Name:            .non_alloc_not_in_segment\r
-    Type:            SHT_PROGBITS\r
-    Flags:           [ ]\r
-    Content:         "FEEDFACE"\r
-ProgramHeaders:\r
-- Type: PT_LOAD\r
-  Flags: [ PF_X, PF_R ]\r
-  Sections:\r
-    - Section: .text\r
-    - Section: .non_alloc_in_segment\r
-\r
-# DATA: {{^[^[:blank:]]+}} de ad be ef ca fe ba be\r
-# DATA-NOT: fe ed fa ce\r
-\r
-# VALIDATE: {{^[^[:blank:]]+}} de ad be ef ca fe ba be fe ed fa ce\r
-\r
-# CHECK:      ElfHeader {\r
-# CHECK-NEXT:   Ident {\r
-# CHECK-NEXT:     Magic: (7F 45 4C 46)\r
-# CHECK-NEXT:     Class: 64-bit (0x2)\r
-# CHECK-NEXT:     DataEncoding: LittleEndian (0x1)\r
-# CHECK-NEXT:     FileVersion: 1\r
-# CHECK-NEXT:     OS/ABI: SystemV (0x0)\r
-# CHECK-NEXT:     ABIVersion: 0\r
-# CHECK-NEXT:     Unused: (00 00 00 00 00 00 00)\r
-# CHECK-NEXT:   }\r
-# CHECK-NEXT:   Type: Executable (0x2)\r
-# CHECK-NEXT:   Machine: EM_X86_64 (0x3E)\r
-# CHECK-NEXT:   Version: 1\r
-# CHECK-NEXT:   Entry: 0x0\r
-# CHECK-NEXT:   ProgramHeaderOffset: 0x40\r
-# CHECK-NEXT:   SectionHeaderOffset: 0x0\r
-# CHECK-NEXT:   Flags [ (0x0)\r
-# CHECK-NEXT:   ]\r
-# CHECK-NEXT:   HeaderSize: 64\r
-# CHECK-NEXT:   ProgramHeaderEntrySize: 56\r
-# CHECK-NEXT:   ProgramHeaderCount: 1\r
-# CHECK-NEXT:   SectionHeaderEntrySize: 0\r
-# CHECK-NEXT:   SectionHeaderCount: 0\r
-# CHECK-NEXT:   StringTableSectionIndex: 0\r
-# CHECK-NEXT: }\r
-\r
-# CHECK:      ProgramHeaders [\r
-# CHECK-NEXT:   ProgramHeader {\r
-# CHECK-NEXT:     Type: PT_LOAD (0x1)\r
-# CHECK-NEXT:     Offset: 0x1000\r
-# CHECK-NEXT:     VirtualAddress: 0x0\r
-# CHECK-NEXT:     PhysicalAddress: 0x0\r
-# CHECK-NEXT:     FileSize: 8\r
-# CHECK-NEXT:     MemSize: 8\r
-# CHECK-NEXT:     Flags [ (0x5)\r
-# CHECK-NEXT:       PF_R (0x4)\r
-# CHECK-NEXT:       PF_X (0x1)\r
-# CHECK-NEXT:     ]\r
-# CHECK-NEXT:     Alignment: 4096\r
-# CHECK-NEXT:   }\r
-# CHECK-NEXT: ]\r
+# RUN: yaml2obj %s > %t
+# RUN: llvm-objcopy --strip-sections %t %t2
+# RUN: llvm-readobj --file-headers --program-headers %t2 | FileCheck %s
+# RUN: od -t x1 -j 4096 -N 12 %t2 | FileCheck %s --check-prefix=DATA
+
+## Sanity check the DATA-NOT line by showing that "fe ed fa ce" appears
+## if --strip-sections is not specified.
+# RUN: llvm-objcopy %t %t3
+# RUN: od -t x1 -j 4096 -N 12 %t3 | FileCheck %s --check-prefix=VALIDATE
+
+## Check that llvm-strip --strip-sections is equivalent to
+## llvm-objcopy --strip-sections. 
+# RUN: llvm-strip --strip-sections %t -o %t4
+# RUN: cmp %t2 %t4
+
+!ELF
+FileHeader:
+  Class:           ELFCLASS64
+  Data:            ELFDATA2LSB
+  Type:            ET_EXEC
+  Machine:         EM_X86_64
+Sections:
+  - Name:            .text
+    Type:            SHT_PROGBITS
+    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
+    AddressAlign:    0x0000000000001000
+    Content:         "DEADBEEF"
+  - Name:            .non_alloc_in_segment
+    Type:            SHT_PROGBITS
+    Flags:           [ ]
+    Content:         "CAFEBABE"
+  - Name:            .non_alloc_not_in_segment
+    Type:            SHT_PROGBITS
+    Flags:           [ ]
+    Content:         "FEEDFACE"
+ProgramHeaders:
+- Type: PT_LOAD
+  Flags: [ PF_X, PF_R ]
+  Sections:
+    - Section: .text
+    - Section: .non_alloc_in_segment
+
+# DATA: {{^[^[:blank:]]+}} de ad be ef ca fe ba be
+# DATA-NOT: fe ed fa ce
+
+# VALIDATE: {{^[^[:blank:]]+}} de ad be ef ca fe ba be fe ed fa ce
+
+# CHECK:      ElfHeader {
+# CHECK-NEXT:   Ident {
+# CHECK-NEXT:     Magic: (7F 45 4C 46)
+# CHECK-NEXT:     Class: 64-bit (0x2)
+# CHECK-NEXT:     DataEncoding: LittleEndian (0x1)
+# CHECK-NEXT:     FileVersion: 1
+# CHECK-NEXT:     OS/ABI: SystemV (0x0)
+# CHECK-NEXT:     ABIVersion: 0
+# CHECK-NEXT:     Unused: (00 00 00 00 00 00 00)
+# CHECK-NEXT:   }
+# CHECK-NEXT:   Type: Executable (0x2)
+# CHECK-NEXT:   Machine: EM_X86_64 (0x3E)
+# CHECK-NEXT:   Version: 1
+# CHECK-NEXT:   Entry: 0x0
+# CHECK-NEXT:   ProgramHeaderOffset: 0x40
+# CHECK-NEXT:   SectionHeaderOffset: 0x0
+# CHECK-NEXT:   Flags [ (0x0)
+# CHECK-NEXT:   ]
+# CHECK-NEXT:   HeaderSize: 64
+# CHECK-NEXT:   ProgramHeaderEntrySize: 56
+# CHECK-NEXT:   ProgramHeaderCount: 1
+# CHECK-NEXT:   SectionHeaderEntrySize: 0
+# CHECK-NEXT:   SectionHeaderCount: 0
+# CHECK-NEXT:   StringTableSectionIndex: 0
+# CHECK-NEXT: }
+
+# CHECK:      ProgramHeaders [
+# CHECK-NEXT:   ProgramHeader {
+# CHECK-NEXT:     Type: PT_LOAD (0x1)
+# CHECK-NEXT:     Offset: 0x1000
+# CHECK-NEXT:     VirtualAddress: 0x0
+# CHECK-NEXT:     PhysicalAddress: 0x0
+# CHECK-NEXT:     FileSize: 8
+# CHECK-NEXT:     MemSize: 8
+# CHECK-NEXT:     Flags [ (0x5)
+# CHECK-NEXT:       PF_R (0x4)
+# CHECK-NEXT:       PF_X (0x1)
+# CHECK-NEXT:     ]
+# CHECK-NEXT:     Alignment: 4096
+# CHECK-NEXT:   }
+# CHECK-NEXT: ]
index 4d21f3dd17bf0da9fed05cba6494379d7ccd9292..21a172cebadb0a8904aa96c2f20949a0cfe8fdf8 100644 (file)
-## Check we are able to set custom sh_offset field\r
-## for different sections.\r
-\r
-# RUN: yaml2obj --docnum=1 %s -o %t1\r
-# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1\r
-\r
-# CASE1:      Section Headers:\r
-# CASE1-NEXT:  [Nr] Name           Type     Address Off\r
-# CASE1-NEXT:  [ 0]                NULL     {{.*}}  000000\r
-# CASE1-NEXT:  [ 1] .dynsym        DYNSYM   {{.*}}  000001\r
-# CASE1-NEXT:  [ 2] .symtab        SYMTAB   {{.*}}  000002\r
-# CASE1-NEXT:  [ 3] .dynamic       DYNAMIC  {{.*}}  000003\r
-# CASE1-NEXT:  [ 4] .rela          RELA     {{.*}}  000004\r
-# CASE1-NEXT:  [ 5] .nobits        NOBITS   {{.*}}  000005\r
-# CASE1-NEXT:  [ 6] .group         GROUP    {{.*}}  000006\r
-# CASE1-NEXT:  [ 7] .gnu.version   VERSYM   {{.*}}  000007\r
-# CASE1-NEXT:  [ 8] .gnu.version_r VERNEED  {{.*}}  000008\r
-# CASE1-NEXT:  [ 9] .gnu.version_d VERDEF   {{.*}}  000009\r
-# CASE1-NEXT:  [10] .regular       PROGBITS {{.*}}  00000a\r
-# CASE1-NEXT:  [11] .strtab        STRTAB   {{.*}}  00000b\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_REL\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: .dynsym\r
-    Type: SHT_DYNSYM\r
-    ShOffset: 0x000000001\r
-  - Name: .symtab\r
-    Type: SHT_SYMTAB\r
-    ShOffset: 0x000000002\r
-  - Name: .dynamic\r
-    Type: SHT_DYNAMIC\r
-    ShOffset: 0x000000003\r
-  - Name: .rela\r
-    Type: SHT_RELA\r
-    ShOffset: 0x000000004\r
-  - Name: .nobits\r
-    Type: SHT_NOBITS\r
-    ShOffset: 0x000000005\r
-  - Name: .group\r
-    Type: SHT_GROUP\r
-    Info: 0\r
-    ShOffset: 0x000000006\r
-    Members:\r
-  - Name: .gnu.version\r
-    Type: SHT_GNU_versym\r
-    Entries: [ ]\r
-    ShOffset: 0x000000007\r
-  - Name: .gnu.version_r\r
-    Type: SHT_GNU_verneed\r
-    Info: 0x0000000000000001\r
-    ShOffset: 0x000000008\r
-    Dependencies:\r
-  - Name: .gnu.version_d\r
-    Type: SHT_GNU_verdef\r
-    Info: 0x0000000000000001\r
-    ShOffset: 0x000000009\r
-    Entries:\r
-  - Name: .regular\r
-    Type: SHT_PROGBITS\r
-    ShOffset: 0x00000000A\r
-  - Name: .strtab\r
-    Type: SHT_STRTAB\r
-    ShOffset: 0x00000000B\r
-\r
-## Here we check that defining ShOffset does not actually change\r
-## the offset at which section data is placed and also does\r
-## not affect file size.\r
-\r
-# RUN: yaml2obj --docnum=2 %s -o %t2\r
-# RUN: yaml2obj --docnum=3 %s -o %t3\r
-# RUN: od -t x1 -v %t2 > %t.txt\r
-# RUN: od -t x1 -v %t3 >> %t.txt\r
-# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2\r
-\r
-# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe\r
-# CASE2: [[FILESIZE:.*]]{{$}}\r
-# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe\r
-# CASE2: [[FILESIZE]]{{$}}\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_REL\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: .foo\r
-    Type: SHT_PROGBITS\r
-    Content: "fefefefefefefefe"\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_REL\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: .foo\r
-    Type: SHT_PROGBITS\r
-    ShOffset: 0xFFFF0000\r
-    Content: "fefefefefefefefe"\r
+## Check we are able to set custom sh_offset field
+## for different sections.
+
+# RUN: yaml2obj --docnum=1 %s -o %t1
+# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1
+
+# CASE1:      Section Headers:
+# CASE1-NEXT:  [Nr] Name           Type     Address Off
+# CASE1-NEXT:  [ 0]                NULL     {{.*}}  000000
+# CASE1-NEXT:  [ 1] .dynsym        DYNSYM   {{.*}}  000001
+# CASE1-NEXT:  [ 2] .symtab        SYMTAB   {{.*}}  000002
+# CASE1-NEXT:  [ 3] .dynamic       DYNAMIC  {{.*}}  000003
+# CASE1-NEXT:  [ 4] .rela          RELA     {{.*}}  000004
+# CASE1-NEXT:  [ 5] .nobits        NOBITS   {{.*}}  000005
+# CASE1-NEXT:  [ 6] .group         GROUP    {{.*}}  000006
+# CASE1-NEXT:  [ 7] .gnu.version   VERSYM   {{.*}}  000007
+# CASE1-NEXT:  [ 8] .gnu.version_r VERNEED  {{.*}}  000008
+# CASE1-NEXT:  [ 9] .gnu.version_d VERDEF   {{.*}}  000009
+# CASE1-NEXT:  [10] .regular       PROGBITS {{.*}}  00000a
+# CASE1-NEXT:  [11] .strtab        STRTAB   {{.*}}  00000b
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name: .dynsym
+    Type: SHT_DYNSYM
+    ShOffset: 0x000000001
+  - Name: .symtab
+    Type: SHT_SYMTAB
+    ShOffset: 0x000000002
+  - Name: .dynamic
+    Type: SHT_DYNAMIC
+    ShOffset: 0x000000003
+  - Name: .rela
+    Type: SHT_RELA
+    ShOffset: 0x000000004
+  - Name: .nobits
+    Type: SHT_NOBITS
+    ShOffset: 0x000000005
+  - Name: .group
+    Type: SHT_GROUP
+    Info: 0
+    ShOffset: 0x000000006
+    Members:
+  - Name: .gnu.version
+    Type: SHT_GNU_versym
+    Entries: [ ]
+    ShOffset: 0x000000007
+  - Name: .gnu.version_r
+    Type: SHT_GNU_verneed
+    Info: 0x0000000000000001
+    ShOffset: 0x000000008
+    Dependencies:
+  - Name: .gnu.version_d
+    Type: SHT_GNU_verdef
+    Info: 0x0000000000000001
+    ShOffset: 0x000000009
+    Entries:
+  - Name: .regular
+    Type: SHT_PROGBITS
+    ShOffset: 0x00000000A
+  - Name: .strtab
+    Type: SHT_STRTAB
+    ShOffset: 0x00000000B
+
+## Here we check that defining ShOffset does not actually change
+## the offset at which section data is placed and also does
+## not affect file size.
+
+# RUN: yaml2obj --docnum=2 %s -o %t2
+# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: od -t x1 -v %t2 > %t.txt
+# RUN: od -t x1 -v %t3 >> %t.txt
+# RUN: FileCheck %s --input-file=%t.txt --check-prefix=CASE2
+
+# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe
+# CASE2: [[FILESIZE:.*]]{{$}}
+# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe
+# CASE2: [[FILESIZE]]{{$}}
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name: .foo
+    Type: SHT_PROGBITS
+    Content: "fefefefefefefefe"
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name: .foo
+    Type: SHT_PROGBITS
+    ShOffset: 0xFFFF0000
+    Content: "fefefefefefefefe"
index 8e9e2f3468d7654565945f14c8ff45a552f89f2a..de2bb774f7d1b018163438776111ac4c13941b03 100644 (file)
-## Check we are able to set custom sh_size field\r
-## for different sections.\r
-\r
-# RUN: yaml2obj --docnum=1 %s -o %t1\r
-# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1\r
-\r
-# CASE1:      Section Headers:\r
-# CASE1-NEXT:  [Nr] Name           Type     Address          Off    Size  \r
-# CASE1-NEXT:  [ 0]                NULL     0000000000000000 000000 000000\r
-# CASE1-NEXT:  [ 1] .dynsym        DYNSYM   0000000000000000 000040 000001\r
-# CASE1-NEXT:  [ 2] .symtab        SYMTAB   0000000000000000 000058 000002\r
-# CASE1-NEXT:  [ 3] .dynamic       DYNAMIC  0000000000000000 000070 000003\r
-# CASE1-NEXT:  [ 4] .rela          RELA     0000000000000000 000070 000004\r
-# CASE1-NEXT:  [ 5] .nobits        NOBITS   0000000000000000 000070 000005\r
-# CASE1-NEXT:  [ 6] .group         GROUP    0000000000000000 000070 000006\r
-# CASE1-NEXT:  [ 7] .gnu.version   VERSYM   0000000000000000 000070 000007\r
-# CASE1-NEXT:  [ 8] .gnu.version_r VERNEED  0000000000000000 000070 000008\r
-# CASE1-NEXT:  [ 9] .gnu.version_d VERDEF   0000000000000000 000070 000009\r
-# CASE1-NEXT:  [10] .regular       PROGBITS 0000000000000000 000070 00000a\r
-# CASE1-NEXT:  [11] .strtab        STRTAB   0000000000000000 000070 00000b\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_REL\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: .dynsym\r
-    Type: SHT_DYNSYM\r
-    ShSize: 0x000000001\r
-  - Name: .symtab\r
-    Type: SHT_SYMTAB\r
-    ShSize: 0x000000002\r
-  - Name: .dynamic\r
-    Type: SHT_DYNAMIC\r
-    ShSize: 0x000000003\r
-  - Name: .rela\r
-    Type: SHT_RELA\r
-    ShSize: 0x000000004\r
-  - Name: .nobits\r
-    Type: SHT_NOBITS\r
-    ShSize: 0x000000005\r
-  - Name: .group\r
-    Type: SHT_GROUP\r
-    Info: 0\r
-    ShSize: 0x000000006\r
-    Members:\r
-  - Name: .gnu.version\r
-    Type: SHT_GNU_versym\r
-    Entries: [ ]\r
-    ShSize: 0x000000007\r
-  - Name: .gnu.version_r\r
-    Type: SHT_GNU_verneed\r
-    Info: 0x0000000000000001\r
-    ShSize: 0x000000008\r
-    Dependencies:\r
-  - Name: .gnu.version_d\r
-    Type: SHT_GNU_verdef\r
-    Info: 0x0000000000000001\r
-    ShSize: 0x000000009\r
-    Entries:\r
-  - Name: .regular\r
-    Type: SHT_PROGBITS\r
-    ShSize: 0x00000000A\r
-  - Name: .strtab\r
-    Type: SHT_STRTAB\r
-    ShSize: 0x00000000B\r
-\r
-## Here we check that defining ShSize does not actually change\r
-## the content and also does not affect file size.\r
-\r
-# RUN: yaml2obj --docnum=2 %s -o %t2\r
-# RUN: yaml2obj --docnum=3 %s -o %t3\r
-# RUN: od -t x1 -v %t2 > %t.txt\r
-# RUN: od -t x1 -v %t3 >> %t.txt\r
-# RUN: FileCheck %s --input-file=%t.txt --ignore-case --check-prefix=CASE2\r
-\r
-# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe\r
-# CASE2: [[FILESIZE:.*]]{{$}}\r
-# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe\r
-# CASE2: [[FILESIZE]]{{$}}\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_REL\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: .foo\r
-    Type: SHT_PROGBITS\r
-    Content: "fefefefefefefefe"\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_REL\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: .foo\r
-    Type: SHT_PROGBITS\r
-    ShSize: 1\r
-    Content: "fefefefefefefefe"\r
-\r
-## Check we can define sh_size larger than section content size\r
-## and thus create overlaping sections.\r
-\r
-# RUN: yaml2obj --docnum=4 %s -o %t4\r
-# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=CASE4\r
-\r
-# CASE4:      Name: .foo\r
-# CASE4:      SectionData (\r
-# CASE4-NEXT: 0000: AAAABBBB |....|\r
-# CASE4:      Name: .bar\r
-# CASE4:      SectionData (\r
-# CASE4-NEXT: 0000: BBBB |..|\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_REL\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: .foo\r
-    Type: SHT_PROGBITS\r
-    Content: "aaaa"\r
-    ShSize: 4\r
-  - Name: .bar\r
-    Type: SHT_PROGBITS\r
-    Content: "bbbb"\r
-\r
-## Check we can set both Size and ShSize and the number of the actual\r
-## bytes written is equal to Size in this case.\r
-\r
-# RUN: yaml2obj --docnum=5 %s -o %t5\r
-# RUN: od -t x1 -v %t5 | FileCheck %s --ignore-case --check-prefix=CASE5\r
-\r
-# CASE5: aa aa 00 00 bb bb\r
-\r
---- !ELF\r
-FileHeader:\r
-  Class:   ELFCLASS64\r
-  Data:    ELFDATA2LSB\r
-  Type:    ET_REL\r
-  Machine: EM_X86_64\r
-Sections:\r
-  - Name: .foo\r
-    Type: SHT_PROGBITS\r
-    Content: "aaaa"\r
-  - Name: .bar\r
-    Type: SHT_PROGBITS\r
-    Size: 2\r
-    ShSize: 4\r
-  - Name: .zed\r
-    Type: SHT_PROGBITS\r
-    Content: "bbbb"\r
+## Check we are able to set custom sh_size field
+## for different sections.
+
+# RUN: yaml2obj --docnum=1 %s -o %t1
+# RUN: llvm-readelf --sections %t1 | FileCheck %s --check-prefix=CASE1
+
+# CASE1:      Section Headers:
+# CASE1-NEXT:  [Nr] Name           Type     Address          Off    Size  
+# CASE1-NEXT:  [ 0]                NULL     0000000000000000 000000 000000
+# CASE1-NEXT:  [ 1] .dynsym        DYNSYM   0000000000000000 000040 000001
+# CASE1-NEXT:  [ 2] .symtab        SYMTAB   0000000000000000 000058 000002
+# CASE1-NEXT:  [ 3] .dynamic       DYNAMIC  0000000000000000 000070 000003
+# CASE1-NEXT:  [ 4] .rela          RELA     0000000000000000 000070 000004
+# CASE1-NEXT:  [ 5] .nobits        NOBITS   0000000000000000 000070 000005
+# CASE1-NEXT:  [ 6] .group         GROUP    0000000000000000 000070 000006
+# CASE1-NEXT:  [ 7] .gnu.version   VERSYM   0000000000000000 000070 000007
+# CASE1-NEXT:  [ 8] .gnu.version_r VERNEED  0000000000000000 000070 000008
+# CASE1-NEXT:  [ 9] .gnu.version_d VERDEF   0000000000000000 000070 000009
+# CASE1-NEXT:  [10] .regular       PROGBITS 0000000000000000 000070 00000a
+# CASE1-NEXT:  [11] .strtab        STRTAB   0000000000000000 000070 00000b
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name: .dynsym
+    Type: SHT_DYNSYM
+    ShSize: 0x000000001
+  - Name: .symtab
+    Type: SHT_SYMTAB
+    ShSize: 0x000000002
+  - Name: .dynamic
+    Type: SHT_DYNAMIC
+    ShSize: 0x000000003
+  - Name: .rela
+    Type: SHT_RELA
+    ShSize: 0x000000004
+  - Name: .nobits
+    Type: SHT_NOBITS
+    ShSize: 0x000000005
+  - Name: .group
+    Type: SHT_GROUP
+    Info: 0
+    ShSize: 0x000000006
+    Members:
+  - Name: .gnu.version
+    Type: SHT_GNU_versym
+    Entries: [ ]
+    ShSize: 0x000000007
+  - Name: .gnu.version_r
+    Type: SHT_GNU_verneed
+    Info: 0x0000000000000001
+    ShSize: 0x000000008
+    Dependencies:
+  - Name: .gnu.version_d
+    Type: SHT_GNU_verdef
+    Info: 0x0000000000000001
+    ShSize: 0x000000009
+    Entries:
+  - Name: .regular
+    Type: SHT_PROGBITS
+    ShSize: 0x00000000A
+  - Name: .strtab
+    Type: SHT_STRTAB
+    ShSize: 0x00000000B
+
+## Here we check that defining ShSize does not actually change
+## the content and also does not affect file size.
+
+# RUN: yaml2obj --docnum=2 %s -o %t2
+# RUN: yaml2obj --docnum=3 %s -o %t3
+# RUN: od -t x1 -v %t2 > %t.txt
+# RUN: od -t x1 -v %t3 >> %t.txt
+# RUN: FileCheck %s --input-file=%t.txt --check-prefix=CASE2
+
+# CASE2: [[OFFSET:.*]] fe fe fe fe fe fe fe fe
+# CASE2: [[FILESIZE:.*]]{{$}}
+# CASE2: [[OFFSET]] fe fe fe fe fe fe fe fe
+# CASE2: [[FILESIZE]]{{$}}
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name: .foo
+    Type: SHT_PROGBITS
+    Content: "fefefefefefefefe"
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name: .foo
+    Type: SHT_PROGBITS
+    ShSize: 1
+    Content: "fefefefefefefefe"
+
+## Check we can define sh_size larger than section content size
+## and thus create overlaping sections.
+
+# RUN: yaml2obj --docnum=4 %s -o %t4
+# RUN: llvm-readobj --sections --section-data %t4 | FileCheck %s --check-prefix=CASE4
+
+# CASE4:      Name: .foo
+# CASE4:      SectionData (
+# CASE4-NEXT: 0000: AAAABBBB |....|
+# CASE4:      Name: .bar
+# CASE4:      SectionData (
+# CASE4-NEXT: 0000: BBBB |..|
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name: .foo
+    Type: SHT_PROGBITS
+    Content: "aaaa"
+    ShSize: 4
+  - Name: .bar
+    Type: SHT_PROGBITS
+    Content: "bbbb"
+
+## Check we can set both Size and ShSize and the number of the actual
+## bytes written is equal to Size in this case.
+
+# RUN: yaml2obj --docnum=5 %s -o %t5
+# RUN: od -t x1 -v %t5 | FileCheck %s --check-prefix=CASE5
+
+# CASE5: aa aa 00 00 bb bb
+
+--- !ELF
+FileHeader:
+  Class:   ELFCLASS64
+  Data:    ELFDATA2LSB
+  Type:    ET_REL
+  Machine: EM_X86_64
+Sections:
+  - Name: .foo
+    Type: SHT_PROGBITS
+    Content: "aaaa"
+  - Name: .bar
+    Type: SHT_PROGBITS
+    Size: 2
+    ShSize: 4
+  - Name: .zed
+    Type: SHT_PROGBITS
+    Content: "bbbb"