[llvm-branch-commits] [lld] 7e69b17 - [ELF][test] Improve .symver & --version-script tests

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Aug 4 09:19:06 PDT 2021


Author: Fangrui Song
Date: 2021-08-04T09:17:51-07:00
New Revision: 7e69b1728c2317610d3e9d82d52ca7ad38adb034

URL: https://github.com/llvm/llvm-project/commit/7e69b1728c2317610d3e9d82d52ca7ad38adb034
DIFF: https://github.com/llvm/llvm-project/commit/7e69b1728c2317610d3e9d82d52ca7ad38adb034.diff

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

And delete redundant tests.

Added: 
    lld/test/ELF/version-script-undef.s

Modified: 
    lld/test/ELF/partition-synthetic-sections.s
    lld/test/ELF/verneed.s
    lld/test/ELF/version-script-symver.s
    lld/test/ELF/version-symbol-undef.s

Removed: 
    lld/test/ELF/undef-version-script.s
    lld/test/ELF/version-script-glob.s
    lld/test/ELF/version-script-hide-so-symbol.s
    lld/test/ELF/version-script-locals.s
    lld/test/ELF/version-script-twice.s


################################################################################
diff  --git a/lld/test/ELF/partition-synthetic-sections.s b/lld/test/ELF/partition-synthetic-sections.s
index e959d96583f7..3654b3cf5c58 100644
--- a/lld/test/ELF/partition-synthetic-sections.s
+++ b/lld/test/ELF/partition-synthetic-sections.s
@@ -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

diff  --git a/lld/test/ELF/verneed.s b/lld/test/ELF/verneed.s
index e5edaeeb6d07..6a90cc48e68f 100644
--- a/lld/test/ELF/verneed.s
+++ b/lld/test/ELF/verneed.s
@@ -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

diff  --git a/lld/test/ELF/version-script-glob.s b/lld/test/ELF/version-script-glob.s
deleted file mode 100644
index 0f2bd88875e2..000000000000
--- a/lld/test/ELF/version-script-glob.s
+++ /dev/null
@@ -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: {{.}}

diff  --git a/lld/test/ELF/version-script-hide-so-symbol.s b/lld/test/ELF/version-script-hide-so-symbol.s
deleted file mode 100644
index ba33c68511d0..000000000000
--- a/lld/test/ELF/version-script-hide-so-symbol.s
+++ /dev/null
@@ -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
-

diff  --git a/lld/test/ELF/version-script-locals.s b/lld/test/ELF/version-script-locals.s
deleted file mode 100644
index 119d4cc7bdd2..000000000000
--- a/lld/test/ELF/version-script-locals.s
+++ /dev/null
@@ -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

diff  --git a/lld/test/ELF/version-script-symver.s b/lld/test/ELF/version-script-symver.s
index b6355949fad0..a4ff1c69c4a8 100644
--- a/lld/test/ELF/version-script-symver.s
+++ b/lld/test/ELF/version-script-symver.s
@@ -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
-
-.global _start
-.global bar
-.symver _start, bar@@VERSION
-_start:
-  jmp bar
+## Test how .symver interacts with --version-script.
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+
+# 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 at 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 at 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 at 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 at v1
+# MIX2-NOT:  {{.}}
+
+.globl foo1; foo1: ret
+.globl foo2; foo2: ret
+.globl foo3; .symver foo3,foo3 at v1; foo3: ret
+.globl foo4; .symver foo4,foo4@@v2; foo4: ret
+
+.globl _start; _start: ret

diff  --git a/lld/test/ELF/version-script-twice.s b/lld/test/ELF/version-script-twice.s
deleted file mode 100644
index 587b7cef01d4..000000000000
--- a/lld/test/ELF/version-script-twice.s
+++ /dev/null
@@ -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 at FBSD_1.1
-openat at FBSD_1.1 = openat
-
-         .global openat@@FBSD_1.2
-openat@@FBSD_1.2 = openat
-
-# CHECK-DAG: openat at FBSD_1.1
-# CHECK-DAG: openat@@FBSD_1.2

diff  --git a/lld/test/ELF/undef-version-script.s b/lld/test/ELF/version-script-undef.s
similarity index 100%
rename from lld/test/ELF/undef-version-script.s
rename to lld/test/ELF/version-script-undef.s

diff  --git a/lld/test/ELF/version-symbol-undef.s b/lld/test/ELF/version-symbol-undef.s
index 1d922770c1f6..22b943a5034e 100644
--- a/lld/test/ELF/version-symbol-undef.s
+++ b/lld/test/ELF/version-symbol-undef.s
@@ -5,9 +5,9 @@
 // RUN:       .quad \"basename at 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
 


        


More information about the llvm-branch-commits mailing list