[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aD1f0CZfbsMR61OX@example.org>
Date: Mon, 2 Jun 2025 10:24:48 +0200
From: Alexey Gladkov <legion@...nel.org>
To: Masahiro Yamada <masahiroy@...nel.org>
Cc: Petr Pavlu <petr.pavlu@...e.com>, Luis Chamberlain <mcgrof@...nel.org>,
Sami Tolvanen <samitolvanen@...gle.com>,
Daniel Gomez <da.gomez@...sung.com>,
Nathan Chancellor <nathan@...nel.org>,
Nicolas Schier <nicolas.schier@...ux.dev>,
linux-kernel@...r.kernel.org, linux-modules@...r.kernel.org,
linux-kbuild@...r.kernel.org
Subject: Re: [PATCH v3 3/6] modpost: Make mod_device_table aliases more unique
On Mon, Jun 02, 2025 at 04:52:36PM +0900, Masahiro Yamada wrote:
> On Tue, May 27, 2025 at 6:08 PM Alexey Gladkov <legion@...nel.org> wrote:
> >
> > In order to avoid symbol conflicts if they appear in the same binary, a
> > more unique alias identifier can be generated.
> >
> > Signed-off-by: Alexey Gladkov <legion@...nel.org>
> > Reviewed-by: Petr Pavlu <petr.pavlu@...e.com>
> > ---
> > include/linux/module.h | 14 ++++++++++++--
> > scripts/mod/file2alias.c | 18 ++++++++++++++----
> > 2 files changed, 26 insertions(+), 6 deletions(-)
> >
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 88048561360f..e7506684069d 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> > @@ -249,10 +249,20 @@ struct module_kobject *lookup_or_create_module_kobject(const char *name);
> > /* What your module does. */
> > #define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)
> >
> > +/* Format: __mod_device_table__<counter>__kmod_<modname>__<type>__<name> */
>
> This format relies on module-name mangling, but
> I hope we will be able to stop doing it some day.
I didn't like this approach either when I found out how it was
implemented.
We can only add the module name to the structure to which the alias is
made. But the problem with this is that right now there is no common
structure for DEVICE_TABLE. Each module comes up with its own.
It is possible to add a common structure, but that would be a big
refactoring.
> Can we come up with a different idea
> in case <modname> contains hyphens?
The hyphen is not a problem for my implementation. In the __KBUILD_MODNAME
macro, hyphens are replaced by underscores.
scripts/Makefile.lib:
name-fix-token = $(subst $(comma),_,$(subst -,_,$1))
name-fix = $(call stringify,$(call name-fix-token,$1))
basename_flags = -DKBUILD_BASENAME=$(call name-fix,$(basetarget))
modname_flags = -DKBUILD_MODNAME=$(call name-fix,$(modname)) \
-D__KBUILD_MODNAME=kmod_$(call name-fix-token,$(modname))
--
Rgrds, legion
Powered by blists - more mailing lists