[lld] 58ad3e8 - [ELF] Improve .o preempting DSO tests

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 4 15:49:59 PDT 2023


Author: Fangrui Song
Date: 2023-11-04T15:49:54-07:00
New Revision: 58ad3e86d771f3f89705f6312e02c3bd59cb9765

URL: https://github.com/llvm/llvm-project/commit/58ad3e86d771f3f89705f6312e02c3bd59cb9765
DIFF: https://github.com/llvm/llvm-project/commit/58ad3e86d771f3f89705f6312e02c3bd59cb9765.diff

LOG: [ELF] Improve .o preempting DSO tests

Added: 
    lld/test/ELF/obj-preempt-dso.s

Modified: 
    

Removed: 
    lld/test/ELF/Inputs/symbol-override.s
    lld/test/ELF/dont-export-hidden.s
    lld/test/ELF/protected-shared.s
    lld/test/ELF/symbol-override.s


################################################################################
diff  --git a/lld/test/ELF/Inputs/symbol-override.s b/lld/test/ELF/Inputs/symbol-override.s
deleted file mode 100644
index ab3bf8dc74b0b94..000000000000000
--- a/lld/test/ELF/Inputs/symbol-override.s
+++ /dev/null
@@ -1,16 +0,0 @@
-.text
-.globl foo
-.type foo, at function
-foo:
-nop
-
-.globl bar
-.type bar, at function
-bar:
-nop
-
-.globl do
-.type do, at function
-do:
-callq foo at PLT
-callq bar at PLT

diff  --git a/lld/test/ELF/dont-export-hidden.s b/lld/test/ELF/dont-export-hidden.s
deleted file mode 100644
index 651c024a03fe76d..000000000000000
--- a/lld/test/ELF/dont-export-hidden.s
+++ /dev/null
@@ -1,40 +0,0 @@
-// REQUIRES: x86
-// RUN: llvm-mc %p/Inputs/shared.s -o %t.o -filetype=obj -triple=x86_64-pc-linux
-// RUN: llvm-mc %s -o %t2.o -filetype=obj -triple=x86_64-pc-linux
-// RUN: ld.lld %t.o -o %t.so -shared
-// RUN: ld.lld %t2.o %t.so -o %t.exe
-// RUN: llvm-readobj --dyn-symbols %t.exe | FileCheck %s
-
-        .global _start
-_start:
-        .global bar
-        .hidden bar
-bar:
-
-        .global bar2
-bar2:
-
-        .global foo
-foo:
-
-// 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:   Symbol {
-// CHECK-NEXT:     Name: bar2
-// CHECK-NEXT:     Value:
-// CHECK-NEXT:     Size: 0
-// CHECK-NEXT:     Binding: Global
-// CHECK-NEXT:     Type: None
-// CHECK-NEXT:     Other: 0
-// CHECK-NEXT:     Section: .text
-// CHECK-NEXT:   }
-// CHECK-NEXT: ]
-

diff  --git a/lld/test/ELF/obj-preempt-dso.s b/lld/test/ELF/obj-preempt-dso.s
new file mode 100644
index 000000000000000..3a262fa53fbe39c
--- /dev/null
+++ b/lld/test/ELF/obj-preempt-dso.s
@@ -0,0 +1,48 @@
+# REQUIRES: x86
+# RUN: rm -rf %t && split-file %s %t && cd %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
+# RUN: ld.lld -shared --version-script=b.ver b.o -o b.so
+# RUN: ld.lld --version-script=a.ver a.o b.so -o a
+# RUN: llvm-readelf --dyn-syms a | FileCheck %s
+
+# CHECK:      1: 0000000000000000 0 NOTYPE  GLOBAL DEFAULT   UND b2
+# CHECK-NEXT: 2: {{.*}}           0 NOTYPE  GLOBAL DEFAULT [[#]] a1
+# CHECK-NEXT: 3: {{.*}}           0 NOTYPE  GLOBAL DEFAULT [[#]] a2
+# CHECK-NEXT: 4: {{.*}}           0 NOTYPE  GLOBAL DEFAULT [[#]] b1
+# CHECK-NEXT: 5: {{.*}}           0 NOTYPE  GLOBAL DEFAULT [[#]] c2@@v2
+# CHECK-NEXT: 6: {{.*}}           0 NOTYPE  GLOBAL DEFAULT [[#]] c1 at v1
+# CHECK-NOT:  {{.}}
+
+#--- a.s
+.globl _start, a1, a2, a3, b1, c1, c2
+_start:
+a1: a2:
+.hidden a3
+a3:
+b1:
+.symver c1, c1 at v1, remove
+c1:
+c2:
+
+.data
+  .quad b2
+
+#--- a.ver
+v1 {};
+v2 { c2; };
+
+#--- b.s
+.globl a1, a2, a3, b1, b2, c1, c2
+.type a1, at function
+a1: a2: a3:
+.protected b1, b2
+b1:
+b2:
+.symver c1, c1 at v1
+c1:
+c2:
+
+#--- b.ver
+v1 {};
+v2 { c2; };

diff  --git a/lld/test/ELF/protected-shared.s b/lld/test/ELF/protected-shared.s
deleted file mode 100644
index 5fed37f9838d3bc..000000000000000
--- a/lld/test/ELF/protected-shared.s
+++ /dev/null
@@ -1,26 +0,0 @@
-# REQUIRES: x86
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
-# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/protected-shared.s -o %t2.o
-# RUN: ld.lld -shared --soname=t2 %t2.o -o %t2.so
-# RUN: ld.lld %t.o %t2.so -o %t
-# RUN: llvm-readelf -s %t | FileCheck %s
-# RUN: ld.lld %t2.so %t.o -o %t1
-# RUN: llvm-readelf -s %t1 | FileCheck %s
-
-# CHECK: Symbol table '.dynsym'
-# CHECK:    Num:    Value          Size Type    Bind   Vis      Ndx Name
-# CHECK:      1: 0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND foo
-
-# CHECK: Symbol table '.symtab'
-# CHECK:    Num:    Value          Size Type    Bind   Vis      Ndx Name
-# CHECK:         0000000000000000     0 NOTYPE  GLOBAL DEFAULT  UND foo
-# CHECK:         {{.*}}               0 NOTYPE  GLOBAL DEFAULT [[#]] bar
-
-        .global  _start
-_start:
-
-        .data
-        .quad foo
-
-        .global bar
-bar:

diff  --git a/lld/test/ELF/symbol-override.s b/lld/test/ELF/symbol-override.s
deleted file mode 100644
index d3b691def4e7a58..000000000000000
--- a/lld/test/ELF/symbol-override.s
+++ /dev/null
@@ -1,21 +0,0 @@
-// REQUIRES: x86
-// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o
-// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/symbol-override.s -o %t2.o
-// RUN: ld.lld -shared %t2.o -o %t2.so
-// RUN: ld.lld %t1.o %t2.so -o %t
-// RUN: llvm-nm -D %t | FileCheck %s
-
-// CHECK:      do
-// CHECK-NEXT: foo
-// CHECK-NOT:  {{.}}
-
-.text
-.globl foo
-.type foo, at function
-foo:
-nop
-
-.text
-.globl _start
-_start:
-callq do at plt


        


More information about the llvm-commits mailing list