llvm-project
46 строк · 1.5 Кб
1# REQUIRES: x86
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
5
6## "_llvm." symbols are not special. LLD would produce duplicate symbol errors
7## if they were not within the LLVM segment.
8
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
12
13## 2/ Test that all sections within an LLVM segment are dropped.
14# RUN: llvm-objdump --section-headers %t/libDuplicate.dylib | FileCheck %s
15
16# CHECK-LABEL: Sections:
17# CHECK-NEXT: Idx Name Size VMA Type
18# CHECK-NEXT: 0 __text 00000000 {{[0-9a-f]+}} TEXT
19
20## 3/ Test that linking global symbol that is not under the LLVM segment produces duplicate
21## symbols
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
25
26# DUP: error: duplicate symbol: _llvm.foo
27
28#--- foo.s
29.globl _llvm.foo
30.ifdef TEXT
31.section __TEXT,__cstring
32.else
33.section __LLVM,__bitcode
34.endif
35_llvm.foo:
36.asciz "test"
37
38#--- bar.s
39.globl _llvm.foo
40.ifdef TEXT
41.section __TEXT,__cstring
42.else
43.section __LLVM,__bitcode
44.endif
45_llvm.foo:
46.asciz "test"
47