#endif
 } __attribute__((aligned(8)));
 
-
+/* encapsulate linker provided built-in (or module) dyndbg data */
+struct _ddebug_info {
+       struct _ddebug *descs;
+       unsigned int num_descs;
+};
 
 #if defined(CONFIG_DYNAMIC_DEBUG_CORE)
 
-int ddebug_add_module(struct _ddebug *tab, unsigned int n,
-                               const char *modname);
+int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname);
+
 extern int ddebug_remove_module(const char *mod_name);
 extern __printf(2, 3)
 void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...);
 #include <linux/errno.h>
 #include <linux/printk.h>
 
-static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n,
-                                   const char *modname)
+static inline int ddebug_add_module(struct _ddebug_info *dinfo, const char *modname)
 {
        return 0;
 }
 
 extern const s32 __start___kcrctab[];
 extern const s32 __start___kcrctab_gpl[];
 
+#include <linux/dynamic_debug.h>
 struct load_info {
        const char *name;
        /* pointer to module in temporary copy, freed at end of load_module() */
        Elf_Shdr *sechdrs;
        char *secstrings, *strtab;
        unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs;
-       struct _ddebug *debug;
-       unsigned int num_debug;
+       struct _ddebug_info dyndbg;
        bool sig_ok;
 #ifdef CONFIG_KALLSYMS
        unsigned long mod_kallsyms_init_off;
 
        }
 }
 
-static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num)
+static void dynamic_debug_setup(struct module *mod, struct _ddebug_info *dyndbg)
 {
-       if (!debug)
+       if (!dyndbg->num_descs)
                return;
-       ddebug_add_module(debug, num, mod->name);
+       ddebug_add_module(dyndbg, mod->name);
 }
 
-static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug)
+static void dynamic_debug_remove(struct module *mod, struct _ddebug_info *dyndbg)
 {
-       if (debug)
+       if (dyndbg->num_descs)
                ddebug_remove_module(mod->name);
 }
 
        if (section_addr(info, "__obsparm"))
                pr_warn("%s: Ignoring obsolete parameters\n", mod->name);
 
-       info->debug = section_objs(info, "__dyndbg",
-                                  sizeof(*info->debug), &info->num_debug);
+       info->dyndbg.descs = section_objs(info, "__dyndbg",
+                                       sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs);
 
        return 0;
 }
        }
 
        init_build_id(mod, info);
-       dynamic_debug_setup(mod, info->debug, info->num_debug);
+       dynamic_debug_setup(mod, &info->dyndbg);
 
        /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */
        ftrace_module_init(mod);
 
  ddebug_cleanup:
        ftrace_release_mod(mod);
-       dynamic_debug_remove(mod, info->debug);
+       dynamic_debug_remove(mod, &info->dyndbg);
        synchronize_rcu();
        kfree(mod->args);
  free_arch_cleanup:
 
  * Allocate a new ddebug_table for the given module
  * and add it to the global list.
  */
-int ddebug_add_module(struct _ddebug *tab, unsigned int n,
-                            const char *name)
+static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base,
+                              const char *modname)
 {
        struct ddebug_table *dt;
 
+       v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs);
+       if (!di->num_descs) {
+               v3pr_info(" skip %s\n", modname);
+               return 0;
+       }
+
        dt = kzalloc(sizeof(*dt), GFP_KERNEL);
        if (dt == NULL) {
-               pr_err("error adding module: %s\n", name);
+               pr_err("error adding module: %s\n", modname);
                return -ENOMEM;
        }
        /*
         * member of struct module, which lives at least as long as
         * this struct ddebug_table.
         */
-       dt->mod_name = name;
-       dt->num_ddebugs = n;
-       dt->ddebugs = tab;
+       dt->mod_name = modname;
+       dt->ddebugs = di->descs;
+       dt->num_ddebugs = di->num_descs;
+
+       INIT_LIST_HEAD(&dt->link);
 
        mutex_lock(&ddebug_lock);
        list_add_tail(&dt->link, &ddebug_tables);
        mutex_unlock(&ddebug_lock);
 
-       vpr_info("%3u debug prints in module %s\n", n, dt->mod_name);
+       vpr_info("%3u debug prints in module %s\n", di->num_descs, modname);
        return 0;
 }
 
+int ddebug_add_module(struct _ddebug_info *di, const char *modname)
+{
+       return __ddebug_add_module(di, 0, modname);
+}
+
 /* helper for ddebug_dyndbg_(boot|module)_param_cb */
 static int ddebug_dyndbg_param_cb(char *param, char *val,
                                const char *modname, int on_err)
        const char *modname;
        char *cmdline;
 
+       struct _ddebug_info di = {
+               .descs = __start___dyndbg,
+               .num_descs = __stop___dyndbg - __start___dyndbg,
+       };
+
        if (&__start___dyndbg == &__stop___dyndbg) {
                if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) {
                        pr_warn("_ddebug table is empty in a CONFIG_DYNAMIC_DEBUG build\n");
 
                if (strcmp(modname, iter->modname)) {
                        mod_ct++;
-                       ret = ddebug_add_module(iter_mod_start, mod_sites, modname);
+                       di.num_descs = mod_sites;
+                       di.descs = iter_mod_start;
+                       ret = __ddebug_add_module(&di, i - mod_sites, modname);
                        if (ret)
                                goto out_err;
 
                        iter_mod_start = iter;
                }
        }
-       ret = ddebug_add_module(iter_mod_start, mod_sites, modname);
+       di.num_descs = mod_sites;
+       di.descs = iter_mod_start;
+       ret = __ddebug_add_module(&di, i - mod_sites, modname);
        if (ret)
                goto out_err;