]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
x86-64: Support APX NF TLS IE with 2 operands
authorLingling Kong <lingling.kong@intel.com>
Tue, 2 Jul 2024 07:49:19 +0000 (15:49 +0800)
committerLingling Kong <lingling.kong@intel.com>
Wed, 3 Jul 2024 02:18:36 +0000 (10:18 +0800)
Support APX NF TLS IE with 2 operands.Verify it with ld and gold.

gas/

* config/tc-i386.c (md_assemble): Allow APX NF TLS IE with
2 operands.
* testsuite/gas/i386/x86-64-gottpoff.d: Updated.
* testsuite/gas/i386/x86-64-gottpoff.s: Add APX NF TLS IE
tests with 2 operands.

gold/

* testsuite/x86_64_ie_to_le.s: Add APX NF TLS IE tests with
2 operands.
* testsuite/x86_64_ie_to_le.sh: Updated.

ld/

* testsuite/ld-x86-64/tlsbindesc.s: Add APX NF TLS IE tests
with 2 operands.
* testsuite/ld-x86-64/tlsbindesc.d: Updated.
* testsuite/ld-x86-64/tlsbindesc.rd: Likewise.

gas/config/tc-i386.c
gas/testsuite/gas/i386/x86-64-gottpoff.d
gas/testsuite/gas/i386/x86-64-gottpoff.s
gold/testsuite/x86_64_ie_to_le.s
gold/testsuite/x86_64_ie_to_le.sh
ld/testsuite/ld-x86-64/tlsbindesc.dd
ld/testsuite/ld-x86-64/tlsbindesc.rd
ld/testsuite/ld-x86-64/tlsbindesc.s

index 2e194313960d8b7bc3e420a4bdd8febcec3ff605..3b4d9cacc2e490881afdc5b0feecd21a3e904322 100644 (file)
@@ -7545,8 +7545,14 @@ md_assemble (char *line)
                && i.base_reg
                && i.base_reg->reg_num == RegIP
                && i.tm.operand_types[0].bitfield.class == Reg
-               && i.tm.operand_types[2].bitfield.class == Reg)
-             /* Allow APX: add %reg1, foo@gottpoff(%rip), %reg2.  */
+               && (i.tm.operand_types[2].bitfield.class == Reg
+                   || i.tm.operands == 2))
+             /* Allow APX:
+                add %reg1, foo@gottpoff(%rip), %reg2
+                add foo@gottpoff(%rip), %reg, %reg2
+                {nf} add foo@gottpoff(%rip), %reg
+                {nf} add %reg1, foo@gottpoff(%rip), %reg2
+                {nf} add foo@gottpoff(%rip), %reg, %reg2.  */
              break;
            /* Fall through.  */
          case BFD_RELOC_386_TLS_GOTIE:
index 5d0dd582425086f84c3ab472be85acef7e06b95a..8f1c10f936cb5d20e169fc3a70ae9a0c94c78164 100644 (file)
@@ -24,4 +24,8 @@ Disassembly of section .text:
  +[a-f0-9]+:   62 f4 9c 18 03 05 00 00 00 00   add    0x0\(%rip\),%rax,%r12        # 78 <_start\+0x78> 74: R_X86_64_CODE_6_GOTTPOFF    foo-0x4
  +[a-f0-9]+:   62 74 fc 14 01 05 00 00 00 00   \{nf\} add %r8,0x0\(%rip\),%r16        # 82 <_start\+0x82>      7e: R_X86_64_CODE_6_GOTTPOFF    foo-0x4
  +[a-f0-9]+:   62 f4 9c 1c 03 05 00 00 00 00   \{nf\} add 0x0\(%rip\),%rax,%r12        # 8c <_start\+0x8c>     88: R_X86_64_CODE_6_GOTTPOFF    foo-0x4
