In an (unused) experimental variation of this series, I had trouble
with __dyndbg* sections getting lost in drm drivers.  While it didn't
happen in this series, it exposed a non-obvious weakness.  So fix it,
by following the model demonstrated in codetag.lds.h.

Introduce include/asm-generic/dyndbg.lds.h, with 2 macros:

DYNDBG_SECTIONS() gets the 2 BOUNDED_SECTION_BY(__yndbg*) calls from
vmlinux.lds.h DATA_DATA, which now includes the new file and calls the
new macro.

MOD_DYNDBG_SECTIONS also has the 2 BOUNDED_SECTION_BY calls, but wraps
them with output section syntax to keep them as known and separate ELF
sections in the module.ko.

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.

CC: Arnd Bergmann <[email protected]>
Signed-off-by: Jim Cromie <[email protected]>
---
 MAINTAINERS                       |  1 +
 include/asm-generic/dyndbg.lds.h  | 19 +++++++++++++++++++
 include/asm-generic/vmlinux.lds.h |  6 ++----
 scripts/module.lds.S              |  2 ++
 4 files changed, 24 insertions(+), 4 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 5fcb7b991776..5c75109d2ee3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -9069,6 +9069,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
diff --git a/include/asm-generic/dyndbg.lds.h b/include/asm-generic/dyndbg.lds.h
new file mode 100644
index 000000000000..f95683aa16b6
--- /dev/null
+++ b/include/asm-generic/dyndbg.lds.h
@@ -0,0 +1,19 @@
+/* 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()                                      \
+       . = ALIGN(8);                                           \
+       BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)                 \
+       BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes)
+
+#define MOD_DYNDBG_SECTIONS()                                           \
+       __dyndbg : {                                                    \
+               BOUNDED_SECTION_BY(__dyndbg, ___dyndbg)                 \
+       }                                                               \
+       __dyndbg_classes : {                                            \
+               BOUNDED_SECTION_BY(__dyndbg_classes, ___dyndbg_classes) \
+       }
+
+#endif /* __ASM_GENERIC_DYNDBG_LDS_H */
diff --git a/include/asm-generic/vmlinux.lds.h 
b/include/asm-generic/vmlinux.lds.h
index acb4aadd74da..9324066aab51 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -340,6 +340,7 @@
 /*
  * .data section
  */
+#include <asm-generic/dyndbg.lds.h>
 #define DATA_DATA                                                      \
        *(.xiptext)                                                     \
        *(DATA_MAIN)                                                    \
@@ -353,10 +354,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()                                                \
diff --git a/scripts/module.lds.S b/scripts/module.lds.S
index 2dc4c8c3e667..027c5c286ea0 100644
--- a/scripts/module.lds.S
+++ b/scripts/module.lds.S
@@ -10,6 +10,7 @@
 #endif
 
 #include <asm-generic/codetag.lds.h>
+#include <asm-generic/dyndbg.lds.h>
 
 SECTIONS {
        /DISCARD/ : {
@@ -59,6 +60,7 @@ SECTIONS {
                *(.rodata..L*)
        }
 
+       MOD_DYNDBG_SECTIONS()
        MOD_SEPARATE_CODETAG_SECTIONS()
 }
 

-- 
2.53.0


Reply via email to