From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 32B973858D37; Wed, 17 Aug 2022 08:01:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 32B973858D37 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] bfd_elf_set_group_contents assertion X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: 31e43bfffbc585a59d07f21f191317a714476e38 X-Git-Newrev: 7744e3278b9f24d8a1a2dd74f75986bd9060724c Message-Id: <20220817080109.32B973858D37@sourceware.org> Date: Wed, 17 Aug 2022 08:01:09 +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, 17 Aug 2022 08:01:09 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D7744e3278b9f= 24d8a1a2dd74f75986bd9060724c commit 7744e3278b9f24d8a1a2dd74f75986bd9060724c Author: Alan Modra Date: Wed Aug 17 17:14:16 2022 +0930 bfd_elf_set_group_contents assertion =20 objcopy of broken SHT_GROUP sections shouldn't write garbage. =20 * elf.c (bfd_elf_set_group_contents): If number of entries is unexpected, fill out section with zeros. Diff: --- bfd/elf.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bfd/elf.c b/bfd/elf.c index 2e01d7e9a44..35aa45e3b90 100644 --- a/bfd/elf.c +++ b/bfd/elf.c @@ -3614,7 +3614,12 @@ bfd_elf_set_group_contents (bfd *abfd, asection *sec= , void *failedptrarg) } =20 loc -=3D 4; - BFD_ASSERT (loc =3D=3D sec->contents); + if (loc !=3D sec->contents) + { + BFD_ASSERT (0); + memset (sec->contents + 4, 0, loc - sec->contents); + loc =3D sec->contents; + } =20 H_PUT_32 (abfd, sec->flags & SEC_LINK_ONCE ? GRP_COMDAT : 0, loc); }