+ +[a-f0-9]+:   62 f4 fc 0c 03 05 00 00 00 00   \{nf\} add 0x0\(%rip\),%rax        # 96 <_start\+0x96>  92: R_X86_64_CODE_6_GOTTPOFF    foo-0x4
+ +[a-f0-9]+:   62 e4 fc 0c 03 05 00 00 00 00   \{nf\} add 0x0\(%rip\),%r16        # a0 <_start\+0xa0>  9c: R_X86_64_CODE_6_GOTTPOFF    foo-0x4
+ +[a-f0-9]+:   62 f4 fc 0c 03 05 00 00 00 00   \{nf\} add 0x0\(%rip\),%rax        # aa <_start\+0xaa>  a6: R_X86_64_CODE_6_GOTTPOFF    foo-0x4
+ +[a-f0-9]+:   62 e4 fc 0c 03 05 00 00 00 00   \{nf\} add 0x0\(%rip\),%r16        # b4 <_start\+0xb4>  b0: R_X86_64_CODE_6_GOTTPOFF    foo-0x4
 #pass
index d1f55017b0a1151e2cc4ef62f98535f4e535d313..48d8a59a746e397c7e5bd4fa829cf0e214002e5a 100644 (file)
@@ -27,3 +27,13 @@ _start:
        add     r12, rax, QWORD PTR [rip + foo@GOTTPOFF]
        {nf} add        r16, QWORD PTR [rip + foo@GOTTPOFF], r8
        {nf} add        r12, rax, QWORD PTR [rip + foo@GOTTPOFF]
+
+       .att_syntax prefix
+
+       {nf} addq       foo@GOTTPOFF(%rip), %rax
+       {nf} addq       foo@GOTTPOFF(%rip), %r16
+
+       .intel_syntax noprefix
+
+       {nf} add        rax, QWORD PTR [rip + foo@GOTTPOFF]
+       {nf} add        r16, QWORD PTR [rip + foo@GOTTPOFF]
index 56f3dfcc35ea841a06e45c0aa9ce60573f90acbc..4bf3f4abafbafe13a04a794b249439b42c216d6c 100644 (file)
@@ -9,6 +9,7 @@ _start:
        movq    foo@gottpoff(%rip), %r20
        addq    %r30, foo@gottpoff(%rip), %r8
        addq    foo@gottpoff(%rip), %rax, %r20
+       {nf} addq       foo@gottpoff(%rip), %r16
        {nf} addq       %r30, foo@gottpoff(%rip), %r8
        {nf} addq       foo@gottpoff(%rip), %rax, %r20
        .size   _start, .-_start
index 29272727c5ac18174bc16b8892b3f35bb32d1ce3..10e84686db8bd6c017e3984f3c664ab1d723e3a3 100755 (executable)
@@ -29,5 +29,6 @@ grep -q "add[ \t]\+\$0x[a-f0-9]\+,%r16" x86_64_ie_to_le.stdout
 grep -q "mov[ \t]\+\$0x[a-f0-9]\+,%r20" x86_64_ie_to_le.stdout
 grep -q "add[ \t]\+\$0x[a-f0-9]\+,%r30,%r8" x86_64_ie_to_le.stdout
 grep -q "add[ \t]\+\$0x[a-f0-9]\+,%rax,%r20" x86_64_ie_to_le.stdout
+grep -q "\{nf\} add[ \t]\+\$0x[a-f0-9]\+,%r16" x86_64_ie_to_le.stdout
 grep -q "\{nf\} add[ \t]\+\$0x[a-f0-9]\+,%r30,%r8" x86_64_ie_to_le.stdout
 grep -q "\{nf\} add[ \t]\+\$0x[a-f0-9]\+,%rax,%r20" x86_64_ie_to_le.stdout
index 7aa1b922b3cd5812bbf4796c70a8c652d28f0883..601dfc2fc6d00a63f50c5023013ce360aa7e0544 100644 (file)
@@ -173,6 +173,9 @@ Disassembly of section .text:
 #                              -> R_X86_64_TPOFF64     sG2
  +[0-9a-f]+:   ([0-9a-f]{2} ){3} *
  +[0-9a-f]+:   62 f4 fc 10 03 ([0-9a-f]{2} ){2}[       ]+add    0x[0-9a-f]+\(%rip\),%rax,%r16 +# [0-9a-f]+ <sG2>
