xref: /llvm-project/llvm/test/tools/llvm-objcopy/wasm/basic-only-section.test (revision 2a6136e552d24b6bf665c42a6e32efc0b2d88fbf)
1## Test --only-section.
2# RUN: yaml2obj %s -o %t
3# RUN: llvm-objcopy --only-section=foo %t %t2
4# RUN: obj2yaml %t2 | FileCheck --implicit-check-not TYPE --implicit-check-not producers %s
5
6## Test that it's the same with only-section + keep-section (for the same section).
7# RUN: llvm-objcopy --only-section=foo --keep-section=foo %t %t2
8# RUN: obj2yaml %t2 | FileCheck --implicit-check-not TYPE --implicit-check-not producers %s
9
10## Also test that only-section overrides remove-section.
11# RUN: llvm-objcopy --only-section=foo --remove-section=foo %t %t2
12# RUN: obj2yaml %t2 | FileCheck --implicit-check-not producers %s
13
14## This file has both known and custom sections. Check that only the foo section is left.
15# CHECK:      Sections:
16# CHECK-NEXT:   - Type: CUSTOM
17# CHECK-NEXT:     Name: foo
18# CHECK-NEXT:     Payload: DEADBEEF
19# CHECK-NEXT: ...
20
21## Test that only-section + keep-section keeps both sections.
22# RUN: llvm-objcopy --only-section=foo --keep-section=producers %t %t2
23# RUN: obj2yaml %t2 | FileCheck --implicit-check-not=TYPE --check-prefix=KEEP %s
24# KEEP: Name: foo
25# KEEP: Name: producers
26
27--- !WASM
28FileHeader:
29  Version: 0x00000001
30Sections:
31  - Type: CUSTOM
32    Name: foo
33    Payload: DEADBEEF
34  - Type: TYPE
35    Signatures:
36      - Index: 0
37        ParamTypes:
38          - I32
39        ReturnTypes:
40          - F32
41  - Type: CUSTOM
42    Name: producers
43    Tools:
44      - Name:   clang
45        Version: 9.0.0
46