<div dir="ltr"><div><br></div><div>so Im trying to constrain the linker to put ELF section pairs</div><div>into contiguous chunks of memory.</div><div><br></div><div>this is on top of:</div><div><a href="https://lore.kernel.org/lkml/20210316050801.2446401-1-jim.cromie@gmail.com/">https://lore.kernel.org/lkml/20210316050801.2446401-1-jim.cromie@gmail.com/</a><br></div><div><br></div><div>The macro below works when used in vmlinux.lds.h,</div><div>it does pack the sections as desired.</div><div><br></div><div>but same macro, when reused in module.lds.h, fails.</div><div><br></div><div>The version below links ok, but appears to absorb the __dyndbg* sections</div><div>into the .data section, which works for vmlinux.lds.h, cuz there we use the __start/stop ___dyndbg* symbols to use the section.</div><div><br></div><div>In contrast, for modules, I want to preserve the named sections</div><div>as proper elf sections in the ko, so that loader picks them up</div><div>and saves them into struct load-info</div><div><br></div><div>Anyone got some deep linker-fu ?</div><div><br></div><div><br></div>[jimc@frodo wk-next]$ git diff<br>diff --git a/include/asm-generic/module.lds.h b/include/asm-generic/module.lds.h<br>index f210d5c1b78b..4840f01a0828 100644<br>--- a/include/asm-generic/module.lds.h<br>+++ b/include/asm-generic/module.lds.h<br>@@ -4,7 +4,26 @@<br> <br> /*<br>  * <asm/module.lds.h> can specify arch-specific sections for linking modules.<br>- * Empty for the asm-generic header.<br>+ * DYNAMIC_DEBUG needs its header sections contiguous with its data sections.<br>  */<br> <br>+#if defined(CONFIG_DYNAMIC_DEBUG) ||                                    \<br>+        (defined(CONFIG_DYNAMIC_DEBUG_CORE)                             \<br>+         && defined(DYNAMIC_DEBUG_MODULE))<br>+#define DYNAMIC_DEBUG_DATA()                                            \<br>+        . = ALIGN(8);                                                   \<br>+        __start___dyndbg_sites = .;                                     \<br>+        KEEP(*(__dyndbg_sites .gnu.linkonce.dyndbg_site))               \<br>+        __stop___dyndbg_sites = .;                                      \<br>+        __start___dyndbg = .;                                           \<br>+        KEEP(*(__dyndbg .gnu.linkonce.dyndbg))                          \<br>+        __stop___dyndbg = .;<br>+#else<br>+#define DYNAMIC_DEBUG_DATA()<br>+#endif<br>+<br>+SECTIONS {<br>+       .data : { DYNAMIC_DEBUG_DATA() }<br>+}<br>+<br> #endif /* __ASM_GENERIC_MODULE_LDS_H */<br></div>