[2/4] modpost: make updating the symbol namespace explict
diff mbox series

Message ID 20191010151443.7399-3-maennich@google.com
State New
Headers show
Series
  • export/modpost: avoid renaming __ksymtab entries for symbol namespaces
Related show

Commit Message

Matthias Maennich Oct. 10, 2019, 3:14 p.m. UTC
Setting the symbol namespace of a symbol within sym_add_exported feels
displaced and lead to issues in the current implementation of symbol
namespaces. This patch makes updating the namespace an explicit call to
decouple it from adding a symbol to the export list.

Signed-off-by: Matthias Maennich <maennich@google.com>
---
 scripts/mod/modpost.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Will Deacon Oct. 11, 2019, 2:24 p.m. UTC | #1
On Thu, Oct 10, 2019 at 04:14:41PM +0100, Matthias Maennich wrote:
> Setting the symbol namespace of a symbol within sym_add_exported feels
> displaced and lead to issues in the current implementation of symbol
> namespaces. This patch makes updating the namespace an explicit call to
> decouple it from adding a symbol to the export list.
> 
> Signed-off-by: Matthias Maennich <maennich@google.com>
> ---
>  scripts/mod/modpost.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 9f5dcdff4d2f..46137b730447 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -382,8 +382,8 @@ static void sym_update_namespace(const char *symname, const char *namespace)
>   * Add an exported symbol - it may have already been added without a
>   * CRC, in this case just update the CRC
>   **/
> -static struct symbol *sym_add_exported(const char *name, const char *namespace,
> -				       struct module *mod, enum export export)
> +static struct symbol *sym_add_exported(const char *name, struct module *mod,
> +				       enum export export)
>  {
>  	struct symbol *s = find_symbol(name);
>  
> @@ -399,7 +399,6 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace,
>  			s->module = mod;
>  		}
>  	}
> -	sym_update_namespace(name, namespace);
>  	s->preloaded = 0;
>  	s->vmlinux   = is_vmlinux(mod->name);
>  	s->kernel    = 0;
> @@ -761,7 +760,8 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
>  		if (strstarts(symname, "__ksymtab_")) {
>  			name = symname + strlen("__ksymtab_");
>  			namespace = sym_extract_namespace(&name);
> -			sym_add_exported(name, namespace, mod, export);
> +			sym_add_exported(name, mod, export);
> +			sym_update_namespace(name, namespace);
>  			free(namespace);
>  		}
>  		if (strcmp(symname, "init_module") == 0)
> @@ -2469,12 +2469,12 @@ static void read_dump(const char *fname, unsigned int kernel)
>  			mod = new_module(modname);
>  			mod->skip = 1;
>  		}
> -		s = sym_add_exported(symname, namespace, mod,
> -				     export_no(export));
> +		s = sym_add_exported(symname, mod, export_no(export));
>  		s->kernel    = kernel;
>  		s->preloaded = 1;
>  		s->is_static = 0;
>  		sym_update_crc(symname, mod, crc, export_no(export));
> +		sym_update_namespace(symname, namespace);

This changes the order wrt setting the namespace and sym_update_crc(), but
that doesn't seem to matter, so:

Acked-by: Will Deacon <will@kernel.org>

Will
Greg Kroah-Hartman Oct. 11, 2019, 3:33 p.m. UTC | #2
On Thu, Oct 10, 2019 at 04:14:41PM +0100, Matthias Maennich wrote:
> Setting the symbol namespace of a symbol within sym_add_exported feels
> displaced and lead to issues in the current implementation of symbol
> namespaces. This patch makes updating the namespace an explicit call to
> decouple it from adding a symbol to the export list.
> 
> Signed-off-by: Matthias Maennich <maennich@google.com>

Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Masahiro Yamada Oct. 12, 2019, 3:22 a.m. UTC | #3
On Fri, Oct 11, 2019 at 12:16 AM Matthias Maennich <maennich@google.com> wrote:
>
> Setting the symbol namespace of a symbol within sym_add_exported feels
> displaced and lead to issues in the current implementation of symbol
> namespaces. This patch makes updating the namespace an explicit call to
> decouple it from adding a symbol to the export list.
>
> Signed-off-by: Matthias Maennich <maennich@google.com>
> ---


