1 ## Show that yaml2obj properly emits program headers with explicit file size,
2 ## memory size and offset parameters.
4 # RUN: yaml2obj --docnum=1 %s -o %t1
5 # RUN: llvm-readobj %t1 --program-headers | FileCheck %s
7 # CHECK: ProgramHeaders [
8 # CHECK: Offset: 0x1234
9 # CHECK: FileSize: 1111
10 # CHECK: MemSize: 9999
12 # CHECK: Offset: 0x2000
16 # CHECK: Offset: 0x2000
20 # CHECK: Offset: 0x1FFF
24 # CHECK: Offset: 0xFFE
28 # CHECK: Offset: 0x3000
32 # CHECK: Offset: 0x2004
33 ## Offset of .nobits2 (0x2009) - offset of .data (0x2004) == 0x5.
64 # Intentionally set to 0x2009 though the previous section is SHT_NOBITS.
68 # Program header with no sections.
69 - Type: 0x6abcdef0 # arbitrary type
73 # Program header with only file size set.
78 # Program header with only mem size set.
83 # Program header with only offset set.
88 # Program header with sections, valid properties.
95 # Program header with invalid properties.
100 # Program header with 2 SHT_NOBITS sections.
106 ## Test the "Offset" property.
108 ## Check that by default the p_offset field of a segment is set to the
109 ## offset of the section with the minimum offset.
110 # RUN: yaml2obj --docnum=2 %s -o %t2
111 # RUN: llvm-readelf %t2 --sections --program-headers | \
112 # RUN: FileCheck %s --check-prefixes=DEFAULT-OFFSET
114 # DEFAULT-OFFSET: [Nr] Name Type Address Off
115 # DEFAULT-OFFSET: [ 1] .foo PROGBITS 0000000000001000 0000b0
116 # DEFAULT-OFFSET-NEXT: [ 2] .bar PROGBITS 0000000000001001 0000b1
118 # DEFAULT-OFFSET: Type Offset
119 # DEFAULT-OFFSET-NEXT: LOAD 0x0000b0
120 # DEFAULT-OFFSET-NEXT: LOAD 0x0000b1
145 ## Check we can set the "Offset" value explicitly to be less than or equal to
146 ## the offset of a section in the segment.
147 # RUN: yaml2obj --docnum=3 -DOFFSET=0x77 %s -o %t3
148 # RUN: llvm-readelf %t3 --sections --program-headers | \
149 # RUN: FileCheck %s --check-prefixes=VALID-OFFSET,VALID-OFFSET-LESS
150 # RUN: yaml2obj --docnum=3 -DOFFSET=0x78 %s -o %t4
151 # RUN: llvm-readelf %t4 --sections --program-headers | \
152 # RUN: FileCheck %s --check-prefixes=VALID-OFFSET,VALID-OFFSET-EQ
154 # VALID-OFFSET: [Nr] Name Type Address Off
155 # VALID-OFFSET: [ 1] .foo PROGBITS 0000000000000000 000078
157 # VALID-OFFSET: Type Offset
158 # VALID-OFFSET-EQ: LOAD 0x000078
159 # VALID-OFFSET-LESS: LOAD 0x000077
177 ## Check we report an error when the "Offset" value is larger than the offset of a section in the segment.
178 # RUN: not yaml2obj --docnum=3 -DOFFSET=0x79 %s -o /dev/null 2>&1 | \
179 # RUN: FileCheck %s --check-prefix=INVALID-OFFSET
181 # INVALID-OFFSET: yaml2obj: error: 'Offset' for segment with index 1 must be less than or equal to the minimum file offset of all included sections (0x78)
183 ## Document that the "Offset" value is checked after the section offset is overriden using "ShOffset".
184 # RUN: yaml2obj --docnum=4 %s -o %t5
185 # RUN: llvm-readelf %t5 --sections --program-headers | FileCheck %s --check-prefix=SHOFFSET
187 # SHOFFSET: [Nr] Name Type Address Off
188 # SHOFFSET: [ 1] .foo PROGBITS 0000000000000000 ffffffff
190 # SHOFFSET: Type Offset
191 # SHOFFSET-NEXT: LOAD 0xffffff00
203 ## Note: the real .foo offset is much less than 0xFFFFFFFF or
204 ## 0xFFFFFF00, but no error is reported.