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