[lld] [X86][LLD] Handle R_X86_64_CODE_6_GOTTPOFF relocation type (PR #117675)

Fangrui Song via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 4 23:56:12 PST 2024


================
@@ -0,0 +1,36 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o
+# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck -DFILE=%t.o %s
+
+# CHECK: error: [[FILE]]:(.text+0x2): invalid prefix with R_X86_64_CODE_4_GOTTPOFF!
+# CHECK-NEXT: error: [[FILE]]:(.text+0x8): invalid prefix with R_X86_64_CODE_6_GOTTPOFF!
+# CHECK-NEXT: error: [[FILE]]:(.text+0x12): R_X86_64_CODE_4_GOTTPOFF must be used in MOVQ or ADDQ instructions only
+# CHECK-NEXT: error: [[FILE]]:(.text+0x1a): R_X86_64_CODE_6_GOTTPOFF must be used in ADDQ instructions with NDD/NF/NDD+NF only
+
+## These negative tests are to check if the invalid prefix and unsupported
+## instructions for TLS relocation types with APX instructions are handled as
+## errors.
+
+.type tls0, at object
+.section .tbss,"awT", at nobits
+.globl tls0
+.align 4
+tls0:
+ .long 0
+ .size tls0, 4
+
+.text
+.globl _start
+_start:
+  addq 0(%rip), %rax, %r16
+  .reloc .-4, R_X86_64_CODE_4_GOTTPOFF, tls0-4
+
+  movq 0(%rip), %r16
+  .reloc .-4, R_X86_64_CODE_6_GOTTPOFF, tls0-4
+
+  andq 0(%rip), %r16
+  .reloc .-4, R_X86_64_CODE_4_GOTTPOFF, tls0-4
+
+  andq 0(%rip), %rax, %r16
+  .reloc .-4, R_X86_64_CODE_6_GOTTPOFF, tls0-4
+
----------------
MaskRay wrote:

delete trailing blank line

https://github.com/llvm/llvm-project/pull/117675


More information about the llvm-commits mailing list