diff options
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r-- | scripts/mod/modpost.c | 29 |
1 files changed, 15 insertions, 14 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 442d5e2ad688..936d3ad23c83 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -166,7 +166,7 @@ struct symbol { | |||
166 | struct module *module; | 166 | struct module *module; |
167 | unsigned int crc; | 167 | unsigned int crc; |
168 | int crc_valid; | 168 | int crc_valid; |
169 | const char *namespace; | 169 | char *namespace; |
170 | unsigned int weak:1; | 170 | unsigned int weak:1; |
171 | unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ | 171 | unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ |
172 | unsigned int kernel:1; /* 1 if symbol is from kernel | 172 | unsigned int kernel:1; /* 1 if symbol is from kernel |
@@ -348,20 +348,18 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec) | |||
348 | return export_unknown; | 348 | return export_unknown; |
349 | } | 349 | } |
350 | 350 | ||
351 | static const char *sym_extract_namespace(const char **symname) | 351 | static char *sym_extract_namespace(const char **symname) |
352 | { | 352 | { |
353 | size_t n; | 353 | char *namespace = NULL; |
354 | char *dupsymname; | 354 | char *ns_separator; |
355 | 355 | ||
356 | n = strcspn(*symname, "."); | 356 | ns_separator = strchr(*symname, '.'); |
357 | if (n < strlen(*symname) - 1) { | 357 | if (ns_separator) { |
358 | dupsymname = NOFAIL(strdup(*symname)); | 358 | namespace = NOFAIL(strndup(*symname, ns_separator - *symname)); |
359 | dupsymname[n] = '\0'; | 359 | *symname = ns_separator + 1; |
360 | *symname = dupsymname; | ||
361 | return dupsymname + n + 1; | ||
362 | } | 360 | } |
363 | 361 | ||
364 | return NULL; | 362 | return namespace; |
365 | } | 363 | } |
366 | 364 | ||
367 | /** | 365 | /** |
@@ -375,7 +373,6 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace, | |||
375 | 373 | ||
376 | if (!s) { | 374 | if (!s) { |
377 | s = new_symbol(name, mod, export); | 375 | s = new_symbol(name, mod, export); |
378 | s->namespace = namespace; | ||
379 | } else { | 376 | } else { |
380 | if (!s->preloaded) { | 377 | if (!s->preloaded) { |
381 | warn("%s: '%s' exported twice. Previous export was in %s%s\n", | 378 | warn("%s: '%s' exported twice. Previous export was in %s%s\n", |
@@ -386,6 +383,8 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace, | |||
386 | s->module = mod; | 383 | s->module = mod; |
387 | } | 384 | } |
388 | } | 385 | } |
386 | free(s->namespace); | ||
387 | s->namespace = namespace ? strdup(namespace) : NULL; | ||
389 | s->preloaded = 0; | 388 | s->preloaded = 0; |
390 | s->vmlinux = is_vmlinux(mod->name); | 389 | s->vmlinux = is_vmlinux(mod->name); |
391 | s->kernel = 0; | 390 | s->kernel = 0; |
@@ -672,7 +671,8 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
672 | unsigned int crc; | 671 | unsigned int crc; |
673 | enum export export; | 672 | enum export export; |
674 | bool is_crc = false; | 673 | bool is_crc = false; |
675 | const char *name, *namespace; | 674 | const char *name; |
675 | char *namespace; | ||
676 | 676 | ||
677 | if ((!is_vmlinux(mod->name) || mod->is_dot_o) && | 677 | if ((!is_vmlinux(mod->name) || mod->is_dot_o) && |
678 | strstarts(symname, "__ksymtab")) | 678 | strstarts(symname, "__ksymtab")) |
@@ -747,6 +747,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, | |||
747 | name = symname + strlen("__ksymtab_"); | 747 | name = symname + strlen("__ksymtab_"); |
748 | namespace = sym_extract_namespace(&name); | 748 | namespace = sym_extract_namespace(&name); |
749 | sym_add_exported(name, namespace, mod, export); | 749 | sym_add_exported(name, namespace, mod, export); |
750 | free(namespace); | ||
750 | } | 751 | } |
751 | if (strcmp(symname, "init_module") == 0) | 752 | if (strcmp(symname, "init_module") == 0) |
752 | mod->has_init = 1; | 753 | mod->has_init = 1; |
@@ -2195,7 +2196,7 @@ static int check_exports(struct module *mod) | |||
2195 | else | 2196 | else |
2196 | basename = mod->name; | 2197 | basename = mod->name; |
2197 | 2198 | ||
2198 | if (exp->namespace) { | 2199 | if (exp->namespace && exp->namespace[0]) { |
2199 | add_namespace(&mod->required_namespaces, | 2200 | add_namespace(&mod->required_namespaces, |
2200 | exp->namespace); | 2201 | exp->namespace); |
2201 | 2202 | ||