* [PATCH v6 6/9] modpost: Add modname to mod_device_table alias
[not found] <cover.1755170493.git.legion@kernel.org>
@ 2025-08-14 13:07 ` Alexey Gladkov
2025-08-14 13:26 ` Danilo Krummrich
0 siblings, 1 reply; 6+ messages in thread
From: Alexey Gladkov @ 2025-08-14 13:07 UTC (permalink / raw)
To: Nathan Chancellor, Nicolas Schier, Masahiro Yamada, Petr Pavlu,
Luis Chamberlain, Sami Tolvanen, Daniel Gomez
Cc: linux-kernel, linux-modules, linux-kbuild, Alexey Gladkov,
Miguel Ojeda, Andreas Hindborg, Danilo Krummrich, Alex Gaynor,
rust-for-linux
At this point, if a symbol is compiled as part of the kernel,
information about which module the symbol belongs to is lost.
To save this it is possible to add the module name to the alias name.
It's not very pretty, but it's possible for now.
Cc: Miguel Ojeda <ojeda@kernel.org>
Cc: Andreas Hindborg <a.hindborg@kernel.org>
Cc: Danilo Krummrich <dakr@kernel.org>
Cc: Alex Gaynor <alex.gaynor@gmail.com>
Cc: rust-for-linux@vger.kernel.org
Signed-off-by: Alexey Gladkov <legion@kernel.org>
---
include/linux/module.h | 14 +++++++++++++-
rust/kernel/device_id.rs | 8 ++++----
scripts/mod/file2alias.c | 18 ++++++++++++++----
3 files changed, 31 insertions(+), 9 deletions(-)
diff --git a/include/linux/module.h b/include/linux/module.h
index 3319a5269d28..e31ee29fac6b 100644
--- a/include/linux/module.h
+++ b/include/linux/module.h
@@ -244,10 +244,22 @@ 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__kmod_<modname>__<type>__<name>
+ * Parts of the string `__kmod_` and `__` are used as delimiters when parsing
+ * a symbol in file2alias.c
+ */
+#define __mod_device_table(type, name) \
+ __PASTE(__mod_device_table__, \
+ __PASTE(__KBUILD_MODNAME, \
+ __PASTE(__, \
+ __PASTE(type, \
+ __PASTE(__, name)))))
+
#ifdef MODULE
/* Creates an alias so file2alias.c can find device table. */
#define MODULE_DEVICE_TABLE(type, name) \
-static typeof(name) __mod_device_table__##type##__##name \
+static typeof(name) __mod_device_table(type, name) \
__attribute__ ((used, alias(__stringify(name))))
#else /* !MODULE */
#define MODULE_DEVICE_TABLE(type, name)
diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs
index 70d57814ff79..62c42da12e9d 100644
--- a/rust/kernel/device_id.rs
+++ b/rust/kernel/device_id.rs
@@ -195,10 +195,10 @@ macro_rules! module_device_table {
($table_type: literal, $module_table_name:ident, $table_name:ident) => {
#[rustfmt::skip]
#[export_name =
- concat!("__mod_device_table__", $table_type,
- "__", module_path!(),
- "_", line!(),
- "_", stringify!($table_name))
+ concat!("__mod_device_table__", line!(),
+ "__kmod_", module_path!(),
+ "__", $table_type,
+ "__", stringify!($table_name))
]
static $module_table_name: [::core::mem::MaybeUninit<u8>; $table_name.raw_ids().size()] =
unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) };
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 00586119a25b..13021266a18f 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1476,8 +1476,8 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
{
void *symval;
char *zeros = NULL;
- const char *type, *name;
- size_t typelen;
+ const char *type, *name, *modname;
+ size_t typelen, modnamelen;
static const char *prefix = "__mod_device_table__";
/* We're looking for a section relative symbol */
@@ -1488,10 +1488,20 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT)
return;
- /* All our symbols are of form __mod_device_table__<type>__<name>. */
+ /* All our symbols are of form __mod_device_table__kmod_<modname>__<type>__<name>. */
if (!strstarts(symname, prefix))
return;
- type = symname + strlen(prefix);
+
+ modname = strstr(symname, "__kmod_");
+ if (!modname)
+ return;
+ modname += strlen("__kmod_");
+
+ type = strstr(modname, "__");
+ if (!type)
+ return;
+ modnamelen = type - modname;
+ type += strlen("__");
name = strstr(type, "__");
if (!name)
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v6 6/9] modpost: Add modname to mod_device_table alias
2025-08-14 13:07 ` [PATCH v6 6/9] modpost: Add modname to mod_device_table alias Alexey Gladkov
@ 2025-08-14 13:26 ` Danilo Krummrich
2025-08-14 13:54 ` Alexey Gladkov
0 siblings, 1 reply; 6+ messages in thread
From: Danilo Krummrich @ 2025-08-14 13:26 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Nathan Chancellor, Nicolas Schier, Masahiro Yamada, Petr Pavlu,
Luis Chamberlain, Sami Tolvanen, Daniel Gomez, linux-kernel,
linux-modules, linux-kbuild, Miguel Ojeda, Andreas Hindborg,
Alex Gaynor, rust-for-linux
On Thu Aug 14, 2025 at 3:07 PM CEST, Alexey Gladkov wrote:
> At this point, if a symbol is compiled as part of the kernel,
> information about which module the symbol belongs to is lost.
>
> To save this it is possible to add the module name to the alias name.
> It's not very pretty, but it's possible for now.
>
> Cc: Miguel Ojeda <ojeda@kernel.org>
> Cc: Andreas Hindborg <a.hindborg@kernel.org>
> Cc: Danilo Krummrich <dakr@kernel.org>
> Cc: Alex Gaynor <alex.gaynor@gmail.com>
> Cc: rust-for-linux@vger.kernel.org
> Signed-off-by: Alexey Gladkov <legion@kernel.org>
> ---
> include/linux/module.h | 14 +++++++++++++-
> rust/kernel/device_id.rs | 8 ++++----
> scripts/mod/file2alias.c | 18 ++++++++++++++----
> 3 files changed, 31 insertions(+), 9 deletions(-)
>
> diff --git a/include/linux/module.h b/include/linux/module.h
> index 3319a5269d28..e31ee29fac6b 100644
> --- a/include/linux/module.h
> +++ b/include/linux/module.h
> @@ -244,10 +244,22 @@ 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__kmod_<modname>__<type>__<name>
> + * Parts of the string `__kmod_` and `__` are used as delimiters when parsing
> + * a symbol in file2alias.c
> + */
> +#define __mod_device_table(type, name) \
> + __PASTE(__mod_device_table__, \
> + __PASTE(__KBUILD_MODNAME, \
> + __PASTE(__, \
> + __PASTE(type, \
> + __PASTE(__, name)))))
> +
> #ifdef MODULE
> /* Creates an alias so file2alias.c can find device table. */
> #define MODULE_DEVICE_TABLE(type, name) \
> -static typeof(name) __mod_device_table__##type##__##name \
> +static typeof(name) __mod_device_table(type, name) \
> __attribute__ ((used, alias(__stringify(name))))
> #else /* !MODULE */
> #define MODULE_DEVICE_TABLE(type, name)
> diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs
> index 70d57814ff79..62c42da12e9d 100644
> --- a/rust/kernel/device_id.rs
> +++ b/rust/kernel/device_id.rs
> @@ -195,10 +195,10 @@ macro_rules! module_device_table {
> ($table_type: literal, $module_table_name:ident, $table_name:ident) => {
> #[rustfmt::skip]
> #[export_name =
> - concat!("__mod_device_table__", $table_type,
> - "__", module_path!(),
> - "_", line!(),
> - "_", stringify!($table_name))
> + concat!("__mod_device_table__", line!(),
Why do we have line!() between "__mod_device_table__" and "__kmod_", while the
format is defined as "__mod_device_table__kmod_<modname>__<type>__<name>" above?
The previous logic was to create a unique name with
using "<module_path>_<line>_<table_name>" as "<name>". So, I think this should
actually be:
concat!("__mod_device_table__kmod_",
module_path!(),
"__", $table_type,
"__", stringify!($table_name),
"_", line!())
rather than the below.
> + "__kmod_", module_path!(),
> + "__", $table_type,
> + "__", stringify!($table_name))
> ]
> static $module_table_name: [::core::mem::MaybeUninit<u8>; $table_name.raw_ids().size()] =
> unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) };
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v6 6/9] modpost: Add modname to mod_device_table alias
2025-08-14 13:26 ` Danilo Krummrich
@ 2025-08-14 13:54 ` Alexey Gladkov
2025-08-14 14:03 ` Danilo Krummrich
0 siblings, 1 reply; 6+ messages in thread
From: Alexey Gladkov @ 2025-08-14 13:54 UTC (permalink / raw)
To: Danilo Krummrich
Cc: Nathan Chancellor, Nicolas Schier, Masahiro Yamada, Petr Pavlu,
Luis Chamberlain, Sami Tolvanen, Daniel Gomez, linux-kernel,
linux-modules, linux-kbuild, Miguel Ojeda, Andreas Hindborg,
Alex Gaynor, rust-for-linux
On Thu, Aug 14, 2025 at 03:26:53PM +0200, Danilo Krummrich wrote:
> On Thu Aug 14, 2025 at 3:07 PM CEST, Alexey Gladkov wrote:
> > At this point, if a symbol is compiled as part of the kernel,
> > information about which module the symbol belongs to is lost.
> >
> > To save this it is possible to add the module name to the alias name.
> > It's not very pretty, but it's possible for now.
> >
> > Cc: Miguel Ojeda <ojeda@kernel.org>
> > Cc: Andreas Hindborg <a.hindborg@kernel.org>
> > Cc: Danilo Krummrich <dakr@kernel.org>
> > Cc: Alex Gaynor <alex.gaynor@gmail.com>
> > Cc: rust-for-linux@vger.kernel.org
> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> > ---
> > include/linux/module.h | 14 +++++++++++++-
> > rust/kernel/device_id.rs | 8 ++++----
> > scripts/mod/file2alias.c | 18 ++++++++++++++----
> > 3 files changed, 31 insertions(+), 9 deletions(-)
> >
> > diff --git a/include/linux/module.h b/include/linux/module.h
> > index 3319a5269d28..e31ee29fac6b 100644
> > --- a/include/linux/module.h
> > +++ b/include/linux/module.h
> > @@ -244,10 +244,22 @@ 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__kmod_<modname>__<type>__<name>
> > + * Parts of the string `__kmod_` and `__` are used as delimiters when parsing
> > + * a symbol in file2alias.c
> > + */
> > +#define __mod_device_table(type, name) \
> > + __PASTE(__mod_device_table__, \
> > + __PASTE(__KBUILD_MODNAME, \
> > + __PASTE(__, \
> > + __PASTE(type, \
> > + __PASTE(__, name)))))
> > +
> > #ifdef MODULE
> > /* Creates an alias so file2alias.c can find device table. */
> > #define MODULE_DEVICE_TABLE(type, name) \
> > -static typeof(name) __mod_device_table__##type##__##name \
> > +static typeof(name) __mod_device_table(type, name) \
> > __attribute__ ((used, alias(__stringify(name))))
> > #else /* !MODULE */
> > #define MODULE_DEVICE_TABLE(type, name)
> > diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs
> > index 70d57814ff79..62c42da12e9d 100644
> > --- a/rust/kernel/device_id.rs
> > +++ b/rust/kernel/device_id.rs
> > @@ -195,10 +195,10 @@ macro_rules! module_device_table {
> > ($table_type: literal, $module_table_name:ident, $table_name:ident) => {
> > #[rustfmt::skip]
> > #[export_name =
> > - concat!("__mod_device_table__", $table_type,
> > - "__", module_path!(),
> > - "_", line!(),
> > - "_", stringify!($table_name))
> > + concat!("__mod_device_table__", line!(),
>
> Why do we have line!() between "__mod_device_table__" and "__kmod_", while the
> format is defined as "__mod_device_table__kmod_<modname>__<type>__<name>" above?
The "__mod_device_table__" is used to filter symbols.
The meaning part starts after "__kmod_" part. After that, order becomes
important.
> The previous logic was to create a unique name with
> using "<module_path>_<line>_<table_name>" as "<name>". So, I think this should
> actually be:
>
> concat!("__mod_device_table__kmod_",
> module_path!(),
> "__", $table_type,
> "__", stringify!($table_name),
> "_", line!())
>
> rather than the below.
No. "stringify!($table_name)" should be the last thing in this string.
This is the a symbol name that will be searched for in the elf to generate
modalias.
>
> > + "__kmod_", module_path!(),
> > + "__", $table_type,
> > + "__", stringify!($table_name))
> > ]
> > static $module_table_name: [::core::mem::MaybeUninit<u8>; $table_name.raw_ids().size()] =
> > unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) };
>
--
Rgrds, legion
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v6 6/9] modpost: Add modname to mod_device_table alias
2025-08-14 13:54 ` Alexey Gladkov
@ 2025-08-14 14:03 ` Danilo Krummrich
2025-08-14 21:46 ` Alexey Gladkov
0 siblings, 1 reply; 6+ messages in thread
From: Danilo Krummrich @ 2025-08-14 14:03 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Nathan Chancellor, Nicolas Schier, Masahiro Yamada, Petr Pavlu,
Luis Chamberlain, Sami Tolvanen, Daniel Gomez, linux-kernel,
linux-modules, linux-kbuild, Miguel Ojeda, Andreas Hindborg,
Alex Gaynor, rust-for-linux
On Thu Aug 14, 2025 at 3:54 PM CEST, Alexey Gladkov wrote:
> On Thu, Aug 14, 2025 at 03:26:53PM +0200, Danilo Krummrich wrote:
>> On Thu Aug 14, 2025 at 3:07 PM CEST, Alexey Gladkov wrote:
>> > At this point, if a symbol is compiled as part of the kernel,
>> > information about which module the symbol belongs to is lost.
>> >
>> > To save this it is possible to add the module name to the alias name.
>> > It's not very pretty, but it's possible for now.
>> >
>> > Cc: Miguel Ojeda <ojeda@kernel.org>
>> > Cc: Andreas Hindborg <a.hindborg@kernel.org>
>> > Cc: Danilo Krummrich <dakr@kernel.org>
>> > Cc: Alex Gaynor <alex.gaynor@gmail.com>
>> > Cc: rust-for-linux@vger.kernel.org
>> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
>> > ---
>> > include/linux/module.h | 14 +++++++++++++-
>> > rust/kernel/device_id.rs | 8 ++++----
>> > scripts/mod/file2alias.c | 18 ++++++++++++++----
>> > 3 files changed, 31 insertions(+), 9 deletions(-)
>> >
>> > diff --git a/include/linux/module.h b/include/linux/module.h
>> > index 3319a5269d28..e31ee29fac6b 100644
>> > --- a/include/linux/module.h
>> > +++ b/include/linux/module.h
>> > @@ -244,10 +244,22 @@ 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__kmod_<modname>__<type>__<name>
>> > + * Parts of the string `__kmod_` and `__` are used as delimiters when parsing
>> > + * a symbol in file2alias.c
>> > + */
>> > +#define __mod_device_table(type, name) \
>> > + __PASTE(__mod_device_table__, \
>> > + __PASTE(__KBUILD_MODNAME, \
>> > + __PASTE(__, \
>> > + __PASTE(type, \
>> > + __PASTE(__, name)))))
>> > +
>> > #ifdef MODULE
>> > /* Creates an alias so file2alias.c can find device table. */
>> > #define MODULE_DEVICE_TABLE(type, name) \
>> > -static typeof(name) __mod_device_table__##type##__##name \
>> > +static typeof(name) __mod_device_table(type, name) \
>> > __attribute__ ((used, alias(__stringify(name))))
>> > #else /* !MODULE */
>> > #define MODULE_DEVICE_TABLE(type, name)
>> > diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs
>> > index 70d57814ff79..62c42da12e9d 100644
>> > --- a/rust/kernel/device_id.rs
>> > +++ b/rust/kernel/device_id.rs
>> > @@ -195,10 +195,10 @@ macro_rules! module_device_table {
>> > ($table_type: literal, $module_table_name:ident, $table_name:ident) => {
>> > #[rustfmt::skip]
>> > #[export_name =
>> > - concat!("__mod_device_table__", $table_type,
>> > - "__", module_path!(),
>> > - "_", line!(),
>> > - "_", stringify!($table_name))
>> > + concat!("__mod_device_table__", line!(),
>>
>> Why do we have line!() between "__mod_device_table__" and "__kmod_", while the
>> format is defined as "__mod_device_table__kmod_<modname>__<type>__<name>" above?
>
> The "__mod_device_table__" is used to filter symbols.
> The meaning part starts after "__kmod_" part. After that, order becomes
> important.
>
>> The previous logic was to create a unique name with
>> using "<module_path>_<line>_<table_name>" as "<name>". So, I think this should
>> actually be:
>>
>> concat!("__mod_device_table__kmod_",
>> module_path!(),
>> "__", $table_type,
>> "__", stringify!($table_name),
>> "_", line!())
>>
>> rather than the below.
>
> No. "stringify!($table_name)" should be the last thing in this string.
> This is the a symbol name that will be searched for in the elf to generate
> modalias.
$table_name is not guaranteed to be unique for a certain module_path!(), hence
we need line!() to guarantee uniqueness.
The symbol name will be unique no matter where you place line!() of course, but
$table_name + line!() is the unique table name, which I think is what we want?
>>
>> > + "__kmod_", module_path!(),
>> > + "__", $table_type,
>> > + "__", stringify!($table_name))
>> > ]
>> > static $module_table_name: [::core::mem::MaybeUninit<u8>; $table_name.raw_ids().size()] =
>> > unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) };
>>
>
> --
> Rgrds, legion
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v6 6/9] modpost: Add modname to mod_device_table alias
2025-08-14 14:03 ` Danilo Krummrich
@ 2025-08-14 21:46 ` Alexey Gladkov
2025-08-14 22:17 ` Danilo Krummrich
0 siblings, 1 reply; 6+ messages in thread
From: Alexey Gladkov @ 2025-08-14 21:46 UTC (permalink / raw)
To: Danilo Krummrich
Cc: Nathan Chancellor, Nicolas Schier, Masahiro Yamada, Petr Pavlu,
Luis Chamberlain, Sami Tolvanen, Daniel Gomez, linux-kernel,
linux-modules, linux-kbuild, Miguel Ojeda, Andreas Hindborg,
Alex Gaynor, rust-for-linux
On Thu, Aug 14, 2025 at 04:03:01PM +0200, Danilo Krummrich wrote:
> On Thu Aug 14, 2025 at 3:54 PM CEST, Alexey Gladkov wrote:
> > On Thu, Aug 14, 2025 at 03:26:53PM +0200, Danilo Krummrich wrote:
> >> On Thu Aug 14, 2025 at 3:07 PM CEST, Alexey Gladkov wrote:
> >> > At this point, if a symbol is compiled as part of the kernel,
> >> > information about which module the symbol belongs to is lost.
> >> >
> >> > To save this it is possible to add the module name to the alias name.
> >> > It's not very pretty, but it's possible for now.
> >> >
> >> > Cc: Miguel Ojeda <ojeda@kernel.org>
> >> > Cc: Andreas Hindborg <a.hindborg@kernel.org>
> >> > Cc: Danilo Krummrich <dakr@kernel.org>
> >> > Cc: Alex Gaynor <alex.gaynor@gmail.com>
> >> > Cc: rust-for-linux@vger.kernel.org
> >> > Signed-off-by: Alexey Gladkov <legion@kernel.org>
> >> > ---
> >> > include/linux/module.h | 14 +++++++++++++-
> >> > rust/kernel/device_id.rs | 8 ++++----
> >> > scripts/mod/file2alias.c | 18 ++++++++++++++----
> >> > 3 files changed, 31 insertions(+), 9 deletions(-)
> >> >
> >> > diff --git a/include/linux/module.h b/include/linux/module.h
> >> > index 3319a5269d28..e31ee29fac6b 100644
> >> > --- a/include/linux/module.h
> >> > +++ b/include/linux/module.h
> >> > @@ -244,10 +244,22 @@ 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__kmod_<modname>__<type>__<name>
> >> > + * Parts of the string `__kmod_` and `__` are used as delimiters when parsing
> >> > + * a symbol in file2alias.c
> >> > + */
> >> > +#define __mod_device_table(type, name) \
> >> > + __PASTE(__mod_device_table__, \
> >> > + __PASTE(__KBUILD_MODNAME, \
> >> > + __PASTE(__, \
> >> > + __PASTE(type, \
> >> > + __PASTE(__, name)))))
> >> > +
> >> > #ifdef MODULE
> >> > /* Creates an alias so file2alias.c can find device table. */
> >> > #define MODULE_DEVICE_TABLE(type, name) \
> >> > -static typeof(name) __mod_device_table__##type##__##name \
> >> > +static typeof(name) __mod_device_table(type, name) \
> >> > __attribute__ ((used, alias(__stringify(name))))
> >> > #else /* !MODULE */
> >> > #define MODULE_DEVICE_TABLE(type, name)
> >> > diff --git a/rust/kernel/device_id.rs b/rust/kernel/device_id.rs
> >> > index 70d57814ff79..62c42da12e9d 100644
> >> > --- a/rust/kernel/device_id.rs
> >> > +++ b/rust/kernel/device_id.rs
> >> > @@ -195,10 +195,10 @@ macro_rules! module_device_table {
> >> > ($table_type: literal, $module_table_name:ident, $table_name:ident) => {
> >> > #[rustfmt::skip]
> >> > #[export_name =
> >> > - concat!("__mod_device_table__", $table_type,
> >> > - "__", module_path!(),
> >> > - "_", line!(),
> >> > - "_", stringify!($table_name))
> >> > + concat!("__mod_device_table__", line!(),
> >>
> >> Why do we have line!() between "__mod_device_table__" and "__kmod_", while the
> >> format is defined as "__mod_device_table__kmod_<modname>__<type>__<name>" above?
> >
> > The "__mod_device_table__" is used to filter symbols.
> > The meaning part starts after "__kmod_" part. After that, order becomes
> > important.
> >
> >> The previous logic was to create a unique name with
> >> using "<module_path>_<line>_<table_name>" as "<name>". So, I think this should
> >> actually be:
> >>
> >> concat!("__mod_device_table__kmod_",
> >> module_path!(),
> >> "__", $table_type,
> >> "__", stringify!($table_name),
> >> "_", line!())
> >>
> >> rather than the below.
> >
> > No. "stringify!($table_name)" should be the last thing in this string.
> > This is the a symbol name that will be searched for in the elf to generate
> > modalias.
>
> $table_name is not guaranteed to be unique for a certain module_path!(), hence
> we need line!() to guarantee uniqueness.
>
> The symbol name will be unique no matter where you place line!() of course, but
> $table_name + line!() is the unique table name, which I think is what we want?
Again, no. We need the entire symbol to be unique so that the linker
doesn't complain. In fact, this symbol will later be removed from the elf.
It is only needed for the modpost utility.
The modpost requires a format symbol:
__mod_device_table__<random>*__kmod_<modname>__<type>__<name>
"<random>*" may or may not exist. This is a place to add uniqueness if
needed.
The fields "<modname>”, "<type>" and "<name>" must be very specific and
must not be random. These values are used for generation.
>
> >>
> >> > + "__kmod_", module_path!(),
> >> > + "__", $table_type,
> >> > + "__", stringify!($table_name))
> >> > ]
> >> > static $module_table_name: [::core::mem::MaybeUninit<u8>; $table_name.raw_ids().size()] =
> >> > unsafe { ::core::mem::transmute_copy($table_name.raw_ids()) };
> >>
> >
> > --
> > Rgrds, legion
>
--
Rgrds, legion
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v6 6/9] modpost: Add modname to mod_device_table alias
2025-08-14 21:46 ` Alexey Gladkov
@ 2025-08-14 22:17 ` Danilo Krummrich
0 siblings, 0 replies; 6+ messages in thread
From: Danilo Krummrich @ 2025-08-14 22:17 UTC (permalink / raw)
To: Alexey Gladkov
Cc: Nathan Chancellor, Nicolas Schier, Masahiro Yamada, Petr Pavlu,
Luis Chamberlain, Sami Tolvanen, Daniel Gomez, linux-kernel,
linux-modules, linux-kbuild, Miguel Ojeda, Andreas Hindborg,
Alex Gaynor, rust-for-linux
On Thu Aug 14, 2025 at 11:46 PM CEST, Alexey Gladkov wrote:
> Again, no. We need the entire symbol to be unique so that the linker
> doesn't complain. In fact, this symbol will later be removed from the elf.
> It is only needed for the modpost utility.
Gotcha -- I think I got confused; for the device ID parts:
Acked-by: Danilo Krummrich <dakr@kernel.org>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-08-14 22:17 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1755170493.git.legion@kernel.org>
2025-08-14 13:07 ` [PATCH v6 6/9] modpost: Add modname to mod_device_table alias Alexey Gladkov
2025-08-14 13:26 ` Danilo Krummrich
2025-08-14 13:54 ` Alexey Gladkov
2025-08-14 14:03 ` Danilo Krummrich
2025-08-14 21:46 ` Alexey Gladkov
2025-08-14 22:17 ` Danilo Krummrich
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).