Add assembler support for @gotplt
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 13 Nov 2014 19:07:31 +0000 (11:07 -0800)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 13 Nov 2014 19:09:40 +0000 (11:09 -0800)
Obsolete R_X86_64_GOTPLT64 and treat it the same as R_X86_64_GOT64.

bfd/

PR gas/17598
* elf64-x86-64.c (elf_x86_64_check_relocs): Treat
R_X86_64_GOTPLT64 the same as R_X86_64_GOT64.
(elf_x86_64_relocate_section): Likewise.

gas/

PR gas/17598
* config/tc-i386.c (reloc): Support BFD_RELOC_X86_64_GOTPLT64.

gas/testsuite/

PR gas/17598
* gas/i386/reloc64.s: Add @gotplt check.

* gas/i386/reloc64.d: Updated.
* gas/i386/reloc64.l: Likewise.

ld/testsuite/

PR gas/17598
* ld-x86-64/x86-64.exp: Run gotplt1.

* ld-x86-64/gotplt1.d: New file.
* ld-x86-64/gotplt1.s: Likewise.

12 files changed:
bfd/ChangeLog
bfd/elf64-x86-64.c
gas/ChangeLog
gas/config/tc-i386.c
gas/testsuite/ChangeLog
gas/testsuite/gas/i386/reloc64.d
gas/testsuite/gas/i386/reloc64.l
gas/testsuite/gas/i386/reloc64.s
ld/testsuite/ChangeLog
ld/testsuite/ld-x86-64/gotplt1.d [new file with mode: 0644]
ld/testsuite/ld-x86-64/gotplt1.s [new file with mode: 0644]
ld/testsuite/ld-x86-64/x86-64.exp

index 701540ef40847255baa0c8f84114d4e764b87349..3cf91d16fe86051e9541d6e7d1bd3a2ec47b7c13 100644 (file)
@@ -1,3 +1,10 @@
+2014-11-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/17598
+       * elf64-x86-64.c (elf_x86_64_check_relocs): Treat
+       R_X86_64_GOTPLT64 the same as R_X86_64_GOT64.
+       (elf_x86_64_relocate_section): Likewise.
+
 2014-11-13  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/17512
index d0ed8a7e0769aef1d7c40b4563306e2805f4ec3c..f2b13e7b89a3d3cc3bd0853f9cf643a6e7a928f5 100644 (file)
@@ -1752,14 +1752,6 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
 
            if (h != NULL)
              {
-               if (r_type == R_X86_64_GOTPLT64)
-                 {
-                   /* This relocation indicates that we also need
-                      a PLT entry, as this is a function.  We don't need
-                      a PLT entry for local symbols.  */
-                   h->needs_plt = 1;
-                   h->plt.refcount += 1;
-                 }
                h->got.refcount += 1;
                old_tls_type = elf_x86_64_hash_entry (h)->tls_type;
              }
