xref: /llvm-project/llvm/test/tools/llvm-objcopy/wasm/dump-section.test (revision c9dd1cc6f0536c6547f322107cd27cd953913f5c)
1## Test the contents of a custom section dumped from a binary.
2# RUN: yaml2obj %s -o %t
3# RUN: llvm-objcopy --dump-section=producers=%t.sec %t
4# RUN: od -t x1 %t.sec | FileCheck %s
5
6# RUN: not llvm-objcopy --dump-section=nonexistent=%t.sec %t 2>&1 | FileCheck --check-prefix=NONEXISTENT %s
7# RUN: not llvm-objcopy --dump-section=producers=%t.dir/bar %t 2>&1 | FileCheck -DMSG=%errc_ENOENT --check-prefix=DIROUT %s
8
9## Raw contents of the producers section.
10# CHECK: 0000000 01 0c 70 72 6f 63 65 73 73 65 64 2d 62 79 01 05
11# CHECK: 0000020 63 6c 61 6e 67 05 39 2e 30 2e 30
12
13# NONEXISTENT: section 'nonexistent' not found
14# DIROUT: error: {{.*}}/bar': [[MSG]]
15
16## Test dumping the type section (a known section).
17# RUN: llvm-objcopy --dump-section=TYPE=%t.sec %t
18# RUN: od -t x1 %t.sec | FileCheck %s --check-prefix=TYPESEC
19
20## Raw contents of the type section.
21# TYPESEC: 000000 01 60 01 7f 01 7d
22# TYPESEC: 000006
23
24## Check that dumping and removing a section works in the same invocation
25# RUN: llvm-objcopy --dump-section=producers=%t.sec --remove-section=producers %t %t2
26# RUN: od -t x1 %t.sec | FileCheck %s
27# RUN: obj2yaml %t2 | FileCheck --check-prefix=REMOVED %s
28
29# REMOVED-NOT: producers
30
31--- !WASM
32FileHeader:
33  Version: 0x00000001
34Sections:
35  - Type: TYPE
36    Signatures:
37      - Index: 0
38        ParamTypes:
39          - I32
40        ReturnTypes:
41          - F32
42  - Type: CUSTOM
43    Name: producers
44    Tools:
45      - Name:   clang
46        Version: 9.0.0
47