[ELF][test] Improve .symver & --version-script tests

And delete redundant tests.
This commit is contained in:
Fangrui Song
2021-07-31 18:57:19 -07:00
parent 0da367145c
commit 52f35c9f14
9 changed files with 51 additions and 125 deletions

View File

@@ -3,7 +3,7 @@
// REQUIRES: x86
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o %t1.o
// RUN: echo "v1 {}; v2 {}; v3 { local: *; };" > %t1.script
// RUN: echo "v1 {}; v2 {}; v3 { global: f1; local: *; };" > %t1.script
// RUN: ld.lld -shared %t1.o --version-script %t1.script -o %t1.so -soname verneed1.so.0 -z separate-code
// RUN: llvm-mc %s -o %t.o -filetype=obj --triple=x86_64-unknown-linux

View File

@@ -1,6 +1,6 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o %t1.o
# RUN: echo "v1 {}; v2 {}; v3 { local: *; };" > %t.script
# RUN: echo "v1 {}; v2 {}; v3 { global: f1; local: *; };" > %t.script
# RUN: ld.lld -shared %t1.o --version-script %t.script -o %t1.so -soname verneed1.so.0
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed2.s -o %t2.o
# RUN: ld.lld -shared %t2.o --version-script %t.script -o %t2.so -soname verneed2.so.0

View File

@@ -1,23 +0,0 @@
# REQUIRES: x86
# RUN: echo "{ global: foo*; bar*; local: *; };" > %t.script
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld -shared --version-script %t.script %t.o -o %t.so
# RUN: llvm-readelf --dyn-syms %t.so | FileCheck %s
.globl foo1, bar1, zed1, local
foo1:
bar1:
zed1:
local:
# CHECK: foo1{{$}}
# CHECK-NEXT: bar1{{$}}
# CHECK-NOT: {{.}}
# RUN: echo "{ global : local; local: *; };" > %t1.script
# RUN: ld.lld -shared --version-script %t1.script %t.o -o %t.so
# RUN: llvm-readelf --dyn-syms %t.so | FileCheck --check-prefix=LOCAL %s
# LOCAL: local{{$}}
# LOCAL-NOT: {{.}}

View File

@@ -1,28 +0,0 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld -shared %t.o -o %t2.so
# RUN: echo "{ local: *; };" > %t.script
# RUN: ld.lld --version-script %t.script -shared %t.o %t2.so -o %t.so
# RUN: llvm-readobj --dyn-syms %t.so | FileCheck %s
# The symbol foo must be hidden. This matches bfd and gold and is
# required to make it possible for a c++ library to hide its own
# operator delete.
# CHECK: DynamicSymbols [
# CHECK-NEXT: Symbol {
# CHECK-NEXT: Name:
# CHECK-NEXT: Value: 0x0
# CHECK-NEXT: Size: 0
# CHECK-NEXT: Binding: Local
# CHECK-NEXT: Type: None
# CHECK-NEXT: Other: 0
# CHECK-NEXT: Section: Undefined
# CHECK-NEXT: }
# CHECK-NEXT: ]
.global foo
foo:
nop

View File

@@ -1,45 +0,0 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: echo "VERSION_1.0 { local: foo1; };" > %t.script
# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
# RUN: llvm-readobj --dyn-syms %t.so | FileCheck --check-prefix=EXACT %s
# EXACT: DynamicSymbols [
# EXACT-NOT: foo1
# EXACT: foo2
# EXACT: foo3
# EXACT: _start
# RUN: echo "VERSION_1.0 { local: foo*; };" > %t.script
# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
# RUN: llvm-readobj --dyn-syms %t.so | FileCheck --check-prefix=WC %s
# WC: DynamicSymbols [
# WC-NOT: foo1
# WC-NOT: foo2
# WC-NOT: foo3
# WC: _start
# RUN: echo "VERSION_1.0 { global: *; local: foo*; };" > %t.script
# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so
# RUN: llvm-readobj --dyn-syms %t.so | FileCheck --check-prefix=MIX %s
# MIX: DynamicSymbols [
# MIX-NOT: foo1
# MIX-NOT: foo2
# MIX-NOT: foo3
# MIX: _start@@VERSION_1.0
.globl foo1
foo1:
ret
.globl foo2
foo2:
ret
.globl foo3
foo3:
ret
.globl _start
_start:
ret

