blob: 97fa96aac70d2dd3c817bbab0bae34c1b743d392 [file] [log] [blame]
Martin Storsjo78a0b412019-01-19 19:42:41 +00001# RUN: yaml2obj %s > %t.in.o
2#
3# RUN: llvm-objdump --section-headers %t.in.o | FileCheck %s --check-prefixes=SECTIONS,SECTIONS-PRE
4# RUN: llvm-objdump -t %t.in.o | FileCheck %s --check-prefixes=SYMBOLS,SYMBOLS-PRE
5#
6# RUN: llvm-objcopy --strip-debug %t.in.o %t.out.o
7# RUN: llvm-objdump --section-headers %t.out.o | FileCheck %s --check-prefixes=SECTIONS
8# RUN: llvm-objdump -t %t.out.o | FileCheck %s --check-prefixes=SYMBOLS
9#
10# Test that --strip-all, --strip-all-gnu, --discard-all and --strip-unneeded,
11# plus llvm-strip without arguments all produce a similiar set of sections
12# (while they remove symbols differently).
13#
14# RUN: llvm-objcopy --strip-all %t.in.o %t.strip-all.o
15# RUN: llvm-objdump --section-headers %t.strip-all.o | FileCheck %s --check-prefixes=SECTIONS
16#
17# RUN: llvm-objcopy --strip-all-gnu %t.in.o %t.strip-all-gnu.o
18# RUN: llvm-objdump --section-headers %t.strip-all-gnu.o | FileCheck %s --check-prefixes=SECTIONS
19#
20# RUN: llvm-objcopy --discard-all %t.in.o %t.discard-all.o
21# RUN: llvm-objdump --section-headers %t.discard-all.o | FileCheck %s --check-prefixes=SECTIONS
22#
23# RUN: llvm-objcopy --discard-all %t.in.o %t.strip-unneeded.o
24# RUN: llvm-objdump --section-headers %t.strip-unneeded.o | FileCheck %s --check-prefixes=SECTIONS
25#
26# SECTIONS: Sections:
27# SECTIONS-NEXT: Idx Name
28# SECTIONS-NEXT: 0 .text
29# SECTIONS-NEXT: 1 .data
30# SECTIONS-NEXT: 2 .bss
31# SECTIONS-NEXT: 3 .xdata
32# SECTIONS-NEXT: 4 .reloc
33# SECTIONS-PRE-NEXT: 5 .debug_discardable
34# SECTIONS-NEXT: {{.*}} .debug_undiscardable
35# SECTIONS-NEXT: {{.*}} .llvm_addrsig
36# SECTIONS-EMPTY:
37#
38# Test that --strip-debug doesn't remove e.g. unreferenced local symbols.
39#
40# SYMBOLS: SYMBOL TABLE:
41# SYMBOLS-NEXT: external
42# SYMBOLS-NEXT: local_unreferenced
43# SYMBOLS-PRE-NEXT: debug_discardable_sym
44# SYMBOLS-NEXT: debug_undiscardable_sym
45# SYMBOLS-EMPTY:
46
47--- !COFF
48header:
49 Machine: IMAGE_FILE_MACHINE_AMD64
50 Characteristics: [ ]
51sections:
52 - Name: .text
53 Characteristics: [ ]
54 Alignment: 4
55 SectionData: 00000000
56 - Name: .data
57 Characteristics: [ ]
58 Alignment: 4
59 SectionData: 00000000
60 - Name: .bss
61 Characteristics: [ ]
62 Alignment: 4
63 SectionData: 00000000
64 - Name: .xdata
65 Characteristics: [ ]
66 Alignment: 4
67 SectionData: 00000000
68 - Name: .reloc
69 Characteristics: [ IMAGE_SCN_MEM_DISCARDABLE ]
70 Alignment: 4
71 SectionData: 00000000
72 - Name: .debug_discardable
73 Characteristics: [ IMAGE_SCN_MEM_DISCARDABLE ]
74 Alignment: 4
75 SectionData: 00000000
76 - Name: .debug_undiscardable
77 Characteristics: [ ]
78 Alignment: 4
79 SectionData: 00000000
80 - Name: .llvm_addrsig
81 Characteristics: [ IMAGE_SCN_LNK_REMOVE ]
82 Alignment: 4
83 SectionData: 00000000
84symbols:
85 - Name: external
86 Value: 0
87 SectionNumber: 1
88 SimpleType: IMAGE_SYM_TYPE_NULL
89 ComplexType: IMAGE_SYM_DTYPE_NULL
90 StorageClass: IMAGE_SYM_CLASS_EXTERNAL
91 - Name: local_unreferenced
92 Value: 0
93 SectionNumber: 1
94 SimpleType: IMAGE_SYM_TYPE_NULL
95 ComplexType: IMAGE_SYM_DTYPE_NULL
96 StorageClass: IMAGE_SYM_CLASS_STATIC
97 - Name: debug_discardable_sym
98 Value: 0
99 SectionNumber: 6
100 SimpleType: IMAGE_SYM_TYPE_NULL
101 ComplexType: IMAGE_SYM_DTYPE_NULL
102 StorageClass: IMAGE_SYM_CLASS_EXTERNAL
103 - Name: debug_undiscardable_sym
104 Value: 0
105 SectionNumber: 7
106 SimpleType: IMAGE_SYM_TYPE_NULL
107 ComplexType: IMAGE_SYM_DTYPE_NULL
108 StorageClass: IMAGE_SYM_CLASS_EXTERNAL
109...