Thread (14 messages) flat view 14 messages, 3 authors, 2025-02-25

Re: [PATCH v5 2/6] scripts/sorttable: Have mcount rela sort use direct values

From: Steven Rostedt <rostedt@goodmis.org>
Date: 2025-02-25 02:10:29
Also in: bpf, linux-arm-kernel, linux-kbuild, linux-s390, lkml
Subsystem: the rest · Maintainer: Linus Torvalds

On Mon, 24 Feb 2025 17:21:47 -0500
Steven Rostedt [off-list ref] wrote:
Hmm, I haven't tried building this with clang.

Can you compile without that commit, run and give me the output from these
two programs:

 ./dump_elf_sym vmlinux __start_mcount_loc __stop_mcount_loc
 ./dump_elf_rela vmlinux .rela.dyn

If the second one fails, remove the '.rela.dyn' and see what that shows.

 https://rostedt.org/code/dump_elf_sym.c
 https://rostedt.org/code/dump_elf_rela.c
Nevermind, Masami told me all I need to do is add LLVM=1 and clang can
handle the cross compiling.

I looked, and sure enough clang on arm64 does it the same way x86 does. So
using the rela items to sort is a gcc thing :-p

Can you try this patch?

-- Steve

diff --git a/scripts/sorttable.c b/scripts/sorttable.c
index 23c7e0e6c024..07ad8116bc8d 100644
--- a/scripts/sorttable.c
+++ b/scripts/sorttable.c
@@ -827,9 +827,14 @@ static void *sort_mcount_loc(void *arg)
 		pthread_exit(m_err);
 	}
 
-	if (sort_reloc)
+	if (sort_reloc) {
 		count = fill_relocs(vals, size, ehdr, emloc->start_mcount_loc);
-	else
+		/* gcc may use relocs to save the addresses, but clang does not. */
+		if (!count) {
+			count = fill_addrs(vals, size, start_loc);
+			sort_reloc = 0;
+		}
+	} else
 		count = fill_addrs(vals, size, start_loc);
 
 	if (count < 0) {
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help