View File

@@ -1,9 +1,49 @@
# REQUIRES: x86
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: ld.lld %t.o -o /dev/null
## Test how .symver interacts with --version-script.
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
.global _start
.global bar
.symver _start, bar@@VERSION
_start:
jmp bar
# RUN: echo 'v1 { local: foo1; }; v2 { local: foo2; };' > %t1.script
# RUN: ld.lld --version-script %t1.script -shared %t.o -o %t1.so
# RUN: llvm-readelf --dyn-syms %t1.so | FileCheck --check-prefix=EXACT %s
# EXACT: UND
# EXACT-NEXT: [[#]] foo3{{$}}
# EXACT-NEXT: [[#]] foo4@@v2
# EXACT-NEXT: [[#]] _start{{$}}
# EXACT-NEXT: [[#]] foo3@v1
# EXACT-NOT: {{.}}
# RUN: echo 'v1 { local: foo*; }; v2 {};' > %t2.script
# RUN: ld.lld --version-script %t2.script -shared %t.o -o %t2.so
# RUN: llvm-readelf --dyn-syms %t2.so | FileCheck --check-prefix=WC %s
# WC: UND
# WC-NEXT: [[#]] foo4@@v2
# WC-NEXT: [[#]] _start{{$}}
# WC-NEXT: [[#]] foo3@v1
# WC-NOT: {{.}}
# RUN: echo 'v1 { global: *; local: foo*; }; v2 {};' > %t3.script
# RUN: ld.lld --version-script %t3.script -shared %t.o -o %t3.so
# RUN: llvm-readelf --dyn-syms %t3.so | FileCheck --check-prefix=MIX1 %s
# MIX1: UND
# MIX1-NEXT: [[#]] foo4@@v2
# MIX1-NEXT: [[#]] _start@@v1
# MIX1-NEXT: [[#]] foo3@v1
# MIX1-NOT: {{.}}
# RUN: echo 'v1 { global: foo*; local: *; }; v2 { global: foo4; local: *; };' > %t4.script
# RUN: ld.lld --version-script %t4.script -shared %t.o -o %t4.so
# RUN: llvm-readelf --dyn-syms %t4.so | FileCheck --check-prefix=MIX2 %s
# MIX2: UND
# MIX2-NEXT: [[#]] foo1@@v1
# MIX2-NEXT: [[#]] foo2@@v1
# MIX2-NEXT: [[#]] foo3@@v1
# MIX2-NEXT: [[#]] foo4@@v2
# MIX2-NEXT: [[#]] foo3@v1
# MIX2-NOT: {{.}}
.globl foo1; foo1: ret
.globl foo2; foo2: ret
.globl foo3; .symver foo3,foo3@v1; foo3: ret
.globl foo4; .symver foo4,foo4@@v2; foo4: ret
.globl _start; _start: ret

View File

@@ -1,18 +0,0 @@
# REQUIRES: x86
# RUN: echo "FBSD_1.1 {}; FBSD_1.2 {};" > %t.ver
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
# RUN: ld.lld -shared %t.o -o %t.so --version-script=%t.ver
# RUN: llvm-readelf --dyn-symbols %t.so | FileCheck %s
.weak openat
openat:
.global openat@FBSD_1.1
openat@FBSD_1.1 = openat
.global openat@@FBSD_1.2
openat@@FBSD_1.2 = openat
# CHECK-DAG: openat@FBSD_1.1
# CHECK-DAG: openat@@FBSD_1.2

View File

@@ -5,9 +5,9 @@
// RUN: .quad \"basename@FBSD_1.1\" " > %t.s
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t.s -o %t.o
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o
// RUN: echo "FBSD_1.0 { local: *; }; FBSD_1.1 { };" > %t2.ver
// RUN: echo "FBSD_1.0 { global: basename; local: *; }; FBSD_1.1 { };" > %t2.ver
// RUN: ld.lld --shared --version-script %t2.ver %t2.o -o %t2.so
// RUN: echo "LIBPKG_1.3 { };" > %t.ver
// RUN: echo "FBSD_1.0 { }; FBSD_1.1 { }; LIBPKG_1.3 { };" > %t.ver
// RUN: ld.lld --shared %t.o --version-script %t.ver %t2.so -o %t.so
// RUN: llvm-readobj --dyn-symbols -r %t.so | FileCheck %s