Fix another memory access error triggered by attempting to parse a corrupt binary.
[deliverable/binutils-gdb.git] / bfd / elf64-x86-64.c
index 957dcd98ce6f3dcf11694d858d26b8129c9c9a9e..448599eb9b34c3985cd673902976575a2e27bf10 100644 (file)
@@ -611,7 +611,7 @@ static const bfd_byte elf_x86_64_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] =
 };
 
 /* The first entry in the x32 IBT-enabled lazy procedure linkage table
-   is the the same as the normal lazy PLT.  Subsequent entries for an
+   is the same as the normal lazy PLT.  Subsequent entries for an
    x32 IBT-enabled lazy procedure linkage table look like this.  */
 
 static const bfd_byte elf_x32_lazy_ibt_plt_entry[LAZY_PLT_ENTRY_SIZE] =
@@ -1885,10 +1885,9 @@ elf_x86_64_tls_transition (struct bfd_link_info *info, bfd *abfd,
 
       _bfd_error_handler
        /* xgettext:c-format */
-       (_("%B: TLS transition from %s to %s against `%s' at 0x%lx "
+       (_("%B: TLS transition from %s to %s against `%s' at %#Lx "
           "in section `%A' failed"),
-        abfd, from->name, to->name, name,
-        (unsigned long) rel->r_offset, sec);
+        abfd, from->name, to->name, name, rel->r_offset, sec);
       bfd_set_error (bfd_error_bad_value);
       return FALSE;
     }
@@ -2428,7 +2427,7 @@ elf_x86_64_check_relocs (bfd *abfd, struct bfd_link_info *info,
   for (rel = relocs; rel < rel_end; rel++)
     {
       unsigned int r_type;
-      unsigned long r_symndx;
+      unsigned int r_symndx;
       struct elf_link_hash_entry *h;
       struct elf_x86_64_link_hash_entry *eh;
       Elf_Internal_Sym *isym;
@@ -4315,14 +4314,7 @@ elf_x86_64_relocate_section (bfd *output_bfd,
        }
 
       if (r_type >= (int) R_X86_64_standard)
-       {
-         _bfd_error_handler
-           /* xgettext:c-format */
-           (_("%B: unrecognized relocation (0x%x) in section `%A'"),
-            input_bfd, r_type, input_section);
-         bfd_set_error (bfd_error_bad_value);
-         return FALSE;
-       }
+       return _bfd_unrecognized_reloc (input_bfd, input_section, r_type);
 
       if (r_type != (int) R_X86_64_32
          || ABI_64_P (output_bfd))
@@ -4574,7 +4566,7 @@ do_ifunc_pointer:
                  _bfd_error_handler
                    /* xgettext:c-format */
                    (_("%B: relocation %s against STT_GNU_IFUNC "
-                      "symbol `%s' has non-zero addend: %d"),
+                      "symbol `%s' has non-zero addend: %Ld"),
                     input_bfd, howto->name, name, rel->r_addend);
                  bfd_set_error (bfd_error_bad_value);
                  return FALSE;
@@ -4670,7 +4662,7 @@ do_ifunc_pointer:
        case R_X86_64_GOTPCREL64:
          /* Use global offset table entry as symbol value.  */
        case R_X86_64_GOTPLT64:
-         /* This is obsolete and treated the the same as GOT64.  */
+         /* This is obsolete and treated the same as GOT64.  */
          base_got = htab->elf.sgot;
 
          if (htab->elf.sgot == NULL)
@@ -4967,11 +4959,9 @@ do_ifunc_pointer:
              && (input_section->flags & SEC_READONLY) != 0
              && h != NULL
              && ((bfd_link_executable (info)
-                 && h->root.type == bfd_link_hash_undefweak
-                 && !resolved_to_zero)
-                 || (bfd_link_pic (info)
-                     && !(bfd_link_pie (info)
-                          && h->root.type == bfd_link_hash_undefined))))
+                  && h->root.type == bfd_link_hash_undefweak
+                  && !resolved_to_zero)
+                 || bfd_link_dll (info)))
            {
              bfd_boolean fail = FALSE;
              bfd_boolean branch
@@ -5116,22 +5106,13 @@ direct:
                          else
                            name = bfd_elf_sym_name (input_bfd, symtab_hdr,
                                                     sym, NULL);
-                         if (addend < 0)
-                           _bfd_error_handler
-                             /* xgettext:c-format */
-                             (_("%B: addend -0x%x in relocation %s against "
-                                "symbol `%s' at 0x%lx in section `%A' is "
-                                "out of range"),
-                              input_bfd, addend, howto->name, name,
-                              (unsigned long) rel->r_offset, input_section);
-                         else
-                           _bfd_error_handler
-                             /* xgettext:c-format */
-                             (_("%B: addend 0x%x in relocation %s against "
-                                "symbol `%s' at 0x%lx in section `%A' is "
-                                "out of range"),
-                              input_bfd, addend, howto->name, name,
-                              (unsigned long) rel->r_offset, input_section);
+                         _bfd_error_handler
+                           /* xgettext:c-format */
+                           (_("%B: addend %s%#x in relocation %s against "
+                              "symbol `%s' at %#Lx in section `%A' is "
+                              "out of range"),
+                            input_bfd, addend < 0 ? "-" : "", addend,
+                            howto->name, name, rel->r_offset, input_section);
                          bfd_set_error (bfd_error_bad_value);
                          return FALSE;
                        }
@@ -5750,10 +5731,10 @@ direct:
        {
          _bfd_error_handler
            /* xgettext:c-format */
-           (_("%B(%A+0x%lx): unresolvable %s relocation against symbol `%s'"),
+           (_("%B(%A+%#Lx): unresolvable %s relocation against symbol `%s'"),
             input_bfd,
             input_section,
-            (long) rel->r_offset,
+            rel->r_offset,
             howto->name,
             h->root.root.string);
          return FALSE;
@@ -5790,9 +5771,9 @@ check_relocation_error:
            {
              _bfd_error_handler
                /* xgettext:c-format */
-               (_("%B(%A+0x%lx): reloc against `%s': error %d"),
+               (_("%B(%A+%#Lx): reloc against `%s': error %d"),
                 input_bfd, input_section,
-                (long) rel->r_offset, name, (int) r);
+                rel->r_offset, name, (int) r);
              return FALSE;
            }
        }
@@ -7407,8 +7388,13 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
          if (sec == NULL)
            info->callbacks->einfo (_("%F: failed to create GNU property section\n"));
 
-         if (!bfd_set_section_alignment (ebfd, sec, 2))
-           goto error_alignment;
+         if (!bfd_set_section_alignment (ebfd, sec,
+                                         ABI_64_P (ebfd) ? 3 : 2))
+           {
+error_alignment:
+             info->callbacks->einfo (_("%F%A: failed to align section\n"),
+                                     sec);
+           }
 
          elf_section_type (sec) = SHT_NOTE;
        }
@@ -7567,11 +7553,7 @@ elf_x86_64_link_setup_gnu_properties (struct bfd_link_info *info)
      properly aligned even if create_dynamic_sections isn't called.  */
   sec = htab->elf.sgot;
   if (!bfd_set_section_alignment (dynobj, sec, 3))
-    {
-error_alignment:
-      info->callbacks->einfo (_("%F%A: failed to align section\n"),
-                             sec);
-    }
+    goto error_alignment;
 
   sec = htab->elf.sgotplt;
   if (!bfd_set_section_alignment (dynobj, sec, 3))
This page took 0.026325 seconds and 4 git commands to generate.