[PATCH v2] elf: Use uint64_t for common symbol alignment warning

H.J. Lu hjl.tools@gmail.com
Thu Oct 2 21:29:18 GMT 2025


On Thu, Oct 2, 2025 at 12:08 PM Collin Funk <collin.funk1@gmail.com> wrote:
>
> "H.J. Lu" <hjl.tools@gmail.com> writes:
>
> > On Thu, Oct 2, 2025 at 11:01 AM Collin Funk <collin.funk1@gmail.com> wrote:
> >>
> >> "H.J. Lu" <hjl.tools@gmail.com> writes:
> >>
> >> > +               uint64_t c_align = UINT64_C (1) << common_align;
> >> > +               uint64_t n_align = UINT64_C (1) << normal_align;
> >> > [...]
> >> > +                   (_("warning: alignment %" PRId64 " of common symbol `%s' in %pB is"
> >> > +                      " greater than the alignment (%" PRId64 ") of its section %pA"),
> >> > +                    c_align, name, common_bfd,
> >> > +                    n_align, h->root.u.def.section);
> >> > [...]
> >> > +                   (_("warning: alignment %" PRId64 " of normal symbol `%s' in %pB"
> >> > +                      " is smaller than %" PRId64 " used by the common definition in %pB"),
> >> > +                    n_align, name, normal_bfd,
> >> > +                    c_align, common_bfd);
> >>
> >> Doesn't this cause -Wformat-signedness errors? Since PRId64 is for
> >> int64_t, not uint64_t.
> >>
> >> Collin
> >
> > Here is the v2 patch with PRIu64.
> >
> > Thanks.
>
> Looks good to me. Confirmed that it fixed the ubsan error.
>
> Reviewed-by: Collin Funk <collin.funk1@gmail.com>
>
> Collin

I am checking it in.

-- 
H.J.


More information about the Binutils mailing list