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) {