Skip to contentSkip to conversation

dyndbg,vmlinux.lds.h: fix i386 section alignment in BOUNDED_SECTION macros

PATCH In review Jim Cromie 4 participants 14 messages Nov 21 – Nov 23

Subsystems (3)
lore
Share & tools
lore

Jim Cromie

author
#0 lore raw

cover dyndbg,vmlinux.lds.h: fix i386 section alignment in BOUNDED_SECTION macros

This series fixes a latent i386 section-alignment bug, by adding explicit alignments into the BOUNDED_SECTION_* linker script macros. The misalignment appears once __dyndbg_classes is split in 2, and the 1st section has just 1 entry; the 2nd section implicitly gets ALIGN(4).

1. Refactor BOUNDED_SECTION_* (and HEADERED_SECTION_*) macros from vmlinux.lds.h into include/asm-generic/bounded_sections.lds.h for reuse.

2. Drop the unused HEADERED_SECTION* macros from bounded_sections.lds.h.

3. Add explicit ALIGN(8) defaults to BOUNDED_SECTION_* (with _ALIGNED variants for non-8-byte tables like ORC_UNWIND_TABLE, EXCEPTION_TABLE, TRACEDATA, INIT_SETUP, and NOTES), fixing an i386 NULL deref in dynamic_debug_init() caused by 28-byte __dyndbg_classes misaligning the following __dyndbg section.

4. Remove now-redundant outer . = ALIGN(8); directives preceding BOUNDED_SECTION* uses in vmlinux.lds.h.

5. Add include/asm-generic/dyndbg.lds.h with DYNDBG_SECTIONS() for vmlinux.lds.h and MOD_DYNDBG_SECTIONS() (0 : ALIGN(8) + KEEP) for scripts/module.lds.S, fixing lost __dyndbg* sections in DRM modules under CONFIG_DRM_USE_DYNAMIC_DEBUG=y.

6. fix checkpatch to skip macro-rules checks on any *.lds.h, in 3 places where only vmlinux.lds.h is currently skipped.

NB: most of this patchset was split out of larger series fixing dyndbg-classmaps.

---
Jim Cromie (6):
vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h vmlinux.lds.h: drop unused HEADERED_SECTION* macros vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 vmlinux.lds.h: remove redundant ALIGN(8) directives dyndbg.lds.S: fix lost dyndbg sections in modules checkpatch.pl: generalize linker script macro exceptions

 MAINTAINERS                                |  1 +
 include/asm-generic/bounded_sections.lds.h | 32 ++++++++++++++
 include/asm-generic/dyndbg.lds.h           | 18 ++++++++
 include/asm-generic/vmlinux.lds.h          | 68 ++++++------------------------
 scripts/checkpatch.pl                      |  6 +--
 scripts/module.lds.S                       |  2 +
 6 files changed, 69 insertions(+), 58 deletions(-)

---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261121-vmlinux-lds-b59410146885

Best regards,

Signature · 1 line
Jim Cromie <[email protected]>
author
#1 lore raw

PATCH 1/6 vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h

Move BOUNDED_SECTION_* macros to a new helper file:
include/asm-generic/bounded_sections.lds.h and include it back into vmlinux.lds.h. This allows its reuse later to fix a failure to keep dyndbg sections in some circumstances.

NOTES:

These macros are only for use in vmlinux.lds.h, where the _start & _end symbols are needed. Modules keep sections separate in ELF sections, with their boundaries known, so the _start and _end are not useful, and may confuse tools not expecting them.

This patch ignores a checkpatch warning, because new file is covered by "GENERIC INCLUDE/ASM HEADER FILES" in MAINTAINERS

---
v3: move include to top

---
 include/asm-generic/bounded_sections.lds.h | 36 ++++++++++++++++++++++++++++++
 include/asm-generic/vmlinux.lds.h          | 31 +------------------------
 2 files changed, 37 insertions(+), 30 deletions(-)
