1 ## This test verifies that llvm-objcopy can add multiple sections to a Mach-O binary.
3 # RUN: yaml2obj %s -o %t
4 # RUN: echo -n FOOabcdefg > %t.foo.data
5 # RUN: echo -n BARabcdefg > %t.bar.data
7 ## Case 1: Add a new section twice into an existing segment.
8 # RUN: llvm-objcopy --add-section __TEXT,__foo=%t.foo.data %t %t.foo.1
9 # RUN: llvm-objcopy --add-section __TEXT,__bar=%t.bar.data %t.foo.1 %t.foo.bar.1
10 # RUN: llvm-readobj --sections --section-data %t.foo.bar.1 \
11 # RUN: | FileCheck %s -check-prefix=CASE1
13 ## Case 2: Add two new sections into an existing segment.
14 # RUN: llvm-objcopy --add-section __TEXT,__foo=%t.foo.data --add-section __TEXT,__bar=%t.bar.data %t %t.foo.bar.2
15 # RUN: llvm-readobj --sections --section-data %t.foo.bar.2 \
16 # RUN: | FileCheck %s -check-prefix=CASE1
18 ## Case 3: Add two new sections into two different segments.
19 # RUN: llvm-objcopy --add-section __FOO,__foo=%t.foo.data --add-section __BAR,__bar=%t.bar.data %t %t.foo.bar.3
20 # RUN: llvm-readobj --sections --section-data %t.foo.bar.3 \
21 # RUN: | FileCheck %s -check-prefix=CASE3
27 cpusubtype: 0x00000003
48 addr: 0x0000000000000000
61 # CASE1-NEXT: Section {
62 # CASE1-NEXT: Index: 0
63 # CASE1-NEXT: Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
64 # CASE1-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
65 # CASE1-NEXT: Address: 0x0
66 # CASE1-NEXT: Size: 0x4
67 # CASE1-NEXT: Offset: 344
68 # CASE1-NEXT: Alignment: 0
69 # CASE1-NEXT: RelocationOffset: 0x0
70 # CASE1-NEXT: RelocationCount: 0
71 # CASE1-NEXT: Type: Regular (0x0)
72 # CASE1-NEXT: Attributes [ (0x800004)
73 # CASE1-NEXT: PureInstructions (0x800000)
74 # CASE1-NEXT: SomeInstructions (0x4)
76 # CASE1-NEXT: Reserved1: 0x0
77 # CASE1-NEXT: Reserved2: 0x0
78 # CASE1-NEXT: Reserved3: 0x0
79 # CASE1-NEXT: SectionData (
80 # CASE1-NEXT: 0000: AABBCCDD |....|
83 # CASE1-NEXT: Section {
84 # CASE1-NEXT: Index: 1
85 # CASE1-NEXT: Name: __foo (5F 5F 66 6F 6F 00 00 00 00 00 00 00 00 00 00 00)
86 # CASE1-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
87 # CASE1-NEXT: Address: 0x4
88 # CASE1-NEXT: Size: 0xA
89 # CASE1-NEXT: Offset: 348
90 # CASE1-NEXT: Alignment: 0
91 # CASE1-NEXT: RelocationOffset: 0x0
92 # CASE1-NEXT: RelocationCount: 0
93 # CASE1-NEXT: Type: Regular (0x0)
94 # CASE1-NEXT: Attributes [ (0x0)
96 # CASE1-NEXT: Reserved1: 0x0
97 # CASE1-NEXT: Reserved2: 0x0
98 # CASE1-NEXT: Reserved3: 0x0
99 # CASE1-NEXT: SectionData (
100 # CASE1-NEXT: 0000: 464F4F61 62636465 6667 |FOOabcdefg|
103 # CASE1-NEXT: Section {
104 # CASE1-NEXT: Index: 2
105 # CASE1-NEXT: Name: __bar (5F 5F 62 61 72 00 00 00 00 00 00 00 00 00 00 00)
106 # CASE1-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
107 # CASE1-NEXT: Address: 0xE
108 # CASE1-NEXT: Size: 0xA
109 # CASE1-NEXT: Offset: 358
110 # CASE1-NEXT: Alignment: 0
111 # CASE1-NEXT: RelocationOffset: 0x0
112 # CASE1-NEXT: RelocationCount: 0
113 # CASE1-NEXT: Type: Regular (0x0)
114 # CASE1-NEXT: Attributes [ (0x0)
116 # CASE1-NEXT: Reserved1: 0x0
117 # CASE1-NEXT: Reserved2: 0x0
118 # CASE1-NEXT: Reserved3: 0x0
119 # CASE1-NEXT: SectionData (
120 # CASE1-NEXT: 0000: 42415261 62636465 6667 |BARabcdefg|
126 # CASE3-NEXT: Section {
127 # CASE3-NEXT: Index: 0
128 # CASE3-NEXT: Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
129 # CASE3-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
130 # CASE3-NEXT: Address: 0x0
131 # CASE3-NEXT: Size: 0x4
132 # CASE3-NEXT: Offset: 488
133 # CASE3-NEXT: Alignment: 0
134 # CASE3-NEXT: RelocationOffset: 0x0
135 # CASE3-NEXT: RelocationCount: 0
136 # CASE3-NEXT: Type: Regular (0x0)
137 # CASE3-NEXT: Attributes [ (0x800004)
138 # CASE3-NEXT: PureInstructions (0x800000)
139 # CASE3-NEXT: SomeInstructions (0x4)
141 # CASE3-NEXT: Reserved1: 0x0
142 # CASE3-NEXT: Reserved2: 0x0
143 # CASE3-NEXT: Reserved3: 0x0
144 # CASE3-NEXT: SectionData (
145 # CASE3-NEXT: 0000: AABBCCDD |....|
148 # CASE3-NEXT: Section {
149 # CASE3-NEXT: Index: 1
150 # CASE3-NEXT: Name: __foo (5F 5F 66 6F 6F 00 00 00 00 00 00 00 00 00 00 00)
151 # CASE3-NEXT: Segment: __FOO (5F 5F 46 4F 4F 00 00 00 00 00 00 00 00 00 00 00)
152 # CASE3-NEXT: Address: 0xB8
153 # CASE3-NEXT: Size: 0xA
154 # CASE3-NEXT: Offset: 492
155 # CASE3-NEXT: Alignment: 0
156 # CASE3-NEXT: RelocationOffset: 0x0
157 # CASE3-NEXT: RelocationCount: 0
158 # CASE3-NEXT: Type: Regular (0x0)
159 # CASE3-NEXT: Attributes [ (0x0)
161 # CASE3-NEXT: Reserved1: 0x0
162 # CASE3-NEXT: Reserved2: 0x0
163 # CASE3-NEXT: Reserved3: 0x0
164 # CASE3-NEXT: SectionData (
165 # CASE3-NEXT: 0000: 464F4F61 62636465 6667 |FOOabcdefg|
168 # CASE3-NEXT: Section {
169 # CASE3-NEXT: Index: 2
170 # CASE3-NEXT: Name: __bar (5F 5F 62 61 72 00 00 00 00 00 00 00 00 00 00 00)
171 # CASE3-NEXT: Segment: __BAR (5F 5F 42 41 52 00 00 00 00 00 00 00 00 00 00 00)
172 # CASE3-NEXT: Address: 0x40B8
173 # CASE3-NEXT: Size: 0xA
174 # CASE3-NEXT: Offset: 502
175 # CASE3-NEXT: Alignment: 0
176 # CASE3-NEXT: RelocationOffset: 0x0
177 # CASE3-NEXT: RelocationCount: 0
178 # CASE3-NEXT: Type: Regular (0x0)
179 # CASE3-NEXT: Attributes [ (0x0)
181 # CASE3-NEXT: Reserved1: 0x0
182 # CASE3-NEXT: Reserved2: 0x0
183 # CASE3-NEXT: Reserved3: 0x0
184 # CASE3-NEXT: SectionData (
185 # CASE3-NEXT: 0000: 42415261 62636465 6667 |BARabcdefg|