public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scripts/sorttable: Fix endianness handling in build-time mcount sort
@ 2025-04-02  1:15 Vasily Gorbik
  2025-04-02 23:22 ` Ihor Solodrai
  0 siblings, 1 reply; 4+ messages in thread
From: Vasily Gorbik @ 2025-04-02  1:15 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Masami Hiramatsu, Catalin Marinas, Nathan Chancellor,
	Ilya Leoshkevich, Ihor Solodrai, Heiko Carstens,
	Alexander Gordeev, linux-kernel

Kernel cross-compilation with BUILDTIME_MCOUNT_SORT produces zeroed
mcount values if the build-host endianness does not match the ELF
file endianness.

The mcount values array is converted from ELF file
endianness to build-host endianness during initialization in
fill_relocs()/fill_addrs(). Avoid extra conversion of these values during
weak-function zeroing; otherwise, they do not match nm-parsed addresses
and all mcount values are zeroed out.

Fixes: ef378c3b8233 ("scripts/sorttable: Zero out weak functions in mcount_loc table")
Reported-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reported-by: Ihor Solodrai <ihor.solodrai@linux.dev>
Closes: https://lore.kernel.org/all/your-ad-here.call-01743522822-ext-4975@work.hours/
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
---
 scripts/sorttable.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index 7b4b3714b1af..deed676bfe38 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -857,7 +857,7 @@ static void *sort_mcount_loc(void *arg)
 		for (void *ptr = vals; ptr < vals + size; ptr += long_size) {
 			uint64_t key;
 
-			key = long_size == 4 ? r((uint32_t *)ptr) : r8((uint64_t *)ptr);
+			key = long_size == 4 ? *(uint32_t *)ptr : *(uint64_t *)ptr;
 			if (!find_func(key)) {
 				if (long_size == 4)
 					*(uint32_t *)ptr = 0;
-- 
2.48.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-04-02 23:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-02  1:15 [PATCH] scripts/sorttable: Fix endianness handling in build-time mcount sort Vasily Gorbik
2025-04-02 23:22 ` Ihor Solodrai
2025-04-02 23:28   ` Steven Rostedt
2025-04-02 23:32     ` Ihor Solodrai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox