Skip to content

Commit 023f124

Browse files
Vasily Gorbikrostedt
authored andcommitted
scripts/sorttable: Fix endianness handling in build-time mcount sort
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. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Catalin Marinas <catalin.marinas@arm.com> Cc: Nathan Chancellor <nathan@kernel.org> Cc: Heiko Carstens <hca@linux.ibm.com> Cc: Alexander Gordeev <agordeev@linux.ibm.com> Link: https://lore.kernel.org/patch.git-dca31444b0f1.your-ad-here.call-01743554658-ext-8692@work.hours Fixes: ef378c3 ("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> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent ea8d764 commit 023f124

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

scripts/sorttable.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ static void *sort_mcount_loc(void *arg)
857857
for (void *ptr = vals; ptr < vals + size; ptr += long_size) {
858858
uint64_t key;
859859

860-
key = long_size == 4 ? r((uint32_t *)ptr) : r8((uint64_t *)ptr);
860+
key = long_size == 4 ? *(uint32_t *)ptr : *(uint64_t *)ptr;
861861
if (!find_func(key)) {
862862
if (long_size == 4)
863863
*(uint32_t *)ptr = 0;

0 commit comments

Comments
 (0)