[PATCH v3 07/18] BFD: Make file offset unsigned in archive symbols
Maciej W. Rozycki
macro@redhat.com
Wed Jan 7 09:31:33 GMT 2026
On Tue, 9 Dec 2025, Jan Beulich wrote:
> > --- binutils-gdb.orig/bfd/elflink.c
> > +++ binutils-gdb/bfd/elflink.c
> > @@ -6273,13 +6273,13 @@ elf_link_add_archive_symbols (bfd *abfd,
> >
> > do
> > {
> > - file_ptr last;
> > + ufile_ptr last;
> > symindex i;
> > carsym *symdef;
> > carsym *symdefend;
> >
> > loop = false;
> > - last = -1;
> > + last = ~0ULL;
>
> This can go wrong when ufile_ptr is wider than long long. Imo such wants to
> be ~0 (or, as before, -1).
We may not want to rely on implementation-defined extended signed integer
types. But, just in case...
Keeping -1 ought indeed to be safe (and ~0 is -1, so the same applies).
I chickened out on it as conversions can be murky water, but here this
clause I believe applies, since -1 is not representable by an unsigned
integer type:
"Otherwise, if the new type is unsigned, the value is converted by
repeatedly adding or subtracting one more than the maximum value that can
be represented in the new type until the value is in the range of the new
type."
-- so I think we should be safe. Fixed in v4 then.
> Unrelated question: Like me, you look to be using quilt. Could I talk you
> into adding
>
> QUILT_NO_DIFF_INDEX=1
>
> to your .quiltrc, so the not really useful Index: lines and the separator
> lines following them would go away?
This is CVS/SVN style. I'd be happy to switch to unidiff/git style, but
it appears `quilt' has no support for such a format and I want to keep the
headings for easier orientation (I could tweak `quilt' myself I suppose to
add the missing format, but I have better things to do).
Why the request, anyway?
Maciej
More information about the Binutils
mailing list