xref: /llvm-project/lld/test/wasm/allow-multiple-definition.s (revision 0367305af849da7ee9237fd83c04ed3a01e8d223)
1# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t1
2# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/allow-multiple-definition.s -o %t2
3# RUN: not wasm-ld %t1 %t2 -o /dev/null
4# RUN: not wasm-ld --allow-multiple-definition --no-allow-multiple-definition %t1 %t2 -o /dev/null
5# RUN: wasm-ld --allow-multiple-definition --fatal-warnings %t1 %t2 -o %t3
6# RUN: wasm-ld --allow-multiple-definition --fatal-warnings %t2 %t1 -o %t4
7# RUN: llvm-objdump --no-print-imm-hex -d %t3 | FileCheck %s
8# RUN: llvm-objdump --no-print-imm-hex -d %t4 | FileCheck --check-prefix=REVERT %s
9
10# RUN: wasm-ld --noinhibit-exec %t2 %t1 -o /dev/null 2>&1 | FileCheck %s --check-prefix=WARN
11# WARN: warning: duplicate symbol: foo
12
13# RUN: wasm-ld -z muldefs --fatal-warnings  %t1 %t2 -o %t3
14# RUN: wasm-ld -z muldefs --fatal-warnings  %t2 %t1 -o %t4
15# RUN: llvm-objdump --no-print-imm-hex -d %t3 | FileCheck %s
16# RUN: llvm-objdump --no-print-imm-hex -d %t4 | FileCheck --check-prefix=REVERT %s
17
18# CHECK:  i32.const 0
19# REVERT:  i32.const 1
20
21# inputs contain different constants for function foo return.
22# Tests below checks that order of files in command line
23# affects on what symbol will be used.
24# If flag allow-multiple-definition is enabled the first
25# meet symbol should be used.
26
27  .hidden foo
28  .globl  foo
29foo:
30  .functype foo () -> (i32)
31  i32.const 0
32  end_function
33
34  .globl _start
35_start:
36  .functype  _start () -> (i32)
37  call foo
38  end_function
39