+#                              -> R_X86_64_TPOFF64     sG2
+ +[0-9a-f]+:   ([0-9a-f]{2} ){3} *
+ +[0-9a-f]+:   62 e4 fc 0c 03 ([0-9a-f]{2} ){2}[       ]+\{nf\} add 0x[0-9a-f]+\(%rip\),%r16 +# [0-9a-f]+ <sG2>
 #                              -> R_X86_64_TPOFF64     sG2
  +[0-9a-f]+:   ([0-9a-f]{2} ){3} *
  +[0-9a-f]+:   62 f4 fc 14 01 ([0-9a-f]{2} ){2}[       ]+\{nf\} add %rax,0x[0-9a-f]+\(%rip\),%r16 +# [0-9a-f]+ <sG2>
@@ -189,6 +192,9 @@ Disassembly of section .text:
 #                                                      sg1
  +[0-9a-f]+:   ff ff ff *
  +[0-9a-f]+:   62 d4 f4 10 81 ([0-9a-f]{2} ){2}[       ]+add    \$0x[0-9a-f]+,%r8,%r17
+#                                                      sg1
+ +[0-9a-f]+:   ff ff ff *
+ +[0-9a-f]+:   62 fc fc 0c 81 ([0-9a-f]{2} ){2}[       ]+\{nf\} add \$0x[0-9a-f]+,%r17
 #                                                      sg1
  +[0-9a-f]+:   ff ff ff *
  +[0-9a-f]+:   62 d4 f4 14 81 ([0-9a-f]{2} ){2}[       ]+\{nf\} add \$0x[0-9a-f]+,%r8,%r17
@@ -205,6 +211,9 @@ Disassembly of section .text:
 #                                                      sl1
  +[0-9a-f]+:   ff ff ff *
  +[0-9a-f]+:   62 d4 fc 18 81 ([0-9a-f]{2} ){2}[       ]+add    \$0x[0-9a-f]+,%r8,%rax
+#                                                      sl1
+ +[0-9a-f]+:   ff ff ff *
+ +[0-9a-f]+:   62 fc fc 0c 81 ([0-9a-f]{2} ){2}[       ]+\{nf\} add \$0x[0-9a-f]+,%r18
 #                                                      sl1
  +[0-9a-f]+:   ff ff ff *
  +[0-9a-f]+:   62 d4 fc 1c 81 ([0-9a-f]{2} ){2}[       ]+\{nf\} add \$0x[0-9a-f]+,%r8,%rax
@@ -221,6 +230,9 @@ Disassembly of section .text:
 #                                                      sh1
  +[0-9a-f]+:   ff ff ff *
  +[0-9a-f]+:   62 fc bc 18 81 ([0-9a-f]{2} ){2}[       ]+add    \$0x[0-9a-f]+,%r19,%r8
+#                                                      sh1
+ +[0-9a-f]+:   ff ff ff *
+ +[0-9a-f]+:   62 fc fc 0c 81 ([0-9a-f]{2} ){2}[       ]+\{nf\} add \$0x[0-9a-f]+,%r19
 #                                                      sh1
  +[0-9a-f]+:   ff ff ff *
  +[0-9a-f]+:   62 fc bc 1c 81 ([0-9a-f]{2} ){2}[       ]+\{nf\} add \$0x[0-9a-f]+,%r19,%r8
index 1e0348e963fef3df79386e32ab874ddfc55df745..2fc965aef20a5c58a9ebcc31559112c4efa30a28 100644 (file)
@@ -15,12 +15,12 @@ Section Headers:
  +\[[ 0-9]+\] .dynsym +.*
  +\[[ 0-9]+\] .dynstr +.*
  +\[[ 0-9]+\] .rela.dyn +.*
