summaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2019-04-11 06:44:53 -0700
committerH.J. Lu <hjl.tools@gmail.com>2019-04-11 06:45:05 -0700
commita0ea3a14dc6a6062c0c1f2bfbb7ad0373ec20843 (patch)
tree973f90b3615d7ba892c8d6e7e02e614c362c7cf1 /bfd
parent9bff840e8cc560f5096a43609ed3e0d980733fd9 (diff)
downloadbinutils-gdb-a0ea3a14dc6a6062c0c1f2bfbb7ad0373ec20843.tar.gz
Check corrupt VTENTRY entry in bfd_elf_gc_record_vtentry
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.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog38
-rw-r--r--bfd/elf-m10300.c4
-rw-r--r--bfd/elf32-arm.c4
-rw-r--r--bfd/elf32-bfin.c4
-rw-r--r--bfd/elf32-cris.c4
-rw-r--r--bfd/elf32-csky.c4
-rw-r--r--bfd/elf32-d10v.c4
-rw-r--r--bfd/elf32-dlx.c4
-rw-r--r--bfd/elf32-fr30.c4
-rw-r--r--bfd/elf32-frv.c4
-rw-r--r--bfd/elf32-hppa.c4
-rw-r--r--bfd/elf32-i386.c4
-rw-r--r--bfd/elf32-iq2000.c4
-rw-r--r--bfd/elf32-m32r.c8
-rw-r--r--bfd/elf32-m68hc1x.c4
-rw-r--r--bfd/elf32-m68k.c4
-rw-r--r--bfd/elf32-mcore.c4
-rw-r--r--bfd/elf32-metag.c4
-rw-r--r--bfd/elf32-or1k.c4
-rw-r--r--bfd/elf32-ppc.c4
-rw-r--r--bfd/elf32-s390.c4
-rw-r--r--bfd/elf32-sh.c4
-rw-r--r--bfd/elf32-v850.c4
-rw-r--r--bfd/elf32-vax.c4
-rw-r--r--bfd/elf32-xstormy16.c4
-rw-r--r--bfd/elf32-xtensa.c4
-rw-r--r--bfd/elf64-mmix.c4
-rw-r--r--bfd/elf64-ppc.c4
-rw-r--r--bfd/elf64-s390.c4
-rw-r--r--bfd/elf64-x86-64.c4
-rw-r--r--bfd/elflink.c12
-rw-r--r--bfd/elfxx-mips.c4
-rw-r--r--bfd/elfxx-sparc.c4
33 files changed, 80 insertions, 98 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a3cdfc6505b..4c42905e59e 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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
diff --git a/bfd/elf-m10300.c b/bfd/elf-m10300.c
index 398636ae0ed..f0ef8eb0bed 100644
--- a/bfd/elf-m10300.c
+++ b/bfd/elf-m10300.c
@@ -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;
diff --git a/bfd/elf32-arm.c b/bfd/elf32-arm.c
index b5b2dab357a..03f3a591712 100644
--- a/bfd/elf32-arm.c
+++ b/bfd/elf32-arm.c
@@ -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;
}
diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c
index 2e4751f89c0..db052a1ff28 100644
--- a/bfd/elf32-bfin.c
+++ b/bfd/elf32-bfin.c
@@ -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;
diff --git a/bfd/elf32-cris.c b/bfd/elf32-cris.c
index 520b61a3f1d..595c36be1fa 100644
--- a/bfd/elf32-cris.c
+++ b/bfd/elf32-cris.c
@@ -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;
diff --git a/bfd/elf32-csky.c b/bfd/elf32-csky.c
index fb380b1395d..b3451b60b21 100644
--- a/bfd/elf32-csky.c
+++ b/bfd/elf32-csky.c
@@ -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;
}
diff --git a/bfd/elf32-d10v.c b/bfd/elf32-d10v.c
index 0c05106835a..4cd0aec106d 100644
--- a/bfd/elf32-d10v.c
+++ b/bfd/elf32-d10v.c
@@ -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;
}
diff --git a/bfd/elf32-dlx.c b/bfd/elf32-dlx.c
index f66e944170a..edddcb1085f 100644
--- a/bfd/elf32-dlx.c
+++ b/bfd/elf32-dlx.c
@@ -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;
}
diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c
index 3a0c3ae209e..6a13767c7ae 100644
--- a/bfd/elf32-fr30.c
+++ b/bfd/elf32-fr30.c
@@ -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;
}
diff --git a/bfd/elf32-frv.c b/bfd/elf32-frv.c
index ebc101ede87..8c6a97dea26 100644
--- a/bfd/elf32-frv.c
+++ b/bfd/elf32-frv.c
@@ -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;
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 95b729aa75b..a61adbc3c89 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -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;
diff --git a/bfd/elf32-i386.c b/bfd/elf32-i386.c
index 5d3f2eb4b52..d2ea5a729e2 100644
--- a/bfd/elf32-i386.c
+++ b/bfd/elf32-i386.c
@@ -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;
diff --git a/bfd/elf32-iq2000.c b/bfd/elf32-iq2000.c
index 096122687da..6e470272929 100644
--- a/bfd/elf32-iq2000.c
+++ b/bfd/elf32-iq2000.c
@@ -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;
diff --git a/bfd/elf32-m32r.c b/bfd/elf32-m32r.c
index 92ed2d19b07..8f05a5e4d6e 100644
--- a/bfd/elf32-m32r.c
+++ b/bfd/elf32-m32r.c
@@ -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;
}
diff --git a/bfd/elf32-m68hc1x.c b/bfd/elf32-m68hc1x.c
index 7a01749191e..6a996789b5b 100644
--- a/bfd/elf32-m68hc1x.c
+++ b/bfd/elf32-m68hc1x.c
@@ -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;
}
diff --git a/bfd/elf32-m68k.c b/bfd/elf32-m68k.c
index 8d0eab06f20..0fe546661f5 100644
--- a/bfd/elf32-m68k.c
+++ b/bfd/elf32-m68k.c
@@ -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;
diff --git a/bfd/elf32-mcore.c b/bfd/elf32-mcore.c
index 764623cce6f..7bca4585089 100644
--- a/bfd/elf32-mcore.c
+++ b/bfd/elf32-mcore.c
@@ -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;
}
diff --git a/bfd/elf32-metag.c b/bfd/elf32-metag.c
index 6d48c8c988f..f68f9dca6f8 100644
--- a/bfd/elf32-metag.c
+++ b/bfd/elf32-metag.c
@@ -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;
}
diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c
index 2f200b197b8..c1bbac98fb0 100644
--- a/bfd/elf32-or1k.c
+++ b/bfd/elf32-or1k.c
@@ -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;
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c
index 6991e8ddc1e..e73539afa2b 100644
--- a/bfd/elf32-ppc.c
+++ b/bfd/elf32-ppc.c
@@ -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;
diff --git a/bfd/elf32-s390.c b/bfd/elf32-s390.c
index 49a301f0627..7bdccdbef98 100644
--- a/bfd/elf32-s390.c
+++ b/bfd/elf32-s390.c
@@ -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;
diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c
index d66ac1269f2..91900b8bea3 100644
--- a/bfd/elf32-sh.c
+++ b/bfd/elf32-sh.c
@@ -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;
diff --git a/bfd/elf32-v850.c b/bfd/elf32-v850.c
index 0de095d3aa9..90a18d3a8d0 100644
--- a/bfd/elf32-v850.c
+++ b/bfd/elf32-v850.c
@@ -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;
diff --git a/bfd/elf32-vax.c b/bfd/elf32-vax.c
index 10c01a9b9ed..2af70507079 100644
--- a/bfd/elf32-vax.c
+++ b/bfd/elf32-vax.c
@@ -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;
diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c
index a64513d578f..05a93266852 100644
--- a/bfd/elf32-xstormy16.c
+++ b/bfd/elf32-xstormy16.c
@@ -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;
}
diff --git a/bfd/elf32-xtensa.c b/bfd/elf32-xtensa.c
index 37ea200eea7..09625e60873 100644
--- a/bfd/elf32-xtensa.c
+++ b/bfd/elf32-xtensa.c
@@ -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;
diff --git a/bfd/elf64-mmix.c b/bfd/elf64-mmix.c
index d332151a365..839bd45b4a6 100644
--- a/bfd/elf64-mmix.c
+++ b/bfd/elf64-mmix.c
@@ -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;
}
diff --git a/bfd/elf64-ppc.c b/bfd/elf64-ppc.c
index 5be3fe00f18..a795ad1578d 100644
--- a/bfd/elf64-ppc.c
+++ b/bfd/elf64-ppc.c
@@ -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;
diff --git a/bfd/elf64-s390.c b/bfd/elf64-s390.c
index 3879676ff36..6bc6dfd50eb 100644
--- a/bfd/elf64-s390.c
+++ b/bfd/elf64-s390.c
@@ -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;
diff --git a/bfd/elf64-x86-64.c b/bfd/elf64-x86-64.c
index 6790228271b..27e23a0793e 100644
--- a/bfd/elf64-x86-64.c
+++ b/bfd/elf64-x86-64.c
@@ -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;
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 8aae9808a1d..81e667dab0c 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -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 *)
diff --git a/bfd/elfxx-mips.c b/bfd/elfxx-mips.c
index 5998bc43a8a..74dadf48f7d 100644
--- a/bfd/elfxx-mips.c
+++ b/bfd/elfxx-mips.c
@@ -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;
diff --git a/bfd/elfxx-sparc.c b/bfd/elfxx-sparc.c
index f09dcbdc18b..e479884071d 100644
--- a/bfd/elfxx-sparc.c
+++ b/bfd/elfxx-sparc.c
@@ -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;