From b3aa58d2e85d5253a35a81320ae4d63ba6a482f0 Mon Sep 17 00:00:00 2001 From: Nicolas Pitre Date: Mon, 16 Apr 2018 15:07:57 -0400 Subject: fixdep: suppress consecutive / from file paths in dependency list files Underscores in symbol names are translated into slashes for path names. Filesystems treat consecutive slashes as if there was only one, so let's do the same in the dependency list for easier grepping, etc. Signed-off-by: Nicolas Pitre Signed-off-by: Masahiro Yamada --- scripts/basic/fixdep.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index f387538c58bc..850966f3d602 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -115,7 +115,7 @@ static void usage(void) */ static void print_dep(const char *m, int slen, const char *dir) { - int c, i; + int c, prev_c = '/', i; printf(" $(wildcard %s/", dir); for (i = 0; i < slen; i++) { @@ -124,7 +124,9 @@ static void print_dep(const char *m, int slen, const char *dir) c = '/'; else c = tolower(c); - putchar(c); + if (c != '/' || prev_c != '/') + putchar(c); + prev_c = c; } printf(".h) \\\n"); } -- cgit v1.2.3 From d5940c60e0575ad666132a612a73e6597f90d4c3 Mon Sep 17 00:00:00 2001 From: Riku Voipio Date: Mon, 7 May 2018 10:11:34 +0300 Subject: kbuild: deb-pkg improve maintainer address generation There is multiple issues with the genaration of maintainer string It uses DEBEMAIL and EMAIL enviroment variables, which may contain angle brackets, creating invalid maintainer strings. The documented KBUILD_BUILD_USER and KBUILD_BUILD_HOST variables are not used. Undocumented and uncommon NAME variable is used. Refactor the Maintainer string to: - use EMAIL or DEBEMAIL directly if they are in form "name " - use KBUILD_BUILD_USER and KBUILD_BUILD_HOST if set before falling back to autodetection - no longer use NAME variable or the useless Anonymous string The logic is switched from multiline if/then/fi statements to compact shell variable substition commands. Reported-by: Mathieu Malaterre Signed-off-by: Riku Voipio Signed-off-by: Masahiro Yamada --- scripts/package/mkdebian | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian index 6adb3a16ba3b..985d72d1ab34 100755 --- a/scripts/package/mkdebian +++ b/scripts/package/mkdebian @@ -71,22 +71,21 @@ if [ "$ARCH" = "um" ] ; then packagename=user-mode-linux-$version fi -# Try to determine maintainer and email values -if [ -n "$DEBEMAIL" ]; then - email=$DEBEMAIL -elif [ -n "$EMAIL" ]; then - email=$EMAIL -else - email=$(id -nu)@$(hostname -f 2>/dev/null || hostname) -fi -if [ -n "$DEBFULLNAME" ]; then - name=$DEBFULLNAME -elif [ -n "$NAME" ]; then - name=$NAME +email=${DEBEMAIL-$EMAIL} + +# use email string directly if it contains +if echo $email | grep -q '<.*>'; then + maintainer=$email else - name="Anonymous" + # or construct the maintainer string + user=${KBUILD_BUILD_USER-$(id -nu)} + name=${DEBFULLNAME-$user} + if [ -z "$email" ]; then + buildhost=${KBUILD_BUILD_HOST-$(hostname -f 2>/dev/null || hostname)} + email="$user@$buildhost" + fi + maintainer="$name <$email>" fi -maintainer="$name <$email>" # Try to determine distribution if [ -n "$KDEB_CHANGELOG_DIST" ]; then -- cgit v1.2.3 From b2c5cdcfd4bcc1fbf1caefe7f3ff909bcee10a6c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 16:23:45 +0900 Subject: modpost: remove symbol prefix support CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX was selected by BLACKFIN, METAG. They were removed by commit 4ba66a976072 ("arch: remove blackfin port"), commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively. No more architecture enables CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX, hence VMLINUX_SYMBOL_STR(foo) can be simplify replaced with "foo". Signed-off-by: Masahiro Yamada Reviewed-by: Sam Ravnborg --- scripts/mod/modpost.c | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 4ff08a0ef5d3..bc71925d4e9b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -19,9 +19,7 @@ #include #include #include "modpost.h" -#include "../../include/generated/autoconf.h" #include "../../include/linux/license.h" -#include "../../include/linux/export.h" /* Are we using CONFIG_MODVERSIONS? */ static int modversions = 0; @@ -591,7 +589,7 @@ static void parse_elf_finish(struct elf_info *info) static int ignore_undef_symbol(struct elf_info *info, const char *symname) { /* ignore __this_module, it will be resolved shortly */ - if (strcmp(symname, VMLINUX_SYMBOL_STR(__this_module)) == 0) + if (strcmp(symname, "__this_module") == 0) return 1; /* ignore global offset table */ if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) @@ -617,9 +615,6 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) return 0; } -#define CRC_PFX VMLINUX_SYMBOL_STR(__crc_) -#define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_) - static void handle_modversions(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) { @@ -634,7 +629,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, export = export_from_sec(info, get_secindex(info, sym)); /* CRC'd symbol */ - if (strncmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { + if (strncmp(symname, "__crc_", strlen("__crc_")) == 0) { is_crc = true; crc = (unsigned int) sym->st_value; if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) { @@ -647,7 +642,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, info->sechdrs[sym->st_shndx].sh_addr : 0); crc = *crcp; } - sym_update_crc(symname + strlen(CRC_PFX), mod, crc, + sym_update_crc(symname + strlen("__crc_"), mod, crc, export); } @@ -685,15 +680,10 @@ static void handle_modversions(struct module *mod, struct elf_info *info, } #endif -#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX - if (symname[0] != '_') - break; - else - symname++; -#endif if (is_crc) { const char *e = is_vmlinux(mod->name) ?"":".ko"; - warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", symname + strlen(CRC_PFX), mod->name, e); + warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", + symname + strlen("__crc_"), mod->name, e); } mod->unres = alloc_symbol(symname, ELF_ST_BIND(sym->st_info) == STB_WEAK, @@ -701,13 +691,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info, break; default: /* All exported symbols */ - if (strncmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { - sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, + if (strncmp(symname, "__ksymtab_", strlen("__ksymtab_")) == 0) { + sym_add_exported(symname + strlen("__ksymtab_"), mod, export); } - if (strcmp(symname, VMLINUX_SYMBOL_STR(init_module)) == 0) + if (strcmp(symname, "init_module") == 0) mod->has_init = 1; - if (strcmp(symname, VMLINUX_SYMBOL_STR(cleanup_module)) == 0) + if (strcmp(symname, "cleanup_module") == 0) mod->has_cleanup = 1; break; } @@ -2230,7 +2220,7 @@ static int add_versions(struct buffer *b, struct module *mod) err = 1; break; } - buf_printf(b, "\t{ %#8x, __VMLINUX_SYMBOL_STR(%s) },\n", + buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name); } -- cgit v1.2.3 From 74d9317161513b63ccb2f58eb866d6e91e13df98 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 16:23:46 +0900 Subject: genksyms: remove symbol prefix support CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX was selected by BLACKFIN, METAG. They were removed by commit 4ba66a976072 ("arch: remove blackfin port"), commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively. No more architecture enables CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX, hence the -s (--symbol-prefix) option is unnecessary. Signed-off-by: Masahiro Yamada Reviewed-by: Sam Ravnborg --- scripts/Makefile.build | 2 -- scripts/genksyms/genksyms.c | 11 +++-------- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 8bdb1dc4072c..22df8d037cf2 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -147,7 +147,6 @@ $(obj)/%.i: $(src)/%.c FORCE cmd_gensymtypes_c = \ $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ $(GENKSYMS) $(if $(1), -T $(2)) \ - $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ $(if $(KBUILD_PRESERVE),-p) \ -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) @@ -355,7 +354,6 @@ cmd_gensymtypes_S = \ sed 's/.*___EXPORT_SYMBOL[[:space:]]*\([a-zA-Z0-9_]*\)[[:space:]]*,.*/EXPORT_SYMBOL(\1);/' ) | \ $(CPP) -D__GENKSYMS__ $(c_flags) -xc - | \ $(GENKSYMS) $(if $(1), -T $(2)) \ - $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \ $(patsubst y,-R,$(CONFIG_MODULE_REL_CRCS)) \ $(if $(KBUILD_PRESERVE),-p) \ -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index c9235d8340f1..e007840f45b9 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -45,7 +45,6 @@ int in_source_file; static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, flag_preserve, flag_warnings, flag_rel_crcs; -static const char *mod_prefix = ""; static int errors; static int nsyms; @@ -693,10 +692,10 @@ void export_symbol(const char *name) fputs(">\n", debugfile); /* Used as a linker script. */ - printf(!flag_rel_crcs ? "%s__crc_%s = 0x%08lx;\n" : + printf(!flag_rel_crcs ? "__crc_%s = 0x%08lx;\n" : "SECTIONS { .rodata : ALIGN(4) { " - "%s__crc_%s = .; LONG(0x%08lx); } }\n", - mod_prefix, name, crc); + "__crc_%s = .; LONG(0x%08lx); } }\n", + name, crc); } } @@ -769,7 +768,6 @@ int main(int argc, char **argv) #ifdef __GNU_LIBRARY__ struct option long_opts[] = { - {"symbol-prefix", 1, 0, 's'}, {"debug", 0, 0, 'd'}, {"warnings", 0, 0, 'w'}, {"quiet", 0, 0, 'q'}, @@ -789,9 +787,6 @@ int main(int argc, char **argv) while ((o = getopt(argc, argv, "s:dwqVDr:T:phR")) != EOF) #endif /* __GNU_LIBRARY__ */ switch (o) { - case 's': - mod_prefix = optarg; - break; case 'd': flag_debug++; break; -- cgit v1.2.3 From 534c9f2ec4c92adbe8791125e7ba66d5023ad51f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 16:23:47 +0900 Subject: kallsyms: remove symbol prefix support CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX was selected by BLACKFIN, METAG. They were removed by commit 4ba66a976072 ("arch: remove blackfin port"), commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively. No more architecture enables CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX, hence the --symbol-prefix option is unnecessary. Signed-off-by: Masahiro Yamada Reviewed-by: Sam Ravnborg --- scripts/kallsyms.c | 47 +++++++++++------------------------------------ scripts/link-vmlinux.sh | 4 ---- 2 files changed, 11 insertions(+), 40 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 5abfbf1b8fe2..80417629b246 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -62,7 +62,6 @@ static struct sym_entry *table; static unsigned int table_size, table_cnt; static int all_symbols = 0; static int absolute_percpu = 0; -static char symbol_prefix_char = '\0'; static int base_relative = 0; int token_profit[0x10000]; @@ -75,7 +74,6 @@ unsigned char best_table_len[256]; static void usage(void) { fprintf(stderr, "Usage: kallsyms [--all-symbols] " - "[--symbol-prefix=] " "[--base-relative] < in.map > out.S\n"); exit(1); } @@ -113,28 +111,22 @@ static int check_symbol_range(const char *sym, unsigned long long addr, static int read_symbol(FILE *in, struct sym_entry *s) { - char str[500]; - char *sym, stype; + char sym[500], stype; int rc; - rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str); + rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, sym); if (rc != 3) { - if (rc != EOF && fgets(str, 500, in) == NULL) + if (rc != EOF && fgets(sym, 500, in) == NULL) fprintf(stderr, "Read error or end of file.\n"); return -1; } - if (strlen(str) > KSYM_NAME_LEN) { + if (strlen(sym) > KSYM_NAME_LEN) { fprintf(stderr, "Symbol %s too long for kallsyms (%zu vs %d).\n" "Please increase KSYM_NAME_LEN both in kernel and kallsyms.c\n", - str, strlen(str), KSYM_NAME_LEN); + sym, strlen(sym), KSYM_NAME_LEN); return -1; } - sym = str; - /* skip prefix char */ - if (symbol_prefix_char && str[0] == symbol_prefix_char) - sym++; - /* Ignore most absolute/undefined (?) symbols. */ if (strcmp(sym, "_text") == 0) _text = s->addr; @@ -155,7 +147,7 @@ static int read_symbol(FILE *in, struct sym_entry *s) is_arm_mapping_symbol(sym)) return -1; /* exclude also MIPS ELF local symbols ($L123 instead of .L123) */ - else if (str[0] == '$') + else if (sym[0] == '$') return -1; /* exclude debugging symbols */ else if (stype == 'N' || stype == 'n') @@ -163,14 +155,14 @@ static int read_symbol(FILE *in, struct sym_entry *s) /* include the type field in the symbol name, so that it gets * compressed together */ - s->len = strlen(str) + 1; + s->len = strlen(sym) + 1; s->sym = malloc(s->len + 1); if (!s->sym) { fprintf(stderr, "kallsyms failure: " "unable to allocate required amount of memory\n"); exit(EXIT_FAILURE); } - strcpy((char *)s->sym + 1, str); + strcpy((char *)s->sym + 1, sym); s->sym[0] = stype; s->percpu_absolute = 0; @@ -233,11 +225,6 @@ static int symbol_valid(struct sym_entry *s) int i; char *sym_name = (char *)s->sym + 1; - /* skip prefix char */ - if (symbol_prefix_char && *sym_name == symbol_prefix_char) - sym_name++; - - /* if --all-symbols is not specified, then symbols outside the text * and inittext sections are discarded */ if (!all_symbols) { @@ -302,15 +289,9 @@ static void read_map(FILE *in) static void output_label(char *label) { - if (symbol_prefix_char) - printf(".globl %c%s\n", symbol_prefix_char, label); - else - printf(".globl %s\n", label); + printf(".globl %s\n", label); printf("\tALGN\n"); - if (symbol_prefix_char) - printf("%c%s:\n", symbol_prefix_char, label); - else - printf("%s:\n", label); + printf("%s:\n", label); } /* uncompress a compressed symbol. When this function is called, the best table @@ -768,13 +749,7 @@ int main(int argc, char **argv) all_symbols = 1; else if (strcmp(argv[i], "--absolute-percpu") == 0) absolute_percpu = 1; - else if (strncmp(argv[i], "--symbol-prefix=", 16) == 0) { - char *p = &argv[i][16]; - /* skip quote */ - if ((*p == '"' && *(p+2) == '"') || (*p == '\'' && *(p+2) == '\'')) - p++; - symbol_prefix_char = *p; - } else if (strcmp(argv[i], "--base-relative") == 0) + else if (strcmp(argv[i], "--base-relative") == 0) base_relative = 1; else usage(); diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh index 9045823c7be7..4bf811c09f59 100755 --- a/scripts/link-vmlinux.sh +++ b/scripts/link-vmlinux.sh @@ -121,10 +121,6 @@ kallsyms() info KSYM ${2} local kallsymopt; - if [ -n "${CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX}" ]; then - kallsymopt="${kallsymopt} --symbol-prefix=_" - fi - if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then kallsymopt="${kallsymopt} --all-symbols" fi -- cgit v1.2.3 From 5a144a1acd0b4b4afd1b2695f7231b58e8848ce6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 16:23:48 +0900 Subject: depmod.sh: remove symbol prefix support CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX was selected by BLACKFIN, METAG. They were removed by commit 4ba66a976072 ("arch: remove blackfin port"), commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively. No more architecture enables CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX, hence the last argument of scripts/depmod.sh can be removed. Signed-off-by: Masahiro Yamada Reviewed-by: Sam Ravnborg --- Makefile | 2 +- scripts/depmod.sh | 25 +++---------------------- 2 files changed, 4 insertions(+), 23 deletions(-) (limited to 'scripts') diff --git a/Makefile b/Makefile index d0d2652db174..a1ea84dfdde6 100644 --- a/Makefile +++ b/Makefile @@ -1760,7 +1760,7 @@ quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),CLEAN $(wildcard $(rm-files)) # Run depmod only if we have System.map and depmod is executable quiet_cmd_depmod = DEPMOD $(KERNELRELEASE) cmd_depmod = $(CONFIG_SHELL) $(srctree)/scripts/depmod.sh $(DEPMOD) \ - $(KERNELRELEASE) "$(patsubst y,_,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX))" + $(KERNELRELEASE) # Create temporary dir for module support files # clean it up only when building all modules diff --git a/scripts/depmod.sh b/scripts/depmod.sh index 9831cca31240..1a6f85e0e6e1 100755 --- a/scripts/depmod.sh +++ b/scripts/depmod.sh @@ -3,36 +3,17 @@ # # A depmod wrapper used by the toplevel Makefile -if test $# -ne 3; then - echo "Usage: $0 /sbin/depmod " >&2 +if test $# -ne 2; then + echo "Usage: $0 /sbin/depmod " >&2 exit 1 fi DEPMOD=$1 KERNELRELEASE=$2 -SYMBOL_PREFIX=$3 if ! test -r System.map -a -x "$DEPMOD"; then exit 0 fi -# older versions of depmod don't support -P -# support was added in module-init-tools 3.13 -if test -n "$SYMBOL_PREFIX"; then - release=$("$DEPMOD" --version) - package=$(echo "$release" | cut -d' ' -f 1) - if test "$package" = "module-init-tools"; then - version=$(echo "$release" | cut -d' ' -f 2) - later=$(printf '%s\n' "$version" "3.13" | sort -V | tail -n 1) - if test "$later" != "$version"; then - # module-init-tools < 3.13, drop the symbol prefix - SYMBOL_PREFIX="" - fi - fi - if test -n "$SYMBOL_PREFIX"; then - SYMBOL_PREFIX="-P $SYMBOL_PREFIX" - fi -fi - # older versions of depmod require the version string to start with three # numbers, so we cheat with a symlink here depmod_hack_needed=true @@ -55,7 +36,7 @@ set -- -ae -F System.map if test -n "$INSTALL_MOD_PATH"; then set -- "$@" -b "$INSTALL_MOD_PATH" fi -"$DEPMOD" "$@" "$KERNELRELEASE" $SYMBOL_PREFIX +"$DEPMOD" "$@" "$KERNELRELEASE" ret=$? if $depmod_hack_needed; then -- cgit v1.2.3 From 704db5433fb43acbf1486303721bd0cbb65af251 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 16:23:50 +0900 Subject: kbuild: remove CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX was selected by BLACKFIN, METAG. They were removed by commit 4ba66a976072 ("arch: remove blackfin port"), commit bb6fb6dfcc17 ("metag: Remove arch/metag/"), respectively. No more architecture enables CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX. Clean up the rest of scripts, and remove the Kconfig entry. Signed-off-by: Masahiro Yamada Reviewed-by: Sam Ravnborg --- arch/Kconfig | 6 ------ scripts/Makefile.build | 7 +------ scripts/adjust_autoksyms.sh | 3 --- 3 files changed, 1 insertion(+), 15 deletions(-) (limited to 'scripts') diff --git a/arch/Kconfig b/arch/Kconfig index 8e0d665c8d53..706dec4d295a 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -686,12 +686,6 @@ config MODULES_USE_ELF_REL Modules only use ELF REL relocations. Modules with ELF RELA relocations will give an error. -config HAVE_UNDERSCORE_SYMBOL_PREFIX - bool - help - Some architectures generate an _ in front of C symbols; things like - module loading and assembly files need to know about this. - config HAVE_IRQ_EXIT_ON_IRQ_STACK bool help diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 22df8d037cf2..753b9add56f5 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -485,15 +485,10 @@ targets += $(lib-target) dummy-object = $(obj)/.lib_exports.o ksyms-lds = $(dot-target).lds -ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX -ref_prefix = EXTERN(_ -else -ref_prefix = EXTERN( -endif quiet_cmd_export_list = EXPORTS $@ cmd_export_list = $(OBJDUMP) -h $< | \ - sed -ne '/___ksymtab/s/.*+\([^ ]*\).*/$(ref_prefix)\1)/p' >$(ksyms-lds);\ + sed -ne '/___ksymtab/s/.*+\([^ ]*\).*/EXTERN(\1)/p' >$(ksyms-lds);\ rm -f $(dummy-object);\ echo | $(CC) $(a_flags) -c -o $(dummy-object) -x assembler -;\ $(LD) $(ld_flags) -r -o $@ -T $(ksyms-lds) $(dummy-object);\ diff --git a/scripts/adjust_autoksyms.sh b/scripts/adjust_autoksyms.sh index 016b3c48a4ec..6e6d63957da3 100755 --- a/scripts/adjust_autoksyms.sh +++ b/scripts/adjust_autoksyms.sh @@ -61,9 +61,6 @@ for mod in "$MODVERDIR"/*.mod; do sed -n -e '3{s/ /\n/g;/^$/!p;}' "$mod" done | sort -u | while read sym; do - if [ -n "$CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX" ]; then - sym="${sym#_}" - fi echo "#define __KSYM_${sym} 1" done >> "$new_ksyms_file" -- cgit v1.2.3 From a6b04f0ed5e931d4be5bf466ad469e2ac25ad6da Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 16:23:52 +0900 Subject: checkpatch: remove VMLINUX_SYMBOL() check Now that VMLINUX_SYMBOL() is no-op and being removed, let's stop checking VMLINUX_SYMBOL(). Signed-off-by: Masahiro Yamada Reviewed-by: Sam Ravnborg --- scripts/checkpatch.pl | 10 ---------- 1 file changed, 10 deletions(-) (limited to 'scripts') diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e16d6713f236..ce582a820c92 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5121,16 +5121,6 @@ sub process { } } -# make sure symbols are always wrapped with VMLINUX_SYMBOL() ... -# all assignments may have only one of the following with an assignment: -# . -# ALIGN(...) -# VMLINUX_SYMBOL(...) - if ($realfile eq 'vmlinux.lds.h' && $line =~ /(?:(?:^|\s)$Ident\s*=|=\s*$Ident(?:\s|$))/) { - WARN("MISSING_VMLINUX_SYMBOL", - "vmlinux.lds.h needs VMLINUX_SYMBOL() around C-visible symbols\n" . $herecurr); - } - # check for redundant bracing round if etc if ($line =~ /(^.*)\bif\b/ && $1 !~ /else\s*$/) { my ($level, $endln, @chunks) = -- cgit v1.2.3 From bca2ccee4c4ac69496d3c8655d7869122fe5aeab Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 18:50:37 +0900 Subject: modpost: pass struct elf_info pointer to get_modinfo() get_(next_)modinfo takes a pointer and length pair of the .modinfo section. Instead, pass struct elf_info pointer to reduce the number of function arguments. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index bc71925d4e9b..37a6a0b42846 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -724,16 +724,17 @@ static char *next_string(char *string, unsigned long *secsize) return string; } -static char *get_next_modinfo(void *modinfo, unsigned long modinfo_len, - const char *tag, char *info) +static char *get_next_modinfo(struct elf_info *info, const char *tag, + char *prev) { char *p; unsigned int taglen = strlen(tag); - unsigned long size = modinfo_len; + char *modinfo = info->modinfo; + unsigned long size = info->modinfo_len; - if (info) { - size -= info - (char *)modinfo; - modinfo = next_string(info, &size); + if (prev) { + size -= prev - modinfo; + modinfo = next_string(prev, &size); } for (p = modinfo; p; p = next_string(p, &size)) { @@ -743,11 +744,10 @@ static char *get_next_modinfo(void *modinfo, unsigned long modinfo_len, return NULL; } -static char *get_modinfo(void *modinfo, unsigned long modinfo_len, - const char *tag) +static char *get_modinfo(struct elf_info *info, const char *tag) { - return get_next_modinfo(modinfo, modinfo_len, tag, NULL); + return get_next_modinfo(info, tag, NULL); } /** @@ -1951,7 +1951,7 @@ static void read_symbols(char *modname) mod->skip = 1; } - license = get_modinfo(info.modinfo, info.modinfo_len, "license"); + license = get_modinfo(&info, "license"); if (!license && !is_vmlinux(modname)) warn("modpost: missing MODULE_LICENSE() in %s\n" "see include/linux/module.h for " @@ -1963,8 +1963,7 @@ static void read_symbols(char *modname) mod->gpl_compatible = 0; break; } - license = get_next_modinfo(info.modinfo, info.modinfo_len, - "license", license); + license = get_next_modinfo(&info, "license", license); } for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { @@ -1977,7 +1976,7 @@ static void read_symbols(char *modname) (is_vmlinux(modname) && vmlinux_section_warnings)) check_sec_ref(mod, modname, &info); - version = get_modinfo(info.modinfo, info.modinfo_len, "version"); + version = get_modinfo(&info, "version"); if (version) maybe_frob_rcs_version(modname, version, info.modinfo, version - (char *)info.hdr); -- cgit v1.2.3 From d62c476521a63053cb28d76ac50e02c2d13b1619 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 18:50:38 +0900 Subject: modpost: use strstarts() helper more widely Currently, strstarts() is only used in export_from_secname(). Use it more widely to improve the code readability. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 37a6a0b42846..8606b6caa21b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -596,19 +596,19 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) return 1; if (info->hdr->e_machine == EM_PPC) /* Special register function linked on all modules during final link of .ko */ - if (strncmp(symname, "_restgpr_", sizeof("_restgpr_") - 1) == 0 || - strncmp(symname, "_savegpr_", sizeof("_savegpr_") - 1) == 0 || - strncmp(symname, "_rest32gpr_", sizeof("_rest32gpr_") - 1) == 0 || - strncmp(symname, "_save32gpr_", sizeof("_save32gpr_") - 1) == 0 || - strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || - strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0) + if (strstarts(symname, "_restgpr_") || + strstarts(symname, "_savegpr_") || + strstarts(symname, "_rest32gpr_") || + strstarts(symname, "_save32gpr_") || + strstarts(symname, "_restvr_") || + strstarts(symname, "_savevr_")) return 1; if (info->hdr->e_machine == EM_PPC64) /* Special register function linked on all modules during final link of .ko */ - if (strncmp(symname, "_restgpr0_", sizeof("_restgpr0_") - 1) == 0 || - strncmp(symname, "_savegpr0_", sizeof("_savegpr0_") - 1) == 0 || - strncmp(symname, "_restvr_", sizeof("_restvr_") - 1) == 0 || - strncmp(symname, "_savevr_", sizeof("_savevr_") - 1) == 0 || + if (strstarts(symname, "_restgpr0_") || + strstarts(symname, "_savegpr0_") || + strstarts(symname, "_restvr_") || + strstarts(symname, "_savevr_") || strcmp(symname, ".TOC.") == 0) return 1; /* Do not ignore this symbol */ @@ -623,13 +623,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info, bool is_crc = false; if ((!is_vmlinux(mod->name) || mod->is_dot_o) && - strncmp(symname, "__ksymtab", 9) == 0) + strstarts(symname, "__ksymtab")) export = export_from_secname(info, get_secindex(info, sym)); else export = export_from_sec(info, get_secindex(info, sym)); /* CRC'd symbol */ - if (strncmp(symname, "__crc_", strlen("__crc_")) == 0) { + if (strstarts(symname, "__crc_")) { is_crc = true; crc = (unsigned int) sym->st_value; if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) { @@ -648,7 +648,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, switch (sym->st_shndx) { case SHN_COMMON: - if (!strncmp(symname, "__gnu_lto_", sizeof("__gnu_lto_")-1)) { + if (strstarts(symname, "__gnu_lto_")) { /* Should warn here, but modpost runs before the linker */ } else warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); @@ -691,7 +691,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, break; default: /* All exported symbols */ - if (strncmp(symname, "__ksymtab_", strlen("__ksymtab_")) == 0) { + if (strstarts(symname, "__ksymtab_")) { sym_add_exported(symname + strlen("__ksymtab_"), mod, export); } @@ -1171,13 +1171,13 @@ static int secref_whitelist(const struct sectioncheck *mismatch, /* Check for pattern 1 */ if (match(tosec, init_data_sections) && match(fromsec, data_sections) && - (strncmp(fromsym, "__param", strlen("__param")) == 0)) + strstarts(fromsym, "__param")) return 0; /* Check for pattern 1a */ if (strcmp(tosec, ".init.text") == 0 && match(fromsec, data_sections) && - (strncmp(fromsym, "__param_ops_", strlen("__param_ops_")) == 0)) + strstarts(fromsym, "__param_ops_")) return 0; /* Check for pattern 2 */ @@ -1532,8 +1532,7 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, from = find_elf_symbol2(elf, r->r_offset, fromsec); fromsym = sym_name(elf, from); - if (!strncmp(fromsym, "reference___initcall", - sizeof("reference___initcall")-1)) + if (strstarts(fromsym, "reference___initcall")) return; tosec = sec_name(elf, get_secindex(elf, sym)); @@ -2163,9 +2162,7 @@ static void add_retpoline(struct buffer *b) static void add_staging_flag(struct buffer *b, const char *name) { - static const char *staging_dir = "drivers/staging"; - - if (strncmp(staging_dir, name, strlen(staging_dir)) == 0) + if (strstarts(name, "drivers/staging")) buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); } -- cgit v1.2.3 From 074a04f572effefe410d7ee452cf3755e828c031 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 18:50:39 +0900 Subject: modpost: remove redundant is_vmlinux() test The second test of is_vmlinux() is redundant. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 8606b6caa21b..9e70a6ac1fcb 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1971,8 +1971,7 @@ static void read_symbols(char *modname) handle_modversions(mod, &info, sym, symname); handle_moddevtable(mod, &info, sym, symname); } - if (!is_vmlinux(modname) || - (is_vmlinux(modname) && vmlinux_section_warnings)) + if (!is_vmlinux(modname) || vmlinux_section_warnings) check_sec_ref(mod, modname, &info); version = get_modinfo(&info, "version"); -- cgit v1.2.3 From 8b1857436baa2b9b6d7330715180aa47a63b15ca Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 9 May 2018 18:50:40 +0900 Subject: modpost: constify *modname function argument where possible Neither find_module() nor read_symbols() does change *modname. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 9e70a6ac1fcb..1663fb19343a 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -121,7 +121,7 @@ void *do_nofail(void *ptr, const char *expr) /* A list of all modules we processed */ static struct module *modules; -static struct module *find_module(char *modname) +static struct module *find_module(const char *modname) { struct module *mod; @@ -1929,7 +1929,7 @@ static char *remove_dot(char *s) return s; } -static void read_symbols(char *modname) +static void read_symbols(const char *modname) { const char *symname; char *version; -- cgit v1.2.3 From 32d0572a75c81a2c70394f9e110ca080b9a733b1 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 21 May 2018 08:58:48 +0200 Subject: coccinelle: mini_lock: improve performance Replace <+... ...+> by ... when any. <+... ...+> is slow, and in some obscure cases involving backward jumps it doesn't force the unlock to actually come after the end of the if. Signed-off-by: Julia Lawall Signed-off-by: Masahiro Yamada --- scripts/coccinelle/locks/mini_lock.cocci | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/coccinelle/locks/mini_lock.cocci b/scripts/coccinelle/locks/mini_lock.cocci index 47f649b0ea87..19c6ee5b986b 100644 --- a/scripts/coccinelle/locks/mini_lock.cocci +++ b/scripts/coccinelle/locks/mini_lock.cocci @@ -67,12 +67,14 @@ identifier lock,unlock; @@ *lock(E1@p,...); -<+... when != E1 +... when != E1 + when any if (...) { ... when != E1 * return@r ...; } -...+> +... when != E1 + when any *unlock@up(E1,...); @script:python depends on org@ -- cgit v1.2.3 From 21195f8e9a473035dc692a40a145f4f083fe5c1f Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Mon, 21 May 2018 08:58:59 +0200 Subject: coccinelle: deref_null: improve performance Move rules looking for some special cases of safe dereferences before the collection of NULL-tested values. The special cases are fairly rare, but somewhat costly to find, because isomorphisms create many variants of the rules. There is thus no need to search for them over and over for each NULL tested expression. Collecting them just once is sufficient and more efficient. Signed-off-by: Julia Lawall Signed-off-by: Masahiro Yamada --- scripts/coccinelle/null/deref_null.cocci | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'scripts') diff --git a/scripts/coccinelle/null/deref_null.cocci b/scripts/coccinelle/null/deref_null.cocci index b16ccb7663a7..cbc6184e69ef 100644 --- a/scripts/coccinelle/null/deref_null.cocci +++ b/scripts/coccinelle/null/deref_null.cocci @@ -14,18 +14,10 @@ virtual context virtual org virtual report -@ifm@ -expression *E; -statement S1,S2; -position p1; -@@ - -if@p1 ((E == NULL && ...) || ...) S1 else S2 - // The following two rules are separate, because both can match a single // expression in different ways @pr1 expression@ -expression *ifm.E; +expression E; identifier f; position p1; @@ @@ -33,7 +25,7 @@ position p1; (E != NULL && ...) ? <+...E->f@p1...+> : ... @pr2 expression@ -expression *ifm.E; +expression E; identifier f; position p2; @@ @@ -46,6 +38,14 @@ position p2; sizeof(<+...E->f@p2...+>) ) +@ifm@ +expression *E; +statement S1,S2; +position p1; +@@ + +if@p1 ((E == NULL && ...) || ...) S1 else S2 + // For org and report modes @r depends on !context && (org || report) exists@ @@ -212,16 +212,8 @@ else S3 // The following three rules are duplicates of ifm, pr1 and pr2 respectively. // It is need because the previous rule as already made a "change". -@ifm1 depends on context && !org && !report@ -expression *E; -statement S1,S2; -position p1; -@@ - -if@p1 ((E == NULL && ...) || ...) S1 else S2 - @pr11 depends on context && !org && !report expression@ -expression *ifm1.E; +expression E; identifier f; position p1; @@ @@ -229,7 +221,7 @@ position p1; (E != NULL && ...) ? <+...E->f@p1...+> : ... @pr12 depends on context && !org && !report expression@ -expression *ifm1.E; +expression E; identifier f; position p2; @@ @@ -242,6 +234,14 @@ position p2; sizeof(<+...E->f@p2...+>) ) +@ifm1 depends on context && !org && !report@ +expression *E; +statement S1,S2; +position p1; +@@ + +if@p1 ((E == NULL && ...) || ...) S1 else S2 + @depends on context && !org && !report exists@ expression subE <= ifm1.E; expression *ifm1.E; -- cgit v1.2.3 From 656c107770e37759d0e888a1c38cd28792ca214b Mon Sep 17 00:00:00 2001 From: Joey Pabalinas Date: Mon, 21 May 2018 23:16:06 -1000 Subject: scripts/tags.sh: use `find` for $ALLSOURCE_ARCHS generation The current code includes 'Kconfig' in ALLSOURCE_ARCHS, but it should not (Kconfig is not an architecture). Replace this with a find-generated string and directly assign it to $ALLSOURCE_ARCHS. The find_all_archs() function is no longer needed for a one-liner with obvious semantics, so inline the arch generation into the surrounding conditional. Signed-off-by: Joey Pabalinas Signed-off-by: Masahiro Yamada --- scripts/tags.sh | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/tags.sh b/scripts/tags.sh index 78e546ff689c..e587610d1492 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh @@ -28,20 +28,11 @@ fi # ignore userspace tools ignore="$ignore ( -path ${tree}tools ) -prune -o" -# Find all available archs -find_all_archs() -{ - ALLSOURCE_ARCHS="" - for arch in `ls ${tree}arch`; do - ALLSOURCE_ARCHS="${ALLSOURCE_ARCHS} "${arch##\/} - done -} - # Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH if [ "${ALLSOURCE_ARCHS}" = "" ]; then ALLSOURCE_ARCHS=${SRCARCH} elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then - find_all_archs + ALLSOURCE_ARCHS=$(find ${tree}arch/ -mindepth 1 -maxdepth 1 -type d -printf '%f ') fi # find sources in arch/$ARCH -- cgit v1.2.3 From ac5db1fc89bf84d7479761e0de855e6376fdab1e Mon Sep 17 00:00:00 2001 From: nixiaoming Date: Thu, 24 May 2018 11:16:12 +0800 Subject: scripts: Fixed printf format mismatch scripts/kallsyms.c: function write_src: "printf", the #1 format specifier "d" need arg type "int", but the according arg "table_cnt" has type "unsigned int" scripts/recordmcount.c: function do_file: "fprintf", the #1 format specifier "d" need arg type "int", but the according arg "(*w2)(ehdr->e_machine)" has type "unsigned int" scripts/recordmcount.h: function find_secsym_ndx: "fprintf", the #1 format specifier "d" need arg type "int", but the according arg "txtndx" has type "unsigned int" Signed-off-by: nixiaoming Acked-by: Steven Rostedt (VMware) Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 2 +- scripts/recordmcount.c | 2 +- scripts/recordmcount.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 80417629b246..a9186a98a37d 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -405,7 +405,7 @@ static void write_src(void) } output_label("kallsyms_num_syms"); - printf("\tPTR\t%d\n", table_cnt); + printf("\tPTR\t%u\n", table_cnt); printf("\n"); /* table of offset markers, that give the offset in the compressed stream diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c index 8c9691c3329e..895c40e8679f 100644 --- a/scripts/recordmcount.c +++ b/scripts/recordmcount.c @@ -500,7 +500,7 @@ do_file(char const *const fname) gpfx = 0; switch (w2(ehdr->e_machine)) { default: - fprintf(stderr, "unrecognized e_machine %d %s\n", + fprintf(stderr, "unrecognized e_machine %u %s\n", w2(ehdr->e_machine), fname); fail_file(); break; diff --git a/scripts/recordmcount.h b/scripts/recordmcount.h index b9897e2be404..2e7793735e14 100644 --- a/scripts/recordmcount.h +++ b/scripts/recordmcount.h @@ -441,7 +441,7 @@ static unsigned find_secsym_ndx(unsigned const txtndx, return symp - sym0; } } - fprintf(stderr, "Cannot find symbol for section %d: %s.\n", + fprintf(stderr, "Cannot find symbol for section %u: %s.\n", txtndx, txtname); fail_file(); } -- cgit v1.2.3