This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Check corrupt VTENTRY entry in bfd_elf_gc_record_vtentry


On Wed, Apr 10, 2019 at 11:08 PM Alan Modra <amodra@gmail.com> wrote:
>
> On Wed, Apr 10, 2019 at 08:32:08PM -0700, H.J. Lu wrote:
> >       * 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.
>
> OK, thanks, except
>
> > --- a/bfd/elf32-hppa.c
> > +++ b/bfd/elf32-hppa.c
> > @@ -1273,9 +1273,9 @@ 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 ? &hh->eh : NULL,
> > +                                       rela->r_addend))
> >           return FALSE;
> >         continue;
> >
>
> let's not special case hh being NULL here.  The call as written before
> should be fine.  &hh->eh is equivalent to
> (struct elf_link_hash_entry *) hh.
>
> Is this a work-around for some nonsense compiler warning?  If so, how
> does it fare with the typical offsetof macro?
> #define offsetof(type, member) ((size_t) &((type *) 0)->member)
>

Fixed and pushed.

Thanks.

-- 
H.J.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]