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