1# REQUIRES: x86 2 3# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o 4# RUN: ld.lld -shared %t2.o -soname shared -o %t2.so 5 6# RUN: echo "{ global: foo1; foo3; local: *; };" > %t.script 7# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o 8# RUN: ld.lld --version-script %t.script -shared %t.o %t2.so -o %t.so 9# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck --check-prefix=DSO %s 10 11# RUN: echo "# comment" > %t3.script 12# RUN: echo "{ local: *; # comment" >> %t3.script 13# RUN: echo -n "}; # comment" >> %t3.script 14# RUN: ld.lld --version-script %t3.script -shared %t.o %t2.so -o %t3.so 15# RUN: llvm-readobj -dyn-symbols %t3.so | FileCheck --check-prefix=DSO2 %s 16 17# RUN: echo "VERSION_1.0 { global: foo1; local: *; };" > %t4.script 18# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" >> %t4.script 19# RUN: ld.lld --version-script %t4.script -shared %t.o %t2.so -o %t4.so 20# RUN: llvm-readobj -dyn-symbols %t4.so | FileCheck --check-prefix=VERDSO %s 21 22# RUN: echo "VERSION_1.0 { global: foo1; local: *; };" > %t5.script 23# RUN: echo "{ global: foo3; local: *; };" >> %t5.script 24# RUN: not ld.lld --version-script %t5.script -shared %t.o %t2.so -o %t5.so 2>&1 | \ 25# RUN: FileCheck -check-prefix=ERR1 %s 26# ERR1: anonymous version definition is used in combination with other version definitions 27 28# RUN: echo "{ global: foo1; local: *; };" > %t5.script 29# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" >> %t5.script 30# RUN: not ld.lld --version-script %t5.script -shared %t.o %t2.so -o %t5.so 2>&1 | \ 31# RUN: FileCheck -check-prefix=ERR2 %s 32# ERR2: EOF expected, but got VERSION_2.0 33 34# RUN: echo "VERSION_1.0 { global: foo1; local: *; };" > %t6.script 35# RUN: echo "VERSION_2.0 { global: foo1; local: *; };" >> %t6.script 36# RUN: ld.lld --version-script %t6.script -shared %t.o %t2.so -o %t6.so 2>&1 | \ 37# RUN: FileCheck -check-prefix=WARN2 %s 38# WARN2: duplicate symbol 'foo1' in version script 39 40# RUN: echo "{ foo1; foo2; };" > %t.list 41# RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2 42# RUN: llvm-readobj %t2 > /dev/null 43 44# DSO: DynamicSymbols [ 45# DSO-NEXT: Symbol { 46# DSO-NEXT: Name: @ 47# DSO-NEXT: Value: 0x0 48# DSO-NEXT: Size: 0 49# DSO-NEXT: Binding: Local (0x0) 50# DSO-NEXT: Type: None (0x0) 51# DSO-NEXT: Other: 0 52# DSO-NEXT: Section: Undefined (0x0) 53# DSO-NEXT: } 54# DSO-NEXT: Symbol { 55# DSO-NEXT: Name: bar@ 56# DSO-NEXT: Value: 0x0 57# DSO-NEXT: Size: 0 58# DSO-NEXT: Binding: Global (0x1) 59# DSO-NEXT: Type: Function (0x2) 60# DSO-NEXT: Other: 0 61# DSO-NEXT: Section: Undefined (0x0) 62# DSO-NEXT: } 63# DSO-NEXT: Symbol { 64# DSO-NEXT: Name: foo1@ 65# DSO-NEXT: Value: 0x1000 66# DSO-NEXT: Size: 0 67# DSO-NEXT: Binding: Global (0x1) 68# DSO-NEXT: Type: None (0x0) 69# DSO-NEXT: Other: 0 70# DSO-NEXT: Section: .text 71# DSO-NEXT: } 72# DSO-NEXT: Symbol { 73# DSO-NEXT: Name: foo3@ 74# DSO-NEXT: Value: 0x1007 75# DSO-NEXT: Size: 0 76# DSO-NEXT: Binding: Global (0x1) 77# DSO-NEXT: Type: None (0x0) 78# DSO-NEXT: Other: 0 79# DSO-NEXT: Section: .text 80# DSO-NEXT: } 81# DSO-NEXT: ] 82 83# DSO2: DynamicSymbols [ 84# DSO2-NEXT: Symbol { 85# DSO2-NEXT: Name: @ 86# DSO2-NEXT: Value: 0x0 87# DSO2-NEXT: Size: 0 88# DSO2-NEXT: Binding: Local (0x0) 89# DSO2-NEXT: Type: None (0x0) 90# DSO2-NEXT: Other: 0 91# DSO2-NEXT: Section: Undefined (0x0) 92# DSO2-NEXT: } 93# DSO2-NEXT: Symbol { 94# DSO2-NEXT: Name: bar@ 95# DSO2-NEXT: Value: 0x0 96# DSO2-NEXT: Size: 0 97# DSO2-NEXT: Binding: Global (0x1) 98# DSO2-NEXT: Type: Function (0x2) 99# DSO2-NEXT: Other: 0 100# DSO2-NEXT: Section: Undefined (0x0) 101# DSO2-NEXT: } 102# DSO2-NEXT: ] 103 104# VERDSO: DynamicSymbols [ 105# VERDSO-NEXT: Symbol { 106# VERDSO-NEXT: Name: @ 107# VERDSO-NEXT: Value: 0x0 108# VERDSO-NEXT: Size: 0 109# VERDSO-NEXT: Binding: Local 110# VERDSO-NEXT: Type: None 111# VERDSO-NEXT: Other: 0 112# VERDSO-NEXT: Section: Undefined 113# VERDSO-NEXT: } 114# VERDSO-NEXT: Symbol { 115# VERDSO-NEXT: Name: bar@ 116# VERDSO-NEXT: Value: 0x0 117# VERDSO-NEXT: Size: 0 118# VERDSO-NEXT: Binding: Global 119# VERDSO-NEXT: Type: Function 120# VERDSO-NEXT: Other: 0 121# VERDSO-NEXT: Section: Undefined 122# VERDSO-NEXT: } 123# VERDSO-NEXT: Symbol { 124# VERDSO-NEXT: Name: foo1@@VERSION_1.0 125# VERDSO-NEXT: Value: 0x1000 126# VERDSO-NEXT: Size: 0 127# VERDSO-NEXT: Binding: Global 128# VERDSO-NEXT: Type: None 129# VERDSO-NEXT: Other: 0 130# VERDSO-NEXT: Section: .text 131# VERDSO-NEXT: } 132# VERDSO-NEXT: Symbol { 133# VERDSO-NEXT: Name: foo3@@VERSION_2.0 134# VERDSO-NEXT: Value: 0x1007 135# VERDSO-NEXT: Size: 0 136# VERDSO-NEXT: Binding: Global 137# VERDSO-NEXT: Type: None 138# VERDSO-NEXT: Other: 0 139# VERDSO-NEXT: Section: .text 140# VERDSO-NEXT: } 141# VERDSO-NEXT: ] 142 143# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o 144# RUN: ld.lld -shared %t.o %t2.so -o %t.so 145# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck --check-prefix=ALL %s 146 147# RUN: echo "{ global: foo1; foo3; };" > %t2.script 148# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o 149# RUN: ld.lld --version-script %t2.script -shared %t.o %t2.so -o %t.so 150# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck --check-prefix=ALL %s 151 152# ALL: DynamicSymbols [ 153# ALL-NEXT: Symbol { 154# ALL-NEXT: Name: @ 155# ALL-NEXT: Value: 0x0 156# ALL-NEXT: Size: 0 157# ALL-NEXT: Binding: Local 158# ALL-NEXT: Type: None 159# ALL-NEXT: Other: 0 160# ALL-NEXT: Section: Undefined 161# ALL-NEXT: } 162# ALL-NEXT: Symbol { 163# ALL-NEXT: Name: _start@ 164# ALL-NEXT: Value: 165# ALL-NEXT: Size: 0 166# ALL-NEXT: Binding: Global 167# ALL-NEXT: Type: None 168# ALL-NEXT: Other: 0 169# ALL-NEXT: Section: .text 170# ALL-NEXT: } 171# ALL-NEXT: Symbol { 172# ALL-NEXT: Name: bar@ 173# ALL-NEXT: Value: 174# ALL-NEXT: Size: 0 175# ALL-NEXT: Binding: Global 176# ALL-NEXT: Type: Function 177# ALL-NEXT: Other: 0 178# ALL-NEXT: Section: Undefined 179# ALL-NEXT: } 180# ALL-NEXT: Symbol { 181# ALL-NEXT: Name: foo1@ 182# ALL-NEXT: Value: 183# ALL-NEXT: Size: 0 184# ALL-NEXT: Binding: Global 185# ALL-NEXT: Type: None 186# ALL-NEXT: Other: 0 187# ALL-NEXT: Section: .text 188# ALL-NEXT: } 189# ALL-NEXT: Symbol { 190# ALL-NEXT: Name: foo2@ 191# ALL-NEXT: Value: 192# ALL-NEXT: Size: 0 193# ALL-NEXT: Binding: Global 194# ALL-NEXT: Type: None 195# ALL-NEXT: Other: 0 196# ALL-NEXT: Section: .text 197# ALL-NEXT: } 198# ALL-NEXT: Symbol { 199# ALL-NEXT: Name: foo3@ 200# ALL-NEXT: Value: 201# ALL-NEXT: Size: 0 202# ALL-NEXT: Binding: Global 203# ALL-NEXT: Type: None 204# ALL-NEXT: Other: 0 205# ALL-NEXT: Section: .text 206# ALL-NEXT: } 207# ALL-NEXT: ] 208 209.globl foo1 210foo1: 211 call bar@PLT 212 ret 213 214.globl foo2 215foo2: 216 ret 217 218.globl foo3 219foo3: 220 call foo2@PLT 221 ret 222 223.globl _start 224_start: 225 ret 226