blob: a084abbb5ba7afe72e8e34779876c4886ea5358a [file] [log] [blame]
Jake Ehrlichd246b0a2017-09-19 21:37:35 +00001# This test tests how ParentSegment is set for Segments. In particular this test
2# tests that if a chain of parents forms, the offsets are chosen for parents
3# first despite the order of the list. It also tests multiple branches of the
4# code that assigns parents.
5
6# RUN: yaml2obj %s -o %t
7# RUN: llvm-objcopy %t %t2
8# RUN: llvm-readobj -program-headers %t2 | FileCheck %s
9
10!ELF
11FileHeader:
12 Class: ELFCLASS64
13 Data: ELFDATA2LSB
14 Type: ET_EXEC
15 Machine: EM_X86_64
16Sections:
17 - Name: .text
18 Type: SHT_PROGBITS
19 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
20 AddressAlign: 0x1000
21 Size: 4096
22 - Name: .text2
23 Type: SHT_PROGBITS
24 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
25 AddressAlign: 0x1000
26 Size: 4096
27 - Name: .text3
28 Type: SHT_PROGBITS
29 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
30 AddressAlign: 0x1000
31 Size: 4096
32 - Name: .text4
33 Type: SHT_PROGBITS
34 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
35 AddressAlign: 0x1000
36 Size: 4096
37 - Name: .text5
38 Type: SHT_PROGBITS
39 Flags: [ SHF_ALLOC, SHF_EXECINSTR ]
40 AddressAlign: 0x1000
41 Size: 4096
42ProgramHeaders:
43 - Type: PT_LOAD
44 Flags: [ PF_X, PF_R ]
45 Sections:
46 - Section: .text
47 - Section: .text2
48 - Type: PT_LOAD
49 Flags: [ PF_X, PF_R ]
50 Sections:
51 - Section: .text4
52 - Section: .text5
53 - Type: PT_LOAD
54 Flags: [ PF_X, PF_R ]
55 Sections:
56 - Section: .text3
57 - Section: .text4
58 - Type: PT_LOAD
59 Flags: [ PF_X, PF_R ]
60 Sections:
61 - Section: .text2
62 - Section: .text3
63
64#CHECK: ProgramHeaders [
65#CHECK-NEXT: ProgramHeader {
66#CHECK-NEXT: Type: PT_LOAD (0x1)
67#CHECK-NEXT: Offset: 0x1000
68#CHECK-NEXT: VirtualAddress: 0x0
69#CHECK-NEXT: PhysicalAddress: 0x0
70#CHECK-NEXT: FileSize: 8192
71#CHECK-NEXT: MemSize: 8192
72#CHECK-NEXT: Flags [ (0x5)
73#CHECK-NEXT: PF_R (0x4)
74#CHECK-NEXT: PF_X (0x1)
75#CHECK-NEXT: ]
76#CHECK-NEXT: Alignment: 4096
77#CHECK-NEXT: }
78#CHECK-NEXT: ProgramHeader {
79#CHECK-NEXT: Type: PT_LOAD (0x1)
80#CHECK-NEXT: Offset: 0x4000
81#CHECK-NEXT: VirtualAddress: 0x0
82#CHECK-NEXT: PhysicalAddress: 0x0
83#CHECK-NEXT: FileSize: 8192
84#CHECK-NEXT: MemSize: 8192
85#CHECK-NEXT: Flags [ (0x5)
86#CHECK-NEXT: PF_R (0x4)
87#CHECK-NEXT: PF_X (0x1)
88#CHECK-NEXT: ]
89#CHECK-NEXT: Alignment: 4096
90#CHECK-NEXT: }
91#CHECK-NEXT: ProgramHeader {
92#CHECK-NEXT: Type: PT_LOAD (0x1)
93#CHECK-NEXT: Offset: 0x3000
94#CHECK-NEXT: VirtualAddress: 0x0
95#CHECK-NEXT: PhysicalAddress: 0x0
96#CHECK-NEXT: FileSize: 8192
97#CHECK-NEXT: MemSize: 8192
98#CHECK-NEXT: Flags [ (0x5)
99#CHECK-NEXT: PF_R (0x4)
100#CHECK-NEXT: PF_X (0x1)
101#CHECK-NEXT: ]
102#CHECK-NEXT: Alignment: 4096
103#CHECK-NEXT: }
104#CHECK-NEXT: ProgramHeader {
105#CHECK-NEXT: Type: PT_LOAD (0x1)
106#CHECK-NEXT: Offset: 0x2000
107#CHECK-NEXT: VirtualAddress: 0x0
108#CHECK-NEXT: PhysicalAddress: 0x0
109#CHECK-NEXT: FileSize: 8192
110#CHECK-NEXT: MemSize: 8192
111#CHECK-NEXT: Flags [ (0x5)
112#CHECK-NEXT: PF_R (0x4)
113#CHECK-NEXT: PF_X (0x1)
114#CHECK-NEXT: ]
115#CHECK-NEXT: Alignment: 4096
116#CHECK-NEXT: }
117#CHECK-NEXT:]