kcore_copy(9)
π kcore_copy(9) π
okay so bestie, welcome to the Kernel API Manual page for kcore_copy β yes the manual name is literally "Kernel API Manual", and yes this function is lowkey a whole vibe. sit down, grab a π, let's get into it.
β¨ NAME β¨
kcore_copy β copy kallsyms, modules and kcore from one directory to another. that's it, that's the tweet π«Ά
π¦ SYNOPSIS π¦
int kcore_copy (const char *from_dir , const char *to_dir );
π ARGUMENTS π
from_dirβ the from directory π the source, the origin, the place we're reading fromto_dirβ the to directory β¨ the destination, the glow-up location, the place we're writing to
π DESCRIPTION π
so what does this icon actually do? it copies the kallsyms, modules and kcore files from one directory to another. periodt.
kallsyms and modules get copied entirely β no crumbs left behind, full send. π§ but kcore? only the code segments get copied. not the whole thing. just the code bits.
the function assumes two segments suffice:
- one for the kernel proper π
- one for all the modules π
the code segments are determined from the kallsyms and modules files. iykyk.
now for the deets on the maps, because this is where it gets juicy:
- the kernel map starts at
_stextor the lowest function symbol, and ends at_etextor the highest function symbol - the module map starts at the lowest module address and ends at the highest module symbol
start addresses get rounded down to the nearest page. end addresses get rounded up to the nearest page. no cap, that's just how it is.
and an extra page is added to the highest kernel symbol and the highest module symbol to, hopefully, encompass that symbol too π₯Ί (the "hopefully" is doing a lot of heavy lifting there and i respect it).
π real talk: because the resulting kcore contains only code sections, it is unusual. like, noticeably weird. not like other kcores.
one significant peculiarity to flag (and bestie, this one matters): the mapping (start -> pgoff) is not the same for the kernel map and the modules map. why? because the data is copied adjacently, whereas the original kcore has gaps. so yeah, the offsets do not line up the way you'd expect β that's not a bug, that's just the assignment. π
finally β and this is the plot twist β the kallsyms file is compared with its copy to check that modules have not been loaded or unloaded while the copies were taking place. a little vibe check at the end, honestly iconic. β
π₯ RETURN π₯
0on success π slay-1on failure π not slay
πΈ SEE ALSO πΈ
- Kernel file
./tools/perf/util/symbol-elf.c elf_symtab__for_each_symbol(9)ref_reloc_sym_not_found(9)ref_reloc(9)populate_sdt_note(9)construct_sdt_notes_list(9)get_sdt_note_list(9)cleanup_sdt_note_list(9)sdt_notes__get_count(9)
okay that's the whole page bestie, you ate that π β¨
this lil masterpiece lives in ./tools/perf/util, dated October 2026 β so go forth, copy those code segments, round those pages, and remember: the mapping is not the same for the kernel map and the modules map. fr fr. π¦ππ
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms