diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/bpf_helpers_doc.py | 4 | ||||
| -rw-r--r-- | scripts/gdb/linux/symbols.py | 3 | ||||
| -rw-r--r-- | scripts/mod/modpost.c | 59 | ||||
| -rw-r--r-- | scripts/mod/modpost.h | 1 | ||||
| -rw-r--r-- | scripts/nsdeps | 6 | ||||
| -rwxr-xr-x | scripts/setlocalversion | 2 | 
6 files changed, 49 insertions, 26 deletions
| diff --git a/scripts/bpf_helpers_doc.py b/scripts/bpf_helpers_doc.py index 7df9ce598ff9..7548569e8076 100755 --- a/scripts/bpf_helpers_doc.py +++ b/scripts/bpf_helpers_doc.py @@ -488,8 +488,8 @@ class PrinterHelpers(Printer):              return t          if t in self.mapped_types:              return self.mapped_types[t] -        print("") -        print("Unrecognized type '%s', please add it to known types!" % t) +        print("Unrecognized type '%s', please add it to known types!" % t, +              file=sys.stderr)          sys.exit(1)      seen_helpers = set() diff --git a/scripts/gdb/linux/symbols.py b/scripts/gdb/linux/symbols.py index 7b7c2fafbc68..be984aa29b75 100644 --- a/scripts/gdb/linux/symbols.py +++ b/scripts/gdb/linux/symbols.py @@ -99,7 +99,8 @@ lx-symbols command."""              attrs[n]['name'].string(): attrs[n]['address']              for n in range(int(sect_attrs['nsections']))}          args = [] -        for section_name in [".data", ".data..read_mostly", ".rodata", ".bss"]: +        for section_name in [".data", ".data..read_mostly", ".rodata", ".bss", +                             ".text", ".text.hot", ".text.unlikely"]:              address = section_name_to_address.get(section_name)              if address:                  args.append(" -s {name} {addr}".format( diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 936d3ad23c83..d2a30a7b3f07 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -348,26 +348,38 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec)  		return export_unknown;  } -static char *sym_extract_namespace(const char **symname) +static const char *namespace_from_kstrtabns(struct elf_info *info, +					    Elf_Sym *kstrtabns)  { -	char *namespace = NULL; -	char *ns_separator; +	char *value = info->ksymtab_strings + kstrtabns->st_value; +	return value[0] ? value : NULL; +} + +static void sym_update_namespace(const char *symname, const char *namespace) +{ +	struct symbol *s = find_symbol(symname); -	ns_separator = strchr(*symname, '.'); -	if (ns_separator) { -		namespace = NOFAIL(strndup(*symname, ns_separator - *symname)); -		*symname = ns_separator + 1; +	/* +	 * That symbol should have been created earlier and thus this is +	 * actually an assertion. +	 */ +	if (!s) { +		merror("Could not update namespace(%s) for symbol %s\n", +		       namespace, symname); +		return;  	} -	return namespace; +	free(s->namespace); +	s->namespace = +		namespace && namespace[0] ? NOFAIL(strdup(namespace)) : NULL;  }  /**   * 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); @@ -383,8 +395,6 @@ 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; @@ -583,6 +593,10 @@ static int parse_elf(struct elf_info *info, const char *filename)  			info->export_unused_gpl_sec = i;  		else if (strcmp(secname, "__ksymtab_gpl_future") == 0)  			info->export_gpl_future_sec = i; +		else if (strcmp(secname, "__ksymtab_strings") == 0) +			info->ksymtab_strings = (void *)hdr + +						sechdrs[i].sh_offset - +						sechdrs[i].sh_addr;  		if (sechdrs[i].sh_type == SHT_SYMTAB) {  			unsigned int sh_link_idx; @@ -672,7 +686,6 @@ static void handle_modversions(struct module *mod, struct elf_info *info,  	enum export export;  	bool is_crc = false;  	const char *name; -	char *namespace;  	if ((!is_vmlinux(mod->name) || mod->is_dot_o) &&  	    strstarts(symname, "__ksymtab")) @@ -745,9 +758,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info,  		/* All exported symbols */  		if (strstarts(symname, "__ksymtab_")) {  			name = symname + strlen("__ksymtab_"); -			namespace = sym_extract_namespace(&name); -			sym_add_exported(name, namespace, mod, export); -			free(namespace); +			sym_add_exported(name, mod, export);  		}  		if (strcmp(symname, "init_module") == 0)  			mod->has_init = 1; @@ -2043,6 +2054,16 @@ static void read_symbols(const char *modname)  		handle_moddevtable(mod, &info, sym, symname);  	} +	/* Apply symbol namespaces from __kstrtabns_<symbol> entries. */ +	for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { +		symname = remove_dot(info.strtab + sym->st_name); + +		if (strstarts(symname, "__kstrtabns_")) +			sym_update_namespace(symname + strlen("__kstrtabns_"), +					     namespace_from_kstrtabns(&info, +								      sym)); +	} +  	// check for static EXPORT_SYMBOL_* functions && global vars  	for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {  		unsigned char bind = ELF_ST_BIND(sym->st_info); @@ -2196,7 +2217,7 @@ static int check_exports(struct module *mod)  		else  			basename = mod->name; -		if (exp->namespace && exp->namespace[0]) { +		if (exp->namespace) {  			add_namespace(&mod->required_namespaces,  				      exp->namespace); @@ -2454,12 +2475,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; diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 92a926d375d2..ad271bc6c313 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -143,6 +143,7 @@ struct elf_info {  	Elf_Section  export_gpl_sec;  	Elf_Section  export_unused_gpl_sec;  	Elf_Section  export_gpl_future_sec; +	char	     *ksymtab_strings;  	char         *strtab;  	char	     *modinfo;  	unsigned int modinfo_len; diff --git a/scripts/nsdeps b/scripts/nsdeps index 3754dac13b31..04cea0921673 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -31,12 +31,12 @@ generate_deps() {  	local mod_file=`echo $@ | sed -e 's/\.ko/\.mod/'`  	local ns_deps_file=`echo $@ | sed -e 's/\.ko/\.ns_deps/'`  	if [ ! -f "$ns_deps_file" ]; then return; fi -	local mod_source_files=`cat $mod_file | sed -n 1p                      \ +	local mod_source_files="`cat $mod_file | sed -n 1p                      \  					      | sed -e 's/\.o/\.c/g'           \ -					      | sed "s/[^ ]* */${srctree}\/&/g"` +					      | sed "s|[^ ]* *|${srctree}/&|g"`"  	for ns in `cat $ns_deps_file`; do  		echo "Adding namespace $ns to module $mod_name (if needed)." -		generate_deps_for_ns $ns $mod_source_files +		generate_deps_for_ns $ns "$mod_source_files"  		# sort the imports  		for source_file in $mod_source_files; do  			sed '/MODULE_IMPORT_NS/Q' $source_file > ${source_file}.tmp diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 220dae0db3f1..a2998b118ef9 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -93,7 +93,7 @@ scm_version()  	# Check for mercurial and a mercurial repo.  	if test -d .hg && hgid=`hg id 2>/dev/null`; then  		# Do we have an tagged version?  If so, latesttagdistance == 1 -		if [ "`hg log -r . --template '{latesttagdistance}'`" == "1" ]; then +		if [ "`hg log -r . --template '{latesttagdistance}'`" = "1" ]; then  			id=`hg log -r . --template '{latesttag}'`  			printf '%s%s' -hg "$id"  		else | 