- +\[[ 0-9]+\] .text +PROGBITS +0+401000 0+1000 0+2fd 00 +AX +0 +0 +4096
- +\[[ 0-9]+\] .tdata +PROGBITS +0+6012fd 0+12fd 0+60 00 WAT +0 +0 +1
- +\[[ 0-9]+\] .tbss +NOBITS +0+60135d 0+135d 0+40 00 WAT +0 +0 +1
- +\[[ 0-9]+\] .dynamic +DYNAMIC +0+601360 0+1360 0+100 10 +WA +4 +0 +8
- +\[[ 0-9]+\] .got +PROGBITS +0+601460 0+1460 0+20 08 +WA +0 +0 +8
- +\[[ 0-9]+\] .got.plt +PROGBITS +0+601480 0+1480 0+18 08 +WA +0 +0 +8
+ +\[[ 0-9]+\] .text +PROGBITS +0+401000 0+1000 0+325 00 +AX +0 +0 +4096
+ +\[[ 0-9]+\] .tdata +PROGBITS +0+601325 0+1325 0+60 00 WAT +0 +0 +1
+ +\[[ 0-9]+\] .tbss +NOBITS +0+601385 0+1385 0+40 00 WAT +0 +0 +1
+ +\[[ 0-9]+\] .dynamic +DYNAMIC +0+601388 0+1388 0+100 10 +WA +4 +0 +8
+ +\[[ 0-9]+\] .got +PROGBITS +0+601488 0+1488 0+20 08 +WA +0 +0 +8
+ +\[[ 0-9]+\] .got.plt +PROGBITS +0+6014a8 0+14a8 0+18 08 +WA +0 +0 +8
  +\[[ 0-9]+\] .symtab +.*
  +\[[ 0-9]+\] .strtab +.*
  +\[[ 0-9]+\] .shstrtab +.*
@@ -28,7 +28,7 @@ Key to Flags:
 #...
 
 Elf file type is EXEC \(Executable file\)
-Entry point 0x401205
+Entry point 0x40122d
 There are [0-9]+ program headers, starting at offset [0-9]+
 
 Program Headers:
@@ -36,10 +36,10 @@ Program Headers:
  +PHDR.*
  +INTERP.*
 .*Requesting program interpreter.*
- +LOAD +0x0+ 0x0+400000 0x0+400000 0x0+12fd 0x0+12fd R E 0x200000
- +LOAD +0x0+12fd 0x0+6012fd 0x0+6012fd 0x0+19b 0x0+19b RW +0x200000
- +DYNAMIC +0x0+1360 0x0+601360 0x0+601360 0x0+100 0x0+100 RW +0x8
- +TLS +0x0+12fd 0x0+6012fd 0x0+6012fd 0x0+60 0x0+a0 R +0x1
+ +LOAD +0x0+ 0x0+400000 0x0+400000 0x0+1325 0x0+1325 R E 0x200000
+ +LOAD +0x0+1325 0x0+601325 0x0+601325 0x0+19b 0x0+19b RW +0x200000
+ +DYNAMIC +0x0+1388 0x0+601388 0x0+601388 0x0+100 0x0+100 RW +0x8
+ +TLS +0x0+1325 0x0+601325 0x0+601325 0x0+60 0x0+a0 R +0x1
 
  Section to Segment mapping:
  +Segment Sections...
@@ -52,10 +52,10 @@ Program Headers:
 
 Relocation section '.rela.dyn' at offset 0x[0-9a-f]+ contains 4 entries:
  +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
-0+601460 +0+100000012 R_X86_64_TPOFF64 +0+ sG5 \+ 0
-0+601468 +0+200000012 R_X86_64_TPOFF64 +0+ sG2 \+ 0
-0+601470 +0+300000012 R_X86_64_TPOFF64 +0+ sG6 \+ 0
-0+601478 +0+400000012 R_X86_64_TPOFF64 +0+ sG1 \+ 0
+0+601488 +0+100000012 R_X86_64_TPOFF64 +0+ sG5 \+ 0
+0+601490 +0+200000012 R_X86_64_TPOFF64 +0+ sG2 \+ 0
+0+601498 +0+300000012 R_X86_64_TPOFF64 +0+ sG6 \+ 0
+0+6014a0 +0+400000012 R_X86_64_TPOFF64 +0+ sG1 \+ 0
 
 Symbol table '\.dynsym' contains [0-9]+ entries:
  +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
