1 # RUN: yaml2obj %s > %t.in.o
3 # RUN: llvm-objdump -section-headers %t.in.o | FileCheck %s --check-prefixes=SECTIONS-PRE
4 # RUN: llvm-objdump -t %t.in.o | FileCheck %s --check-prefixes=SYMBOLS-PRE
6 # RUN: llvm-objcopy -R .bss %t.in.o %t.remove-bss.o
7 # RUN: llvm-objdump -section-headers %t.remove-bss.o | FileCheck %s --check-prefix=SECTIONS-REMOVE-BSS
8 # RUN: llvm-objdump -t %t.remove-bss.o | FileCheck %s --check-prefix=SYMBOLS-REMOVE-BSS
10 # RUN: llvm-objcopy --remove-section .bss %t.in.o %t.cmp.o
11 # RUN: cmp %t.remove-bss.o %t.cmp.o
13 # RUN: llvm-objcopy -R .text %t.in.o %t.remove-text.o
14 # RUN: llvm-objdump -section-headers %t.remove-text.o | FileCheck %s --check-prefix=SECTIONS-REMOVE-TEXT
15 # RUN: llvm-objdump -t %t.remove-text.o | FileCheck %s --check-prefix=SYMBOLS-REMOVE-TEXT
17 # RUN: not llvm-objcopy -R .comdat %t.in.o %t.remove-comdat.o 2>&1 | FileCheck %s --check-prefix=ERROR-RELOC
19 # RUN: llvm-objcopy -R .text -R .comdat %t.in.o %t.remove-text-comdat.o
20 # RUN: llvm-objdump -section-headers %t.remove-text-comdat.o | FileCheck %s --check-prefix=SECTIONS-REMOVE-TEXT-COMDAT
21 # RUN: llvm-objdump -t %t.remove-text-comdat.o | FileCheck %s --check-prefix=SYMBOLS-REMOVE-TEXT-COMDAT
24 # SECTIONS-PRE: Sections:
25 # SECTIONS-PRE-NEXT: Idx Name
26 # SECTIONS-PRE-NEXT: 0 .text
27 # SECTIONS-PRE-NEXT: 1 .bss
28 # SECTIONS-PRE-NEXT: 2 .comdat
29 # SECTIONS-PRE-NEXT: 3 .associative
32 # SYMBOLS-PRE: SYMBOL TABLE:
33 # SYMBOLS-PRE-NEXT: {{.*}}(sec -1){{.*}} @feat.00
34 # SYMBOLS-PRE-NEXT: {{.*}}(sec 1){{.*}} .text
35 # SYMBOLS-PRE-NEXT: AUX scnlen {{.*}} assoc 1 comdat 0
36 # SYMBOLS-PRE-NEXT: {{.*}}(sec 2){{.*}} .bss
37 # SYMBOLS-PRE-NEXT: AUX scnlen {{.*}} assoc 2 comdat 0
38 # SYMBOLS-PRE-NEXT: {{.*}}(sec 4){{.*}} .associative
39 # SYMBOLS-PRE-NEXT: AUX scnlen {{.*}} assoc 3 comdat 5
40 # SYMBOLS-PRE-NEXT: {{.*}}(sec 3){{.*}} .comdat
41 # SYMBOLS-PRE-NEXT: AUX scnlen {{.*}} assoc 3 comdat 2
42 # SYMBOLS-PRE-NEXT: {{.*}}(sec 3){{.*}} foo
43 # SYMBOLS-PRE-NEXT: {{.*}}(sec 1){{.*}} main
47 # Removing the .bss section removes one symbol and its aux symbol,
48 # and updates the section indices in symbols pointing to later
49 # symbols, including the aux section defintitions.
51 # Testing that the absolute symbol @feat.00 survives the section number
54 # SECTIONS-REMOVE-BSS: Sections:
55 # SECTIONS-REMOVE-BSS-NEXT: Idx Name
56 # SECTIONS-REMOVE-BSS-NEXT: 0 .text
57 # SECTIONS-REMOVE-BSS-NEXT: 1 .comdat
58 # SECTIONS-REMOVE-BSS-NEXT: 2 .associative
59 # SECTIONS-REMOVE-BSS-EMPTY:
61 # SYMBOLS-REMOVE-BSS: SYMBOL TABLE:
62 # SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec -1){{.*}} @feat.00
63 # SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 1){{.*}} .text
64 # SYMBOLS-REMOVE-BSS-NEXT: AUX scnlen {{.*}} assoc 1 comdat 0
65 # SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 3){{.*}} .associative
66 # SYMBOLS-REMOVE-BSS-NEXT: AUX scnlen {{.*}} assoc 2 comdat 5
67 # SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 2){{.*}} .comdat
68 # SYMBOLS-REMOVE-BSS-NEXT: AUX scnlen {{.*}} assoc 2 comdat 2
69 # SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 2){{.*}} foo
70 # SYMBOLS-REMOVE-BSS-NEXT: {{.*}}(sec 1){{.*}} main
71 # SYMBOLS-REMOVE-BSS-EMPTY:
74 # Removing the .text section is ok and just removes the external symbol
77 # SECTIONS-REMOVE-TEXT: Sections:
78 # SECTIONS-REMOVE-TEXT-NEXT: Idx Name
79 # SECTIONS-REMOVE-TEXT-NEXT: 0 .bss
80 # SECTIONS-REMOVE-TEXT-NEXT: 1 .comdat
81 # SECTIONS-REMOVE-TEXT-NEXT: 2 .associative
82 # SECTIONS-REMOVE-TEXT-EMPTY:
84 # SYMBOLS-REMOVE-TEXT: SYMBOL TABLE:
85 # SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec -1){{.*}} @feat.00
86 # SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec 1){{.*}} .bss
87 # SYMBOLS-REMOVE-TEXT-NEXT: AUX scnlen {{.*}} assoc 1 comdat 0
88 # SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec 3){{.*}} .associative
89 # SYMBOLS-REMOVE-TEXT-NEXT: AUX scnlen {{.*}} assoc 2 comdat 5
90 # SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec 2){{.*}} .comdat
91 # SYMBOLS-REMOVE-TEXT-NEXT: AUX scnlen {{.*}} assoc 2 comdat 2
92 # SYMBOLS-REMOVE-TEXT-NEXT: {{.*}}(sec 2){{.*}} foo
93 # SYMBOLS-REMOVE-TEXT-EMPTY:
96 # Removing the .comdat section fails, since the .text section has relocations
99 # ERROR-RELOC: relocation target 'foo' ({{.*}}) not found
102 # Removing the .comdat section and .text (with a relocation against .comdat)
103 # works, as it also removes the .associative section transitively.
105 # SECTIONS-REMOVE-TEXT-COMDAT: Sections:
106 # SECTIONS-REMOVE-TEXT-COMDAT-NEXT: Idx Name
107 # SECTIONS-REMOVE-TEXT-COMDAT-NEXT: 0 .bss
108 # SECTIONS-REMOVE-TEXT-COMDAT-EMPTY:
110 # SYMBOLS-REMOVE-TEXT-COMDAT: SYMBOL TABLE:
111 # SYMBOLS-REMOVE-TEXT-COMDAT-NEXT: {{.*}}(sec -1){{.*}} @feat.00
112 # SYMBOLS-REMOVE-TEXT-COMDAT-NEXT: {{.*}}(sec 1){{.*}} .bss
113 # SYMBOLS-REMOVE-TEXT-COMDAT-NEXT: AUX scnlen {{.*}} assoc 1 comdat 0
114 # SYMBOLS-REMOVE-TEXT-COMDAT-EMPTY:
118 Machine: IMAGE_FILE_MACHINE_AMD64
124 SectionData: 488B0500000000C3
128 Type: IMAGE_REL_AMD64_REL32
134 Characteristics: [ IMAGE_SCN_LNK_COMDAT ]
136 SectionData: '2A000000'
138 Characteristics: [ IMAGE_SCN_LNK_COMDAT ]
140 SectionData: '0000000000000000'
145 SimpleType: IMAGE_SYM_TYPE_NULL
146 ComplexType: IMAGE_SYM_DTYPE_NULL
147 StorageClass: IMAGE_SYM_CLASS_STATIC
151 SimpleType: IMAGE_SYM_TYPE_NULL
152 ComplexType: IMAGE_SYM_DTYPE_NULL
153 StorageClass: IMAGE_SYM_CLASS_STATIC
156 NumberOfRelocations: 1
157 NumberOfLinenumbers: 0
163 SimpleType: IMAGE_SYM_TYPE_NULL
164 ComplexType: IMAGE_SYM_DTYPE_NULL
165 StorageClass: IMAGE_SYM_CLASS_STATIC
168 NumberOfRelocations: 0
169 NumberOfLinenumbers: 0
175 SimpleType: IMAGE_SYM_TYPE_NULL
176 ComplexType: IMAGE_SYM_DTYPE_NULL
177 StorageClass: IMAGE_SYM_CLASS_STATIC
180 NumberOfRelocations: 0
181 NumberOfLinenumbers: 0
184 Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE
188 SimpleType: IMAGE_SYM_TYPE_NULL
189 ComplexType: IMAGE_SYM_DTYPE_NULL
190 StorageClass: IMAGE_SYM_CLASS_STATIC
193 NumberOfRelocations: 0
194 NumberOfLinenumbers: 0
197 Selection: IMAGE_COMDAT_SELECT_ANY
201 SimpleType: IMAGE_SYM_TYPE_NULL
202 ComplexType: IMAGE_SYM_DTYPE_NULL
203 StorageClass: IMAGE_SYM_CLASS_EXTERNAL
207 SimpleType: IMAGE_SYM_TYPE_NULL
208 ComplexType: IMAGE_SYM_DTYPE_NULL
209 StorageClass: IMAGE_SYM_CLASS_EXTERNAL