2 Commits
Author SHA1 Message Date
Lorenzo Stoakes (ARM) 5005f8043c elf-parse: add section flags, symbol binding and mapping helpers
Extend elf-parse to be able to read the symbol table of vmlinux in
kallsyms.

This requires the ability to open ELF files in read-only mode, so provide
elf_map_ro() to do so.

It also requires accessors for section flags and symbol bindings, so
provide these via shdr_flags() and sym_bind().

It's useful to be able to open an ELF file, map it, and then have easy
access to its section headers, names and symbol table, so introduce struct
elf_file to store this.

In order to obtain this data also provide elf_open_ro() and elf_close().

Also, check for the file being an ELF file first in elf_parse(). This is
the logical thing to check for first, but additionally prevents kallsyms
from having to check this it self.

Assisted-by: LLM
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: Lorenzo Stoakes (ARM) <[email protected]>
Link: https://patch.msgid.link/[email protected]
Signed-off-by: Nathan Chancellor <[email protected]>
2026-09-26 00:16:35 +01:00
Steven Rostedt b055f4c431 sorttable: Move ELF parsing into scripts/elf-parse.[ch]
In order to share the elf parsing that is in sorttable.c so that other
programs could use the same code, move it into elf-parse.c and
elf-parse.h.

Cc: Masami Hiramatsu <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Mathieu Desnoyers <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Arnd Bergmann <[email protected]>
Cc: Masahiro Yamada <[email protected]>
Cc: Nathan Chancellor <[email protected]>
Cc: Nicolas Schier <[email protected]>
Cc: Nick Desaulniers <[email protected]>
Cc: Catalin Marinas <[email protected]>
Cc: Linus Torvalds <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Steven Rostedt (Google) <[email protected]>
2025-10-24 16:43:14 -04:00