[llvm-objcopy] [COFF] Implement --only-keep-debug
[llvm-core.git] / test / tools / llvm-objcopy / COFF / only-keep-debug.test
blob5518d4000fcfaf5a0990a9c6563b8aa86435465c
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
7 Check that all non-debug/buildid sections with IMAGE_SCN_CNT_CODE
8 or IMAGE_SCN_CNT_INITIALIZED_DATA are truncated, and no others.
10 SECTIONS:      Sections [
11 SECTIONS-NEXT:  Section {
12 SECTIONS-NEXT:   Number: 1
13 SECTIONS-NEXT:   Name: .text
14 SECTIONS-NEXT:   VirtualSize: 0x4
15 SECTIONS-NEXT:   VirtualAddress:
16 SECTIONS-NEXT:   RawDataSize: 0
17 SECTIONS:       Section {
18 SECTIONS-NEXT:   Number: 2
19 SECTIONS-NEXT:   Name: .rdata
20 SECTIONS-NEXT:   VirtualSize: 0x4
21 SECTIONS-NEXT:   VirtualAddress:
22 SECTIONS-NEXT:   RawDataSize: 0
23 SECTIONS:       Section {
24 SECTIONS-NEXT:   Number: 3
25 SECTIONS-NEXT:   Name: .buildid
26 SECTIONS-NEXT:   VirtualSize: 0x4
27 SECTIONS-NEXT:   VirtualAddress:
28 SECTIONS-NEXT:   RawDataSize: 512
29 SECTIONS:       Section {
30 SECTIONS-NEXT:   Number: 4
31 SECTIONS-NEXT:   Name: .reloc
32 SECTIONS-NEXT:   VirtualSize: 0x4
33 SECTIONS-NEXT:   VirtualAddress:
34 SECTIONS-NEXT:   RawDataSize: 0
35 SECTIONS:       Section {
36 SECTIONS-NEXT:   Number: 5
37 SECTIONS-NEXT:   Name: .debug_discardable
38 SECTIONS-NEXT:   VirtualSize: 0x4
39 SECTIONS-NEXT:   VirtualAddress:
40 SECTIONS-NEXT:   RawDataSize: 512
41 SECTIONS:       Section {
42 SECTIONS-NEXT:   Number: 6
43 SECTIONS-NEXT:   Name: .debug_undiscardable
44 SECTIONS-NEXT:   VirtualSize: 0x4
45 SECTIONS-NEXT:   VirtualAddress:
46 SECTIONS-NEXT:   RawDataSize: 512
47 SECTIONS:       Section {
48 SECTIONS-NEXT:   Number: 7
49 SECTIONS-NEXT:   Name: .unflagged
50 SECTIONS-NEXT:   VirtualSize: 0x4
51 SECTIONS-NEXT:   VirtualAddress:
52 SECTIONS-NEXT:   RawDataSize: 512
54 SYMBOLS:      SYMBOL TABLE:
55 SYMBOLS-NEXT: main
56 SYMBOLS-NEXT: debug_discardable_sym
57 SYMBOLS-NEXT: debug_undiscardable_sym
58 SYMBOLS-EMPTY: