From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1062) id 4B6CE3857733; Sat, 3 Jun 2023 08:06:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B6CE3857733 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] Re: loongarch readelf support X-Act-Checkin: binutils-gdb X-Git-Author: Alan Modra X-Git-Refname: refs/heads/master X-Git-Oldrev: c6e6e3ab2b70458d34c4a7a2e7e1637d38d49e8f X-Git-Newrev: 89c70cd358b8fa46b84cd100efc95495ff0160ae Message-Id: <20230603080635.4B6CE3857733@sourceware.org> Date: Sat, 3 Jun 2023 08:06:35 +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: Sat, 03 Jun 2023 08:06:35 -0000 https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3D89c70cd358b8= fa46b84cd100efc95495ff0160ae commit 89c70cd358b8fa46b84cd100efc95495ff0160ae Author: Alan Modra Date: Sat Jun 3 17:16:04 2023 +0930 Re: loongarch readelf support =20 Another segfault. =20 * readelf.c (target_specific_reloc_handling): Sanity check loongarch reloc r_offset. Diff: --- binutils/readelf.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/binutils/readelf.c b/binutils/readelf.c index 042d2301517..23d3e21bea6 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -14021,8 +14021,9 @@ target_specific_reloc_handling (Filedata *filedata, unsigned int reloc_size =3D 0; int leb_ret =3D 0; =20 - value =3D read_leb128 (start + reloc->r_offset, end, false, - &reloc_size, &leb_ret); + if (reloc->r_offset < (size_t) (end - start)) + value =3D read_leb128 (start + reloc->r_offset, end, false, + &reloc_size, &leb_ret); if (leb_ret !=3D 0 || reloc_size =3D=3D 0 || reloc_size > 8) error (_("LoongArch ULEB128 field at 0x%lx contains invalid " "ULEB128 value\n"),