include/asm-generic/bounded_sections.lds.h new file +36 -0
new file mode 100644
index 000000000000..8c29293ca7fb
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+
+#ifndef _ASM_GENERIC_BOUNDED_SECTIONS_H
+#define _ASM_GENERIC_BOUNDED_SECTIONS_H
+
+#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	_BEGIN_##_label_ = .;						\
+	KEEP(*(_sec_))							\
+	_END_##_label_ = .;
+
+#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	_label_##_BEGIN_ = .;						\
+	KEEP(*(_sec_))							\
+	_label_##_END_ = .;
+
+#define BOUNDED_SECTION_BY(_sec_, _label_)				\
+	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
+
+#define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
+
+#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+	_HDR_##_label_	= .;						\
+	KEEP(*(.gnu.linkonce.##_sec_))					\
+	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
+
+#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
+	_label_##_HDR_ = .;						\
+	KEEP(*(.gnu.linkonce.##_sec_))					\
+	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
+
+#define HEADERED_SECTION_BY(_sec_, _label_)				\
+	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
+
+#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
+
+#endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */
include/asm-generic/vmlinux.lds.h +1 -30
index 3eb732942d69..5fed4194983c 100644
@@ -50,6 +50,7 @@
  *               [__nosave_begin, __nosave_end] for the nosave data
  */
 
+#include <asm-generic/bounded_sections.lds.h>
 #include <asm-generic/codetag.lds.h>
 
 #ifndef LOAD_OFFSET
@@ -211,36 +212,6 @@
 # endif
 #endif
 
-#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
-	_BEGIN_##_label_ = .;						\
-	KEEP(*(_sec_))							\
-	_END_##_label_ = .;
-
-#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
-	_label_##_BEGIN_ = .;						\
-	KEEP(*(_sec_))							\
-	_label_##_END_ = .;
-
-#define BOUNDED_SECTION_BY(_sec_, _label_)				\
-	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
-
-#define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
-
-#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
-	_HDR_##_label_	= .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
-	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
-
-#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
-	_label_##_HDR_ = .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
-	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
-
-#define HEADERED_SECTION_BY(_sec_, _label_)				\
-	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
-
-#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
-
 #ifdef CONFIG_TRACE_BRANCH_PROFILING
 #define LIKELY_PROFILE()						\
 	BOUNDED_SECTION_BY(_ftrace_annotated_branch, _annotated_branch_profile)
Signature · 1 line
2.56.1
author
#2 lore raw

PATCH 2/6 vmlinux.lds.h: drop unused HEADERED_SECTION* macros

In reply to Jim Cromie

These macros are unused, no point in carrying them any more.

NB: these macros were just moved to bounded_sections.lds.h, from vmlinux.lds.h, which is the known entity, and therefore more meaningful in the 1-line summary, so thats what I used as the topic.

---
 include/asm-generic/bounded_sections.lds.h | 15 ---------------
 1 file changed, 15 deletions(-)
include/asm-generic/bounded_sections.lds.h +0 -15
index 8c29293ca7fb..268cdc34389b 100644
@@ -18,19 +18,4 @@
 
 #define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
 
-#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
-	_HDR_##_label_	= .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
-	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
-
-#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
-	_label_##_HDR_ = .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
-	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
-
-#define HEADERED_SECTION_BY(_sec_, _label_)				\
-	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
-
-#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
-
 #endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */
Signature · 1 line
2.56.1
author
#5 lore raw

PATCH 3/6 vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386

In reply to Jim Cromie

Almost all uses of the BOUNDED_SECTION macros are ALIGN(8), either explicitly, or by being below an aligned section containing x*8 byte objects. The noteworthy exception is BOUNDED_SECTION(__dyndbg), which immediately follows BOUNDED_SECTION(__dyndbg_classes).

On i386, struct _ddebug_classmap is 28 bytes, so without an explicit ALIGN(8) in the macro, the following __dyndbg section gets misaligned, causing a NULL ptr deref in dynamic_debug_init().

So fix this with an explicit ALIGN(8) in the existing BOUNDED_SECTION macros, and introduce _ALIGNED variants to handle the cases with an explicit . = ALIGN(x)

Also add explicit alignments for: EXCEPTION_TABLE, ORC_UNWIND_TABLE, TRACEDATA, INIT_SETUP, and NOTES.

update BOUNDED_SECTION uses inside . = ALIGN(x) stanzas to use _ALIGNED variants, but keep the outer ALIGNs so the symbols between them are not "re-aligned".

In particular, scripts/sorttable.c does not tolerate sloppy padding.

At the top of ORC_UNWIND_TABLE, add . = ALIGN(4) to match the struct orc_header __align() call in the code:

commit b9f174c811e3 ("x86/unwind/orc: Add ELF section with ORC version identifier")

---
v3:

sashiko complained about NOTES and .BTF_ids.
gemini asserts that NOTES are natively 4-byte aligned, add comment repeating it. .BTF_ids doesnt use BOUNDED_BY, since start/end isnt needed; sashiko evidently got confused by immediately preceding usage.

v2:

sashiko picked up 2 cases, added to the explicit list above
https://sashiko.dev/#/patchset/20260515-asm-generic-1-v3-0-680b273666d4%40gmail.com

---
 include/asm-generic/bounded_sections.lds.h | 17 ++++++++++++++---
 include/asm-generic/vmlinux.lds.h          | 18 ++++++++++--------
 2 files changed, 24 insertions(+), 11 deletions(-)
include/asm-generic/bounded_sections.lds.h +14 -3
index 268cdc34389b..8ff3e3420f60 100644
@@ -3,19 +3,30 @@
 #ifndef _ASM_GENERIC_BOUNDED_SECTIONS_H
 #define _ASM_GENERIC_BOUNDED_SECTIONS_H
 
-#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+#define BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, _ALIGNED_) \
+	. = ALIGN(_ALIGNED_);						\
 	_BEGIN_##_label_ = .;						\
 	KEEP(*(_sec_))							\
 	_END_##_label_ = .;
 
-#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+#define BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, 8)
+
+#define BOUNDED_SECTION_POST_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, _ALIGNED_) \
+	. = ALIGN(_ALIGNED_);						\
 	_label_##_BEGIN_ = .;						\
 	KEEP(*(_sec_))							\
 	_label_##_END_ = .;
 
+#define BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)	\
+	BOUNDED_SECTION_POST_LABEL_ALIGNED(_sec_, _label_, _BEGIN_, _END_, 8)
+
 #define BOUNDED_SECTION_BY(_sec_, _label_)				\
 	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
 
-#define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
+#define BOUNDED_SECTION_BY_ALIGNED(_sec_, _label_, _ALIGNED_)		\
+	BOUNDED_SECTION_PRE_LABEL_ALIGNED(_sec_, _label_, __start, __stop, _ALIGNED_)
+
+#define BOUNDED_SECTION(_sec)   BOUNDED_SECTION_BY(_sec, _sec)
 
 #endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */
include/asm-generic/vmlinux.lds.h +10 -8
index 5fed4194983c..c570495d8de5 100644
@@ -640,7 +640,7 @@
 #define EXCEPTION_TABLE(align)						\
 	. = ALIGN(align);						\
 	__ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {		\
-		BOUNDED_SECTION_BY(__ex_table, ___ex_table)		\
+		BOUNDED_SECTION_BY_ALIGNED(__ex_table, ___ex_table, align) \
 	}
 
 /*
@@ -679,7 +679,7 @@
 #define BTF								\
 	. = ALIGN(PAGE_SIZE);						\
 	.BTF : AT(ADDR(.BTF) - LOAD_OFFSET) {				\
-		BOUNDED_SECTION_BY(.BTF, _BTF)				\
+		BOUNDED_SECTION_BY_ALIGNED(.BTF, _BTF, PAGE_SIZE)	\
 	}								\
 	BTF_INLINE							\
 	BTF_INLINE_LINK						\
@@ -871,16 +871,17 @@
 
 #ifdef CONFIG_UNWINDER_ORC
 #define ORC_UNWIND_TABLE						\
+	. = ALIGN(4);							\
 	.orc_header : AT(ADDR(.orc_header) - LOAD_OFFSET) {		\
-		BOUNDED_SECTION_BY(.orc_header, _orc_header)		\
+		BOUNDED_SECTION_BY_ALIGNED(.orc_header, _orc_header, 4)	\
 	}								\
 	. = ALIGN(4);							\
 	.orc_unwind_ip : AT(ADDR(.orc_unwind_ip) - LOAD_OFFSET) {	\
-		BOUNDED_SECTION_BY(.orc_unwind_ip, _orc_unwind_ip)	\
+		BOUNDED_SECTION_BY_ALIGNED(.orc_unwind_ip, _orc_unwind_ip, 4)\
 	}								\
 	. = ALIGN(2);							\
 	.orc_unwind : AT(ADDR(.orc_unwind) - LOAD_OFFSET) {		\
-		BOUNDED_SECTION_BY(.orc_unwind, _orc_unwind)		\
+		BOUNDED_SECTION_BY_ALIGNED(.orc_unwind, _orc_unwind, 2)	\
 	}								\
 	text_size = _etext - _stext;					\
 	. = ALIGN(4);							\
@@ -908,7 +909,7 @@
 #define TRACEDATA							\
 	. = ALIGN(4);							\
 	.tracedata : AT(ADDR(.tracedata) - LOAD_OFFSET) {		\
-		BOUNDED_SECTION_POST_LABEL(.tracedata, __tracedata, _start, _end) \
+		BOUNDED_SECTION_POST_LABEL_ALIGNED(.tracedata, __tracedata, _start, _end, 4) \
 	}
 #else
 #define TRACEDATA
@@ -937,13 +938,14 @@
 		*(.note.gnu.property)					\
 	}								\
 	.notes : AT(ADDR(.notes) - LOAD_OFFSET) {			\
-		BOUNDED_SECTION_BY(.note.*, _notes)			\
+		/* *(.note.*) are natively 4-byte aligned */		\
+		BOUNDED_SECTION_BY_ALIGNED(.note.*, _notes, 4)		\
 	} NOTES_HEADERS							\
 	NOTES_HEADERS_RESTORE
 
 #define INIT_SETUP(initsetup_align)					\
 		. = ALIGN(initsetup_align);				\
-		BOUNDED_SECTION_POST_LABEL(.init.setup, __setup, _start, _end)
+		BOUNDED_SECTION_POST_LABEL_ALIGNED(.init.setup, __setup, _start, _end, initsetup_align)
 
 #define INIT_CALLS_LEVEL(level)						\
 		__initcall##level##_start = .;				\
Signature · 1 line
2.56.1
author
#6 lore raw

PATCH 4/6 vmlinux.lds.h: remove redundant ALIGN(8) directives

In reply to Jim Cromie

The BOUNDED_SECTION_PRE_LABEL and BOUNDED_SECTION_POST_LABEL macros were recently updated to inherently enforce an 8-byte alignment. This makes the explicit '. = ALIGN(8);' statements preceding 'naked' macro calls in vmlinux.lds.h redundant.

Remove these redundant alignment directives to clean up the file and clarify that the macros handle their own alignment padding.

---
 include/asm-generic/vmlinux.lds.h | 13 -------------
 1 file changed, 13 deletions(-)
include/asm-generic/vmlinux.lds.h +0 -13
index c570495d8de5..20c49684d89d 100644
@@ -228,7 +228,6 @@
 
 #ifdef CONFIG_KPROBES
 #define KPROBE_BLACKLIST()				\
-	. = ALIGN(8);					\
 	BOUNDED_SECTION(_kprobe_blacklist)
 #else
 #define KPROBE_BLACKLIST()
@@ -244,7 +243,6 @@
 
 #ifdef CONFIG_EVENT_TRACING
 #define FTRACE_EVENTS()							\
-	. = ALIGN(8);							\
 	BOUNDED_SECTION(_ftrace_events)					\
 	BOUNDED_SECTION_BY(_ftrace_eval_map, _ftrace_eval_maps)
 #else
@@ -261,7 +259,6 @@
 
 #ifdef CONFIG_FTRACE_SYSCALLS
 #define TRACE_SYSCALLS()			\
-	. = ALIGN(8);				\
 	BOUNDED_SECTION_BY(__syscalls_metadata, _syscalls_metadata)
 #else
 #define TRACE_SYSCALLS()
@@ -276,7 +273,6 @@
 
 #ifdef CONFIG_SERIAL_EARLYCON
 #define EARLYCON_TABLE()						\
-	. = ALIGN(8);							\
 	BOUNDED_SECTION_POST_LABEL(__earlycon_table, __earlycon_table, , _end)
 #else
 #define EARLYCON_TABLE()
@@ -284,11 +280,9 @@
 
 #ifdef CONFIG_SECURITY
 #define LSM_TABLE()					\
-	. = ALIGN(8);					\
 	BOUNDED_SECTION_PRE_LABEL(.lsm_info.init, _lsm_info, __start, __end)
 
 #define EARLY_LSM_TABLE()						\
-	. = ALIGN(8);							\
 	BOUNDED_SECTION_PRE_LABEL(.early_lsm_info.init, _early_lsm_info, __start, __end)
 #else
 #define LSM_TABLE()
@@ -314,7 +308,6 @@
 
 #ifdef CONFIG_ACPI
 #define ACPI_PROBE_TABLE(name)						\
-	. = ALIGN(8);							\
 	BOUNDED_SECTION_POST_LABEL(__##name##_acpi_probe_table,		\
 				   __##name##_acpi_probe_table,, _end)
 #else
@@ -323,7 +316,6 @@
 
 #ifdef CONFIG_THERMAL
 #define THERMAL_TABLE(name)						\
-	. = ALIGN(8);							\
 	BOUNDED_SECTION_POST_LABEL(__##name##_thermal_table,		\
 				   __##name##_thermal_table,, _end)
 #else
@@ -403,12 +395,10 @@
 	__end_init_stack = .;
 
 #define JUMP_TABLE_DATA							\
-	. = ALIGN(8);							\
 	BOUNDED_SECTION_BY(__jump_table, ___jump_table)
 
 #ifdef CONFIG_HAVE_STATIC_CALL_INLINE
 #define STATIC_CALL_DATA						\
-	. = ALIGN(8);							\
 	BOUNDED_SECTION_BY(.static_call_sites, _static_call_sites)	\
 	BOUNDED_SECTION_BY(.static_call_tramp_key, _static_call_tramp_key)
 #else
@@ -453,7 +443,6 @@
 		*(.rodata) *(.rodata.*) *(.data.rel.ro*)		\
 		SCHED_DATA						\
 		RO_AFTER_INIT_DATA	/* Read only after init */	\
-		. = ALIGN(8);						\
 		BOUNDED_SECTION_BY(__tracepoints_ptrs, ___tracepoints_ptrs) \
 		*(__tracepoints_strings)/* Tracepoints: strings */	\
 	}								\
@@ -989,12 +978,10 @@
 
 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
 #define KUNIT_TABLE()							\
-		. = ALIGN(8);						\
 		BOUNDED_SECTION_POST_LABEL(.kunit_test_suites, __kunit_suites, _start, _end)
 
 /* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
 #define KUNIT_INIT_TABLE()						\
-		. = ALIGN(8);						\
 		BOUNDED_SECTION_POST_LABEL(.kunit_init_test_suites, \
 				__kunit_init_suites, _start, _end)
 
Signature · 1 line
2.56.1
author
#7 lore raw

PATCH 5/6 dyndbg.lds.S: fix lost dyndbg sections in modules

In reply to Jim Cromie

With CONFIG_DRM_USE_DYNAMIC_DEBUG=y, several build configs had problems with __dyndbg* sections getting lost in drm drivers. Fix this by following the model demonstrated in codetag.lds.h.

Introduce include/asm-generic/dyndbg.lds.h, to bundle dynamic-debug's multiple sections together, into 2 macros:

vmlinux.lds.h DATA_DATA: move the 2 BOUNDED_SECTION_BY(__dyndbg*) calls into dyndbg.lds.h DYNDBG_SECTIONS(). vmlinux.lds.h now includes the new file and calls the new macro.

MOD_DYNDBG_SECTIONS keeps the 2 sections by name, aligns them and sets the output address to 0 when the sections are empty.

dyndbg.lds.h includes (reuses) bounded-section.lds.h

scripts/module.lds.S: now calls MOD_DYNDBG_SECTIONS right before the CODETAG macro (consistent with their placements in vmlinux.lds.h), and also includes dyndbg.lds.h

This isolates vmlinux.lds.h from further __dyndbg section additions.

---
v3: move #includes to top, drop extra ALIGN(8) in DYNDBG_SECTIONS, add RvBy

v2: Address linker script review feedback for relocatable modules.

MOD_DYNDBG_SECTIONS() used the BOUNDED_SECTION_BY() macro, which proved problematic for kernel modules for two reasons:

1. Unwanted Empty Sections:
BOUNDED_SECTION_BY() automatically generates __start and __stop symbols. When applied to MOD_DYNDBG_SECTIONS(), the linker assumes the sections are populated due to the symbol definitions, forcing an empty __dyndbg and __dyndbg_classes output section in every compiled module, even those without dynamic debug configuration. Since the module loader uses section_objs() to locate data via ELF headers instead of relying on __start/__stop symbols, these assignments are completely unnecessary.

2. Non-zero Output Addresses:
During relocatable linking (e.g., ld.bfd -r), omitting an explicit base address causes the section to inherit the current location counter. This results in non-zero sh_addr values in .ko files, which is confusing, degrades compressibility, and can cause issues with external tools parsing the ELF.

Fix both issues by dropping BOUNDED_SECTION_BY() in favor of a simple KEEP(*(...)) constraint and explicitly defining the sections with a 0 base address: __dyndbg 0 : ALIGN(8) { ... }.

fixup-inc-vml

---
 MAINTAINERS                       |  1 +
 include/asm-generic/dyndbg.lds.h  | 18 ++++++++++++++++++
 include/asm-generic/vmlinux.lds.h |  6 ++----
 scripts/module.lds.S              |  2 ++
 4 files changed, 23 insertions(+), 4 deletions(-)
MAINTAINERS +1 -0
index ccbcdc0799b9..1acdf6e8b30b 100644
@@ -9505,6 +9505,7 @@ DYNAMIC DEBUG
 M:	Jason Baron <[email protected]>
 M:	Jim Cromie <[email protected]>
 S:	Maintained
+F:	include/asm-generic/dyndbg.lds.h
 F:	include/linux/dynamic_debug.h
 F:	lib/dynamic_debug.c
 F:	lib/test_dynamic_debug.c
include/asm-generic/dyndbg.lds.h new file +18 -0
new file mode 100644
index 000000000000..9d8951bef688
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef __ASM_GENERIC_DYNDBG_LDS_H
+#define __ASM_GENERIC_DYNDBG_LDS_H
+
+#include <asm-generic/bounded_sections.lds.h>
+#define DYNDBG_SECTIONS()					\
+	BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)			\
+	BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)
+
+#define MOD_DYNDBG_SECTIONS()						\
+	__dyndbg 0 : ALIGN(8) {						\
+		KEEP(*(__dyndbg))					\
+	}								\
+	__dyndbg_classes 0 : ALIGN(8) {					\
+		KEEP(*(__dyndbg_classes))				\
+	}
+
+#endif /* __ASM_GENERIC_DYNDBG_LDS_H */
include/asm-generic/vmlinux.lds.h +2 -4
index 20c49684d89d..f2f29f2e4e6c 100644
@@ -52,6 +52,7 @@
 
 #include <asm-generic/bounded_sections.lds.h>
 #include <asm-generic/codetag.lds.h>
+#include <asm-generic/dyndbg.lds.h>
 
 #ifndef LOAD_OFFSET
 #define LOAD_OFFSET 0
@@ -344,10 +345,7 @@
 	*(.data..do_once)						\
 	STRUCT_ALIGN();							\
 	*(__tracepoints)						\
-	/* implement dynamic printk debug */				\
-	. = ALIGN(8);							\
-	BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)		\
-	BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)				\
+	DYNDBG_SECTIONS()						\
 	CODETAG_SECTIONS()						\
 	LIKELY_PROFILE()		       				\
 	BRANCH_PROFILE()						\
scripts/module.lds.S +2 -0
index d0f200428957..5950ff8edc31 100644
@@ -5,6 +5,7 @@
  */
 
 #include <asm-generic/codetag.lds.h>
+#include <asm-generic/dyndbg.lds.h>
 
 SECTIONS {
 	/DISCARD/ : {
@@ -56,6 +57,7 @@ SECTIONS {
 		*(.rodata..L*)
 	}
 
+	MOD_DYNDBG_SECTIONS()
 	MOD_SEPARATE_CODETAG_SECTIONS()
 }
 
Signature · 1 line
2.56.1
author
#8 lore raw

PATCH 6/6 checkpatch.pl: generalize linker script macro exceptions

In reply to Jim Cromie

checkpatch skips macro-rule checks in linker scripts; 3 of them explicitly check for vmlinux.lds.h, and 1 (the 1st) skips on any *.lds.h. Generalize the 3 to match the 1st, including the escapes on the dots, so they're literal checks for '.'

---
 scripts/checkpatch.pl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +3 -3
index b8b64f720191..318e1f2577fd 100755
@@ -6016,7 +6016,7 @@ sub process {
 # Usually multi-statement macros should be enclosed in a do {} while
 # (0) loop.  Grab the first statement and ensure its the whole macro
 # if its not enclosed in a known good container
-		if ($realfile !~ m@/vmlinux.lds.h$@ &&
+		if ($realfile !~ m@/\.lds\.h$@ &&
 		    $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
 			my $ln = $linenr;
 			my $cnt = $realcnt;
@@ -6175,7 +6175,7 @@ sub process {
 
 # check for line continuations outside of #defines, preprocessor #, and asm
 
-		} elsif ($realfile =~ m@/vmlinux.lds.h$@) {
+		} elsif ($realfile =~ m@/\.lds\.h$@) {
 		    $line =~ s/(\w+)/$maybe_linker_symbol{$1}++/ge;
 		    #print "REAL: $realfile\nln: $line\nkeys:", sort keys %maybe_linker_symbol;
 		} else {
@@ -6192,7 +6192,7 @@ sub process {
 # single-statement macros do not need to be enclosed in do while (0) loop,
 # macro should not end with a semicolon
 		if ($perl_version_ok &&
-		    $realfile !~ m@/vmlinux.lds.h$@ &&
+		    $realfile !~ m@/\.lds\.h$@ &&
 		    $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
 			my $ln = $linenr;
 			my $cnt = $realcnt;
Signature · 1 line
2.56.1
#9 lore raw

Re: [PATCH 6/6] checkpatch.pl: generalize linker script macro exceptions

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Medium] checkpatch: literal slash in regex in process() breaks *.lds.h matching --

Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [Medium] checkpatch: literal slash in regex in process() breaks *.lds.h matching
--

commit 1481804dada7e62db737a08856db566e01d7b6bb
Author: Jim Cromie <[email protected]>

checkpatch.pl: generalize linker script macro exceptions

This commit replaces three explicit vmlinux.lds.h path checks in process() with a pattern intended to match any *.lds.h linker script header.

Quoted 23 lines
scripts/checkpatch.pl +2 -2
index b8b64f7201915..318e1f2577fd4 100755
@@ -6016,7 +6016,7 @@ sub process {
 # Usually multi-statement macros should be enclosed in a do {} while
 # (0) loop.  Grab the first statement and ensure its the whole macro
 # if its not enclosed in a known good container
-		if ($realfile !~ m@/vmlinux.lds.h$@ &&
+		if ($realfile !~ m@/\.lds\.h$@ &&
 		    $line =~ /^.\s*\#\s*define\s*$Ident(\()?/) {
 			my $ln = $linenr;
 			my $cnt = $realcnt;
@@ -6175,7 +6175,7 @@ sub process {
 
 # check for line continuations outside of #defines, preprocessor #, and asm
 
-		} elsif ($realfile =~ m@/vmlinux.lds.h$@) {
+		} elsif ($realfile =~ m@/\.lds\.h$@) {
 		    $line =~ s/(\w+)/$maybe_linker_symbol{$1}++/ge;
 		    #print "REAL: $realfile\nln: $line\nkeys:", sort keys %maybe_linker_symbol;
 		} else {

scripts/checkpatch.pl sub process { · line 6198

Quoted 8 lines
scripts/checkpatch.pl +1 -1
@@ -6192,7 +6192,7 @@ sub process {
 # single-statement macros do not need to be enclosed in do while (0) loop,
 # macro should not end with a semicolon
 		if ($perl_version_ok &&
-		    $realfile !~ m@/vmlinux.lds.h$@ &&
+		    $realfile !~ m@/\.lds\.h$@ &&
 		    $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
 			my $ln = $linenr;
 			my $cnt = $realcnt;

[Severity: Medium]
Does m@/\.lds\.h$@ fail to match vmlinux.lds.h and other *.lds.h files?

Because m@...@ uses @ as the regex delimiter, the leading / is matched as a literal path separator, so the pattern only matches a file literally named .lds.h. As a result, this regression causes checkpatch to stop excluding vmlinux.lds.h and other *.lds.h headers from macro and line continuation checks (unlike the earlier m@.*\.lds\.h$@ check in process()).

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=6
maintainer
#10 lore raw

Re: [PATCH 6/6] checkpatch.pl: generalize linker script macro exceptions

In reply to Jim Cromie
Quoted 6 lines · On Sat, 2026-11-21 at 15:49 -0700, Jim Cromie via B4 Relay wrote:

From: Jim Cromie <[email protected]>

checkpatch skips macro-rule checks in linker scripts; 3 of them explicitly check for vmlinux.lds.h, and 1 (the 1st) skips on any *.lds.h. Generalize the 3 to match the 1st, including the escapes on the dots, so they're literal checks for '.'

Please remember to email the checkpatch maintainer too.

Quoted 11 lines
---
 scripts/checkpatch.pl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +0 -0
index b8b64f720191..318e1f2577fd 100755

scripts/checkpatch.pl sub process { · line 6019

Quoted 5 lines
scripts/checkpatch.pl +1 -1
@@ -6016,7 +6016,7 @@ sub process {
 # Usually multi-statement macros should be enclosed in a do {} while
 # (0) loop.  Grab the first statement and ensure its the whole macro
 # if its not enclosed in a known good container
-		if ($realfile !~ m@/vmlinux.lds.h$@ &&
+		if ($realfile !~ m@/\.lds\.h$@ &&

Probably better to have something like
my $is_linker_file = '\.lds\.h$';
or maybe
my $is_linker_file = '\Q.lds.h\E$';

and use that everywhere

Quoted 19 lines
scripts/checkpatch.pl +1 -1
@@ -6175,7 +6175,7 @@ sub process {
 
 # check for line continuations outside of #defines, preprocessor #, and asm
 
-		} elsif ($realfile =~ m@/vmlinux.lds.h$@) {
+		} elsif ($realfile =~ m@/\.lds\.h$@) {
 
 		    $line =~ s/(\w+)/$maybe_linker_symbol{$1}++/ge;
 		    #print "REAL: $realfile\nln: $line\nkeys:", sort keys %maybe_linker_symbol;
scripts/checkpatch.pl +1 -1
 		} else {
@@ -6192,7 +6192,7 @@ sub process {
 # single-statement macros do not need to be enclosed in do while (0) loop,
 # macro should not end with a semicolon
 		if ($perl_version_ok &&
-		    $realfile !~ m@/vmlinux.lds.h$@ &&
+		    $realfile !~ m@/\.lds\.h$@ &&
 		    $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
 			my $ln = $linenr;
 			my $cnt = $realcnt;
#3 lore raw

Re: [PATCH 2/6] vmlinux.lds.h: drop unused HEADERED_SECTION* macros

In reply to Jim Cromie
Quoted 7 lines · On Sat, 21 Nov 2026 15:49:20 -0700 Jim Cromie via B4 Relay…

From: Jim Cromie <[email protected]>

These macros are unused, no point in carrying them any more.

NB: these macros were just moved to bounded_sections.lds.h, from vmlinux.lds.h, which is the known entity, and therefore more meaningful in the 1-line summary, so thats what I used as the topic.

Maybe remove them first?

David

Quoted 31 lines
---
 include/asm-generic/bounded_sections.lds.h | 15 ---------------
 1 file changed, 15 deletions(-)
include/asm-generic/bounded_sections.lds.h +0 -15
index 8c29293ca7fb..268cdc34389b 100644
@@ -18,19 +18,4 @@
 
 #define BOUNDED_SECTION(_sec)	 BOUNDED_SECTION_BY(_sec, _sec)
 
-#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
-	_HDR_##_label_	= .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
-	BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
-
-#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
-	_label_##_HDR_ = .;						\
-	KEEP(*(.gnu.linkonce.##_sec_))					\
-	BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
-
-#define HEADERED_SECTION_BY(_sec_, _label_)				\
-	HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
-
-#define HEADERED_SECTION(_sec)	 HEADERED_SECTION_BY(_sec, _sec)
-
 #endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */
#12 lore raw
In reply to Jim Cromie
Quoted 4 lines · On Sat, 21 Nov 2026 15:49:18 -0700 Jim Cromie via B4 Relay…

This series fixes a latent i386 section-alignment bug, by adding explicit alignments into the BOUNDED_SECTION_* linker script macros. The misalignment appears once __dyndbg_classes is split in 2, and the 1st section has just 1 entry; the 2nd section implicitly gets ALIGN(4).

Would everything work if all these sections got an ALIGN(8)? It would simplify everything and only cost a few bytes of memory that no one is really going to notice.

(Apart from BTF which seems to be page aligned.)

David

Quoted 49 lines

1. Refactor BOUNDED_SECTION_* (and HEADERED_SECTION_*) macros from vmlinux.lds.h into include/asm-generic/bounded_sections.lds.h for reuse.

2. Drop the unused HEADERED_SECTION* macros from bounded_sections.lds.h.

3. Add explicit ALIGN(8) defaults to BOUNDED_SECTION_* (with _ALIGNED variants for non-8-byte tables like ORC_UNWIND_TABLE, EXCEPTION_TABLE, TRACEDATA, INIT_SETUP, and NOTES), fixing an i386 NULL deref in dynamic_debug_init() caused by 28-byte __dyndbg_classes misaligning the following __dyndbg section.

4. Remove now-redundant outer . = ALIGN(8); directives preceding BOUNDED_SECTION* uses in vmlinux.lds.h.

5. Add include/asm-generic/dyndbg.lds.h with DYNDBG_SECTIONS() for vmlinux.lds.h and MOD_DYNDBG_SECTIONS() (0 : ALIGN(8) + KEEP) for scripts/module.lds.S, fixing lost __dyndbg* sections in DRM modules under CONFIG_DRM_USE_DYNAMIC_DEBUG=y.

6. fix checkpatch to skip macro-rules checks on any *.lds.h, in 3 places where only vmlinux.lds.h is currently skipped.

NB: most of this patchset was split out of larger series fixing dyndbg-classmaps.

---
Jim Cromie (6):
vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h vmlinux.lds.h: drop unused HEADERED_SECTION* macros vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 vmlinux.lds.h: remove redundant ALIGN(8) directives dyndbg.lds.S: fix lost dyndbg sections in modules checkpatch.pl: generalize linker script macro exceptions

 MAINTAINERS                                |  1 +
 include/asm-generic/bounded_sections.lds.h | 32 ++++++++++++++
 include/asm-generic/dyndbg.lds.h           | 18 ++++++++
 include/asm-generic/vmlinux.lds.h          | 68 ++++++------------------------
 scripts/checkpatch.pl                      |  6 +--
 scripts/module.lds.S                       |  2 +
 6 files changed, 69 insertions(+), 58 deletions(-)

---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261121-vmlinux-lds-b59410146885

Best regards,

#13 lore raw
Quoted 4 lines · David Laight

On Sat, 21 Nov 2026 15:49:18 -0700
Jim Cromie via B4 Relay <[email protected]> wrote:

Quoted 9 lines
Quoted 4 lines

This series fixes a latent i386 section-alignment bug, by adding explicit alignments into the BOUNDED_SECTION_* linker script macros. The misalignment appears once __dyndbg_classes is split in 2, and the 1st section has just 1 entry; the 2nd section implicitly gets ALIGN(4).

Would everything work if all these sections got an ALIGN(8)? It would simplify everything and only cost a few bytes of memory that no one is really going to notice.

I tried that 1st, iirc the ORC_UNWIND table in particular did not like it - the size and placement checks are quite strict, and I didnt want to fiddle with changing the rules.

Quoted 54 lines

(Apart from BTF which seems to be page aligned.)

David

Quoted 49 lines

1. Refactor BOUNDED_SECTION_* (and HEADERED_SECTION_*) macros from vmlinux.lds.h into include/asm-generic/bounded_sections.lds.h for reuse.

2. Drop the unused HEADERED_SECTION* macros from bounded_sections.lds.h.

3. Add explicit ALIGN(8) defaults to BOUNDED_SECTION_* (with _ALIGNED variants for non-8-byte tables like ORC_UNWIND_TABLE, EXCEPTION_TABLE, TRACEDATA, INIT_SETUP, and NOTES), fixing an i386 NULL deref in dynamic_debug_init() caused by 28-byte __dyndbg_classes misaligning the following __dyndbg section.

4. Remove now-redundant outer . = ALIGN(8); directives preceding BOUNDED_SECTION* uses in vmlinux.lds.h.

5. Add include/asm-generic/dyndbg.lds.h with DYNDBG_SECTIONS() for vmlinux.lds.h and MOD_DYNDBG_SECTIONS() (0 : ALIGN(8) + KEEP) for scripts/module.lds.S, fixing lost __dyndbg* sections in DRM modules under CONFIG_DRM_USE_DYNAMIC_DEBUG=y.

6. fix checkpatch to skip macro-rules checks on any *.lds.h, in 3 places where only vmlinux.lds.h is currently skipped.

NB: most of this patchset was split out of larger series fixing dyndbg-classmaps.

---
Jim Cromie (6):
vmlinux.lds.h: refactor BOUNDED_SECTION_* macros into bounded_sections.lds.h vmlinux.lds.h: drop unused HEADERED_SECTION* macros vmlinux.lds.h: Fix ALIGN(8) omission causing NULL ptr on i386 vmlinux.lds.h: remove redundant ALIGN(8) directives dyndbg.lds.S: fix lost dyndbg sections in modules checkpatch.pl: generalize linker script macro exceptions

 MAINTAINERS                                |  1 +
 include/asm-generic/bounded_sections.lds.h | 32 ++++++++++++++
 include/asm-generic/dyndbg.lds.h           | 18 ++++++++
 include/asm-generic/vmlinux.lds.h          | 68 ++++++------------------------
 scripts/checkpatch.pl                      |  6 +--
 scripts/module.lds.S                       |  2 +
 6 files changed, 69 insertions(+), 58 deletions(-)

---
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
change-id: 20261121-vmlinux-lds-b59410146885

Best regards,

#4 lore raw

Re: [PATCH 2/6] vmlinux.lds.h: drop unused HEADERED_SECTION* macros

In reply to David Laight
Quoted 6 lines · David Laight
Quoted 2 lines · On Sat, 21 Nov 2026 15:49:20 -0700 Jim Cromie via B4 Relay…

From: Jim Cromie <[email protected]>

Quoted 8 lines
Quoted 5 lines

These macros are unused, no point in carrying them any more.

NB: these macros were just moved to bounded_sections.lds.h, from vmlinux.lds.h, which is the known entity, and therefore more meaningful in the 1-line summary, so thats what I used as the topic.

Maybe remove them first?

yea, I'll do that.
thanks

Quoted 34 lines

David

Quoted 31 lines
---
 include/asm-generic/bounded_sections.lds.h | 15 ---------------
 1 file changed, 15 deletions(-)
include/asm-generic/bounded_sections.lds.h +0 -15
index 8c29293ca7fb..268cdc34389b 100644
@@ -18,19 +18,4 @@
 
 #define BOUNDED_SECTION(_sec)         BOUNDED_SECTION_BY(_sec, _sec)
 
-#define HEADERED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
-     _HDR_##_label_  = .;                                            \
-     KEEP(*(.gnu.linkonce.##_sec_))                                  \
-     BOUNDED_SECTION_PRE_LABEL(_sec_, _label_, _BEGIN_, _END_)
-
-#define HEADERED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_, _HDR_) \
-     _label_##_HDR_ = .;                                             \
-     KEEP(*(.gnu.linkonce.##_sec_))                                  \
-     BOUNDED_SECTION_POST_LABEL(_sec_, _label_, _BEGIN_, _END_)
-
-#define HEADERED_SECTION_BY(_sec_, _label_)                          \
-     HEADERED_SECTION_PRE_LABEL(_sec_, _label_, __start, __stop)
-
-#define HEADERED_SECTION(_sec)        HEADERED_SECTION_BY(_sec, _sec)
-
 #endif /* _ASM_GENERIC_BOUNDED_SECTIONS_H */
#11 lore raw

Re: [PATCH 6/6] checkpatch.pl: generalize linker script macro exceptions

In reply to Joe Perches
Quoted 10 lines · Joe Perches
Quoted 6 lines · On Sat, 2026-11-21 at 15:49 -0700, Jim Cromie via B4 Relay wrote:

From: Jim Cromie <[email protected]>

checkpatch skips macro-rule checks in linker scripts; 3 of them explicitly check for vmlinux.lds.h, and 1 (the 1st) skips on any *.lds.h. Generalize the 3 to match the 1st, including the escapes on the dots, so they're literal checks for '.'

Please remember to email the checkpatch maintainer too.

ack.
I missed that b4 prep -c didnt add you.

Quoted 23 lines
Quoted 12 lines
---
 scripts/checkpatch.pl | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
scripts/checkpatch.pl +0 -0
index b8b64f720191..318e1f2577fd 100755

scripts/checkpatch.pl sub process { · line 6019

Quoted 5 lines
scripts/checkpatch.pl +1 -1
@@ -6016,7 +6016,7 @@ sub process {
 # Usually multi-statement macros should be enclosed in a do {} while
 # (0) loop.  Grab the first statement and ensure its the whole macro
 # if its not enclosed in a known good container
-             if ($realfile !~ m@/vmlinux.lds.h$@ &&
+             if ($realfile !~ m@/\.lds\.h$@ &&

Probably better to have something like
my $is_linker_file = '\.lds\.h$';
or maybe
my $is_linker_file = '\Q.lds.h\E$';

Quoted 1 line

and use that everywhere

yup.

Quoted 20 lines
Quoted 20 lines
scripts/checkpatch.pl +1 -1
@@ -6175,7 +6175,7 @@ sub process {
 
 # check for line continuations outside of #defines, preprocessor #, and asm
 
-             } elsif ($realfile =~ m@/vmlinux.lds.h$@) {
+             } elsif ($realfile =~ m@/\.lds\.h$@) {
 
                  $line =~ s/(\w+)/$maybe_linker_symbol{$1}++/ge;
                  #print "REAL: $realfile\nln: $line\nkeys:", sort keys %maybe_linker_symbol;
              } else {
scripts/checkpatch.pl +1 -1
@@ -6192,7 +6192,7 @@ sub process {
 # single-statement macros do not need to be enclosed in do while (0) loop,
 # macro should not end with a semicolon
              if ($perl_version_ok &&
-                 $realfile !~ m@/vmlinux.lds.h$@ &&
+                 $realfile !~ m@/\.lds\.h$@ &&
                  $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) {
                      my $ln = $linenr;
                      my $cnt = $realcnt;