public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Mike Frysinger <vapier@gentoo.org>
To: Alan Modra <amodra@gmail.com>
Cc: Brett Werling <bwerl.dev@gmail.com>,
	Jan Beulich <jbeulich@suse.com>,
	binutils@sourceware.org
Subject: Re: [PATCH] readelf: use fseeko for elf files >= 2 GiB on x86_64-mingw32
Date: Wed, 16 Nov 2022 17:09:53 +0700	[thread overview]
Message-ID: <Y3S28TUFiADoOZn+@vapier> (raw)
In-Reply-To: <Y3K2X5myepTWZpI/@squeak.grove.modra.org>

[-- Attachment #1: Type: text/plain, Size: 1542 bytes --]

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 wrote:
> > On Mon, Nov 14, 2022 at 9:30 AM Jan Beulich <jbeulich@suse.com> 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 off_t
> > > > accordingly. When building readelf for x86_64-mingw32, a long will only
> > > > be 32 bits wide. If the elf file in question is >= 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 fseeko
> > > > 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.
> > 
> > I think you are correct, this will need some conditional logic to be "safe"
> > 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.
> 
> See bfd/bfdio.c and bfd/configure.ac

should we look at bfd using gnulib ?  growing our own portability layer sounds
like a lot of dupicative effort ...

at the very least, binutils/ should be able to without much trouble.
-mike

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2022-11-16 10:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-14 15:03 Brett Werling
2022-11-14 15:30 ` Jan Beulich
2022-11-14 15:52   ` Brett Werling
2022-11-14 21:42     ` Alan Modra
2022-11-16 10:09       ` Mike Frysinger [this message]
2022-11-16 10:46         ` Jan Beulich
2022-11-16 14:01           ` Mike Frysinger
2022-11-16 14:44             ` Michael Matz
2022-11-16 15:40               ` Mike Frysinger
2022-11-16 15:58                 ` Jose E. Marchesi
2022-11-16 16:13                 ` Michael Matz
2022-11-16 17:09                   ` Mike Frysinger
2022-11-16 21:19                     ` Brett Werling
2022-11-17  8:02                       ` Mike Frysinger
2022-11-17 13:21                     ` Michael Matz
2022-11-15 14:57 ` [PATCH] readelf: use fseeko64 or fseeko if possible Brett Werling
2022-11-17  7:02   ` Alan Modra
2022-11-17 14:09     ` Brett Werling
2022-11-17 14:34 ` Brett Werling
2022-11-21 21:52   ` Alan Modra
2022-11-22 13:46     ` Michael Matz
2022-11-22 21:55       ` Alan Modra
2022-11-22 21:57   ` Alan Modra
2022-11-22 21:59     ` Don't use "long" in readelf for file offsets Alan Modra

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3S28TUFiADoOZn+@vapier \
    --to=vapier@gentoo.org \
    --cc=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    --cc=bwerl.dev@gmail.com \
    --cc=jbeulich@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).