[lld] e6bd68c - [ELF][test] Improve symver-non-default.s to test foo and foo at v1 combining for executable linking
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 4 10:19:19 PDT 2023
Author: Fangrui Song
Date: 2023-11-04T10:19:14-07:00
New Revision: e6bd68c90b1a386e276f53ba28fdfdfda48bcea1
URL: https://github.com/llvm/llvm-project/commit/e6bd68c90b1a386e276f53ba28fdfdfda48bcea1
DIFF: https://github.com/llvm/llvm-project/commit/e6bd68c90b1a386e276f53ba28fdfdfda48bcea1.diff
LOG: [ELF][test] Improve symver-non-default.s to test foo and foo at v1 combining for executable linking
Added:
Modified:
lld/test/ELF/symver-non-default.s
Removed:
################################################################################
diff --git a/lld/test/ELF/symver-non-default.s b/lld/test/ELF/symver-non-default.s
index 4923a5108018a38..0fe50367147e613 100644
--- a/lld/test/ELF/symver-non-default.s
+++ b/lld/test/ELF/symver-non-default.s
@@ -8,32 +8,52 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64 %t/def3.s -o %t/def3.o
## foo at v1 & foo defined at the same location are combined.
-# RUN: ld.lld -shared --version-script=%t/ver1 %t/def1.o %t/ref.o -o %t1
-# RUN: llvm-readelf --dyn-syms %t1 | FileCheck %s --check-prefix=CHECK1
-# RUN: ld.lld -shared --version-script=%t/ver2 %t/def1.o %t/ref.o -o %t1
-# RUN: llvm-readelf --dyn-syms %t1 | FileCheck %s --check-prefix=CHECK1
+# RUN: ld.lld -shared --version-script=%t/ver1 %t/def1.o %t/ref.o -o %t1.so
+# RUN: llvm-readelf --dyn-syms %t1.so | FileCheck %s --check-prefix=CHECK1
+# RUN: ld.lld -shared --version-script=%t/ver2 %t/def1.o %t/ref.o -o %t1.so
+# RUN: llvm-readelf --dyn-syms %t1.so | FileCheck %s --check-prefix=CHECK1
# CHECK1: 1: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo at v1
# CHECK1-EMPTY:
+## Test an executable link without exporting foo.
+# RUN: ld.lld -pie --version-script=%t/ver1 %t/def1.o %t/ref.o -o %t1
+# RUN: llvm-readelf -s %t1 | FileCheck %s --check-prefix=EXE1
+
+# EXE1: Symbol table '.dynsym' contains 1 entries:
+# EXE1: Symbol table '.symtab' contains 3 entries:
+# EXE1: 2: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo{{$}}
+
## def2.o doesn't define foo. foo at v1 & undefined foo are unrelated.
-# RUN: ld.lld -shared --version-script=%t/ver1 %t/def2.o %t/ref.o -o %t2
-# RUN: llvm-readelf -r --dyn-syms %t2 | FileCheck %s --check-prefix=CHECK2
+# RUN: ld.lld -shared --version-script=%t/ver1 %t/def2.o %t/ref.o -o %t2.so
+# RUN: llvm-readelf -r --dyn-syms %t2.so | FileCheck %s --check-prefix=CHECK2
# CHECK2: R_X86_64_JUMP_SLOT {{.*}} foo + 0
# CHECK2: 1: {{.*}} NOTYPE GLOBAL DEFAULT UND foo{{$}}
# CHECK2-NEXT: 2: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo at v1
# CHECK2-EMPTY:
+# RUN: not ld.lld -pie --version-script=%t/ver1 %t/def2.o %t/ref.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=EXE2
+
+# EXE2: error: undefined symbol: foo{{$}}
+
## def2.o doesn't define foo. foo at v1 & defined foo are unrelated.
-# RUN: ld.lld -shared --version-script=%t/ver1 %t/def2.o %t/def3.o %t/ref.o -o %t3
-# RUN: llvm-readelf -r --dyn-syms %t3 | FileCheck %s --check-prefix=CHECK3
+# RUN: ld.lld -shared --version-script=%t/ver1 %t/def2.o %t/def3.o %t/ref.o -o %t3.so
+# RUN: llvm-readelf -r --dyn-syms %t3.so | FileCheck %s --check-prefix=CHECK3
# CHECK3: R_X86_64_JUMP_SLOT {{.*}} foo + 0
# CHECK3: 1: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo at v1
# CHECK3-NEXT: 2: {{.*}} NOTYPE GLOBAL DEFAULT [[#]] foo{{$}}
# CHECK3-EMPTY:
+# RUN: ld.lld -pie --version-script=%t/ver1 %t/def2.o %t/def3.o %t/ref.o -o %t3
+# RUN: llvm-readelf -s %t3 | FileCheck %s --check-prefix=EXE3
+
+# EXE3: Symbol table '.dynsym' contains 1 entries:
+# EXE3: Symbol table '.symtab' contains 4 entries:
+# EXE3: 2: {{.*}} NOTYPE GLOBAL DEFAULT [[#SEC:]] foo{{$}}
+# EXE3-NEXT: 3: {{.*}} NOTYPE GLOBAL DEFAULT [[#SEC]] foo{{$}}
+
## foo at v1 overrides the defined foo which is affected by a version script.
# RUN: ld.lld -shared --version-script=%t/ver2 %t/def2.o %t/def3.o %t/ref.o -o %t4
# RUN: llvm-readelf -r --dyn-syms %t4 | FileCheck %s --check-prefix=CHECK4
More information about the llvm-commits
mailing list