> > Hi Steven,
> >
> > On 6.12.0, sorttable is unable to sort 64-bit ELFs on 32-bit hosts because
> > of the parsing of the start_mcount_loc and stop_mcount_loc values in
> > get_mcount_loc():
> >
> >   *_start = strtoul(start_buff, NULL, 16);
> >
> > and
> >
> >  *_stop = strtoul(stop_buff, NULL, 16);
> >
> > This code makes the (often correct) assumption that the host and the target
> > have the same architecture, however it runs into issues when compiling for
> > a 64-bit target on a 32-bit host, as unsigned long is shorter than the
> > pointer width. As a result, I've noticed that both start and stop max out
> > at 2^32 - 1.
>
> So this has been broken for some time?

Since 2021, it seems like. However, this slipped from my radar since
we've been using 5.10 for the longest time, which didn't have
CONFIG_BUILDTIME_MCOUNT_SORT.

> >
> > It seems that commit 4acda8ed fixes this issue inadvertently by directly
> > extracting them from the ELF using the correct width. I'm wondering if it
> > is possible to backport this as well as the other sorttable refactors to
> > 6.12.0 since they fix this issue.
>
> You should ask Greg KH on this.

Sounds good, tagging Greg.

Sahil


On Mon, Mar 24, 2025 at 12:35 PM Steven Rostedt <[email protected]> wrote:
>
> On Thu, 20 Mar 2025 16:54:58 -0500
> Sahil Gupta <[email protected]> wrote:
>
> > Hi Steven,
> >
> > On 6.12.0, sorttable is unable to sort 64-bit ELFs on 32-bit hosts because
> > of the parsing of the start_mcount_loc and stop_mcount_loc values in
> > get_mcount_loc():
> >
> >   *_start = strtoul(start_buff, NULL, 16);
> >
> > and
> >
> >  *_stop = strtoul(stop_buff, NULL, 16);
> >
> > This code makes the (often correct) assumption that the host and the target
> > have the same architecture, however it runs into issues when compiling for
> > a 64-bit target on a 32-bit host, as unsigned long is shorter than the
> > pointer width. As a result, I've noticed that both start and stop max out
> > at 2^32 - 1.
>
> So this has been broken for some time?
>
> >
> > It seems that commit 4acda8ed fixes this issue inadvertently by directly
> > extracting them from the ELF using the correct width. I'm wondering if it
> > is possible to backport this as well as the other sorttable refactors to
> > 6.12.0 since they fix this issue.
>
> You should ask Greg KH on this.
>
> -- Steve
>

Reply via email to