Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lld / test / ELF / symver-non-default.s
blob4923a5108018a382fecb9008576e79bb30ef024d
1 # REQUIRES: x86
2 ## Test symbol resolution related to .symver produced non-default version symbols.
4 # RUN: split-file %s %t
5 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/ref.s -o %t/ref.o
6 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def1.s -o %t/def1.o
7 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def2.s -o %t/def2.o
8 # RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def3.s -o %t/def3.o
10 ## foo@v1 & foo defined at the same location are combined.
11 # RUN: ld.lld -shared --version-script=%t/ver1 %t/def1.o %t/ref.o -o %t1
12 # RUN: llvm-readelf --dyn-syms %t1 | FileCheck %s --check-prefix=CHECK1
13 # RUN: ld.lld -shared --version-script=%t/ver2 %t/def1.o %t/ref.o -o %t1
14 # RUN: llvm-readelf --dyn-syms %t1 | FileCheck %s --check-prefix=CHECK1
16 # CHECK1: 1: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo@v1
17 # CHECK1-EMPTY:
19 ## def2.o doesn't define foo. foo@v1 & undefined foo are unrelated.
20 # RUN: ld.lld -shared --version-script=%t/ver1 %t/def2.o %t/ref.o -o %t2
21 # RUN: llvm-readelf -r --dyn-syms %t2 | FileCheck %s --check-prefix=CHECK2
23 # CHECK2: R_X86_64_JUMP_SLOT {{.*}} foo + 0
24 # CHECK2: 1: {{.*}} NOTYPE GLOBAL DEFAULT UND foo{{$}}
25 # CHECK2-NEXT: 2: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo@v1
26 # CHECK2-EMPTY:
28 ## def2.o doesn't define foo. foo@v1 & defined foo are unrelated.
29 # RUN: ld.lld -shared --version-script=%t/ver1 %t/def2.o %t/def3.o %t/ref.o -o %t3
30 # RUN: llvm-readelf -r --dyn-syms %t3 | FileCheck %s --check-prefix=CHECK3
32 # CHECK3: R_X86_64_JUMP_SLOT {{.*}} foo + 0
33 # CHECK3: 1: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo@v1
34 # CHECK3-NEXT: 2: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo{{$}}
35 # CHECK3-EMPTY:
37 ## foo@v1 overrides the defined foo which is affected by a version script.
38 # RUN: ld.lld -shared --version-script=%t/ver2 %t/def2.o %t/def3.o %t/ref.o -o %t4
39 # RUN: llvm-readelf -r --dyn-syms %t4 | FileCheck %s --check-prefix=CHECK4
41 # CHECK4: R_X86_64_JUMP_SLOT {{.*}} foo@v1 + 0
42 # CHECK4: 1: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo@v1
43 # CHECK4-EMPTY:
45 #--- ver1
46 v1 {};
48 #--- ver2
49 v1 { foo; };
51 #--- ref.s
52 call foo
54 #--- def1.s
55 .globl foo
56 .symver foo, foo@v1
57 foo:
58 ret
60 #--- def2.s
61 .globl foo_v1
62 .symver foo_v1, foo@v1, remove
63 foo_v1:
64 ret
66 #--- def3.s
67 .globl foo
68 foo:
69 ret