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