1## .empty is not covered by a segment. Its offset is moved to 0x200 to fill the gap.
2# RUN: yaml2obj --docnum=1 %s -o %t1
3# RUN: llvm-objcopy %t1 %t1.out
4# RUN: llvm-readelf -S %t1.out | FileCheck --check-prefix=CHECK1 %s
5
6# CHECK1:      Name         Type     Address          Off
7# CHECK1-NEXT:              NULL     0000000000000000 000000
8# CHECK1-NEXT: .foo         PROGBITS 0000000000000000 000100
9# CHECK1-NEXT: .empty       PROGBITS 0000000000001000 000200
10# CHECK1-NEXT: .baz         PROGBITS 0000000000001000 001000
11
12--- !ELF
13FileHeader:
14  Class:   ELFCLASS64
15  Data:    ELFDATA2LSB
16  Type:    ET_EXEC
17  Machine: EM_X86_64
18Sections:
19  - Name:         gap
20    Type:         Fill
21    Size:         0xE00
22  - Name:         .foo
23    Type:         SHT_PROGBITS
24    Flags:        [ SHF_ALLOC ]
25    AddressAlign: 0x100
26    Address:      0
27    Size:         0x100
28  - Name:         .empty
29    Type:         SHT_PROGBITS
30    Flags:        [ SHF_ALLOC ]
31    Address:      0x1000
32  - Name:         .baz
33    Type:         SHT_PROGBITS
34    Flags:        [ SHF_ALLOC ]
35    AddressAlign: 0x1000
36    Address:      0x1000
37    Size:         0x100
38
39## Test that we attribute .empty to the second segment. Its offset is assigned according to
40## the p_offset of the second segment.
41# RUN: yaml2obj --docnum=2 %s -o %t2
42# RUN: llvm-objcopy %t2 %t2.out
43# RUN: llvm-readelf -S -l %t2.out | FileCheck --check-prefix=CHECK2 %s
44
45# CHECK2:      Name         Type     Address          Off
46# CHECK2-NEXT:              NULL     0000000000000000 000000
47# CHECK2-NEXT: .foo         PROGBITS 0000000000000000 000100
48# CHECK2-NEXT: .empty       PROGBITS 0000000000001000 001000
49# CHECK2-NEXT: .baz         PROGBITS 0000000000001000 001000
50
51# CHECK2:      Type  Offset   VirtAddr           PhysAddr           FileSiz  MemSiz   Flg Align
52# CHECK2-NEXT: LOAD  0x000100 0x0000000000000000 0x0000000000000000 0x000100 0x000100     0x100
53# CHECK2-NEXT: LOAD  0x001000 0x0000000000001000 0x0000000000001000 0x000100 0x000100     0x1000
54
55--- !ELF
56FileHeader:
57  Class:   ELFCLASS64
58  Data:    ELFDATA2LSB
59  Type:    ET_EXEC
60  Machine: EM_X86_64
61Sections:
62  - Name:         gap
63    Type:         Fill
64    Size:         0xE00
65  - Name:         .foo
66    Type:         SHT_PROGBITS
67    Flags:        [ SHF_ALLOC ]
68    AddressAlign: 0x100
69    Address:      0
70    Size:         0x100
71  - Name:         .empty
72    Type:         SHT_PROGBITS
73    Flags:        [ SHF_ALLOC ]
74    Address:      0x1000
75  - Name:         .baz
76    Type:         SHT_PROGBITS
77    Flags:        [ SHF_ALLOC ]
78    AddressAlign: 0x1000
79    Address:      0x1000
80    Size:         0x100
81ProgramHeaders:
82  - Type:     PT_LOAD
83    VAddr:    0
84    Align:    0x100
85    FirstSec: .foo
86    LastSec:  .foo
87  - Type:     PT_LOAD
88    VAddr:    0x1000
89    Align:    0x1000
90    FirstSec: .empty
91    LastSec:  .baz
92