Return relocation error on unsupported relocation.
authorH.J. Lu <hjl.tools@gmail.com>
Sat, 9 Apr 2011 15:37:57 +0000 (15:37 +0000)
committerH.J. Lu <hjl.tools@gmail.com>
Sat, 9 Apr 2011 15:37:57 +0000 (15:37 +0000)
2011-04-09  H.J. Lu  <hongjiu.lu@intel.com>

* elf32-i386.c (elf_i386_relocate_section): Return relocation
error on unsupported relocation.
* elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.

bfd/ChangeLog
bfd/elf32-i386.c
bfd/elf64-x86-64.c

index c745c2ac3d453b4f597cea79273b5fa4ceeb1b22..a7242776c64a264d8008827cc4ee1f4480f26c52 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-09  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf32-i386.c (elf_i386_relocate_section): Return relocation
+       error on unsupported relocation.
+       * elf64-x86-64.c (elf_x86_64_relocate_section): Likewise.
+
 2011-04-09  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR binutils/12657
index 1b76cb4a4540578d19092c50e61a72d328459fce..acabeb31f41893c2caffb4cda9932e657a8d4788 100644 (file)
@@ -3451,7 +3451,11 @@ elf_i386_relocate_section (bfd *output_bfd,
 
              sreloc = elf_section_data (input_section)->sreloc;
 
-             BFD_ASSERT (sreloc != NULL && sreloc->contents != NULL);
+             if (sreloc == NULL || sreloc->contents == NULL)
+               {
+                 r = bfd_reloc_notsupported;
+                 goto check_relocation_error;
+               }
 
              loc = sreloc->contents;
              loc += sreloc->reloc_count++ * sizeof (Elf32_External_Rel);
@@ -4096,6 +4100,7 @@ do_relocation:
                                    contents, rel->r_offset,
                                    relocation, 0);
 
+check_relocation_error:
       if (r != bfd_reloc_ok)
        {
          const char *name;
index 927b3ed4a5f0f984f78e43174faa4be0c3cb5ccb..ea837a3946e390b74662fd4f22e1a2f83bcf0ec9 100644 (file)
@@ -3411,7 +3411,11 @@ elf_x86_64_relocate_section (bfd *output_bfd,
 
              sreloc = elf_section_data (input_section)->sreloc;
 
-             BFD_ASSERT (sreloc != NULL && sreloc->contents != NULL);
+             if (sreloc == NULL || sreloc->contents == NULL)
+               {
+                 r = bfd_reloc_notsupported;
+                 goto check_relocation_error;
+               }
 
              elf_append_rela (output_bfd, sreloc, &outrel);
 
@@ -3868,6 +3872,7 @@ do_relocation:
                                    contents, rel->r_offset,
                                    relocation, rel->r_addend);
 
+check_relocation_error:
       if (r != bfd_reloc_ok)
        {
          const char *name;
@@ -3896,7 +3901,7 @@ do_relocation:
          else
            {
              (*_bfd_error_handler)
-               (_("%B(%A+0x%lx): reloc against `%s': error %d"),
+               (_("%B(%A+0x%lx): reloc against `%s': error %r"),
                 input_bfd, input_section,
                 (long) rel->r_offset, name, (int) r);
              return FALSE;