[PATCH] readelf: use fseeko for elf files >= 2 GiB on x86_64-mingw32
Mike Frysinger
vapier@gentoo.org
Wed Nov 16 10:09:53 GMT 2022
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20221116/719e1034/attachment-0001.sig>
More information about the Binutils
mailing list