1 # RUN: yaml2obj --docnum=1 %s -o %t
2 # RUN: llvm-readobj -l %t | FileCheck %s
12 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
13 AddressAlign: 0x0000000000001000
17 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
19 AddressAlign: 0x0000000000000010
24 AddressAlign: 0x0000000000001000
38 - Type: PT_GNU_EH_FRAME
41 - Type: PT_GNU_PROPERTY
43 #CHECK: ProgramHeaders [
44 #CHECK-NEXT: ProgramHeader {
45 #CHECK-NEXT: Type: PT_LOAD
46 #CHECK-NEXT: Offset: 0x1000
47 #CHECK-NEXT: VirtualAddress: 0xAAAA1000
48 #CHECK-NEXT: PhysicalAddress: 0xFFFF1000
49 #CHECK-NEXT: FileSize: 20
50 #CHECK-NEXT: MemSize: 20
55 #CHECK-NEXT: Alignment: 4096
57 #CHECK-NEXT: ProgramHeader {
58 #CHECK-NEXT: Type: PT_LOAD
59 #CHECK-NEXT: Offset: 0x2000
60 #CHECK-NEXT: VirtualAddress: 0xAAAA2000
61 #CHECK-NEXT: PhysicalAddress: 0xFFFF2000
62 #CHECK-NEXT: FileSize: 4
63 #CHECK-NEXT: MemSize: 4
67 #CHECK-NEXT: Alignment: 4096
69 #CHECK-NEXT: ProgramHeader {
70 #CHECK-NEXT: Type: PT_GNU_EH_FRAME (0x6474E550)
72 #CHECK-NEXT: ProgramHeader {
73 #CHECK-NEXT: Type: PT_GNU_STACK (0x6474E551)
75 #CHECK-NEXT: ProgramHeader {
76 #CHECK-NEXT: Type: PT_GNU_RELRO (0x6474E552)
78 #CHECK-NEXT: ProgramHeader {
79 #CHECK-NEXT: Type: PT_GNU_PROPERTY (0x6474E553)
83 ## Check we do not allow referencing sections that do not exist.
84 # RUN: not yaml2obj -DFIRST=".unknown1" -DLAST=".unknown2" --docnum=2 %s 2>&1 | \
85 # RUN: FileCheck %s --check-prefix=UNKNOWN-ERR
87 # UNKNOWN-ERR: error: unknown section or fill referenced: '.unknown1' by the 'FirstSec' key of the program header with index 0
88 # UNKNOWN-ERR: error: unknown section or fill referenced: '.unknown2' by the 'LastSec' key of the program header with index 0
118 FirstSec: [[FIRST=<none>]]
119 LastSec: [[LAST=<none>]]
121 ## Check we report an error when the index of the section specified by the "FirstSec" key
122 ## is greater than the index of the section specified by the "LastSec" key.
124 # RUN: not yaml2obj -DFIRST=".bar" -DLAST=".foo" --docnum=2 %s 2>&1 | \
125 # RUN: FileCheck %s --check-prefix=ORDER-ERR
127 # ORDER-ERR: error: program header with index 0: the section index of .bar is greater than the index of .foo
129 ## Check that we can't use the "LastSec" key without the "FirstSec" key.
131 # RUN: not yaml2obj -DLAST=".foo" --docnum=2 %s 2>&1 | \
132 # RUN: FileCheck %s --check-prefix=ONLY-LAST-ERR
134 # ONLY-LAST-ERR: error: the "LastSec" key can't be used without the "FirstSec" key
136 ## Check that we can't use the "FirstSec" key without the "LastSec" key.
138 # RUN: not yaml2obj -DFIRST=".foo" --docnum=2 %s 2>&1 | \
139 # RUN: FileCheck %s --check-prefix=ONLY-FIRST-ERR
141 # ONLY-FIRST-ERR: error: the "FirstSec" key can't be used without the "LastSec" key
143 ## Check we create an empty segment when neither "FirstSec" nor "LastSec" are specified.
145 # RUN: yaml2obj --docnum=2 %s -o %t3
146 # RUN: llvm-readelf --program-headers %t3 | FileCheck %s --check-prefix=EMPTY-SEGMENT
148 # EMPTY-SEGMENT: Type Offset VirtAddr PhysAddr FileSiz MemSiz
149 # EMPTY-SEGMENT: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x000000 0x000000
150 # EMPTY-SEGMENT-EMPTY:
152 ## Check that we include all sections between FirstSec and LastSec in the segment when both keys are used.
154 # RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".zed" %s -o %t4
155 # RUN: llvm-readelf --program-headers %t4 | FileCheck %s --check-prefix=BOTH
157 # BOTH: Type Offset VirtAddr PhysAddr FileSiz MemSiz
158 # BOTH-NEXT: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000230 0x000230
160 ## Check that we include fills that are between FirstSec and LastSec in the segment when both keys are used.
162 # RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".fill1" %s -o %t5a
163 # RUN: llvm-readelf --program-headers %t5a | FileCheck %s --check-prefix=FILL1
165 # FILL1: Type Offset VirtAddr PhysAddr FileSiz MemSiz
166 # FILL1: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000340 0x000340
168 # RUN: yaml2obj --docnum=2 -DFIRST=".foo" -DLAST=".fill2" %s -o %t5b
169 # RUN: llvm-readelf --program-headers %t5b | FileCheck %s --check-prefix=FILL2
171 # FILL2: Type Offset VirtAddr PhysAddr FileSiz MemSiz
172 # FILL2: LOAD 0x000100 0x0000000000000000 0x0000000000000000 0x000450 0x000450