]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Check corrupt VTENTRY entry in bfd_elf_gc_record_vtentry
authorH.J. Lu <hjl.tools@gmail.com>
Thu, 11 Apr 2019 13:44:53 +0000 (06:44 -0700)
committerH.J. Lu <hjl.tools@gmail.com>
Thu, 11 Apr 2019 13:45:05 +0000 (06:45 -0700)
Instead of BFD_ASSERT (h != NULL) with

ld: BFD ... assertion fail .../bfd/elf64-x86-64.c:2562
ld: bad.o: invalid string offset 50331648 >= 371 for section `nterp'

check corrupt VTENTRY entry in bfd_elf_gc_record_vtentry with

ld: bad.o: section 'g': corrupt VTENTRY entry

* elf-m10300.c (mn10300_elf_check_relocs): Remove BFD_ASSERT of
"h != NULL".  Don't check "h != NULL" before calling.
bfd_elf_gc_record_vtentry.
* elf32-arm.c (elf32_arm_check_relocs): Likewise.
* elf32-bfin.c (bfin_check_relocs): Likewise.
* elf32-cris.c (cris_elf_check_relocs): Likewise.
* elf32-csky.c (csky_elf_check_relocs): Likewise.
* elf32-d10v.c (elf32_d10v_check_relocs): Likewise.
* elf32-dlx.c (elf32_dlx_check_relocs): Likewise.
* elf32-fr30.c (fr30_elf_check_relocs): Likewise.
* elf32-frv.c (elf32_frv_check_relocs): Likewise.
* elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
* elf32-i386.c (elf_i386_check_relocs): Likewise.
* elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
* elf32-m32r.c (m32r_elf_check_relocs): Likewise.
* elf32-m68hc1x.c (elf32_m68hc11_check_relocs): Likewise.
* elf32-m68k.c (elf_m68k_check_relocs): Likewise.
* elf32-mcore.c (mcore_elf_check_relocs): Likewise.
* elf32-metag.c (elf_metag_check_relocs): Likewise.
* elf32-or1k.c (or1k_elf_check_relocs): Likewise.
* elf32-ppc.c (ppc_elf_check_relocs): Likewise.
* elf32-s390.c (elf_s390_check_relocs): Likewise.
* elf32-sh.c (sh_elf_check_relocs): Likewise.
* elf32-v850.c (v850_elf_check_relocs): Likewise.
* elf32-vax.c (elf_vax_check_relocs): Likewise.
* elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise.
* elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
* elf64-mmix.c (mmix_elf_check_relocs): Likewise.
* elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
* elf64-s390.c (elf_s390_check_relocs): Likewise.
* elf64-x86-64.c (elf_s390_check_relocs): Likewise.
* elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
* elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
* elflink.c (bfd_elf_gc_record_vtinherit): Check for corrupt
VTENTRY entry.

33 files changed:
bfd/ChangeLog
bfd/elf-m10300.c
bfd/elf32-arm.c
bfd/elf32-bfin.c
bfd/elf32-cris.c
bfd/elf32-csky.c
bfd/elf32-d10v.c
bfd/elf32-dlx.c
bfd/elf32-fr30.c
bfd/elf32-frv.c
bfd/elf32-hppa.c
bfd/elf32-i386.c
bfd/elf32-iq2000.c
bfd/elf32-m32r.c
bfd/elf32-m68hc1x.c
bfd/elf32-m68k.c
bfd/elf32-mcore.c
bfd/elf32-metag.c
bfd/elf32-or1k.c
bfd/elf32-ppc.c
bfd/elf32-s390.c
bfd/elf32-sh.c
bfd/elf32-v850.c
bfd/elf32-vax.c
bfd/elf32-xstormy16.c
bfd/elf32-xtensa.c
bfd/elf64-mmix.c
bfd/elf64-ppc.c
bfd/elf64-s390.c
bfd/elf64-x86-64.c
bfd/elflink.c
bfd/elfxx-mips.c
bfd/elfxx-sparc.c

index a3cdfc6505bdcfd7825c5932ff8e9020f34884ee..4c42905e59e1a2bb19445bfadb5c0af12a7605f0 100644 (file)
@@ -1,3 +1,41 @@
+2019-04-11  H.J. Lu  <hongjiu.lu@intel.com>
+
+       * elf-m10300.c (mn10300_elf_check_relocs): Remove BFD_ASSERT of
+       "h != NULL".  Don't check "h != NULL" before calling.
+       bfd_elf_gc_record_vtentry.
+       * elf32-arm.c (elf32_arm_check_relocs): Likewise.
+       * elf32-bfin.c (bfin_check_relocs): Likewise.
+       * elf32-cris.c (cris_elf_check_relocs): Likewise.
+       * elf32-csky.c (csky_elf_check_relocs): Likewise.
+       * elf32-d10v.c (elf32_d10v_check_relocs): Likewise.
+       * elf32-dlx.c (elf32_dlx_check_relocs): Likewise.
+       * elf32-fr30.c (fr30_elf_check_relocs): Likewise.
+       * elf32-frv.c (elf32_frv_check_relocs): Likewise.
+       * elf32-hppa.c (elf32_hppa_check_relocs): Likewise.
+       * elf32-i386.c (elf_i386_check_relocs): Likewise.
+       * elf32-iq2000.c (iq2000_elf_check_relocs): Likewise.
+       * elf32-m32r.c (m32r_elf_check_relocs): Likewise.
+       * elf32-m68hc1x.c (elf32_m68hc11_check_relocs): Likewise.
+       * elf32-m68k.c (elf_m68k_check_relocs): Likewise.
+       * elf32-mcore.c (mcore_elf_check_relocs): Likewise.
+       * elf32-metag.c (elf_metag_check_relocs): Likewise.
+       * elf32-or1k.c (or1k_elf_check_relocs): Likewise.
+       * elf32-ppc.c (ppc_elf_check_relocs): Likewise.
+       * elf32-s390.c (elf_s390_check_relocs): Likewise.
+       * elf32-sh.c (sh_elf_check_relocs): Likewise.
+       * elf32-v850.c (v850_elf_check_relocs): Likewise.
+       * elf32-vax.c (elf_vax_check_relocs): Likewise.
+       * elf32-xstormy16.c (xstormy16_elf_check_relocs): Likewise.
+       * elf32-xtensa.c (elf_xtensa_check_relocs): Likewise.
+       * elf64-mmix.c (mmix_elf_check_relocs): Likewise.
+       * elf64-ppc.c (ppc64_elf_check_relocs): Likewise.
+       * elf64-s390.c (elf_s390_check_relocs): Likewise.
+       * elf64-x86-64.c (elf_s390_check_relocs): Likewise.
+       * elfxx-mips.c (_bfd_mips_elf_check_relocs): Likewise.
+       * elfxx-sparc.c (_bfd_sparc_elf_check_relocs): Likewise.
+       * elflink.c (bfd_elf_gc_record_vtinherit): Check for corrupt
+       VTENTRY entry.
+
 2019-04-11  Alan Modra  <amodra@gmail.com>
 
        PR 24435
index 398636ae0edefcaa24a969dfa3c186463dc8be6e..f0ef8eb0bed52baef5f324f3e9b8c3a8a261b6f5 100644 (file)
@@ -1136,9 +1136,7 @@ mn10300_elf_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_MN10300_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            goto fail;
          break;
 
index b5b2dab357a39286c158b65d9cdd74c1f7bbecd1..03f3a591712a0e8ab32fb9ccb2ad7f0d48777a7e 100644 (file)
@@ -15380,9 +15380,7 @@ elf32_arm_check_relocs (bfd *abfd, struct bfd_link_info *info,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_ARM_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
            return FALSE;
          break;
        }
index 2e4751f89c0ab7ce4dc70f557c95599b02b3b3d2..db052a1ff2898e54bf2d0a013742313d074ebeef 100644 (file)
@@ -1210,9 +1210,7 @@ bfin_check_relocs (bfd * abfd,
        /* This relocation describes which C++ vtable entries
           are actually used.  Record for later use during GC.  */
        case R_BFIN_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 520b61a3f1d0075bd1c607061f53bc944a987b1a..595c36be1fa68835db0454e146214bc4ac05806e 100644 (file)
@@ -3485,9 +3485,7 @@ cris_elf_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_CRIS_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index fb380b1395d76eeb48be49273973ec279693bdf7..b3451b60b217720e9ce4bb5fcf0d1d34fd4812f0 100644 (file)
@@ -2873,9 +2873,7 @@ csky_elf_check_relocs (bfd * abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_CKCORE_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
        }
index 0c05106835a9f3d256a9d05f76c6cc3644b98ebd..4cd0aec106d94eb49451d4115e10be68e1179f13 100644 (file)
@@ -308,9 +308,7 @@ elf32_d10v_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_D10V_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
            return FALSE;
          break;
        }
index f66e944170aea92ceb5da2e85dde96bb29d7b6f6..edddcb1085f1f0431597abd0f0152765bf75f5bd 100644 (file)
@@ -465,9 +465,7 @@ elf32_dlx_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_DLX_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
        }
index 3a0c3ae209ec372fb91b218906a0c7b216d98152..6a13767c7ae6a7f1271b16116e92084d3892c0bc 100644 (file)
@@ -687,9 +687,7 @@ fr30_elf_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_FR30_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
        }
index ebc101ede87a1c8b7498d3928e9c04073a2d1c42..8c6a97dea26f4789d90b3b32547d77feb8126dbb 100644 (file)
@@ -6237,9 +6237,7 @@ elf32_frv_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_FRV_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 95b729aa75b124fb5a23cece57bdda4a6097d95a..a61adbc3c8995b015cbe9a0faeadf93f350f6e58 100644 (file)
@@ -1273,9 +1273,7 @@ elf32_hppa_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_PARISC_GNU_VTENTRY:
-         BFD_ASSERT (hh != NULL);
-         if (hh != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, &hh->eh, rela->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, &hh->eh, rela->r_addend))
            return FALSE;
          continue;
 
index 5d3f2eb4b529247f2f56e1748720f500d2babfe8..d2ea5a729e22e97f090d5f26a654f9d907938a09 100644 (file)
@@ -1908,9 +1908,7 @@ do_size:
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_386_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
            goto error_return;
          break;
 
index 096122687da7ba48771e41a1719cfac380068bcf..6e470272929a7085f63a45a4dae2fc11bc689a97 100644 (file)
@@ -501,9 +501,7 @@ iq2000_elf_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries
             are actually used.  Record for later use during GC.  */
        case R_IQ2000_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 92ed2d19b073fb7cd3683c613ba128895701ff2a..8f05a5e4d6eec2dc91980818f4407c6356ef1238 100644 (file)
@@ -3807,15 +3807,11 @@ m32r_elf_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_M32R_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
            return FALSE;
          break;
        case R_M32R_RELA_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
        }
index 7a01749191e3dd88dc7ca40fa2c3b19154217f78..6a996789b5bbf0fb9f030fe6605b09a9c0d6653e 100644 (file)
@@ -890,9 +890,7 @@ elf32_m68hc11_check_relocs (bfd *abfd, struct bfd_link_info *info,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_M68HC11_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
        }
index 8d0eab06f208b6bd389894f2898aaa93c61c58cb..0fe546661f5a12e85fcd43507b20294cb059f007 100644 (file)
@@ -2801,9 +2801,7 @@ elf_m68k_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_68K_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 764623cce6f73b73a386a3ba0cb01fdb02a811db..7bca45850898d31570cc468df419b66559ce8744 100644 (file)
@@ -628,9 +628,7 @@ mcore_elf_check_relocs (bfd * abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_MCORE_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
        }
index 6d48c8c988f5da798ae6dffaba4fd338d4b5a44c..f68f9dca6f80098f498c043b89fa940b0d1af4c1 100644 (file)
@@ -2374,9 +2374,7 @@ elf_metag_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_METAG_GNU_VTENTRY:
-         BFD_ASSERT (hh != NULL);
-         if (hh != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, &hh->eh, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, &hh->eh, rel->r_addend))
            return FALSE;
          break;
        }
index 2f200b197b8a2d142b40785c5f4d09225c62042e..c1bbac98fb08857b9fb57834b0f3dc81f8103811 100644 (file)
@@ -1927,9 +1927,7 @@ or1k_elf_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_OR1K_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 6991e8ddc1e544d0d9aea6f4abe48b11a8ea3128..e73539afa2b1d17e92b52b2f3297d3b7f1a23ea2 100644 (file)
@@ -3316,9 +3316,7 @@ ppc_elf_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_PPC_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 49a301f0627e102424a061bacc520ef21c031f1d..7bdccdbef982f3d491fa94c412648407e7fac76f 100644 (file)
@@ -1366,9 +1366,7 @@ elf_s390_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_390_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index d66ac1269f26cae854ef948a854db1d0778ddd91..91900b8bea3d2efabcee55742b03aae4f6c8b7bc 100644 (file)
@@ -5570,9 +5570,7 @@ sh_elf_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_SH_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 0de095d3aa95389c498bf5f6345dc4ae2256436b..90a18d3a8d07af7ddfbe9359685db74e16b27bf5 100644 (file)
@@ -101,9 +101,7 @@ v850_elf_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries
           are actually used.  Record for later use during GC.  */
        case R_V850_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 10c01a9b9ed8d3b0e9093dda8581cb21b68fc397..2af7050707925ed49b4373cd15133afc62f82780 100644 (file)
@@ -783,9 +783,7 @@ elf_vax_check_relocs (bfd *abfd, struct bfd_link_info *info, asection *sec,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_VAX_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index a64513d578f2be9941dc9f334550818c5d2753c8..05a932668529d3dfd8d07f6860b9627d2f09865b 100644 (file)
@@ -513,9 +513,7 @@ xstormy16_elf_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_XSTORMY16_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
        }
index 37ea200eea74f5c3b8bcd4d11b0eed99e0ffed97..09625e60873350f115902f88054a59c73e560fff 100644 (file)
@@ -1102,9 +1102,7 @@ elf_xtensa_check_relocs (bfd *abfd,
        case R_XTENSA_GNU_VTENTRY:
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          continue;
 
index d332151a36552ec961be328e9aae3d0d8ac0996d..839bd45b4a6715198976afaa448f4d16c0359e74 100644 (file)
@@ -2004,9 +2004,7 @@ mmix_elf_check_relocs (bfd *abfd,
        /* This relocation describes which C++ vtable entries are actually
           used.  Record for later use during GC.  */
        case R_MMIX_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
        }
index 5be3fe00f18dc75a0c7e3bcf9967a8f909567bd9..a795ad1578d237be13584c3ca0530c6b0524e2b7 100644 (file)
@@ -4555,9 +4555,7 @@ ppc64_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_PPC64_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 3879676ff36cfb8cb39972676c50b84ecfea2212..6bc6dfd50eb5124a768a99f008d79e1b72aa7105 100644 (file)
@@ -1301,9 +1301,7 @@ elf_s390_check_relocs (bfd *abfd,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_390_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;
 
index 6790228271b38c9ed5e44a59d715171f0f456f8a..27e23a0793e1d9261e6986c1bd4267f63d6f464e 100644 (file)
@@ -2373,9 +2373,7 @@ do_size:
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_X86_64_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            goto error_return;
          break;
 
index 8aae9808a1d2889ac9e7921252dbe525bc5eb9a3..81e667dab0cd7c223cb55c30a0f90900a8b604ca 100644 (file)
@@ -13727,14 +13727,22 @@ bfd_elf_gc_record_vtinherit (bfd *abfd,
 /* Called from check_relocs to record the existence of a VTENTRY reloc.  */
 
 bfd_boolean
-bfd_elf_gc_record_vtentry (bfd *abfd ATTRIBUTE_UNUSED,
-                          asection *sec ATTRIBUTE_UNUSED,
+bfd_elf_gc_record_vtentry (bfd *abfd, asection *sec,
                           struct elf_link_hash_entry *h,
                           bfd_vma addend)
 {
   const struct elf_backend_data *bed = get_elf_backend_data (abfd);
   unsigned int log_file_align = bed->s->log_file_align;
 
+  if (!h)
+    {
+      /* xgettext:c-format */
+      _bfd_error_handler (_("%pB: section '%pA': corrupt VTENTRY entry"),
+                         abfd, sec);
+      bfd_set_error (bfd_error_bad_value);
+      return FALSE;
+    }
+
   if (!h->u2.vtable)
     {
       h->u2.vtable = ((struct elf_link_virtual_table_entry *)
index 5998bc43a8a0e0a8a35d833d34834d1dddbe5466..74dadf48f7d2f34ea2476af075194bdb6a9c2b78 100644 (file)
@@ -8992,9 +8992,7 @@ _bfd_mips_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
          /* This relocation describes which C++ vtable entries are actually
             used.  Record for later use during GC.  */
        case R_MIPS_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
            return FALSE;
          break;
 
index f09dcbdc18b35ac77dd047f4b3645ba786555e5b..e479884071da97f308d1b6068c33928e8f4e9659 100644 (file)
@@ -1837,9 +1837,7 @@ _bfd_sparc_elf_check_relocs (bfd *abfd, struct bfd_link_info *info,
          break;
 
        case R_SPARC_GNU_VTENTRY:
-         BFD_ASSERT (h != NULL);
-         if (h != NULL
-             && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
+         if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_addend))
            return FALSE;
          break;