1## Test --add-section. This test dumps and removes the section first and checks
2## that adding it back doesn't change the result.
3# RUN: yaml2obj %s -o %t
4# RUN: llvm-objcopy --dump-section=producers=%t.sec --remove-section=producers %t %t2
5# RUN: llvm-objcopy --add-section=producers=%t.sec %t2 %t3
6# RUN: obj2yaml %t3 | FileCheck %s
7
8## Check that the producers section has been added back unchanged.
9# CHECK:      Name: producers
10# CHECK-NEXT: Tools:
11# CHECK-NEXT:  - Name:    clang
12# CHECK-NEXT:    Version: 9.0.0
13
14# Check that the section is replaced with new content in one invocation.
15# RUN: echo "123" > %t4
16# RUN: llvm-objcopy --remove-section=foo --add-section=foo=%t4 %t %t5
17# RUN: obj2yaml %t5 | FileCheck %s --check-prefix=REPLACE
18
19# REPLACE: - Type:  CUSTOM
20# REPLACE:   Name:    foo
21# REPLACE:   Payload: 3132330A
22
23--- !WASM
24FileHeader:
25  Version: 0x00000001
26Sections:
27  - Type: TYPE
28    Signatures:
29      - Index: 0
30        ParamTypes:
31          - I32
32        ReturnTypes:
33          - F32
34      - Index: 1
35        ParamTypes:
36          - I32
37          - I64
38        ReturnTypes: []
39  - Type: FUNCTION
40    FunctionTypes:
41      - 0
42      - 1
43  - Type: CODE
44    Relocations:
45      - Type: R_WASM_TABLE_INDEX_SLEB
46        Index: 0
47        Offset: 0x00000000
48      - Type: R_WASM_FUNCTION_INDEX_LEB
49        Index: 1
50        Offset: 0x0000000
51    Functions:
52      - Index: 0
53        Locals:
54         - Type: I32
55           Count: 3
56        Body: 010101010B
57      - Index: 1
58        Locals:
59         - Type:  I32
60           Count: 1
61        Body: 010101010B
62  - Type: CUSTOM
63    Name: linking
64    Version: 2
65    SymbolTable:
66      - Index:    0
67        Kind:     FUNCTION
68        Name:     func1
69        Flags:    [  ]
70        Function: 0
71      - Index:    1
72        Kind:     FUNCTION
73        Name:     func2
74        Flags:    [  ]
75        Function: 1
76  - Type: CUSTOM
77    Name: producers
78    Tools:
79      - Name:   clang
80        Version: 9.0.0
81  - Type: CUSTOM
82    Name: foo
83    Payload: ABC123
84