Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'modules-for-v5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux

Pull modules fixes from Jessica Yu:

- Revert __ksymtab_$namespace.$symbol naming scheme back to
__ksymtab_$symbol, as it was causing issues with depmod.

Instead, have modpost extract a symbol's namespace from __kstrtabns
and __ksymtab_strings.

- Fix `make nsdeps` for out of tree kernel builds (make O=...) caused
by unescaped '/'.

Use a different sed delimiter to avoid this problem.

* tag 'modules-for-v5.4-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux:
scripts/nsdeps: use alternative sed delimiter
symbol namespaces: revert to previous __ksymtab name scheme
modpost: make updating the symbol namespace explicit
modpost: delegate updating namespaces to separate function

+47 -29
+5 -9
include/linux/export.h
··· 18 18 #define THIS_MODULE ((struct module *)0) 19 19 #endif 20 20 21 - #define NS_SEPARATOR "." 22 - 23 21 #ifdef CONFIG_MODVERSIONS 24 22 /* Mark the CRC weak since genksyms apparently decides not to 25 23 * generate a checksums for some symbols */ ··· 46 48 * absolute relocations that require runtime processing on relocatable 47 49 * kernels. 48 50 */ 49 - #define __KSYMTAB_ENTRY_NS(sym, sec, ns) \ 51 + #define __KSYMTAB_ENTRY_NS(sym, sec) \ 50 52 __ADDRESSABLE(sym) \ 51 53 asm(" .section \"___ksymtab" sec "+" #sym "\", \"a\" \n" \ 52 54 " .balign 4 \n" \ 53 - "__ksymtab_" #ns NS_SEPARATOR #sym ": \n" \ 55 + "__ksymtab_" #sym ": \n" \ 54 56 " .long " #sym "- . \n" \ 55 57 " .long __kstrtab_" #sym "- . \n" \ 56 58 " .long __kstrtabns_" #sym "- . \n" \ ··· 72 74 int namespace_offset; 73 75 }; 74 76 #else 75 - #define __KSYMTAB_ENTRY_NS(sym, sec, ns) \ 76 - static const struct kernel_symbol __ksymtab_##sym##__##ns \ 77 - asm("__ksymtab_" #ns NS_SEPARATOR #sym) \ 77 + #define __KSYMTAB_ENTRY_NS(sym, sec) \ 78 + static const struct kernel_symbol __ksymtab_##sym \ 78 79 __attribute__((section("___ksymtab" sec "+" #sym), used)) \ 79 80 __aligned(sizeof(void *)) \ 80 81 = { (unsigned long)&sym, __kstrtab_##sym, __kstrtabns_##sym } 81 82 82 83 #define __KSYMTAB_ENTRY(sym, sec) \ 83 84 static const struct kernel_symbol __ksymtab_##sym \ 84 - asm("__ksymtab_" #sym) \ 85 85 __attribute__((section("___ksymtab" sec "+" #sym), used)) \ 86 86 __aligned(sizeof(void *)) \ 87 87 = { (unsigned long)&sym, __kstrtab_##sym, NULL } ··· 111 115 static const char __kstrtabns_##sym[] \ 112 116 __attribute__((section("__ksymtab_strings"), used, aligned(1))) \ 113 117 = #ns; \ 114 - __KSYMTAB_ENTRY_NS(sym, sec, ns) 118 + __KSYMTAB_ENTRY_NS(sym, sec) 115 119 116 120 #define ___EXPORT_SYMBOL(sym, sec) \ 117 121 ___export_symbol_common(sym, sec); \
+40 -19
scripts/mod/modpost.c
··· 348 348 return export_unknown; 349 349 } 350 350 351 - static char *sym_extract_namespace(const char **symname) 351 + static const char *namespace_from_kstrtabns(struct elf_info *info, 352 + Elf_Sym *kstrtabns) 352 353 { 353 - char *namespace = NULL; 354 - char *ns_separator; 354 + char *value = info->ksymtab_strings + kstrtabns->st_value; 355 + return value[0] ? value : NULL; 356 + } 355 357 356 - ns_separator = strchr(*symname, '.'); 357 - if (ns_separator) { 358 - namespace = NOFAIL(strndup(*symname, ns_separator - *symname)); 359 - *symname = ns_separator + 1; 358 + static void sym_update_namespace(const char *symname, const char *namespace) 359 + { 360 + struct symbol *s = find_symbol(symname); 361 + 362 + /* 363 + * That symbol should have been created earlier and thus this is 364 + * actually an assertion. 365 + */ 366 + if (!s) { 367 + merror("Could not update namespace(%s) for symbol %s\n", 368 + namespace, symname); 369 + return; 360 370 } 361 371 362 - return namespace; 372 + free(s->namespace); 373 + s->namespace = 374 + namespace && namespace[0] ? NOFAIL(strdup(namespace)) : NULL; 363 375 } 364 376 365 377 /** 366 378 * Add an exported symbol - it may have already been added without a 367 379 * CRC, in this case just update the CRC 368 380 **/ 369 - static struct symbol *sym_add_exported(const char *name, const char *namespace, 370 - struct module *mod, enum export export) 381 + static struct symbol *sym_add_exported(const char *name, struct module *mod, 382 + enum export export) 371 383 { 372 384 struct symbol *s = find_symbol(name); 373 385 ··· 395 383 s->module = mod; 396 384 } 397 385 } 398 - free(s->namespace); 399 - s->namespace = namespace ? strdup(namespace) : NULL; 400 386 s->preloaded = 0; 401 387 s->vmlinux = is_vmlinux(mod->name); 402 388 s->kernel = 0; ··· 593 583 info->export_unused_gpl_sec = i; 594 584 else if (strcmp(secname, "__ksymtab_gpl_future") == 0) 595 585 info->export_gpl_future_sec = i; 586 + else if (strcmp(secname, "__ksymtab_strings") == 0) 587 + info->ksymtab_strings = (void *)hdr + 588 + sechdrs[i].sh_offset - 589 + sechdrs[i].sh_addr; 596 590 597 591 if (sechdrs[i].sh_type == SHT_SYMTAB) { 598 592 unsigned int sh_link_idx; ··· 686 672 enum export export; 687 673 bool is_crc = false; 688 674 const char *name; 689 - char *namespace; 690 675 691 676 if ((!is_vmlinux(mod->name) || mod->is_dot_o) && 692 677 strstarts(symname, "__ksymtab")) ··· 758 745 /* All exported symbols */ 759 746 if (strstarts(symname, "__ksymtab_")) { 760 747 name = symname + strlen("__ksymtab_"); 761 - namespace = sym_extract_namespace(&name); 762 - sym_add_exported(name, namespace, mod, export); 763 - free(namespace); 748 + sym_add_exported(name, mod, export); 764 749 } 765 750 if (strcmp(symname, "init_module") == 0) 766 751 mod->has_init = 1; ··· 2054 2043 handle_moddevtable(mod, &info, sym, symname); 2055 2044 } 2056 2045 2046 + /* Apply symbol namespaces from __kstrtabns_<symbol> entries. */ 2047 + for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { 2048 + symname = remove_dot(info.strtab + sym->st_name); 2049 + 2050 + if (strstarts(symname, "__kstrtabns_")) 2051 + sym_update_namespace(symname + strlen("__kstrtabns_"), 2052 + namespace_from_kstrtabns(&info, 2053 + sym)); 2054 + } 2055 + 2057 2056 // check for static EXPORT_SYMBOL_* functions && global vars 2058 2057 for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { 2059 2058 unsigned char bind = ELF_ST_BIND(sym->st_info); ··· 2217 2196 else 2218 2197 basename = mod->name; 2219 2198 2220 - if (exp->namespace && exp->namespace[0]) { 2199 + if (exp->namespace) { 2221 2200 add_namespace(&mod->required_namespaces, 2222 2201 exp->namespace); 2223 2202 ··· 2475 2454 mod = new_module(modname); 2476 2455 mod->skip = 1; 2477 2456 } 2478 - s = sym_add_exported(symname, namespace, mod, 2479 - export_no(export)); 2457 + s = sym_add_exported(symname, mod, export_no(export)); 2480 2458 s->kernel = kernel; 2481 2459 s->preloaded = 1; 2482 2460 s->is_static = 0; 2483 2461 sym_update_crc(symname, mod, crc, export_no(export)); 2462 + sym_update_namespace(symname, namespace); 2484 2463 } 2485 2464 release_file(file, size); 2486 2465 return;
+1
scripts/mod/modpost.h
··· 143 143 Elf_Section export_gpl_sec; 144 144 Elf_Section export_unused_gpl_sec; 145 145 Elf_Section export_gpl_future_sec; 146 + char *ksymtab_strings; 146 147 char *strtab; 147 148 char *modinfo; 148 149 unsigned int modinfo_len;
+1 -1
scripts/nsdeps
··· 33 33 if [ ! -f "$ns_deps_file" ]; then return; fi 34 34 local mod_source_files=`cat $mod_file | sed -n 1p \ 35 35 | sed -e 's/\.o/\.c/g' \ 36 - | sed "s/[^ ]* */${srctree}\/&/g"` 36 + | sed "s|[^ ]* *|${srctree}/&|g"` 37 37 for ns in `cat $ns_deps_file`; do 38 38 echo "Adding namespace $ns to module $mod_name (if needed)." 39 39 generate_deps_for_ns $ns $mod_source_files