From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) by sourceware.org (Postfix) with ESMTP id 99CE438A908A for ; Wed, 16 Nov 2022 10:09:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 99CE438A908A Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gentoo.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gentoo.org Received: by smtp.gentoo.org (Postfix, from userid 559) id CEFCE33C1C1; Wed, 16 Nov 2022 10:09:55 +0000 (UTC) Date: Wed, 16 Nov 2022 17:09:53 +0700 From: Mike Frysinger To: Alan Modra Cc: Brett Werling , Jan Beulich , binutils@sourceware.org Subject: Re: [PATCH] readelf: use fseeko for elf files >= 2 GiB on x86_64-mingw32 Message-ID: Mail-Followup-To: Alan Modra , Brett Werling , Jan Beulich , binutils@sourceware.org References: <20221114150348.112815-1-bwerl.dev@gmail.com> <8c1844c9-4b04-0200-c24e-c33009562477@suse.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="smeRhLwNj8VjYHGM" Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-4.9 required=5.0 tests=BAYES_00,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,KAM_NUMSUBJECT,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --smeRhLwNj8VjYHGM Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On 15 Nov 2022 08:12, Alan Modra via Binutils wrote: > On Mon, Nov 14, 2022 at 09:52:30AM -0600, Brett Werling via Binutils wrot= e: > > On Mon, Nov 14, 2022 at 9:30 AM Jan Beulich wrote: > > > On 14.11.2022 16:03, Brett Werling via Binutils wrote: > > > > Switch all fseek calls to fseeko and cast the given offset as an of= f_t > > > > accordingly. When building readelf for x86_64-mingw32, a long will = only > > > > be 32 bits wide. If the elf file in question is >=3D 2 GiB, that is > > > > greater than the max long value, and therefore fseek will fail > > > > indicating that the offset is negative. > > > > > > > > To work around this and support up to 4 GiB, we switch to using fse= eko > > > > and cast the unsigned long offsets as off_t values because the size= of > > > > off_t is 64 bits on x86_64-mingw32. > > > > > > Is fseeko() uniformly available on all platforms binutils can be built > > > for? I'm afraid the answer is no, so at least you'd need to introduce > > > some configure logic for this plus some abstraction. > >=20 > > I think you are correct, this will need some conditional logic to be "s= afe" > > to > > include, and even then the casting to off_t would become a little more > > complicated. I will look deeper into what can be done here. >=20 > See bfd/bfdio.c and bfd/configure.ac should we look at bfd using gnulib ? growing our own portability layer sou= nds like a lot of dupicative effort ... at the very least, binutils/ should be able to without much trouble. -mike --smeRhLwNj8VjYHGM Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEuQK1JxMl+JKsJRrUQWM7n+g39YEFAmN0tvEACgkQQWM7n+g3 9YHfWg//SiaPeHiFIUfJhwgOKiuxLR6Q4W12iCDKI7eRI5mdurZBgCWgYe+n5tzA WdQOPO2yoUADIbAOlgFTzg5tzglGEaCZLYGrlTM41L8yi4qztNbs2Cs9Q10wzzxJ yi+BcJxl4Dqc+/FoNkrTlQYPXiW+o8n4a+HWjSnsNlNQtYuSRpVe8848QunqJLJ9 04xwAZUGa8ckCbK8ELjY/1iX7c7dgzEr/toZWBJpP6W61a7ARaUOBqR/W+Z8rT8n tFUIhKy8u/1kE1UMJ/LzZxyzYN3T62DBLDuYK+Tw6gKtK/YXVvobWp5dGFbrz2xp 0pht/NqU3gVe2MnViywhU29cTE8ceg7VxNfrUNldb4ZyOkKx6PlpLNFBrRFz7Yhw ZmKrA1LjcBNpQYggB1u3b5lavjLNJS5skizUD5+jJE7l/km4nkKDMqcB6AyGBmXj NFn8W+XeWWaewFF+pKdVi6W5EsXbHYePAilMEoJjLEFmF+nwEPPxJFAydi1rwfY7 R1T8YXZQro0vsPcJuGZo0NAt0tn5umphFYTHpkiPLgDTdp4f4QGdEJ15N3w4fapg LSZ1FkZwpnpyvASrSv5855XEv9iHKYj5Ev0+AYOorUh6CtoBTd7cUlbdnqO9oQQM tY6MlGyFriJ/fiaPHpncXLriAagW9rYfrxbZiyBHGJmh31KU1mY= =cSL/ -----END PGP SIGNATURE----- --smeRhLwNj8VjYHGM--