From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 828283864830; Fri, 19 Apr 2024 07:18:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 828283864830 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1713511103; bh=UstzMmJg8Ju0oO2qgdSgQXq62cnKN2X/jw82IQ949Jg=; h=From:To:Subject:Date:From; b=n1bvOGE7i2FbSdSfWlt8lToSwpDGvBD85rNWiW0VT1VWNO/PIxWWLQqhg9drMdOs5 ouaLOBktCvecTyaBbp+oTZkxXi0fCMAsh+woQvg7av+b/UgZjjP6SZnLZlTujIK79U P/pMc8h4GImZT8VBhM6Y9jgBWloyzduS42YiolH8= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: binutils-cvs@sourceware.org Subject: [binutils-gdb] Re: elf: Strip unreferenced weak undefined symbols X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: eebad48efeeee858be83d754a6b1326133e51d36 X-Git-Newrev: 9cf3c87e166b2f3728ae5c50c501f64f385e349e Message-Id: <20240419071823.828283864830@sourceware.org> Date: Fri, 19 Apr 2024 07:18:23 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D9cf3c87e166b= 2f3728ae5c50c501f64f385e349e commit 9cf3c87e166b2f3728ae5c50c501f64f385e349e Author: Alan Modra Date: Fri Apr 19 16:35:30 2024 +0930 Re: elf: Strip unreferenced weak undefined symbols =20 PR ld/31652 * elflink.c (_bfd_elf_link_output_relocs): Don't segfault on NULL rel_hash. Diff: --- bfd/elflink.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bfd/elflink.c b/bfd/elflink.c index 4f72d1b2a90..6db6a9c0b47 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -2985,12 +2985,13 @@ _bfd_elf_link_output_relocs (bfd *output_bfd, * bed->s->int_rels_per_ext_rel); while (irela < irelaend) { - if (*rel_hash) + if (rel_hash && *rel_hash) (*rel_hash)->has_reloc =3D 1; (*swap_out) (output_bfd, irela, erel); irela +=3D bed->s->int_rels_per_ext_rel; erel +=3D input_rel_hdr->sh_entsize; - rel_hash++; + if (rel_hash) + rel_hash++; } =20 /* Bump the counter, so that we know where to add the next set of