aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
authorMark Brown <broonie@kernel.org>2026-05-29 18:08:24 +0100
committerMark Brown <broonie@kernel.org>2026-05-29 18:08:24 +0100
commit941509f96942e695a03a74ef27c383e4dcaa02d9 (patch)
treee8112f512d9ba26b81bd169e316ce055c331639a /Documentation
parentabe9aea29db876486fe215636f1070487d00a483 (diff)
parent2c31897a17e55a6da529b4e797e98c6febc60fd2 (diff)
downloadlinux-next-history-941509f96942e695a03a74ef27c383e4dcaa02d9.tar.gz
Merge branch 'kbuild-for-next' of https://git.kernel.org/pub/scm/linux/kernel/git/kbuild/linux.git
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/kbuild/makefiles.rst41
1 files changed, 33 insertions, 8 deletions
diff --git a/Documentation/kbuild/makefiles.rst b/Documentation/kbuild/makefiles.rst
index 24a4708d26e8e..7521cae7d56f1 100644
--- a/Documentation/kbuild/makefiles.rst
+++ b/Documentation/kbuild/makefiles.rst
@@ -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?