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

- From: Arnd Bergmann \<arnd@arndb.de\>
- Date: 2025-02-24 21:11:30 
- List: linux-trace-kernel
- Page: https://ratatoskr.run/linux-trace-kernel/2025/02/2941869
- Thread: https://ratatoskr.run/linux-trace-kernel/2025/02/2932386/t.md

```text
On Tue, Feb 18, 2025, at 20:59, Steven Rostedt wrote:
> From: Steven Rostedt <rostedt@goodmis.org>
>
> The mcount_loc sorting for when the values are stored in the Elf_Rela
> entries uses the compare_extable() function to do the compares in the
> qsort(). That function does handle byte swapping if the machine being
> compiled for is a different endian than the host machine. But the
> sort_relocs() function sorts an array that pulled in the values from the
> Elf_Rela section and has already done the swapping.
>
> Create two new compare functions that will sort the direct values. One
> will sort 32 bit values and the other will sort the 64 bit value. One of
> these will be assigned to a compare_values function pointer and that will
> be used for sorting the Elf_Rela mcount values.
>
> Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
> ---

This is what I get on arm64 randconfig builds using clang after your
patch:

  failed to sort mcount 'Expected 24260 mcount elements but found 0
  ': vmlinux
  Failed to sort kernel tables

I have not tried to understand what your patch does. See the attached
defconfig for a reproducer.

      Arnd
```

## Attachments

- [defconfig](https://ratatoskr.run/linux-trace-kernel/2025/02/2941869/attachment/0) (application/octet-stream, 25930 bytes)
