From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id D1BFE3858D37; Wed, 19 Apr 2023 23:34:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1BFE3858D37 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Alan Modra To: bfd-cvs@sourceware.org Subject: [binutils-gdb] sh4-linux segfaults running ld testsuite X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 2605f35cda6ec0710ad87e14912dd4ee537e674e X-Git-Newrev: 509fdd5a8720250b8e0ddb5691ec94352c85e970 Message-Id: <20230419233455.D1BFE3858D37@sourceware.org> Date: Wed, 19 Apr 2023 23:34:55 +0000 (GMT) X-BeenThere: binutils-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2023 23:34:55 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D509fdd5a8720= 250b8e0ddb5691ec94352c85e970 commit 509fdd5a8720250b8e0ddb5691ec94352c85e970 Author: Alan Modra Date: Thu Apr 20 07:01:22 2023 +0930 sh4-linux segfaults running ld testsuite =20 Segmentation fault FAIL: pr22269-1 (static pie undefined weak) and others running "visibility (hidden undef)" tests =20 No code has any right to access bfd_link_hash_entry u.def without first checking the type, and SYMBOL_REFERENCES_LOCAL isn't sufficient. =20 * elf32-sh.c (sh_elf_finish_dynamic_symbol): Don't use relative relocs in GOT unless symbol is defined. Diff: --- bfd/elf32-sh.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bfd/elf32-sh.c b/bfd/elf32-sh.c index fdcc5870890..499233d1355 100644 --- a/bfd/elf32-sh.c +++ b/bfd/elf32-sh.c @@ -6174,6 +6174,8 @@ sh_elf_finish_dynamic_symbol (bfd *output_bfd, struct= bfd_link_info *info, The entry in the global offset table will already have been initialized in the relocate_section function. */ if (bfd_link_pic (info) + && (h->root.type =3D=3D bfd_link_hash_defined + || h->root.type =3D=3D bfd_link_hash_defweak) && SYMBOL_REFERENCES_LOCAL (info, h)) { if (htab->fdpic_p)