[AArch64] Support RAS extension for ARMv8 onwards.
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index 380376d93c16d464f2ab4bc481ff3cff40074f17..5533b4ad526940a6e1f7478635d0c26c8317db20 100644 (file)
@@ -900,6 +900,10 @@ struct elf_x86_64_link_hash_table
   bfd_vma next_jump_slot_index;
   /* The index of the next R_X86_64_IRELATIVE entry in .rela.plt.  */
   bfd_vma next_irelative_index;
+
+  /* TRUE if there are dynamic relocs against IFUNC symbols that apply
+     to read-only sections.  */
+  bfd_boolean readonly_dynrelocs_against_ifunc;
 };
 
 /* Get the x86-64 ELF linker hash table from a link_info structure.  */
@@ -1973,8 +1977,10 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
          /* Let's help debug shared library creation.  These relocs
             cannot be used in shared libs.  Don't error out for
             sections we don't care about, such as debug sections or
-            non-constant sections.  */
-         if (bfd_link_pic (info)
+            non-constant sections, or when relocation overflow check
+            is disabled.  */
+         if (!info->no_reloc_overflow_check
+             && bfd_link_pic (info)
              && (sec->flags & SEC_ALLOC) != 0
              && (sec->flags & SEC_READONLY) != 0)
            {
@@ -2071,7 +2077,8 @@ do_size:
               && (sec->flags & SEC_ALLOC) != 0
               && (! IS_X86_64_PCREL_TYPE (r_type)
                   || (h != NULL
-                      && (! SYMBOLIC_BIND (info, h)
+                      && (! (bfd_link_pie (info)
+                             || SYMBOLIC_BIND (info, h))
                           || h->root.type == bfd_link_hash_defweak
                           || !h->def_regular))))
              || (ELIMINATE_COPY_RELOCS
@@ -2656,6 +2663,7 @@ elf_x86_64_allocate_dynrelocs (struct elf_link_hash_entry *h, void * inf)
     {
       if (_bfd_elf_allocate_ifunc_dyn_relocs (info, h,
                                              &eh->dyn_relocs,
+                                             &htab->readonly_dynrelocs_against_ifunc,
                                              plt_entry_size,
                                              plt_entry_size,
                                              GOT_ENTRY_SIZE))
@@ -3896,8 +3904,7 @@ elf_x86_64_size_dynamic_sections (bfd *output_bfd,
 
          if ((info->flags & DF_TEXTREL) != 0)
            {
-             if ((elf_tdata (output_bfd)->has_gnu_symbols
-                  & elf_gnu_symbol_ifunc) == elf_gnu_symbol_ifunc)
+             if (htab->readonly_dynrelocs_against_ifunc)
                {
                  info->callbacks->einfo
                    (_("%P%X: read-only segment has dynamic IFUNC relocations; recompile with -fPIC\n"));
@@ -4828,8 +4835,8 @@ direct:
              else if (h != NULL
                       && h->dynindx != -1
                       && (IS_X86_64_PCREL_TYPE (r_type)
-                          || ! bfd_link_pic (info)
-                          || ! SYMBOLIC_BIND (info, h)
+                          || !(bfd_link_executable (info)
+                               || SYMBOLIC_BIND (info, h))
                           || ! h->def_regular))
                {
                  if ((r_type != R_X86_64_PC64 && r_type != R_X86_64_64)
@@ -4842,8 +4849,12 @@ direct:
                }
              else
                {
-                 /* This symbol is local, or marked to become local.  */
-                 if (r_type == htab->pointer_r_type)
+                 /* This symbol is local, or marked to become local.
+                    When relocation overflow check is disabled, we
+                    convert R_X86_64_32 to dynamic R_X86_64_RELATIVE.  */
+                 if (r_type == htab->pointer_r_type
+                     || (r_type == R_X86_64_32
+                         && info->no_reloc_overflow_check))
                    {
                      relocate = TRUE;
                      outrel.r_info = htab->r_info (0, R_X86_64_RELATIVE);
@@ -6697,16 +6708,33 @@ static const struct bfd_elf_special_section
 
 /* The 64-bit static TLS arena size is rounded to the nearest 16-byte
    boundary.  */
-#undef elf_backend_static_tls_alignment
+#undef  elf_backend_static_tls_alignment
 #define elf_backend_static_tls_alignment    16
 
 /* The Solaris 2 ABI requires a plt symbol on all platforms.
 
    Cf. Linker and Libraries Guide, Ch. 2, Link-Editor, Generating the Output
    File, p.63.  */
-#undef elf_backend_want_plt_sym
+#undef  elf_backend_want_plt_sym
 #define elf_backend_want_plt_sym           1
 
+#undef  elf_backend_strtab_flags
+#define elf_backend_strtab_flags       SHF_STRINGS
+
+static bfd_boolean
+elf64_x86_64_set_special_info_link (const bfd *ibfd ATTRIBUTE_UNUSED,
+                                   bfd *obfd ATTRIBUTE_UNUSED,
+                                   const Elf_Internal_Shdr *isection ATTRIBUTE_UNUSED,
+                                   Elf_Internal_Shdr *osection ATTRIBUTE_UNUSED)
+{
+  /* PR 19938: FIXME: Need to add code for setting the sh_info
+     and sh_link fields of Solaris specific section types.  */
+  return FALSE;
+}
+
+#undef  elf_backend_set_special_section_info_and_link
+#define elf_backend_set_special_section_info_and_link elf64_x86_64_set_special_info_link
+
 #include "elf64-target.h"
 
 /* Native Client support.  */
@@ -6738,6 +6766,8 @@ elf64_x86_64_nacl_elf_object_p (bfd *abfd)
 #undef elf_backend_static_tls_alignment
 #undef elf_backend_want_plt_sym
 #define elf_backend_want_plt_sym       0
+#undef  elf_backend_strtab_flags
+#undef  elf_backend_set_special_section_info_and_link
 
 /* NaCl uses substantially different PLT entries for the same effects.  */
 
This page took 0.025121 seconds and 4 git commands to generate.