Automatic date update in version.in
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index 7016964aceb38c439c222a447e0db3c00e3996f7..a0ebd2cf69ae02d6d5348e2d916256d147d52ae4 100644 (file)
@@ -344,9 +344,6 @@ elf_x86_64_info_to_howto (bfd *abfd, arelent *cache_ptr,
   unsigned r_type;
 
   r_type = ELF32_R_TYPE (dst->r_info);
-  if (r_type != (unsigned int) R_X86_64_GNU_VTINHERIT
-      && r_type != (unsigned int) R_X86_64_GNU_VTENTRY)
-    r_type &= ~R_X86_64_converted_reloc_bit;
   cache_ptr->howto = elf_x86_64_rtype_to_howto (abfd, r_type);
   if (cache_ptr->howto == NULL)
     return FALSE;
@@ -442,6 +439,10 @@ elf_x86_64_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
 }
 
 #ifdef CORE_HEADER
+# if GCC_VERSION >= 8000
+#  pragma GCC diagnostic push
+#  pragma GCC diagnostic ignored "-Wstringop-truncation"
+# endif
 static char *
 elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
                            int note_type, ...)
@@ -527,6 +528,9 @@ elf_x86_64_write_core_note (bfd *abfd, char *buf, int *bufsiz,
     }
   /* NOTREACHED */
 }
+# if GCC_VERSION >= 8000
+#  pragma GCC diagnostic pop
+# endif
 #endif
 \f
 /* Functions for the x86-64 ELF linker.         */
@@ -2503,6 +2507,10 @@ elf_x86_64_relocate_section (bfd *output_bfd,
 
          if ((input_section->flags & SEC_ALLOC) == 0)
            {
+             /* If this is a SHT_NOTE section without SHF_ALLOC, treat
+                STT_GNU_IFUNC symbol as STT_FUNC.  */
+             if (elf_section_type (input_section) == SHT_NOTE)
+               goto skip_ifunc;
              /* Dynamic relocs are not propagated for SEC_DEBUGGING
                 sections because such sections are not SEC_ALLOC and
                 thus ld.so will not process them.  */
@@ -2726,6 +2734,7 @@ do_ifunc_pointer:
            }
        }
 
+skip_ifunc:
       resolved_to_zero = (eh != NULL
                          && UNDEFINED_WEAK_RESOLVED_TO_ZERO (info, eh));
 
@@ -4406,15 +4415,23 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
 
       if (htab->tlsdesc_plt)
        {
+         /* The TLSDESC entry in a lazy procedure linkage table.  */
+         static const bfd_byte tlsdesc_plt_entry[LAZY_PLT_ENTRY_SIZE] =
+           {
+             0xf3, 0x0f, 0x1e, 0xfa,   /* endbr64              */
+             0xff, 0x35, 8, 0, 0, 0,   /* pushq GOT+8(%rip)    */
+             0xff, 0x25, 16, 0, 0, 0   /* jmpq *GOT+TDG(%rip)  */
+           };
+
          bfd_put_64 (output_bfd, (bfd_vma) 0,
                      htab->elf.sgot->contents + htab->tlsdesc_got);
 
          memcpy (htab->elf.splt->contents + htab->tlsdesc_plt,
-                 htab->lazy_plt->plt0_entry,
-                 htab->lazy_plt->plt0_entry_size);
+                 tlsdesc_plt_entry, LAZY_PLT_ENTRY_SIZE);
 
-         /* Add offset for pushq GOT+8(%rip), since the
-            instruction uses 6 bytes subtract this value.  */
+         /* Add offset for pushq GOT+8(%rip), since ENDBR64 uses 4
+            bytes and the instruction uses 6 bytes, subtract these
+            values.  */
          bfd_put_32 (output_bfd,
                      (htab->elf.sgotplt->output_section->vma
                       + htab->elf.sgotplt->output_offset
@@ -4422,14 +4439,13 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
                       - htab->elf.splt->output_section->vma
                       - htab->elf.splt->output_offset
                       - htab->tlsdesc_plt
-                      - 6),
+                      - 4 - 6),
                      (htab->elf.splt->contents
                       + htab->tlsdesc_plt
-                      + htab->lazy_plt->plt0_got1_offset));
-         /* Add offset for the PC-relative instruction accessing
-            GOT+TDG, where TDG stands for htab->tlsdesc_got,
-            subtracting the offset to the end of that
-            instruction.  */
+                      + 4 + 2));
+         /* Add offset for indirect branch via GOT+TDG, where TDG
+            stands for htab->tlsdesc_got, subtracting the offset
+            to the end of that instruction.  */
          bfd_put_32 (output_bfd,
                      (htab->elf.sgot->output_section->vma
                       + htab->elf.sgot->output_offset
@@ -4437,10 +4453,9 @@ elf_x86_64_finish_dynamic_sections (bfd *output_bfd,
                       - htab->elf.splt->output_section->vma
                       - htab->elf.splt->output_offset
                       - htab->tlsdesc_plt
-                      - htab->lazy_plt->plt0_got2_insn_end),
+                      - 4 - 6 - 6),
                      (htab->elf.splt->contents
-                      + htab->tlsdesc_plt
-                      + htab->lazy_plt->plt0_got2_offset));
+                      + htab->tlsdesc_plt + 4 + 6 + 2));
        }
     }
 
@@ -5012,6 +5027,9 @@ elf_x86_64_special_sections[]=
 #define elf_backend_hide_symbol \
   _bfd_x86_elf_hide_symbol
 
+#undef elf64_bed
+#define elf64_bed elf64_x86_64_bed
+
 #include "elf64-target.h"
 
 /* CloudABI support.  */
@@ -5296,6 +5314,9 @@ elf32_x86_64_nacl_elf_object_p (bfd *abfd)
 #define elf_backend_size_info \
   _bfd_elf32_size_info
 
+#undef elf32_bed
+#define        elf32_bed                       elf32_x86_64_bed
+
 #include "elf32-target.h"
 
 /* Restore defaults.  */
This page took 0.024607 seconds and 4 git commands to generate.