1 ## Show that llvm-objcopy adds a new section into a 64-bit object if
2 ## --add-section is given.
4 # RUN: yaml2obj %s -o %t
5 # RUN: echo -n abcdefg > %t.data
7 ## Case 1: Add a new section into an existing segment.
8 # RUN: llvm-objcopy --add-section __TEXT,__bar=%t.data %t %t.out1
9 # RUN: llvm-readobj --sections --section-data %t.out1 \
10 # RUN: | FileCheck %s --check-prefixes=COMMON,CASE1
12 ## Case 2: Add a new section into a nonexistent segment.
13 # RUN: llvm-objcopy --add-section __FOO,__bar=%t.data %t %t.out2
14 # RUN: llvm-readobj --sections --section-data %t.out2 \
15 # RUN: | FileCheck %s --check-prefixes=COMMON,CASE2
16 # RUN: llvm-readobj --sections --section-data %t.out2 \
17 # RUN: | FileCheck %s --check-prefixes=COMMON,CASE2
19 ## Case 3: Add a new section into an existing segment using /dev/null as an input.
20 # RUN: llvm-objcopy --add-section __TEXT,__bar=/dev/null %t %t.out3
21 # RUN: llvm-readobj --sections --section-data %t.out3 \
22 # RUN: | FileCheck %s --check-prefixes=COMMON,CASE3
28 cpusubtype: 0x00000003
49 addr: 0x0000000000000000
62 # COMMON-NEXT: Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
63 # COMMON-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
64 # COMMON-NEXT: Address: 0x0
65 # COMMON-NEXT: Size: 0x4
66 # COMMON-NEXT: Offset:
67 # COMMON-NEXT: Alignment: 0
68 # COMMON-NEXT: RelocationOffset: 0x0
69 # COMMON-NEXT: RelocationCount: 0
70 # COMMON-NEXT: Type: Regular (0x0)
71 # COMMON-NEXT: Attributes [ (0x800004)
72 # COMMON-NEXT: PureInstructions (0x800000)
73 # COMMON-NEXT: SomeInstructions (0x4)
75 # COMMON-NEXT: Reserved1: 0x0
76 # COMMON-NEXT: Reserved2: 0x0
77 # COMMON-NEXT: Reserved3: 0x0
78 # COMMON-NEXT: SectionData (
79 # COMMON-NEXT: 0000: AABBCCDD |....|
83 # COMMON-NEXT: Name: __bar (5F 5F 62 61 72 00 00 00 00 00 00 00 00 00 00 00)
85 # CASE1-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
86 # CASE1-NEXT: Address: 0x4
87 # CASE1-NEXT: Size: 0x7
88 # CASE1-NEXT: Offset: 268
90 # CASE2: Segment: __FOO (5F 5F 46 4F 4F 00 00 00 00 00 00 00 00 00 00 00)
91 # CASE2-NEXT: Address: 0xB8
92 # CASE2-NEXT: Size: 0x7
93 # CASE2-NEXT: Offset: 340
95 # CASE3-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
96 # CASE3-NEXT: Address: 0x4
97 # CASE3-NEXT: Size: 0x0
98 # CASE3-NEXT: Offset: 268
100 # COMMON-NEXT: Alignment: 0
101 # COMMON-NEXT: RelocationOffset: 0x0
102 # COMMON-NEXT: RelocationCount: 0
103 # COMMON-NEXT: Type: Regular (0x0)
104 # COMMON-NEXT: Attributes [ (0x0)
106 # COMMON-NEXT: Reserved1: 0x0
107 # COMMON-NEXT: Reserved2: 0x0
108 # COMMON-NEXT: Reserved3: 0x0
110 # CASE1-NEXT: SectionData (
111 # CASE1-NEXT: 0000: 61626364 656667 |abcdefg|
114 # CASE2-NEXT: SectionData (
115 # CASE2-NEXT: 0000: 61626364 656667 |abcdefg|
118 # CASE3-NEXT: SectionData (