2016-04-23 04:21:26 +08:00
|
|
|
# REQUIRES: x86
|
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o
|
|
|
|
# RUN: ld.lld -shared %t2.o -soname shared -o %t2.so
|
|
|
|
|
|
|
|
# RUN: echo "{ global: foo1; foo3; local: *; };" > %t.script
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
2019-08-04 17:05:21 +08:00
|
|
|
# RUN: ld.lld --version-script %t.script -shared %t.o %t2.so -o %t.so --fatal-warnings
|
2019-09-06 23:10:31 +08:00
|
|
|
# RUN: llvm-readelf --dyn-syms %t.so | FileCheck --check-prefix=DSO %s
|
2016-04-23 04:21:26 +08:00
|
|
|
|
2016-06-16 21:29:48 +08:00
|
|
|
# RUN: echo "# comment" > %t3.script
|
|
|
|
# RUN: echo "{ local: *; # comment" >> %t3.script
|
|
|
|
# RUN: echo -n "}; # comment" >> %t3.script
|
2016-04-23 04:21:26 +08:00
|
|
|
# RUN: ld.lld --version-script %t3.script -shared %t.o %t2.so -o %t3.so
|
2019-09-06 23:10:31 +08:00
|
|
|
# RUN: llvm-readelf --dyn-syms %t3.so | FileCheck --check-prefix=DSO2 %s
|
2016-04-23 04:21:26 +08:00
|
|
|
|
2017-02-03 21:24:01 +08:00
|
|
|
## Also check that both "global:" and "global :" forms are accepted
|
|
|
|
# RUN: echo "VERSION_1.0 { global : foo1; local : *; };" > %t4.script
|
2016-09-08 04:50:41 +08:00
|
|
|
# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" >> %t4.script
|
2019-08-04 17:05:21 +08:00
|
|
|
# RUN: ld.lld --version-script %t4.script -shared %t.o %t2.so -o %t4.so --fatal-warnings
|
2019-09-06 23:10:31 +08:00
|
|
|
# RUN: llvm-readelf --dyn-syms %t4.so | FileCheck --check-prefix=VERDSO %s
|
2016-06-17 02:47:04 +08:00
|
|
|
|
2016-09-08 04:50:41 +08:00
|
|
|
# RUN: echo "VERSION_1.0 { global: foo1; local: *; };" > %t5.script
|
|
|
|
# RUN: echo "{ global: foo3; local: *; };" >> %t5.script
|
2020-02-13 13:48:45 +08:00
|
|
|
# RUN: not ld.lld --version-script %t5.script -shared %t.o %t2.so -o /dev/null 2>&1 | \
|
2016-09-01 04:03:54 +08:00
|
|
|
# RUN: FileCheck -check-prefix=ERR1 %s
|
|
|
|
# ERR1: anonymous version definition is used in combination with other version definitions
|
2016-06-17 02:47:04 +08:00
|
|
|
|
2016-09-08 04:50:41 +08:00
|
|
|
# RUN: echo "{ global: foo1; local: *; };" > %t5.script
|
|
|
|
# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" >> %t5.script
|
2020-02-13 13:48:45 +08:00
|
|
|
# RUN: not ld.lld --version-script %t5.script -shared %t.o %t2.so -o /dev/null 2>&1 | \
|
2016-09-01 04:03:54 +08:00
|
|
|
# RUN: FileCheck -check-prefix=ERR2 %s
|
|
|
|
# ERR2: EOF expected, but got VERSION_2.0
|
2016-06-17 02:47:04 +08:00
|
|
|
|
2016-12-09 01:54:26 +08:00
|
|
|
# RUN: echo "{ foo1; foo2; };" > %t.list
|
2016-06-17 02:47:04 +08:00
|
|
|
# RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2
|
|
|
|
# RUN: llvm-readobj %t2 > /dev/null
|
|
|
|
|
2017-12-07 11:25:39 +08:00
|
|
|
## Check that we can handle multiple "--version-script" options.
|
|
|
|
# RUN: echo "VERSION_1.0 { global : foo1; local : *; };" > %t7a.script
|
|
|
|
# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" > %t7b.script
|
|
|
|
# RUN: ld.lld --version-script %t7a.script --version-script %t7b.script -shared %t.o %t2.so -o %t7.so
|
2019-09-06 23:10:31 +08:00
|
|
|
# RUN: llvm-readelf --dyn-syms %t7.so | FileCheck --check-prefix=VERDSO %s
|
|
|
|
|
|
|
|
# DSO: bar{{$}}
|
|
|
|
# DSO-NEXT: foo1{{$}}
|
|
|
|
# DSO-NEXT: foo3{{$}}
|
|
|
|
# DSO-NOT: {{.}}
|
|
|
|
|
|
|
|
# DSO2: bar{{$}}
|
|
|
|
# DSO2-NOT: {{.}}
|
|
|
|
|
|
|
|
# VERDSO: bar{{$}}
|
|
|
|
# VERDSO-NEXT: foo1@@VERSION_1.0
|
|
|
|
# VERDSO-NEXT: foo3@@VERSION_2.0
|
|
|
|
# VERDSO-NOT: {{.}}
|
2016-06-17 21:38:09 +08:00
|
|
|
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
2017-10-06 17:37:44 +08:00
|
|
|
# RUN: ld.lld --hash-style=sysv -shared %t.o %t2.so -o %t.so
|
2019-09-06 23:10:31 +08:00
|
|
|
# RUN: llvm-readelf --dyn-syms %t.so | FileCheck --check-prefix=ALL %s
|
2016-06-17 21:38:09 +08:00
|
|
|
|
|
|
|
# RUN: echo "{ global: foo1; foo3; };" > %t2.script
|
|
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
|
2017-10-06 17:37:44 +08:00
|
|
|
# RUN: ld.lld --hash-style=sysv --version-script %t2.script -shared %t.o %t2.so -o %t.so
|
2019-09-06 23:10:31 +08:00
|
|
|
# RUN: llvm-readelf --dyn-syms %t.so | FileCheck --check-prefix=ALL %s
|
|
|
|
|
2021-02-14 02:32:27 +08:00
|
|
|
# ALL: foo1{{$}}
|
2019-09-06 23:10:31 +08:00
|
|
|
# ALL-NEXT: bar{{$}}
|
|
|
|
# ALL-NEXT: foo2{{$}}
|
|
|
|
# ALL-NEXT: foo3{{$}}
|
2021-02-14 02:32:27 +08:00
|
|
|
# ALL-NEXT: _start{{$}}
|
2019-09-06 23:10:31 +08:00
|
|
|
# ALL-NOT: {{.}}
|
2016-06-17 21:38:09 +08:00
|
|
|
|
2018-03-07 01:05:12 +08:00
|
|
|
# RUN: echo "VERSION_1.0 { global: foo1; foo1; local: *; };" > %t8.script
|
2018-07-03 01:48:23 +08:00
|
|
|
# RUN: ld.lld --version-script %t8.script -shared %t.o -o /dev/null --fatal-warnings
|
2018-03-07 01:05:12 +08:00
|
|
|
|
2016-04-23 04:21:26 +08:00
|
|
|
.globl foo1
|
|
|
|
foo1:
|
|
|
|
call bar@PLT
|
|
|
|
ret
|
|
|
|
|
|
|
|
.globl foo2
|
|
|
|
foo2:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.globl foo3
|
|
|
|
foo3:
|
|
|
|
call foo2@PLT
|
|
|
|
ret
|
|
|
|
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
ret
|