1 ## Show that llvm-objcopy adds a new section into a 32-bit object file 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
17 ## Case 3: Add a new section into an existing segment using /dev/null as an input.
18 # RUN: llvm-objcopy --add-section __TEXT,__bar=/dev/null %t %t.out3
19 # RUN: llvm-readobj --sections --section-data %t.out3 \
20 # RUN: | FileCheck %s --check-prefixes=COMMON,CASE3
26 cpusubtype: 0x00000003
46 addr: 0x0000000000000000
59 # COMMON-NEXT: Name: __text (5F 5F 74 65 78 74 00 00 00 00 00 00 00 00 00 00)
60 # COMMON-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
61 # COMMON-NEXT: Address: 0x0
62 # COMMON-NEXT: Size: 0x4
63 # COMMON-NEXT: Offset:
64 # COMMON-NEXT: Alignment: 0
65 # COMMON-NEXT: RelocationOffset: 0x0
66 # COMMON-NEXT: RelocationCount: 0
67 # COMMON-NEXT: Type: Regular (0x0)
68 # COMMON-NEXT: Attributes [ (0x800004)
69 # COMMON-NEXT: PureInstructions (0x800000)
70 # COMMON-NEXT: SomeInstructions (0x4)
72 # COMMON-NEXT: Reserved1: 0x0
73 # COMMON-NEXT: Reserved2: 0x0
74 # COMMON-NEXT: SectionData (
75 # COMMON-NEXT: 0000: AABBCCDD |....|
79 # COMMON-NEXT: Name: __bar (5F 5F 62 61 72 00 00 00 00 00 00 00 00 00 00 00)
81 # CASE1-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
82 # CASE1-NEXT: Address: 0x4
83 # CASE1-NEXT: Size: 0x7
84 # CASE1-NEXT: Offset: 224
86 # CASE2-NEXT: Segment: __FOO (5F 5F 46 4F 4F 00 00 00 00 00 00 00 00 00 00 00)
87 # CASE2-NEXT: Address: 0x98
88 # CASE2-NEXT: Size: 0x7
89 # CASE2-NEXT: Offset: 280
91 # CASE3-NEXT: Segment: __TEXT (5F 5F 54 45 58 54 00 00 00 00 00 00 00 00 00 00)
92 # CASE3-NEXT: Address: 0x4
93 # CASE3-NEXT: Size: 0x0
94 # CASE3-NEXT: Offset: 224
96 # COMMON-NEXT: Alignment: 0
97 # COMMON-NEXT: RelocationOffset: 0x0
98 # COMMON-NEXT: RelocationCount: 0
99 # COMMON-NEXT: Type: Regular (0x0)
100 # COMMON-NEXT: Attributes [ (0x0)
102 # COMMON-NEXT: Reserved1: 0x0
103 # COMMON-NEXT: Reserved2: 0x0
105 # CASE1-NEXT: SectionData (
106 # CASE1-NEXT: 0000: 61626364 656667 |abcdefg|
109 # CASE2-NEXT: SectionData (
110 # CASE2-NEXT: 0000: 61626364 656667 |abcdefg|
113 # CASE3-NEXT: SectionData (