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