xref: /llvm-project/lld/test/MachO/abs-duplicate.s (revision 58edaef3fe08b81d9e3c172dd38338508be7ac79)
1# REQUIRES: x86
2# RUN: rm -rf %t; split-file %s %t
3# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o
4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weakfoo.s -o %t/weakfoo.o
5# RUN: not %lld -lSystem %t/test.o %t/weakfoo.o -o /dev/null 2>&1 | FileCheck %s
6
7# CHECK:      error: duplicate symbol: _weakfoo
8# CHECK-NEXT: >>> defined in {{.*}}/test.o
9# CHECK-NEXT: >>> defined in {{.*}}/weakfoo.o
10
11## Duplicate absolute symbols that will be dead stripped later should not fail.
12# RUN: %lld -lSystem -dead_strip --dead-strip-duplicates -map %t/stripped-duplicate-map \
13# RUN:     %t/test.o %t/weakfoo.o -o %t/test
14# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=DUP
15# DUP-LABEL: SYMBOL TABLE:
16# DUP-NEXT:   g F __TEXT,__text _main
17# DUP-NEXT:   g F __TEXT,__text __mh_execute_header
18# DUP-NEXT:   *UND* dyld_stub_binder
19
20## Dead stripped non-section symbols don't show up in map files because there's no input section.
21## Check that _weakfoo doesn't show up. This matches ld64.
22# RUN: FileCheck --check-prefix=DUPMAP %s < %t/stripped-duplicate-map
23# DUPMAP: _main
24# DUPMAP-LABEL: Dead Stripped Symbols
25# DUPMAP-NOT: _weakfoo
26
27#--- weakfoo.s
28.globl _weakfoo
29## The weak attribute is ignored for absolute symbols, so we will have a
30## duplicate symbol error for _weakfoo.
31.weak_definition _weakfoo
32_weakfoo = 0x1234
33
34#--- test.s
35.globl _main, _weakfoo
36.weak_definition _weakfoo
37_weakfoo = 0x5678
38
39.text
40_main:
41  ret
42