On Tue, Mar 25, 2025 at 05:06:56PM -0700, Sahil Gupta wrote:
The ftrace __mcount_loc buildtime sort does not work properly when the host is 32-bit and the target is 64-bit. sorttable parses the start and stop addresses by calling strtoul on the buffer holding the hexadecimal string. Since the target is 64-bit but unsigned long on 32-bit machines is 32 bits, strtoul, and by extension the start and stop addresses, can max out to 2^32 - 1.
This patch adds a new macro, parse_addr, that corresponds to a strtoul or strtoull call based on whether you are operating on a 32-bit ELF or a 64-bit ELF. This way, the correct width is guaranteed whether or not the host is 32-bit. This should cleanly apply on all of the 6.x stable kernels.
Manually verified that the __mcount_loc section is sorted by parsing the ELF and verified tests corresponding to CONFIG_FTRACE_SORT_STARTUP_TEST for kernels built on a 32-bit and a 64-bit host.
Signed-off-by: Sahil Gupta s.gupta@arista.com
scripts/sorttable.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
What is the upstream git commit of this?
If it's not upstream, then you need to document the heck out of why we can't take whatever is upstream already, which I don't see here :(
thanks,
greg k-h