public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: binutils@sourceware.org
Subject: Re: [PATCH] Check corrupt VTENTRY entry in bfd_elf_gc_record_vtentry
Date: Thu, 11 Apr 2019 06:08:00 -0000	[thread overview]
Message-ID: <20190411060825.GJ14424@bubble.grove.modra.org> (raw)
In-Reply-To: <20190411033208.706-1-hjl.tools@gmail.com>

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)

-- 
Alan Modra
Australia Development Lab, IBM

  reply	other threads:[~2019-04-11  6:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-11  3:32 H.J. Lu
2019-04-11  6:08 ` Alan Modra [this message]
2019-04-11 13:47   ` H.J. Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190411060825.GJ14424@bubble.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=hjl.tools@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).