kunit_activate_static_stub(9)
π
kunit_activate_static_stub (9) β from the Kernel API Manual, bestie β¨
okay so. this is a page from the Kernel API Manual and honestly it's giving "tiny header file, huge power" energy. let's get into it π«Ά
β¨ NAME β¨
kunit_activate_static_stub β replace a function using static stubs. that's it. that's the whole vibe. π₯
β¨ SYNOPSIS β¨
kunit_activate_static_stub (test , real_fn_addr , replacement_addr );
three args, no notes, slay π
β¨ ARGUMENTS β¨
testβ a pointer to thestruct kunittest context for the current test. like, the test you're literally in right now. main character energy πreal_fn_addrβ the address of the function you wanna replace. the og, the original, the one getting swapped out πreplacement_addrβ the address of the function you're replacing it with. the understudy that's about to eat π
β¨ DESCRIPTION β¨
when it's activated, calls to real_fn_addr from within this test β even if they're called indirectly β will instead call replacement_addr. sneak attack. ninja swap. no cap, that's the whole trick π§
β οΈ important caveat bestie, don't skip this: the function pointed to byreal_fn_addrmust begin with the static stub prologue inKUNIT_STATIC_STUB_REDIRECTfor this to work. no prologue, no redirect. that's the deal π
also, real_fn_addr and replacement_addr must have the same type. matching types only, mismatches are not it π
and when you're done being dramatic, the redirection can be disabled again with kunit_deactivate_static_stub. cleanup era πΈ
β¨ SEE ALSO β¨
- the kernel file
./include/kunit/static_stub.h KUNIT_STATIC_STUB_REDIRECT(9)kunit_deactivate_static_stub(9)
iykyk π
and that's the page!! this masterpiece lives in ./include/kunit and the version/date stamp on it is October 2026 β so yeah, mark your calendars, bestie ππ
π¦ 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