RFC kallsyms: add option to include relative filepaths into kallsyms
Get series with b4
b4 am [email protected]Versions newest first
- v1 RFC Latest3 patches 15 repliesIn review
Patches in v1 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | modpost: fix TO_NATIVE() with expressions and constsscripts/ | +4 | 4 replies | |
| 2/3 | increase kallsyms length limitinclude/ kernel/ scripts/ | +4 | 1 reply | |
| 3/3 | kallsyms: add option to include relative filepaths into kallsyms.gitignore Makefile init/ +9 more | +788 | 7 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.
Cover letter [RFC PATCH 0/3] kallsyms: add option to include relative filepaths into kallsyms
This is an early RFC to not rewrite stuff one more time later on if the implementation is not acceptable or any major design changes are required. For the TODO list, please scroll to the end.
Make kallsyms independent of symbols positions in vmlinux (or module) by including relative filepath in each symbol's kallsyms value. I.e.
dev_gro_receive -> net/core/gro.c:dev_gro_receive
For the implementation details, please look at the patch 3/3. Patch 2/3 is just a stub, I plan to reuse kallsyms enhancement from the Rust series for it.
Patch 1/3 is a fix of one modpost macro straight from 2.6.12-rc2.
A nice side effect is that it's now easier to debug the kernel, as stacktraces will now tell every call's place in the file tree:
[ 0.733191] Call Trace: [ 0.733668] <TASK> [ 0.733980] lib/dump_stack.c:dump_stack_lvl+0x48/0x68 [ 0.734689] kernel/panic.c:panic+0xf8/0x2ae [ 0.735291] init/do_mounts.c:mount_block_root+0x143/0x1ea [ 0.736046] init/do_mounts.c:prepare_namespace+0x13f/0x16e [ 0.736798] init/main.c:kernel_init_freeable+0x240/0x24f [ 0.737549] ? init/main.c:rest_init+0xc0/0xc0 [ 0.738171] init/main.c:kernel_init+0x1a/0x140 [ 0.738765] arch/x86/entry/entry_64.S:ret_from_fork+0x1f/0x30 [ 0.739529] </TASK>
Here are some stats:
Despite running a small utility on each object file and a script on each built-in.a plus one at the kallsyms generation process, it adds only 3 seconds to the whole clean build time:
make -j$(($(nproc) + 1)) all compile_commands.json 19071.12s user 3481.97s system 4587% cpu 8:11.64 total make -j$(($(nproc) + 1)) all compile_commands.json 19202.88s user 3598.80s system 4607% cpu 8:14.85 total
Compressed kallsyms become bigger by 1.4 Mbytes on x86_64 standard distroconfig - 60% of the kallsyms and 2.4% of the decompressed vmlinux in the memory:
ffffffff8259ab30 D kallsyms_offsetsffffffff82624ed0 D kallsyms_relative_baseffffffff82624ed8 D kallsyms_num_symsffffffff82624ee0 D kallsyms_namesffffffff827e9c68 D kallsyms_markersffffffff827ea510 D kallsyms_token_tableffffffff827ea8c0 D kallsyms_token_indexffffffff827eaac0 d .LC1
->
ffffffff8259ac30 D kallsyms_offsetsffffffff82624fb8 D kallsyms_relative_baseffffffff82624fc0 D kallsyms_num_symsffffffff82624fc8 D kallsyms_namesffffffff8294de50 D kallsyms_markersffffffff8294e6f8 D kallsyms_token_tableffffffff8294eac8 D kallsyms_token_indexffffffff8294ecc8 d .LC1
TODO:
* ELF rel and MIPS relocation support (only rela currently, just to test on x86_64);
* modules support. Currently, the kernel reuses standard ELF strtab for module kallsyms. My plan is to create a new section which will have the same symbol order as symtab, but point to new complete strings with filepaths, and use this section solely for kallsyms (leaving symtab alone);
* LTO support (now relies on that object files are ELFs);
* the actual kallsyms/livepatching/probes code which will use filepaths instead of indexes/positions.
Have fun!
Alexander Lobakin (3):
modpost: fix TO_NATIVE() with expressions and consts [STUB] increase kallsyms length limit
kallsyms: add option to include relative filepaths into kallsyms
.gitignore | 1 + Makefile | 2 +- include/linux/kallsyms.h | 2 +- init/Kconfig | 26 ++- kernel/livepatch/core.c | 4 +- scripts/Makefile.build | 7 +- scripts/Makefile.lib | 10 +- scripts/Makefile.modfinal | 3 +- scripts/gen_sympaths.pl | 270 ++++++++++++++++++++++++++ scripts/kallsyms.c | 89 +++++++-- scripts/link-vmlinux.sh | 14 +- scripts/mod/.gitignore | 1 + scripts/mod/Makefile | 9 + scripts/mod/modpost.h | 7 +- scripts/mod/sympath.c | 385 ++++++++++++++++++++++++++++++++++++++ 15 files changed, 796 insertions(+), 34 deletions(-) create mode 100755 scripts/gen_sympaths.pl create mode 100644 scripts/mod/sympath.c
Signature · 1 line
2.37.2