2 # RUN: rm -rf %t; split-file %s %t
3 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/foo.s -o %t/foo.o
4 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/bar.s -o %t/bar.o
6 ## "_llvm." symbols are not special. LLD would produce duplicate symbol errors
7 ## if they were not within the LLVM segment.
9 ## 1/ Test that LLD does not produce duplicate symbols errors when linking global symbols
10 ## with the same name under the LLVM segment.
11 # RUN: %lld -dylib %t/foo.o %t/bar.o -o %t/libDuplicate.dylib
13 ## 2/ Test that all sections within an LLVM segment are dropped.
14 # RUN: llvm-objdump --section-headers %t/libDuplicate.dylib | FileCheck %s
16 # CHECK-LABEL: Sections:
17 # CHECK-NEXT: Idx Name Size VMA Type
18 # CHECK-NEXT: 0 __text 00000000 {{[0-9a-f]+}} TEXT
20 ## 3/ Test that linking global symbol that is not under the LLVM segment produces duplicate
22 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin --defsym TEXT=0 %t/foo.s -o %t/foo.o
23 # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin --defsym TEXT=0 %t/bar.s -o %t/bar.o
24 # RUN: not %lld -dylib %t/foo.o %t/bar.o -o %t/libDuplicate.dylib 2>&1 | FileCheck %s --check-prefix=DUP
26 # DUP: error: duplicate symbol: _llvm.foo
31 .section __TEXT,__cstring
33 .section __LLVM,__bitcode
41 .section __TEXT,__cstring
43 .section __LLVM,__bitcode