@@ -2181,8 +2173,6 @@ elf_x86_64_gc_sweep_hook (bfd *abfd, struct bfd_link_info *info,
        case R_X86_64_GOTPLT64:
          if (h != NULL)
            {
-             if (r_type == R_X86_64_GOTPLT64 && h->plt.refcount > 0)
-               h->plt.refcount -= 1;
              if (h->got.refcount > 0)
                h->got.refcount -= 1;
              if (h->type == STT_GNU_IFUNC)
@@ -3720,12 +3710,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
        case R_X86_64_GOTPCREL64:
          /* Use global offset table entry as symbol value.  */
        case R_X86_64_GOTPLT64:
-         /* This is the same as GOT64 for relocation purposes, but
-            indicates the existence of a PLT entry.  The difficulty is,
-            that we must calculate the GOT slot offset from the PLT
-            offset, if this symbol got a PLT entry (it was global).
-            Additionally if it's computed from the PLT entry, then that
-            GOT offset is relative to .got.plt, not to .got.  */
+         /* This is obsolete and treated the the same as GOT64.  */
          base_got = htab->elf.sgot;
 
          if (htab->elf.sgot == NULL)
index e7248c45e1c406924dd1bd16294d3c3c1dfe2521..e6744766b8fc52001df4b2dc72e80b258b1b311b 100644 (file)
@@ -1,3 +1,8 @@
+2014-11-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/17598
+       * config/tc-i386.c (reloc): Support BFD_RELOC_X86_64_GOTPLT64.
+
 2014-11-13  Nick Clifton  <nickc@redhat.com>
 
        PR binutils/17512
index 51d58c173f6c149649d1d5605aec16c6dd10f47f..f54f077e4cf0a1643fdab34288ca2603572e99c4 100644 (file)
@@ -2835,6 +2835,9 @@ reloc (unsigned int size,
          case BFD_RELOC_X86_64_GOT32:
            return BFD_RELOC_X86_64_GOT64;
            break;
+         case BFD_RELOC_X86_64_GOTPLT64:
+           return BFD_RELOC_X86_64_GOTPLT64;
+           break;
          case BFD_RELOC_X86_64_PLTOFF64:
            return BFD_RELOC_X86_64_PLTOFF64;
            break;
index 972b2e65170fb1ac232d2b794cd34ca42e5a4459..7908363f77b9f6d09ef57680b36e36dd0e16d699 100644 (file)
@@ -1,3 +1,11 @@
+2014-11-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/17598
+       * gas/i386/reloc64.s: Add @gotplt check.
+
+       * gas/i386/reloc64.d: Updated.
+       * gas/i386/reloc64.l: Likewise.
+
 2014-11-07  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/17482
index 44919825fd29a52d86391903331b2c837d4e2a13..ea7f696a6b1b6c9864ac98ed407464192d55ccda 100644 (file)
@@ -50,6 +50,7 @@ Disassembly of section \.text:
 .*[    ]+R_X86_64_TPOFF32[     ]+xtrn
 .*[    ]+R_X86_64_TPOFF32[     ]+xtrn
 .*[    ]+R_X86_64_TPOFF32[     ]+xtrn
+.*[    ]+R_X86_64_GOTPLT64[    ]+xtrn
 Disassembly of section \.data:
 #...
 .*[    ]+R_X86_64_64[  ]+xtrn
@@ -89,3 +90,4 @@ Disassembly of section \.data:
 .*[    ]+R_X86_64_PC8[         ]+xtrn
 .*[    ]+R_X86_64_GOT32[       ]+xtrn-0x4
 .*[    ]+R_X86_64_GOT32[       ]+xtrn\+0x4
+.*[    ]+R_X86_64_GOTPLT64[    ]+xtrn
index ded5cabd36626a56e777d5ca707e279273227a18..5e970cb7b6d84da7ec17bb1c19b6254dd908fda0 100644 (file)
 .*:195: Error: .*
 .*:196: Error: .*
 .*:197: Error: .*
+.*:208: Error: .*
+.*:209: Error: .*
+.*:210: Error: .*
+.*:211: Error: .*
+.*:212: Error: .*
+.*:213: Error: .*
+.*:214: Error: .*
+.*:218: Error: .*
+.*:219: Error: .*
+.*:220: Error: .*
index 7b35a029b14fa37b1b9d5f3f9fda2ec63c83d0ad..ecaaef527644049baf0e2fcaa2278a28345f9dc8 100644 (file)
@@ -202,3 +202,19 @@ bad        .byte   xtrn@tpoff
        .data
        .long   xtrn@got - 4
        .long   xtrn@got + 4
+
+       .text
+       movabs  $xtrn@gotplt, %rax
+bad    add     $xtrn@gotplt, %rax
+bad    mov     $xtrn@gotplt, %eax
+bad    mov     $xtrn@gotplt, %ax
+bad    mov     $xtrn@gotplt, %al
+bad    mov     xtrn@gotplt(%rbx), %eax
+bad    mov     xtrn@gotplt(%ebx), %eax
+bad    call    xtrn@gotplt
+
+       .data
+       .quad   xtrn@gotplt
+bad    .long   xtrn@gotplt
+bad    .word   xtrn@gotplt
+bad    .byte   xtrn@gotplt
index dddada5684772886a70cc9d3a5e6c98f282b6ffa..4d78aab1b624f2c70d9ef37b525cafebe702c9fb 100644 (file)
@@ -1,3 +1,11 @@
+2014-11-13  H.J. Lu  <hongjiu.lu@intel.com>
+
+       PR gas/17598
+       * ld-x86-64/x86-64.exp: Run gotplt1.
+
+       * ld-x86-64/gotplt1.d: New file.
+       * ld-x86-64/gotplt1.s: Likewise.
+
 2014-11-11  Jiong Wang <jiong.wang@arm.com>
 
        * lib/ld-lib.exp (run_ld_link_exec_tests): Append board_cflags if gcc
diff --git a/ld/testsuite/ld-x86-64/gotplt1.d b/ld/testsuite/ld-x86-64/gotplt1.d
new file mode 100644 (file)
index 0000000..f2ee245
--- /dev/null
@@ -0,0 +1,6 @@
+#as: --64
+#ld: -shared -melf_x86_64
+#readelf: -r --wide
+
+#...
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_GLOB_DAT +[0-9a-f]+ +foo \+ 0
diff --git a/ld/testsuite/ld-x86-64/gotplt1.s b/ld/testsuite/ld-x86-64/gotplt1.s
new file mode 100644 (file)
index 0000000..0675843
--- /dev/null
@@ -0,0 +1,5 @@
+       .globl _start
+       .type   _start, @function
+_start:
+       movabsq $foo@GOTPLT, %rax
+       .size   _start, .-_start
index 54786a78a22d3196b186f629aabbb3b175f297af..a9b68ff213382e80c43d6b8c8d0e479a0df97f54 100644 (file)
@@ -227,6 +227,7 @@ run_dump_test "pr12570a"
 run_dump_test "pr12570b"
 run_dump_test "pr14215"
 run_dump_test "pr14207"
+run_dump_test "gotplt1"
 
 if { ![istarget "x86_64-*-linux*"] && ![istarget "x86_64-*-nacl*"]} {
     return
This page took 0.038868 seconds and 4 git commands to generate.