* [PATCH] kbuild: Makefile.lib: fix offsets generation with debug info
@ 2026-09-28 10:53 Dmitry Kandybka
0 siblings, 0 replies; only message in thread
From: Dmitry Kandybka @ 2026-09-28 10:53 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier; +Cc: linux-kbuild, linux-kernel, stable
When debug information is enabled (e.g. -ggdb3), the assembler
output file (e.g. kernel/sched/rq-offsets.s) contains additional
directives such as .ascii with offset info and debug metadata.
For example:
.ascii "->RQ_nr_pinned $3048 offsetof(struct rq, nr_pinned)" #
...
.ascii "->func); __data = (it_func_ptr)->data; ((void(*)(void *, pro"
The current sed-offsets macro uses [^ ]* to match constant names,
which is too permissive and can match unexpected characters when
debug directives are present. Additionally, the fallback command
's:->::; p;' strips '->' from any unmatched line and prints it,
which causes debug metadata to leak into the generated header
file (include/generated/rq-offsets.h), breaking the build.
Replace [^ ]* with [[:alnum:]_]* to match only valid C identifiers,
and remove the fallback 's:->::' command so that only successfully
transformed lines are emitted into the generated header.
Fixes: 7dd47b95b0f5 ("kbuild: consolidate redundant sed script ASM offset generation")
Signed-off-by: Dmitry Kandybka <d.kandybka@gmail.com>
---
scripts/Makefile.lib | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 0a4fdd8bd975..32251eb6ca33 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -493,9 +493,8 @@ quiet_cmd_zstd22_with_size = ZSTD22 $@
# the .ascii directive whereas GCC keeps the <space> as-is.
define sed-offsets
's:^[[:space:]]*\.ascii[[:space:]]*"\(.*\)".*:\1:; \
- /^->/{s:->#\(.*\):/* \1 */:; \
- s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \
- s:->::; p;}'
+ /^->/{s:->#\(.*\):/* \1 */:p; \
+ s:^->\([[:alnum:]_]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:p;}'
endef
# Use filechk to avoid rebuilds when a header changes, but the resulting file
--
2.54.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-28 10:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-28 10:53 [PATCH] kbuild: Makefile.lib: fix offsets generation with debug info Dmitry Kandybka
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®