[lld] a439ef5 - [ELF][test] Improve copy relocation/canonical PLT entry tests
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Mon Dec 11 12:32:16 PST 2023
Author: Fangrui Song
Date: 2023-12-11T12:32:13-08:00
New Revision: a439ef518dc0a30b85cf041cd3b83641ea78308f
URL: https://github.com/llvm/llvm-project/commit/a439ef518dc0a30b85cf041cd3b83641ea78308f
DIFF: https://github.com/llvm/llvm-project/commit/a439ef518dc0a30b85cf041cd3b83641ea78308f.diff
LOG: [ELF][test] Improve copy relocation/canonical PLT entry tests
Added:
Modified:
lld/test/ELF/x86-64-dyn-rel-error.s
lld/test/ELF/x86-64-reloc-32.s
Removed:
lld/test/ELF/x86-64-dyn-rel-error2.s
################################################################################
diff --git a/lld/test/ELF/x86-64-dyn-rel-error.s b/lld/test/ELF/x86-64-dyn-rel-error.s
index 8f41f1493dde7b..edc2875c6fa63c 100644
--- a/lld/test/ELF/x86-64-dyn-rel-error.s
+++ b/lld/test/ELF/x86-64-dyn-rel-error.s
@@ -1,17 +1,43 @@
-// REQUIRES: x86
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t2.o
-// RUN: ld.lld %t2.o -shared -o %t2.so
-// RUN: not ld.lld -shared %t.o %t2.so -o /dev/null 2>&1 | FileCheck %s
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %p/Inputs/shared.s -o %t2.o
+# RUN: ld.lld %t2.o -shared -o %t2.so --threads=1
+# RUN: not ld.lld -pie %t.o %t2.so -o /dev/null --threads=1 2>&1 | FileCheck %s
+# RUN: not ld.lld -shared %t.o %t2.so -o /dev/null --threads=1 2>&1 | FileCheck %s --check-prefixes=CHECK,SHARED
- .global _start
-_start:
- .data
- .long zed
+# CHECK: error: relocation R_X86_64_32 cannot be used against symbol 'zed'; recompile with -fPIC
+# CHECK-NEXT: >>> defined in {{.*}}.so
+# CHECK-NEXT: >>> referenced by {{.*}}.o:(.data+0x0)
+# CHECK-EMPTY:
+# CHECK-NEXT: error: relocation R_X86_64_PC32 cannot be used against symbol 'zed'; recompile with -fPIC
+# CHECK-NEXT: >>> defined in {{.*}}.so
+# CHECK-NEXT: >>> referenced by {{.*}}.o:(.data+0x4)
+# CHECK-EMPTY:
+# CHECK-NEXT: error: relocation R_X86_64_64 cannot be used against symbol '_start'; recompile with -fPIC
+# SHARED: error: relocation R_X86_64_64 cannot be used against symbol 'main'; recompile with -fPIC
+# SHARED: error: relocation R_X86_64_64 cannot be used against symbol 'data'; recompile with -fPIC
+# CHECK-NOT: error:
+
+# RUN: ld.lld --noinhibit-exec %t.o %t2.so -o /dev/null 2>&1 | FileCheck --check-prefix=WARN %s
+# RUN: not ld.lld --export-dynamic --unresolved-symbols=ignore-all %t.o -o /dev/null 2>&1 | FileCheck --check-prefix=WARN %s
-// CHECK: error: relocation R_X86_64_32 cannot be used against symbol 'zed'; recompile with -fPIC
+# WARN: relocation R_X86_64_32 cannot be used against symbol 'zed'; recompile with -fPIC
+# WARN: relocation R_X86_64_PC32 cannot be used against symbol 'zed'; recompile with -fPIC
+
+ .global _start, main, data
+ .type main, @function
+ .type data, @object
+_start:
+ ret
+main:
+ ret
-// RUN: ld.lld --noinhibit-exec %t.o %t2.so -o /dev/null 2>&1 | FileCheck --check-prefix=WARN %s
-// RUN: not ld.lld --export-dynamic --unresolved-symbols=ignore-all %t.o -o /dev/null 2>&1 | FileCheck --check-prefix=WARN %s
+.data
+data:
+.long zed
+.long zed - .
-// WARN: relocation R_X86_64_32 cannot be used against symbol 'zed'; recompile with -fPIC
+.rodata
+.quad _start
+.quad main
+.quad data
diff --git a/lld/test/ELF/x86-64-dyn-rel-error2.s b/lld/test/ELF/x86-64-dyn-rel-error2.s
deleted file mode 100644
index 853e61faef68e5..00000000000000
--- a/lld/test/ELF/x86-64-dyn-rel-error2.s
+++ /dev/null
@@ -1,14 +0,0 @@
-// REQUIRES: x86
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
-// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t2.o
-// RUN: ld.lld %t2.o -shared -o %t2.so
-// RUN: not ld.lld -shared %t.o %t2.so -o /dev/null 2>&1 | FileCheck %s
-
-// CHECK: error: relocation R_X86_64_PC32 cannot be used against symbol 'zed'; recompile with -fPIC
-// CHECK: >>> defined in {{.*}}.so
-// CHECK: >>> referenced by {{.*}}.o:(.data+0x0)
-
- .global _start
-_start:
- .data
- .long zed - .
diff --git a/lld/test/ELF/x86-64-reloc-32.s b/lld/test/ELF/x86-64-reloc-32.s
index 70a46301ad24a4..bf2fc26a582048 100644
--- a/lld/test/ELF/x86-64-reloc-32.s
+++ b/lld/test/ELF/x86-64-reloc-32.s
@@ -1,9 +1,6 @@
# REQUIRES: x86
# RUN: rm -rf %t && split-file %s %t
-
-## Check recompile with -fPIC error message
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t/shared.s -o %t/shared.o
-# RUN: not ld.lld -shared %t/shared.o -o /dev/null 2>&1 | FileCheck %s
# CHECK: error: relocation R_X86_64_32 cannot be used against symbol '_shared'; recompile with -fPIC
# CHECK: >>> defined in {{.*}}
More information about the llvm-commits
mailing list