Reviewed-by: Masahiro Yamada <yamada.masahiro@socionext.com>



>  scripts/mod/modpost.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 9f5dcdff4d2f..46137b730447 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -382,8 +382,8 @@ static void sym_update_namespace(const char *symname, const char *namespace)
>   * Add an exported symbol - it may have already been added without a
>   * CRC, in this case just update the CRC
>   **/
> -static struct symbol *sym_add_exported(const char *name, const char *namespace,
> -                                      struct module *mod, enum export export)
> +static struct symbol *sym_add_exported(const char *name, struct module *mod,
> +                                      enum export export)
>  {
>         struct symbol *s = find_symbol(name);
>
> @@ -399,7 +399,6 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace,
>                         s->module = mod;
>                 }
>         }
> -       sym_update_namespace(name, namespace);
>         s->preloaded = 0;
>         s->vmlinux   = is_vmlinux(mod->name);
>         s->kernel    = 0;
> @@ -761,7 +760,8 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
>                 if (strstarts(symname, "__ksymtab_")) {
>                         name = symname + strlen("__ksymtab_");
>                         namespace = sym_extract_namespace(&name);
> -                       sym_add_exported(name, namespace, mod, export);
> +                       sym_add_exported(name, mod, export);
> +                       sym_update_namespace(name, namespace);
>                         free(namespace);
>                 }
>                 if (strcmp(symname, "init_module") == 0)
> @@ -2469,12 +2469,12 @@ static void read_dump(const char *fname, unsigned int kernel)
>                         mod = new_module(modname);
>                         mod->skip = 1;
>                 }
> -               s = sym_add_exported(symname, namespace, mod,
> -                                    export_no(export));
> +               s = sym_add_exported(symname, mod, export_no(export));
>                 s->kernel    = kernel;
>                 s->preloaded = 1;
>                 s->is_static = 0;
>                 sym_update_crc(symname, mod, crc, export_no(export));
> +               sym_update_namespace(symname, namespace);
>         }
>         release_file(file, size);
>         return;
> --
> 2.23.0.581.g78d2f28ef7-goog
>

Patch
diff mbox series

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 9f5dcdff4d2f..46137b730447 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -382,8 +382,8 @@  static void sym_update_namespace(const char *symname, const char *namespace)
  * Add an exported symbol - it may have already been added without a
  * CRC, in this case just update the CRC
  **/
-static struct symbol *sym_add_exported(const char *name, const char *namespace,
-				       struct module *mod, enum export export)
+static struct symbol *sym_add_exported(const char *name, struct module *mod,
+				       enum export export)
 {
 	struct symbol *s = find_symbol(name);
 
@@ -399,7 +399,6 @@  static struct symbol *sym_add_exported(const char *name, const char *namespace,
 			s->module = mod;
 		}
 	}
-	sym_update_namespace(name, namespace);
 	s->preloaded = 0;
 	s->vmlinux   = is_vmlinux(mod->name);
 	s->kernel    = 0;
@@ -761,7 +760,8 @@  static void handle_modversions(struct module *mod, struct elf_info *info,
 		if (strstarts(symname, "__ksymtab_")) {
 			name = symname + strlen("__ksymtab_");
 			namespace = sym_extract_namespace(&name);
-			sym_add_exported(name, namespace, mod, export);
+			sym_add_exported(name, mod, export);
+			sym_update_namespace(name, namespace);
 			free(namespace);
 		}
 		if (strcmp(symname, "init_module") == 0)
@@ -2469,12 +2469,12 @@  static void read_dump(const char *fname, unsigned int kernel)
 			mod = new_module(modname);
 			mod->skip = 1;
 		}
-		s = sym_add_exported(symname, namespace, mod,
-				     export_no(export));
+		s = sym_add_exported(symname, mod, export_no(export));
 		s->kernel    = kernel;
 		s->preloaded = 1;
 		s->is_static = 0;
 		sym_update_crc(symname, mod, crc, export_no(export));
+		sym_update_namespace(symname, namespace);
 	}
 	release_file(file, size);
 	return;