1 RUN: yaml2obj %p/Inputs/only-keep-sections.yaml > %t.in.exe
3 RUN: llvm-objcopy --only-keep-debug %t.in.exe %t.out.exe
4 RUN: llvm-readobj --sections %t.out.exe | FileCheck %s --check-prefix=SECTIONS
5 RUN: llvm-objdump -t %t.out.exe | FileCheck %s --check-prefix=SYMBOLS
6 # Run llvm-strip with --strip-symbol on a non-existent symbol to prevent
7 # defaulting to --strip-all.
8 RUN: llvm-strip --only-keep-debug --strip-symbol foo %t.in.exe -o %t-strip.out.exe
9 RUN: cmp %t.out.exe %t-strip.out.exe
11 Check that all non-debug/buildid sections with IMAGE_SCN_CNT_CODE
12 or IMAGE_SCN_CNT_INITIALIZED_DATA are truncated, and no others.
15 SECTIONS-NEXT: Section {
16 SECTIONS-NEXT: Number: 1
17 SECTIONS-NEXT: Name: .text
18 SECTIONS-NEXT: VirtualSize: 0x4
19 SECTIONS-NEXT: VirtualAddress:
20 SECTIONS-NEXT: RawDataSize: 0
22 SECTIONS-NEXT: Number: 2
23 SECTIONS-NEXT: Name: .rdata
24 SECTIONS-NEXT: VirtualSize: 0x4
25 SECTIONS-NEXT: VirtualAddress:
26 SECTIONS-NEXT: RawDataSize: 0
28 SECTIONS-NEXT: Number: 3
29 SECTIONS-NEXT: Name: .buildid
30 SECTIONS-NEXT: VirtualSize: 0x4
31 SECTIONS-NEXT: VirtualAddress:
32 SECTIONS-NEXT: RawDataSize: 512
34 SECTIONS-NEXT: Number: 4
35 SECTIONS-NEXT: Name: .reloc
36 SECTIONS-NEXT: VirtualSize: 0x4
37 SECTIONS-NEXT: VirtualAddress:
38 SECTIONS-NEXT: RawDataSize: 0
40 SECTIONS-NEXT: Number: 5
41 SECTIONS-NEXT: Name: .debug_discardable
42 SECTIONS-NEXT: VirtualSize: 0x4
43 SECTIONS-NEXT: VirtualAddress:
44 SECTIONS-NEXT: RawDataSize: 512
46 SECTIONS-NEXT: Number: 6
47 SECTIONS-NEXT: Name: .debug_undiscardable
48 SECTIONS-NEXT: VirtualSize: 0x4
49 SECTIONS-NEXT: VirtualAddress:
50 SECTIONS-NEXT: RawDataSize: 512
52 SECTIONS-NEXT: Number: 7
53 SECTIONS-NEXT: Name: .unflagged
54 SECTIONS-NEXT: VirtualSize: 0x4
55 SECTIONS-NEXT: VirtualAddress:
56 SECTIONS-NEXT: RawDataSize: 512
58 SYMBOLS: SYMBOL TABLE:
60 SYMBOLS-NEXT: debug_discardable_sym
61 SYMBOLS-NEXT: debug_undiscardable_sym