1# RUN: yaml2obj %s -o %t
2# RUN: llvm-objcopy -R .text2 %t %t2
3# RUN: llvm-readobj --file-headers --sections --program-headers %t2 | FileCheck %s
4
5!ELF
6FileHeader:
7  Class:           ELFCLASS64
8  Data:            ELFDATA2LSB
9  Type:            ET_EXEC
10  Machine:         EM_X86_64
11Sections:
12  - Name:            .text
13    Type:            SHT_PROGBITS
14    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
15    Address:         0x1000
16    AddressAlign:    0x1000
17    Size:            0x1000
18  - Name:            .text2
19    Type:            SHT_PROGBITS
20    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
21    Address:         0x2000
22    AddressAlign:    0x1000
23    Size:            0x1000
24  - Name:            .text3
25    Type:            SHT_PROGBITS
26    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
27    Address:         0x3000
28    AddressAlign:    0x1000
29    Size:            0x1000
30ProgramHeaders:
31  - Type:     PT_LOAD
32    Flags:    [ PF_R ]
33    VAddr:    0x1000
34    FirstSec: .text
35    LastSec:  .text
36  - Type:     PT_LOAD
37    Flags:    [ PF_X, PF_R ]
38    VAddr:    0x3000
39    FirstSec: .text3
40    LastSec:  .text3
41## TODO (grimar): without the following line (i.e. without an empty symbol table),
42## llvm-objcopy adds an empty .strtab section. It doesn't look correct.
43Symbols: []
44
45#CHECK: SectionHeaderCount: 4
46
47# CHECK:           Sections [
48# CHECK-NEXT:        Section {
49# CHECK-NEXT:          Index: 0
50# CHECK-NEXT:          Name:  (0)
51# CHECK-NEXT:          Type: SHT_NULL (0x0)
52# CHECK-NEXT:          Flags [ (0x0)
53# CHECK-NEXT:          ]
54# CHECK-NEXT:          Address: 0x0
55# CHECK-NEXT:          Offset: 0x0
56# CHECK-NEXT:          Size: 0
57# CHECK-NEXT:          Link: 0
58# CHECK-NEXT:          Info: 0
59# CHECK-NEXT:          AddressAlignment: 0
60# CHECK-NEXT:          EntrySize: 0
61# CHECK-NEXT:        }
62# CHECK-NEXT:        Section {
63# CHECK-NEXT:          Index: 1
64# CHECK-NEXT:          Name: .text
65# CHECK-NEXT:          Type: SHT_PROGBITS (0x1)
66# CHECK-NEXT:          Flags [ (0x6)
67# CHECK-NEXT:            SHF_ALLOC (0x2)
68# CHECK-NEXT:            SHF_EXECINSTR (0x4)
69# CHECK-NEXT:          ]
70# CHECK-NEXT:          Address: 0x1000
71# CHECK-NEXT:          Offset: 0x1000
72# CHECK-NEXT:          Size: 4096
73# CHECK-NEXT:          Link: 0
74# CHECK-NEXT:          Info: 0
75# CHECK-NEXT:          AddressAlignment: 4096
76# CHECK-NEXT:          EntrySize: 0
77# CHECK-NEXT:        }
78# CHECK-NEXT:        Section {
79# CHECK-NEXT:          Index: 2
80# CHECK-NEXT:          Name: .text3
81# CHECK-NEXT:          Type: SHT_PROGBITS (0x1)
82# CHECK-NEXT:          Flags [ (0x6)
83# CHECK-NEXT:            SHF_ALLOC (0x2)
84# CHECK-NEXT:            SHF_EXECINSTR (0x4)
85# CHECK-NEXT:          ]
86# CHECK-NEXT:          Address: 0x3000
87# CHECK-NEXT:          Offset: 0x2000
88# CHECK-NEXT:          Size: 4096
89# CHECK-NEXT:          Link: 0
90# CHECK-NEXT:          Info: 0
91# CHECK-NEXT:          AddressAlignment: 4096
92# CHECK-NEXT:          EntrySize: 0
93# CHECK-NEXT:        }
94# CHECK-NEXT:        Section {
95# CHECK-NEXT:          Index: 3
96# CHECK-NEXT:          Name: .shstrtab
97# CHECK-NEXT:          Type: SHT_STRTAB (0x3)
98# CHECK-NEXT:          Flags [ (0x0)
99# CHECK-NEXT:          ]
100# CHECK-NEXT:          Address: 0x0
101# CHECK-NEXT:          Offset:
102# CHECK-NEXT:          Size:
103# CHECK-NEXT:          Link: 0
104# CHECK-NEXT:          Info: 0
105# CHECK-NEXT:          AddressAlignment: 1
106# CHECK-NEXT:          EntrySize: 0
107# CHECK-NEXT:        }
108# CHECK-NEXT:      ]
109
110
111# CHECK:     ProgramHeaders [
112# CHECK-NEXT:  ProgramHeader {
113# CHECK-NEXT:    Type: PT_LOAD (0x1)
114# CHECK-NEXT:    Offset: 0x1000
115# CHECK-NEXT:    VirtualAddress: 0x1000
116# CHECK-NEXT:    PhysicalAddress: 0x1000
117# CHECK-NEXT:    FileSize: 4096
118# CHECK-NEXT:    MemSize: 4096
119# CHECK-NEXT:    Flags [ (0x4)
120# CHECK-NEXT:      PF_R (0x4)
121# CHECK-NEXT:    ]
122# CHECK-NEXT:    Alignment: 4096
123# CHECK-NEXT:  }
124# CHECK-NEXT:  ProgramHeader {
125# CHECK-NEXT:    Type: PT_LOAD (0x1)
126# CHECK-NEXT:    Offset: 0x2000
127# CHECK-NEXT:    VirtualAddress: 0x3000
128# CHECK-NEXT:    PhysicalAddress: 0x3000
129# CHECK-NEXT:    FileSize: 4096
130# CHECK-NEXT:    MemSize: 4096
131# CHECK-NEXT:    Flags [ (0x5)
132# CHECK-NEXT:      PF_R (0x4)
133# CHECK-NEXT:      PF_X (0x1)
134# CHECK-NEXT:    ]
135# CHECK-NEXT:    Alignment: 4096
136# CHECK-NEXT:  }
137# CHECK-NEXT:]
138