|
| 1 | +From 5f799e4752d441263ae6656062e2fca98f51c6cb Mon Sep 17 00:00:00 2001 |
| 2 | +From: Vasily Gorbik <gor@linux.ibm.com> |
| 3 | +Date: Wed, 2 Apr 2025 03:15:35 +0200 |
| 4 | +Subject: [PATCH] scripts/sorttable: Fix endianness handling in build-time |
| 5 | + mcount sort |
| 6 | + |
| 7 | +Kernel cross-compilation with BUILDTIME_MCOUNT_SORT produces zeroed |
| 8 | +mcount values if the build-host endianness does not match the ELF |
| 9 | +file endianness. |
| 10 | + |
| 11 | +The mcount values array is converted from ELF file |
| 12 | +endianness to build-host endianness during initialization in |
| 13 | +fill_relocs()/fill_addrs(). Avoid extra conversion of these values during |
| 14 | +weak-function zeroing; otherwise, they do not match nm-parsed addresses |
| 15 | +and all mcount values are zeroed out. |
| 16 | + |
| 17 | +Fixes: ef378c3b8233 ("scripts/sorttable: Zero out weak functions in mcount_loc table") |
| 18 | +Reported-by: Ilya Leoshkevich <iii@linux.ibm.com> |
| 19 | +Reported-by: Ihor Solodrai <ihor.solodrai@linux.dev> |
| 20 | +Closes: https://lore.kernel.org/all/your-ad-here.call-01743522822-ext-4975@work.hours/ |
| 21 | +Signed-off-by: Vasily Gorbik <gor@linux.ibm.com> |
| 22 | +--- |
| 23 | + scripts/sorttable.c | 2 +- |
| 24 | + 1 file changed, 1 insertion(+), 1 deletion(-) |
| 25 | + |
| 26 | +diff --git a/scripts/sorttable.c b/scripts/sorttable.c |
| 27 | +index 7b4b3714b1af..deed676bfe38 100644 |
| 28 | +--- a/scripts/sorttable.c |
| 29 | ++++ b/scripts/sorttable.c |
| 30 | +@@ -857,7 +857,7 @@ static void *sort_mcount_loc(void *arg) |
| 31 | + for (void *ptr = vals; ptr < vals + size; ptr += long_size) { |
| 32 | + uint64_t key; |
| 33 | + |
| 34 | +- key = long_size == 4 ? r((uint32_t *)ptr) : r8((uint64_t *)ptr); |
| 35 | ++ key = long_size == 4 ? *(uint32_t *)ptr : *(uint64_t *)ptr; |
| 36 | + if (!find_func(key)) { |
| 37 | + if (long_size == 4) |
| 38 | + *(uint32_t *)ptr = 0; |
| 39 | +-- |
| 40 | +2.49.0 |
| 41 | + |
0 commit comments