]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86: Allow R_386_TLS_LE_32 with KMOVD
authorH.J. Lu <hjl.tools@gmail.com>
Tue, 27 Aug 2024 12:58:32 +0000 (05:58 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Tue, 27 Aug 2024 20:16:40 +0000 (13:16 -0700)
Since there is no TLS IE transition, allow R_386_TLS_LE_32 with KMOVD.

gas/

PR gas/28595
* config/tc-i386.c (i386_assemble): Remove BFD_RELOC_386_TLS_LE_32
from TLS code check.
* testsuite/gas/i386/inval-tls.s: Remove foo@tpoff(%eax).
* testsuite/gas/i386/inval-tls.l: Updated.

ld/

PR gas/28595
* testsuite/ld-i386/i386.exp: Run tlsle1.
* testsuite/ld-i386/tlsle1.d: New file.
* testsuite/ld-i386/tlsle1.s: Likewise.

Signed-off-by: H.J. Lu <hjl.tools@gmail.com>
gas/config/tc-i386.c
gas/testsuite/gas/i386/inval-tls.l
gas/testsuite/gas/i386/inval-tls.s
ld/testsuite/ld-i386/i386.exp
ld/testsuite/ld-i386/tlsle1.d [new file with mode: 0644]
ld/testsuite/ld-i386/tlsle1.s [new file with mode: 0644]

index ad68ba9322df3c947afbf2f3c865ada5b9e07583..20dcb38919e8c0a6958bf468647cc9b67074708e 100644 (file)
@@ -6578,13 +6578,13 @@ i386_assemble (char *line)
          return;
        }
 
-      /* Don't allow e.g. KMOV in TLS code sequences.  */
+      /* Don't allow e.g. KMOV in TLS code sequences which will trigger
+        linker error later.  */
       for (j = i.imm_operands; j < i.operands; ++j)
        switch (i.reloc[j])
          {
          case BFD_RELOC_X86_64_GOTTPOFF:
          case BFD_RELOC_386_TLS_GOTIE:
-         case BFD_RELOC_386_TLS_LE_32:
          case BFD_RELOC_X86_64_TLSLD:
            as_bad (_("TLS relocation cannot be used with `%s'"), insn_name (&i.tm));
            return;
index 59e7c30f46f0676357b199442ae9a289c4909d5b..907e80610a8794d3a3e8112483c9be57e799634d 100644 (file)
@@ -1,3 +1,2 @@
 .*: Assembler messages:
 .*:3: Error: .* `kmovd'
-.*:4: Error: .* `kmovd'
index 3fe85c31ff3776d3c2d6a3822ee578ab0d8e0523..ba0e1b81dc9064ec515ad6271fc5b7c82dbe22c8 100644 (file)
@@ -1,4 +1,3 @@
        .text
 # All the following should be illegal
        kmovd   foo@gotntpoff(%eax), %k0
-       kmovd   foo@tpoff(%eax), %k0
index adc88e42ad84fc685ab70b8830fb167d20c73d98..6f97f5daa23dd949d19a1760eeb0b84ee5f4f9e1 100644 (file)
@@ -314,6 +314,7 @@ run_dump_test "tlsie2"
 run_dump_test "tlsie3"
 run_dump_test "tlsie4"
 run_dump_test "tlsie5"
+run_dump_test "tlsle1"
 run_dump_test "hidden1"
 run_dump_test "hidden2"
 run_dump_test "hidden3"
diff --git a/ld/testsuite/ld-i386/tlsle1.d b/ld/testsuite/ld-i386/tlsle1.d
new file mode 100644 (file)
index 0000000..d304e7b
--- /dev/null
@@ -0,0 +1,16 @@
+#name: TLS LE with kmovd
+#as: --32
+#ld: -melf_i386
+#objdump: -dw
+
+.*: +file format .*
+
+
+Disassembly of section .text:
+
+0+8049000 <_start>:
+ +[a-f0-9]+:   65 c4 e1 f9 90 05 04 00 00 00   kmovd  %gs:0x4,%k0
+ +[a-f0-9]+:   c4 e1 f9 90 80 04 00 00 00      kmovd  0x4\(%eax\),%k0
+ +[a-f0-9]+:   65 c4 e1 f9 90 05 fc ff ff ff   kmovd  %gs:0xfffffffc,%k0
+ +[a-f0-9]+:   c4 e1 f9 90 80 fc ff ff ff      kmovd  -0x4\(%eax\),%k0
+#pass
diff --git a/ld/testsuite/ld-i386/tlsle1.s b/ld/testsuite/ld-i386/tlsle1.s
new file mode 100644 (file)
index 0000000..283b903
--- /dev/null
@@ -0,0 +1,14 @@
+       .text
+       .globl _start
+_start:
+       kmovd %gs:foo@tpoff,%k0
+       kmovd foo@tpoff(%eax),%k0
+       kmovd %gs:foo@ntpoff,%k0
+       kmovd foo@ntpoff(%eax),%k0
+       .globl foo
+       .section        .tdata,"awT",@progbits
+       .align 4
+       .type   foo, @object
+       .size   foo, 4
+foo:
+       .long   100