Skip to content
systemcoding.dev
Kernels

Generate the assembly for one kernel file with make foo.s

Get the compiler's assembly for one kernel file with make foo.s on Linux 6.12, to see how a driver function really compiles for your config.

1 min read
Summarize in AI

To check what the compiler did with an inline helper or a READ_ONCE, look at the assembly. Kbuild has a pattern rule for it: ask for the .s file instead of the .o, and it runs the same compiler command with -S.

Shell
make drivers/net/dummy.s
grep -n 'dummy_xmit:' drivers/net/dummy.s
Text
  CC [M]  drivers/net/dummy.s
1186:dummy_xmit:

The line number depends on your compiler and config, so expect a different one. The file lands next to the source, and the same trick gives .i for the preprocessed source, handy for macro expansion bugs. Everything is built with your .config flags: retpolines, stack protector and CONFIG_FRAME_POINTER all show up in the output.

The .s file is not a replacement for disassembling the final object. Link-time effects, such as relocations and the alternatives patched in at boot, only appear in objdump -dr drivers/net/dummy.o. Delete the generated .s and .i files when you finish, so they do not show up in git status.

Also inAssembly
Share

More snippets

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.