1# RUN: yaml2obj --docnum=1 %s -o %t
2# RUN: llvm-objcopy --strip-non-alloc %t %t.out
3# RUN: llvm-readobj --file-headers --sections %t.out | FileCheck %s
4
5# CHECK: SectionHeaderCount: 5
6# CHECK: Name: non_alloc_in_segment
7# CHECK: Name: .bss
8# CHECK: Name: .text
9# CHECK: Name: .shstrtab
10
11--- !ELF
12FileHeader:
13  Class:           ELFCLASS64
14  Data:            ELFDATA2LSB
15  Type:            ET_REL
16  Machine:         EM_X86_64
17Sections:
18  - Name:            non_alloc_in_segment
19    Type:            SHT_PROGBITS
20    Flags:           [ ]
21    Size:            4
22  - Name:            .bss
23    Type:            SHT_NOBITS
24    Flags:           [ SHF_ALLOC ]
25  - Name:            .text
26    Type:            SHT_PROGBITS
27    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
28ProgramHeaders:
29  # Use an arbitrary segment type to show that the segment type is unimportant.
30  - Type:     0x61234567
31    FirstSec: non_alloc_in_segment
32    LastSec:  non_alloc_in_segment
33
34# RUN: yaml2obj --docnum=2 %s -o %t2
35# RUN: llvm-objcopy --strip-non-alloc %t2 %t2.out
36# RUN: llvm-readobj --file-headers --sections %t2.out | FileCheck --check-prefix=CHECK2 %s
37
38# CHECK2: SectionHeaderCount: 3
39# CHECK2: Name: .text
40# CHECK2: Name: .shstrtab
41
42--- !ELF
43FileHeader:
44  Class:     ELFCLASS64
45  Data:      ELFDATA2LSB
46  Type:      ET_REL
47  Machine:   EM_X86_64
48Sections:
49  - Name:    .text
50    Type:    SHT_PROGBITS
51    Flags:   [ SHF_ALLOC, SHF_EXECINSTR ]
52## empty_trailing_non_alloc is considered included by the segment,
53## so it will be retained.
54  - Name:    empty_trailing_non_alloc
55    Type:    SHT_PROGBITS
56  - Name:    trailing_non_alloc
57    Type:    SHT_PROGBITS
58    Content: 00
59ProgramHeaders:
60  - Type:     0x61234567
61    FirstSec: .text
62    LastSec:  .text
63