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