@@ -88,8 +88,8 @@ Symbol table '\.symtab' contains [0-9]+ entries:
  +[0-9]+: 0+9c +0 +TLS +LOCAL +DEFAULT +8 bl8
 .* FILE +LOCAL +DEFAULT +ABS 
  +[0-9]+: 0+a0 +0 +TLS +LOCAL +DEFAULT +7 _TLS_MODULE_BASE_
- +[0-9]+: 0+601360 +0 +OBJECT +LOCAL +DEFAULT +9 _DYNAMIC
- +[0-9]+: 0+601480 +0 +OBJECT +LOCAL +DEFAULT +11 _GLOBAL_OFFSET_TABLE_
+ +[0-9]+: 0+601388 +0 +OBJECT +LOCAL +DEFAULT +9 _DYNAMIC
+ +[0-9]+: 0+6014a8 +0 +OBJECT +LOCAL +DEFAULT +11 _GLOBAL_OFFSET_TABLE_
  +[0-9]+: 0+1c +0 +TLS +GLOBAL +DEFAULT +7 sg8
  +[0-9]+: 0+7c +0 +TLS +GLOBAL +DEFAULT +8 bg8
  +[0-9]+: 0+74 +0 +TLS +GLOBAL +DEFAULT +8 bg6
@@ -104,7 +104,7 @@ Symbol table '\.symtab' contains [0-9]+ entries:
  +[0-9]+: 0+58 +0 +TLS +GLOBAL +HIDDEN +7 sh7
  +[0-9]+: 0+5c +0 +TLS +GLOBAL +HIDDEN +7 sh8
  +[0-9]+: 0+ +0 +TLS +GLOBAL +DEFAULT +7 sg1
- +[0-9]+: 0+401205 +0 +FUNC +GLOBAL +DEFAULT +6 _start
+ +[0-9]+: 0+40122d +0 +FUNC +GLOBAL +DEFAULT +6 _start
  +[0-9]+: 0+4c +0 +TLS +GLOBAL +HIDDEN +7 sh4
  +[0-9]+: 0+78 +0 +TLS +GLOBAL +DEFAULT +8 bg7
  +[0-9]+: 0+50 +0 +TLS +GLOBAL +HIDDEN +7 sh5
index 8aad1025de846f2af39d5520044ff0ff6d104d5c..39ba3bbaa9f6c4beac64bee136c3fd09616b2c91 100644 (file)
@@ -131,6 +131,7 @@ fn2:
        addq    sG2@gottpoff(%rip), %r16
        addq    %rax, sG2@gottpoff(%rip), %r16
        addq    sG2@gottpoff(%rip), %rax, %r16
+       {nf} addq       sG2@gottpoff(%rip), %r16
        {nf} addq       %rax, sG2@gottpoff(%rip), %r16
        {nf} addq       sG2@gottpoff(%rip), %rax, %r16
 
@@ -138,6 +139,7 @@ fn2:
        addq    sg1@gottpoff(%rip), %r17
        addq    %r8, sg1@gottpoff(%rip), %r17
        addq    sg1@gottpoff(%rip), %r8, %r17
+       {nf} addq       sg1@gottpoff(%rip), %r17
        {nf} addq       %r8, sg1@gottpoff(%rip), %r17
        {nf} addq       sg1@gottpoff(%rip), %r8, %r17
 
@@ -145,6 +147,7 @@ fn2:
        addq    sl1@gottpoff(%rip), %r18
        addq    %r8, sl1@gottpoff(%rip), %rax
        addq    sl1@gottpoff(%rip), %r8, %rax
+       {nf} addq       sl1@gottpoff(%rip), %r18
        {nf} addq       %r8, sl1@gottpoff(%rip), %rax
        {nf} addq       sl1@gottpoff(%rip), %r8, %rax
 
@@ -152,6 +155,7 @@ fn2:
        addq    sh1@gottpoff(%rip), %r19
        addq    %r19, sh1@gottpoff(%rip), %r8
        addq    sh1@gottpoff(%rip), %r19, %r8
+       {nf} addq       sh1@gottpoff(%rip), %r19
        {nf} addq       %r19, sh1@gottpoff(%rip), %r8
        {nf} addq       sh1@gottpoff(%rip), %r19, %r8