2 # RUN: rm -rf %t && split-file %s %t && cd %t
4 # RUN: llvm-mc -filetype=obj -triple=riscv64 1.s -o 1.o
5 # RUN: ld.lld 1.o --shared -o 1.so
6 # RUN: llvm-readelf -d -s 1.so | FileCheck --check-prefix=CHECK1 %s
8 # CHECK1: Symbol table '.dynsym'
9 # CHECK1: 0 NOTYPE GLOBAL DEFAULT [VARIANT_CC] [[#]] func_global_def
10 # CHECK1: Symbol table '.symtab'
11 # CHECK1: 0 NOTYPE GLOBAL DEFAULT [VARIANT_CC] [[#]] func_global_def
13 # RUN: llvm-mc -filetype=obj -triple=riscv64 2.s -o 2.o
14 # RUN: ld.lld 2.o --shared -o 2.so
15 # RUN: llvm-readelf -d -s 2.so | FileCheck --check-prefix=CHECK2 %s
17 # CHECK2: 0x0000000070000001 (RISCV_VARIANT_CC) 0x0
18 # CHECK2: Symbol table '.dynsym'
19 # CHECK2: 0 NOTYPE GLOBAL DEFAULT [VARIANT_CC] [[#]] func_global_def
20 # CHECK2: Symbol table '.symtab'
21 # CHECK2: 0 NOTYPE GLOBAL DEFAULT [VARIANT_CC] [[#]] func_global_def
23 # RUN: llvm-mc -filetype=obj -triple=riscv32 3.s -o 3.o
24 # RUN: ld.lld 3.o --shared -o 3.so
25 # RUN: llvm-readelf -d -s 3.so | FileCheck --check-prefix=CHECK3 %s
27 # CHECK3: 0x70000001 (RISCV_VARIANT_CC) 0x0
28 # CHECK3: Symbol table '.dynsym'
29 # CHECK3: 0 IFUNC GLOBAL DEFAULT [VARIANT_CC] UND ifunc_global_def
30 # CHECK3: 0 NOTYPE GLOBAL DEFAULT [[#]] func_global_def
32 # RUN: llvm-mc -filetype=obj -triple=riscv32 4.s -o 4.o
33 # RUN: ld.lld 4.o --shared -o 4.so
34 # RUN: llvm-readelf -d -s 4.so | FileCheck --check-prefix=CHECK4 %s
36 # CHECK4-NOT: (RISCV_VARIANT_CC)
37 # CHECK4: Symbol table '.dynsym'
38 # CHECK4: 0 IFUNC GLOBAL DEFAULT [VARIANT_CC] [[#]] ifunc_global_def
40 # RUN: llvm-mc -filetype=obj -triple=riscv64 5.s -o 5.o
41 # RUN: ld.lld 5.o --shared -o 5.so
42 # RUN: llvm-readelf -d -s 5.so | FileCheck --check-prefix=CHECK5 %s
44 # CHECK5: Symbol table '.dynsym' contains 4 entries:
45 # CHECK5: 0 NOTYPE GLOBAL DEFAULT [VARIANT_CC] UND func_global_undef
46 # CHECK5-NEXT: 0 NOTYPE GLOBAL DEFAULT [VARIANT_CC] [[#]] func_global_def
47 # CHECK5-NEXT: 0 IFUNC GLOBAL DEFAULT [VARIANT_CC] [[#]] ifunc_global_def
48 # CHECK5: Symbol table '.symtab' contains 10 entries:
49 # CHECK5: 0 NOTYPE LOCAL DEFAULT [VARIANT_CC] [[#]] func_local
50 # CHECK5-NEXT: 0 IFUNC LOCAL DEFAULT [VARIANT_CC] [[#]] ifunc_local
51 # CHECK5: 0 NOTYPE LOCAL HIDDEN [VARIANT_CC] [[#]] func_global_hidden
52 # CHECK5-NEXT: 0 IFUNC LOCAL HIDDEN [VARIANT_CC] [[#]] ifunc_global_hidden
53 # CHECK5: 0 NOTYPE GLOBAL DEFAULT [VARIANT_CC] [[#]] func_global_def
54 # CHECK5-NEXT: 0 NOTYPE GLOBAL DEFAULT [VARIANT_CC] UND func_global_undef
55 # CHECK5-NEXT: 0 IFUNC GLOBAL DEFAULT [VARIANT_CC] [[#]] ifunc_global_def
58 ## An object with a variant_pcs symbol but without a R_RISCV_JMP_SLOT
59 ## should not generate a DT_RISCV_VARIANT_CC.
61 .global func_global_def
62 .variant_cc func_global_def
68 ## An object with a variant_cc symbol and with a R_RISCV_JMP_SLOT
69 ## should generate a DT_RISCV_VARIANT_CC.
71 .global func_global_def
72 .variant_cc func_global_def
78 ## Same as before, but targeting a GNU IFUNC.
80 .global ifunc_global_def
81 .global func_global_def
82 .variant_cc ifunc_global_def
83 .type ifunc_global_def, %gnu_indirect_function
89 ## An object with a variant_cc symbol and with a R_RISCV_IRELATIVE
90 ## should not generate a DT_RISCV_VARIANT_CC.
92 .global ifunc_global_def
93 .global func_global_def
94 .variant_cc ifunc_global_def
95 .type ifunc_global_def, %gnu_indirect_function
101 ## Check if STO_RISCV_VARIANT_CC is kept on symbol st_other for both undef,
102 ## local, and hidden visibility.
104 .global func_global_def, func_global_undef, func_global_hidden
105 .global ifunc_global_def, ifunc_global_hidden
108 .hidden func_global_hidden, ifunc_global_hidden
110 .type ifunc_global_def, %gnu_indirect_function
111 .type ifunc_global_hidden, %gnu_indirect_function
112 .type ifunc_local, %gnu_indirect_function
114 .variant_cc func_global_def
115 .variant_cc func_global_undef
116 .variant_cc func_global_hidden
117 .variant_cc func_local
118 .variant_cc ifunc_global_def
119 .variant_cc ifunc_global_hidden
120 .variant_cc ifunc_local