kbuild: document generation of offset header files

Replace the placeholder reference with a description of how Kbuild
generates offset header files such as include/generated/asm-offsets.h.

Remove the corresponding TODO entry now that this is documented.

Signed-off-by: Piyush Patle <piyushpatle228@gmail.com>
Reviewed-by: Nicolas Schier <nsc@kernel.org>
Link: https://patch.msgid.link/20260410221257.191517-1-piyushpatle228@gmail.com
Signed-off-by: Nathan Chancellor <nathan@kernel.org>
This commit is contained in:
Piyush Patle 2026-04-11 03:42:54 +05:30 committed by Nathan Chancellor
parent 254f49634e
commit a0d7be4ab3
No known key found for this signature in database
GPG Key ID: 1D6B269171C01A96

View File

@ -1285,8 +1285,39 @@ Example::
In this example, the file target maketools will be processed
before descending down in the subdirectories.
See also chapter XXX-TODO that describes how kbuild supports
generating offset header files.
Generating offset header files
------------------------------
The ``include/generated/asm-offsets.h`` header exposes C structure
member offsets and other compile-time constants to assembly code. It
is generated from ``arch/$(SRCARCH)/kernel/asm-offsets.c``.
The source file uses ``DEFINE()``, ``OFFSET()``, ``BLANK()`` and
``COMMENT()`` from ``<linux/kbuild.h>``. These emit marker strings
through inline asm that Kbuild extracts from the compiled assembly
output.
Example::
#include <linux/kbuild.h>
#include <linux/sched.h>
int main(void)
{
OFFSET(TSK_ACTIVE_MM, task_struct, active_mm);
DEFINE(THREAD_SIZE, THREAD_SIZE);
BLANK();
return 0;
}
The rules are defined in the top-level ``Kbuild`` and
``scripts/Makefile.lib``. The header is built during Kbuild's
``prepare`` phase, after ``archprepare`` and before descending into
subdirectories.
The same mechanism generates ``include/generated/bounds.h`` from
``kernel/bounds.c`` and ``include/generated/rq-offsets.h`` from
``kernel/sched/rq-offsets.c``.
List directories to visit when descending
-----------------------------------------
@ -1690,9 +1721,3 @@ Credits
- Updates by Kai Germaschewski <kai@tp1.ruhr-uni-bochum.de>
- Updates by Sam Ravnborg <sam@ravnborg.org>
- Language QA by Jan Engelhardt <jengelh@gmx.de>
TODO
====
- Generating offset header files.
- Add more variables to chapters 7 or 9?