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