Automatic date update in version.in
[binutils-gdb.git] / bfd / elfxx-x86.c
index 7ac2411fc80d2f23eff352629c8e9bd275fe63bc..acb2cc8528db8f69bd5168da42cd64bcdabd1905 100644 (file)
@@ -524,6 +524,24 @@ elf_x86_allocate_dynrelocs (struct elf_link_hash_entry *h, void *inf)
     {
       asection *sreloc;
 
+      if (eh->def_protected
+         && elf_has_no_copy_on_protected (h->root.u.def.section->owner))
+       {
+         /* Disallow copy relocation against non-copyable protected
+            symbol.  */
+         asection *s = p->sec->output_section;
+         if (s != NULL && (s->flags & SEC_READONLY) != 0)
+           {
+             info->callbacks->einfo
+               /* xgettext:c-format */
+               (_("%F%P: %pB: copy relocation against non-copyable "
+                  "protected symbol `%s' in %pB\n"),
+                p->sec->owner, h->root.root.string,
+                h->root.u.def.section->owner);
+             return false;
+           }
+       }
+
       sreloc = elf_section_data (p->sec)->sreloc;
 
       BFD_ASSERT (sreloc != NULL);
@@ -1942,9 +1960,9 @@ _bfd_elf_x86_valid_reloc_p (asection *input_section,
       irel = *rel;
 
       /* Only allow relocations against absolute symbol, which can be
-        resolved as absolute value + addend.  GOTPCREL relocations
-        are allowed since absolute value + addend is stored in the
-        GOT slot.  */
+        resolved as absolute value + addend.  GOTPCREL and GOT32
+        relocations are allowed since absolute value + addend is
+        stored in the GOT slot.  */
       if (bed->target_id == X86_64_ELF_DATA)
        {
          r_type &= ~R_X86_64_converted_reloc_bit;
@@ -1965,7 +1983,9 @@ _bfd_elf_x86_valid_reloc_p (asection *input_section,
       else
        valid_p = (r_type == R_386_32
                   || r_type == R_386_16
-                  || r_type == R_386_8);
+                  || r_type == R_386_8
+                  || r_type == R_386_GOT32
+                  || r_type == R_386_GOT32X);
 
       if (valid_p)
        *no_dynreloc_p = true;