mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
Modules fixes for v5.4-rc3
- Fix broken external module builds due to a modpost bug in read_dump(), where the namespace was not being strdup'd and sym->namespace would be set to bogus data. - Various namespace-related kbuild fixes and cleanups thanks to Masahiro Yamada. Signed-off-by: Jessica Yu <jeyu@kernel.org> -----BEGIN PGP SIGNATURE----- iQIcBAABCgAGBQJdoKV/AAoJEMBFfjjOO8FyrmEP/0jDzB0qkLF0oZe+Bc76qogY IK2/qF1GFrtyIBMzCNMb5ds+2K/iGTxbW1wXRWChHOr2knTyJ00R6YPahYvovOgR FgIYAL4q2fz9idjmZrNg5EiCrsvwBqYixQG7m0R3F5peZ6FqRipXQ61+R/jm2oq4 eS2VrNyuvLle5Be2JZgA9/gUlQtUSLS7aqSk8MHbbCDGTHU9jMGfuOk+l2txqKQn ryXV9Lj7YfQpV5cr9nJkVw0MIvq7aWXPUrsXwT3mpPTV+003JCw5bpWHvlsJMCfJ kc17gPDz382Vqohk5iJbWULerkMlSI05UVAKhc2KkAuZn2IRz9i0VI1KCMUJdphh d/fhDhkpFWXyWb6A+522V+JSt+Kz2B4N3wUXug4BtWU8dP5Rpp2luCVRGWbJEPiZ eBOkBtp42kLoJSkRzOGIZKAVUdb0f5hWRhtBXUSY64JYLv+4WpB/xZvf3mgfBWmh 9r0siZ9Jkd9Bfl87AymHIGzhR2jnVAyIFn+eKfS/L/hPt/8ouEhL2VsEfRAkHYtq wx5Bm1F6hP07YpUoAQU8t2I3vxw7p6emlW/YwsZEWfiq1RZepbO3NxT8xoxLjG8J GCoh2ZXKLENA5GumkA9PR6vvP3VoOS54DIukeWcCGzfUPedNI3muSvJmGbWvVcix 1k4mI4jDYAaD9oXh8YZv =Ebck -----END PGP SIGNATURE----- Merge tag 'modules-for-v5.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux Pull module fixes from Jessica Yu: "Code cleanups and kbuild/namespace related fixups from Masahiro. Most importantly, it fixes a namespace-related modpost issue for external module builds - Fix broken external module builds due to a modpost bug in read_dump(), where the namespace was not being strdup'd and sym->namespace would be set to bogus data. - Various namespace-related kbuild fixes and cleanups thanks to Masahiro Yamada" * tag 'modules-for-v5.4-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/jeyu/linux: doc: move namespaces.rst from kbuild/ to core-api/ nsdeps: make generated patches independent of locale nsdeps: fix hashbang of scripts/nsdeps kbuild: fix build error of 'make nsdeps' in clean tree module: rename __kstrtab_ns_* to __kstrtabns_* to avoid symbol conflict modpost: fix broken sym->namespace for external module builds module: swap the order of symbol.namespace scripts: add_namespace: Fix coccicheck failed
This commit is contained in:
commit
c6f6ebd77c
8 changed files with 27 additions and 22 deletions
|
@ -6,6 +6,8 @@
|
|||
/// add a missing namespace tag to a module source file.
|
||||
///
|
||||
|
||||
virtual report
|
||||
|
||||
@has_ns_import@
|
||||
declarer name MODULE_IMPORT_NS;
|
||||
identifier virtual.ns;
|
||||
|
|
|
@ -166,7 +166,7 @@ struct symbol {
|
|||
struct module *module;
|
||||
unsigned int crc;
|
||||
int crc_valid;
|
||||
const char *namespace;
|
||||
char *namespace;
|
||||
unsigned int weak:1;
|
||||
unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */
|
||||
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)
|
|||
return export_unknown;
|
||||
}
|
||||
|
||||
static const char *sym_extract_namespace(const char **symname)
|
||||
static char *sym_extract_namespace(const char **symname)
|
||||
{
|
||||
size_t n;
|
||||
char *dupsymname;
|
||||
char *namespace = NULL;
|
||||
char *ns_separator;
|
||||
|
||||
n = strcspn(*symname, ".");
|
||||
if (n < strlen(*symname) - 1) {
|
||||
dupsymname = NOFAIL(strdup(*symname));
|
||||
dupsymname[n] = '\0';
|
||||
*symname = dupsymname;
|
||||
return dupsymname + n + 1;
|
||||
ns_separator = strchr(*symname, '.');
|
||||
if (ns_separator) {
|
||||
namespace = NOFAIL(strndup(*symname, ns_separator - *symname));
|
||||
*symname = ns_separator + 1;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return namespace;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -375,7 +373,6 @@ static struct symbol *sym_add_exported(const char *name, const char *namespace,
|
|||
|
||||
if (!s) {
|
||||
s = new_symbol(name, mod, export);
|
||||
s->namespace = namespace;
|
||||
} else {
|
||||
if (!s->preloaded) {
|
||||
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,
|
|||
s->module = mod;
|
||||
}
|
||||
}
|
||||
free(s->namespace);
|
||||
s->namespace = namespace ? strdup(namespace) : NULL;
|
||||
s->preloaded = 0;
|
||||
s->vmlinux = is_vmlinux(mod->name);
|
||||
s->kernel = 0;
|
||||
|
@ -672,7 +671,8 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
|
|||
unsigned int crc;
|
||||
enum export export;
|
||||
bool is_crc = false;
|
||||
const char *name, *namespace;
|
||||
const char *name;
|
||||
char *namespace;
|
||||
|
||||
if ((!is_vmlinux(mod->name) || mod->is_dot_o) &&
|
||||
strstarts(symname, "__ksymtab"))
|
||||
|
@ -747,6 +747,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
|
|||
name = symname + strlen("__ksymtab_");
|
||||
namespace = sym_extract_namespace(&name);
|
||||
sym_add_exported(name, namespace, mod, export);
|
||||
free(namespace);
|
||||
}
|
||||
if (strcmp(symname, "init_module") == 0)
|
||||
mod->has_init = 1;
|
||||
|
@ -2195,7 +2196,7 @@ static int check_exports(struct module *mod)
|
|||
else
|
||||
basename = mod->name;
|
||||
|
||||
if (exp->namespace) {
|
||||
if (exp->namespace && exp->namespace[0]) {
|
||||
add_namespace(&mod->required_namespaces,
|
||||
exp->namespace);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
#!/bin/sh
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
# Linux kernel symbol namespace import generator
|
||||
#
|
||||
|
@ -41,7 +41,7 @@ generate_deps() {
|
|||
for source_file in $mod_source_files; do
|
||||
sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp
|
||||
offset=$(wc -l ${source_file}.tmp | awk '{print $1;}')
|
||||
cat $source_file | grep MODULE_IMPORT_NS | sort -u >> ${source_file}.tmp
|
||||
cat $source_file | grep MODULE_IMPORT_NS | LANG=C sort -u >> ${source_file}.tmp
|
||||
tail -n +$((offset +1)) ${source_file} | grep -v MODULE_IMPORT_NS >> ${source_file}.tmp
|
||||
if ! diff -q ${source_file} ${source_file}.tmp; then
|
||||
mv ${source_file}.tmp ${source_file}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue