From 78a20a012ecea857e438b1f9e8091acb290bd0f5 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 21 Aug 2019 13:12:37 +0900 Subject: video/logo: move pnmtologo tool to drivers/video/logo/ from scripts/ This tool is only used by drivers/video/logo/Makefile. No reason to keep it in scripts/. Signed-off-by: Masahiro Yamada --- scripts/.gitignore | 1 - scripts/Makefile | 2 - scripts/pnmtologo.c | 514 ---------------------------------------------------- 3 files changed, 517 deletions(-) delete mode 100644 scripts/pnmtologo.c (limited to 'scripts') diff --git a/scripts/.gitignore b/scripts/.gitignore index 17f8cef88fa8..4aa1806c59c2 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore @@ -4,7 +4,6 @@ bin2c conmakehash kallsyms -pnmtologo unifdef recordmcount sortextable diff --git a/scripts/Makefile b/scripts/Makefile index 3e86b300f5a1..00c47901cb06 100644 --- a/scripts/Makefile +++ b/scripts/Makefile @@ -4,7 +4,6 @@ # the kernel for the build process. # --------------------------------------------------------------------------- # kallsyms: Find all symbols in vmlinux -# pnmttologo: Convert pnm files to logo files # conmakehash: Create chartable # conmakehash: Create arrays for initializing the kernel console tables @@ -12,7 +11,6 @@ HOST_EXTRACFLAGS += -I$(srctree)/tools/include hostprogs-$(CONFIG_BUILD_BIN2C) += bin2c hostprogs-$(CONFIG_KALLSYMS) += kallsyms -hostprogs-$(CONFIG_LOGO) += pnmtologo hostprogs-$(CONFIG_VT) += conmakehash hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable diff --git a/scripts/pnmtologo.c b/scripts/pnmtologo.c deleted file mode 100644 index 4718d7895f0b..000000000000 --- a/scripts/pnmtologo.c +++ /dev/null @@ -1,514 +0,0 @@ - -/* - * Convert a logo in ASCII PNM format to C source suitable for inclusion in - * the Linux kernel - * - * (C) Copyright 2001-2003 by Geert Uytterhoeven - * - * -------------------------------------------------------------------------- - * - * This file is subject to the terms and conditions of the GNU General Public - * License. See the file COPYING in the main directory of the Linux - * distribution for more details. - */ - -#include -#include -#include -#include -#include -#include -#include - - -static const char *programname; -static const char *filename; -static const char *logoname = "linux_logo"; -static const char *outputname; -static FILE *out; - - -#define LINUX_LOGO_MONO 1 /* monochrome black/white */ -#define LINUX_LOGO_VGA16 2 /* 16 colors VGA text palette */ -#define LINUX_LOGO_CLUT224 3 /* 224 colors */ -#define LINUX_LOGO_GRAY256 4 /* 256 levels grayscale */ - -static const char *logo_types[LINUX_LOGO_GRAY256+1] = { - [LINUX_LOGO_MONO] = "LINUX_LOGO_MONO", - [LINUX_LOGO_VGA16] = "LINUX_LOGO_VGA16", - [LINUX_LOGO_CLUT224] = "LINUX_LOGO_CLUT224", - [LINUX_LOGO_GRAY256] = "LINUX_LOGO_GRAY256" -}; - -#define MAX_LINUX_LOGO_COLORS 224 - -struct color { - unsigned char red; - unsigned char green; - unsigned char blue; -}; - -static const struct color clut_vga16[16] = { - { 0x00, 0x00, 0x00 }, - { 0x00, 0x00, 0xaa }, - { 0x00, 0xaa, 0x00 }, - { 0x00, 0xaa, 0xaa }, - { 0xaa, 0x00, 0x00 }, - { 0xaa, 0x00, 0xaa }, - { 0xaa, 0x55, 0x00 }, - { 0xaa, 0xaa, 0xaa }, - { 0x55, 0x55, 0x55 }, - { 0x55, 0x55, 0xff }, - { 0x55, 0xff, 0x55 }, - { 0x55, 0xff, 0xff }, - { 0xff, 0x55, 0x55 }, - { 0xff, 0x55, 0xff }, - { 0xff, 0xff, 0x55 }, - { 0xff, 0xff, 0xff }, -}; - - -static int logo_type = LINUX_LOGO_CLUT224; -static unsigned int logo_width; -static unsigned int logo_height; -static struct color **logo_data; -static struct color logo_clut[MAX_LINUX_LOGO_COLORS]; -static unsigned int logo_clutsize; -static int is_plain_pbm = 0; - -static void die(const char *fmt, ...) - __attribute__ ((noreturn)) __attribute ((format (printf, 1, 2))); -static void usage(void) __attribute ((noreturn)); - - -static unsigned int get_number(FILE *fp) -{ - int c, val; - - /* Skip leading whitespace */ - do { - c = fgetc(fp); - if (c == EOF) - die("%s: end of file\n", filename); - if (c == '#') { - /* Ignore comments 'till end of line */ - do { - c = fgetc(fp); - if (c == EOF) - die("%s: end of file\n", filename); - } while (c != '\n'); - } - } while (isspace(c)); - - /* Parse decimal number */ - val = 0; - while (isdigit(c)) { - val = 10*val+c-'0'; - /* some PBM are 'broken'; GiMP for example exports a PBM without space - * between the digits. This is Ok cause we know a PBM can only have a '1' - * or a '0' for the digit. */ - if (is_plain_pbm) - break; - c = fgetc(fp); - if (c == EOF) - die("%s: end of file\n", filename); - } - return val; -} - -static unsigned int get_number255(FILE *fp, unsigned int maxval) -{ - unsigned int val = get_number(fp); - return (255*val+maxval/2)/maxval; -} - -static void read_image(void) -{ - FILE *fp; - unsigned int i, j; - int magic; - unsigned int maxval; - - /* open image file */ - fp = fopen(filename, "r"); - if (!fp) - die("Cannot open file %s: %s\n", filename, strerror(errno)); - - /* check file type and read file header */ - magic = fgetc(fp); - if (magic != 'P') - die("%s is not a PNM file\n", filename); - magic = fgetc(fp); - switch (magic) { - case '1': - case '2': - case '3': - /* Plain PBM/PGM/PPM */ - break; - - case '4': - case '5': - case '6': - /* Binary PBM/PGM/PPM */ - die("%s: Binary PNM is not supported\n" - "Use pnmnoraw(1) to convert it to ASCII PNM\n", filename); - - default: - die("%s is not a PNM file\n", filename); - } - logo_width = get_number(fp); - logo_height = get_number(fp); - - /* allocate image data */ - logo_data = (struct color **)malloc(logo_height*sizeof(struct color *)); - if (!logo_data) - die("%s\n", strerror(errno)); - for (i = 0; i < logo_height; i++) { - logo_data[i] = malloc(logo_width*sizeof(struct color)); - if (!logo_data[i]) - die("%s\n", strerror(errno)); - } - - /* read image data */ - switch (magic) { - case '1': - /* Plain PBM */ - is_plain_pbm = 1; - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) - logo_data[i][j].red = logo_data[i][j].green = - logo_data[i][j].blue = 255*(1-get_number(fp)); - break; - - case '2': - /* Plain PGM */ - maxval = get_number(fp); - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) - logo_data[i][j].red = logo_data[i][j].green = - logo_data[i][j].blue = get_number255(fp, maxval); - break; - - case '3': - /* Plain PPM */ - maxval = get_number(fp); - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) { - logo_data[i][j].red = get_number255(fp, maxval); - logo_data[i][j].green = get_number255(fp, maxval); - logo_data[i][j].blue = get_number255(fp, maxval); - } - break; - } - - /* close file */ - fclose(fp); -} - -static inline int is_black(struct color c) -{ - return c.red == 0 && c.green == 0 && c.blue == 0; -} - -static inline int is_white(struct color c) -{ - return c.red == 255 && c.green == 255 && c.blue == 255; -} - -static inline int is_gray(struct color c) -{ - return c.red == c.green && c.red == c.blue; -} - -static inline int is_equal(struct color c1, struct color c2) -{ - return c1.red == c2.red && c1.green == c2.green && c1.blue == c2.blue; -} - -static void write_header(void) -{ - /* open logo file */ - if (outputname) { - out = fopen(outputname, "w"); - if (!out) - die("Cannot create file %s: %s\n", outputname, strerror(errno)); - } else { - out = stdout; - } - - fputs("/*\n", out); - fputs(" * DO NOT EDIT THIS FILE!\n", out); - fputs(" *\n", out); - fprintf(out, " * It was automatically generated from %s\n", filename); - fputs(" *\n", out); - fprintf(out, " * Linux logo %s\n", logoname); - fputs(" */\n\n", out); - fputs("#include \n\n", out); - fprintf(out, "static unsigned char %s_data[] __initdata = {\n", - logoname); -} - -static void write_footer(void) -{ - fputs("\n};\n\n", out); - fprintf(out, "const struct linux_logo %s __initconst = {\n", logoname); - fprintf(out, "\t.type\t\t= %s,\n", logo_types[logo_type]); - fprintf(out, "\t.width\t\t= %d,\n", logo_width); - fprintf(out, "\t.height\t\t= %d,\n", logo_height); - if (logo_type == LINUX_LOGO_CLUT224) { - fprintf(out, "\t.clutsize\t= %d,\n", logo_clutsize); - fprintf(out, "\t.clut\t\t= %s_clut,\n", logoname); - } - fprintf(out, "\t.data\t\t= %s_data\n", logoname); - fputs("};\n\n", out); - - /* close logo file */ - if (outputname) - fclose(out); -} - -static int write_hex_cnt; - -static void write_hex(unsigned char byte) -{ - if (write_hex_cnt % 12) - fprintf(out, ", 0x%02x", byte); - else if (write_hex_cnt) - fprintf(out, ",\n\t0x%02x", byte); - else - fprintf(out, "\t0x%02x", byte); - write_hex_cnt++; -} - -static void write_logo_mono(void) -{ - unsigned int i, j; - unsigned char val, bit; - - /* validate image */ - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) - if (!is_black(logo_data[i][j]) && !is_white(logo_data[i][j])) - die("Image must be monochrome\n"); - - /* write file header */ - write_header(); - - /* write logo data */ - for (i = 0; i < logo_height; i++) { - for (j = 0; j < logo_width;) { - for (val = 0, bit = 0x80; bit && j < logo_width; j++, bit >>= 1) - if (logo_data[i][j].red) - val |= bit; - write_hex(val); - } - } - - /* write logo structure and file footer */ - write_footer(); -} - -static void write_logo_vga16(void) -{ - unsigned int i, j, k; - unsigned char val; - - /* validate image */ - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) { - for (k = 0; k < 16; k++) - if (is_equal(logo_data[i][j], clut_vga16[k])) - break; - if (k == 16) - die("Image must use the 16 console colors only\n" - "Use ppmquant(1) -map clut_vga16.ppm to reduce the number " - "of colors\n"); - } - - /* write file header */ - write_header(); - - /* write logo data */ - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) { - for (k = 0; k < 16; k++) - if (is_equal(logo_data[i][j], clut_vga16[k])) - break; - val = k<<4; - if (++j < logo_width) { - for (k = 0; k < 16; k++) - if (is_equal(logo_data[i][j], clut_vga16[k])) - break; - val |= k; - } - write_hex(val); - } - - /* write logo structure and file footer */ - write_footer(); -} - -static void write_logo_clut224(void) -{ - unsigned int i, j, k; - - /* validate image */ - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) { - for (k = 0; k < logo_clutsize; k++) - if (is_equal(logo_data[i][j], logo_clut[k])) - break; - if (k == logo_clutsize) { - if (logo_clutsize == MAX_LINUX_LOGO_COLORS) - die("Image has more than %d colors\n" - "Use ppmquant(1) to reduce the number of colors\n", - MAX_LINUX_LOGO_COLORS); - logo_clut[logo_clutsize++] = logo_data[i][j]; - } - } - - /* write file header */ - write_header(); - - /* write logo data */ - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) { - for (k = 0; k < logo_clutsize; k++) - if (is_equal(logo_data[i][j], logo_clut[k])) - break; - write_hex(k+32); - } - fputs("\n};\n\n", out); - - /* write logo clut */ - fprintf(out, "static unsigned char %s_clut[] __initdata = {\n", - logoname); - write_hex_cnt = 0; - for (i = 0; i < logo_clutsize; i++) { - write_hex(logo_clut[i].red); - write_hex(logo_clut[i].green); - write_hex(logo_clut[i].blue); - } - - /* write logo structure and file footer */ - write_footer(); -} - -static void write_logo_gray256(void) -{ - unsigned int i, j; - - /* validate image */ - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) - if (!is_gray(logo_data[i][j])) - die("Image must be grayscale\n"); - - /* write file header */ - write_header(); - - /* write logo data */ - for (i = 0; i < logo_height; i++) - for (j = 0; j < logo_width; j++) - write_hex(logo_data[i][j].red); - - /* write logo structure and file footer */ - write_footer(); -} - -static void die(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vfprintf(stderr, fmt, ap); - va_end(ap); - - exit(1); -} - -static void usage(void) -{ - die("\n" - "Usage: %s [options] \n" - "\n" - "Valid options:\n" - " -h : display this usage information\n" - " -n : specify logo name (default: linux_logo)\n" - " -o : output to file instead of stdout\n" - " -t : specify logo type, one of\n" - " mono : monochrome black/white\n" - " vga16 : 16 colors VGA text palette\n" - " clut224 : 224 colors (default)\n" - " gray256 : 256 levels grayscale\n" - "\n", programname); -} - -int main(int argc, char *argv[]) -{ - int opt; - - programname = argv[0]; - - opterr = 0; - while (1) { - opt = getopt(argc, argv, "hn:o:t:"); - if (opt == -1) - break; - - switch (opt) { - case 'h': - usage(); - break; - - case 'n': - logoname = optarg; - break; - - case 'o': - outputname = optarg; - break; - - case 't': - if (!strcmp(optarg, "mono")) - logo_type = LINUX_LOGO_MONO; - else if (!strcmp(optarg, "vga16")) - logo_type = LINUX_LOGO_VGA16; - else if (!strcmp(optarg, "clut224")) - logo_type = LINUX_LOGO_CLUT224; - else if (!strcmp(optarg, "gray256")) - logo_type = LINUX_LOGO_GRAY256; - else - usage(); - break; - - default: - usage(); - break; - } - } - if (optind != argc-1) - usage(); - - filename = argv[optind]; - - read_image(); - switch (logo_type) { - case LINUX_LOGO_MONO: - write_logo_mono(); - break; - - case LINUX_LOGO_VGA16: - write_logo_vga16(); - break; - - case LINUX_LOGO_CLUT224: - write_logo_clut224(); - break; - - case LINUX_LOGO_GRAY256: - write_logo_gray256(); - break; - } - exit(0); -} -- cgit From 521b29b6ff53aa642ca0964ad34c2ebcb8dbad14 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Mon, 26 Aug 2019 02:28:33 +0900 Subject: kconfig: split util.c out of parser.y util.c exists both in scripts/kconfig/ and scripts/kconfig/lxdialog. Prior to commit 54b8ae66ae1a ("kbuild: change *FLAGS_.o to take the path relative to $(obj)"), Kbuild could not pass different flags to source files with the same basename. Now that this issue was solved, you can split util.c out of parser.y and compile them independently of each other. Signed-off-by: Masahiro Yamada --- scripts/kconfig/Makefile | 2 +- scripts/kconfig/parser.y | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index ef2f2336c469..1ce83269a5dc 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -144,7 +144,7 @@ help: # =========================================================================== # object files used by all kconfig flavours common-objs := confdata.o expr.o lexer.lex.o parser.tab.o preprocess.o \ - symbol.o + symbol.o util.o $(obj)/lexer.lex.o: $(obj)/parser.tab.h HOSTCFLAGS_lexer.lex.o := -I $(srctree)/$(src) diff --git a/scripts/kconfig/parser.y b/scripts/kconfig/parser.y index 60936c76865b..b3eff9613cf8 100644 --- a/scripts/kconfig/parser.y +++ b/scripts/kconfig/parser.y @@ -727,5 +727,4 @@ void zconfdump(FILE *out) } } -#include "util.c" #include "menu.c" -- cgit From fab546e6cd7aee6574472ad3239db07ee1d94c09 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 6 Nov 2019 23:52:15 +0900 Subject: kbuild: update comments in scripts/Makefile.modpost The comment line "When building external modules ..." explains the same thing as "Include the module's Makefile ..." a few lines below. The comment "they may be used when building the .mod.c file" is no longer true; .mod.c file is compiled in scripts/Makefile.modfinal since commit 9b9a3f20cbe0 ("kbuild: split final module linking out into Makefile.modfinal"). I still keep the code in case $(obj) or $(src) is used in the external module Makefile. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 952fff485546..cc19b95c2116 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -67,10 +67,9 @@ __modpost: else -# When building external modules load the Kbuild file to retrieve EXTRA_SYMBOLS info ifneq ($(KBUILD_EXTMOD),) -# set src + obj - they may be used when building the .mod.c file +# set src + obj - they may be used in the modules's Makefile obj := $(KBUILD_EXTMOD) src := $(obj) -- cgit From 1747269ab016b49650c952099b0ca096ed5c06f1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 3 Oct 2019 19:29:13 +0900 Subject: modpost: do not parse vmlinux for external module builds When building external modules, $(objtree)/Module.symvers is scanned for symbol information of vmlinux and in-tree modules. Additionally, vmlinux is parsed if it exists in $(objtree)/. This is totally redundant since all the necessary information is contained in $(objtree)/Module.symvers. Do not parse vmlinux at all for external module builds. This makes sense because vmlinux is deleted by 'make clean'. 'make clean' leaves all the build artifacts for building external modules. vmlinux is unneeded for that. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index cc19b95c2116..13842693c143 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -67,7 +67,11 @@ __modpost: else -ifneq ($(KBUILD_EXTMOD),) +MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - + +ifeq ($(KBUILD_EXTMOD),) +MODPOST += $(wildcard vmlinux) +else # set src + obj - they may be used in the modules's Makefile obj := $(KBUILD_EXTMOD) @@ -78,8 +82,6 @@ include $(if $(wildcard $(KBUILD_EXTMOD)/Kbuild), \ $(KBUILD_EXTMOD)/Kbuild, $(KBUILD_EXTMOD)/Makefile) endif -MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - $(wildcard vmlinux) - # find all modules listed in modules.order modules := $(sort $(shell cat $(MODORDER))) -- cgit From 39808e451fdf30d20099a92e5185a0acb028d826 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 3 Oct 2019 19:29:14 +0900 Subject: kbuild: do not read $(KBUILD_EXTMOD)/Module.symvers Since commit 040fcc819a2e ("kbuild: improved modversioning support for external modules"), the external module build reads Module.symvers in the directory of the module itself, then dumps symbols back into it. It accumulates stale symbols in the file when you build an external module incrementally. The idea behind it was, as the commit log explained, you can copy Modules.symvers from one module to another when you need to pass symbol information between two modules. However, the manual copy of the file sounds questionable to me, and containing stale symbols is a downside. Some time later, commit 0d96fb20b7ed ("kbuild: Add new Kbuild variable KBUILD_EXTRA_SYMBOLS") introduced a saner approach. So, this commit removes the former one. Going forward, the external module build dumps symbols into Module.symvers to be carried via KBUILD_EXTRA_SYMBOLS, but never reads it automatically. With the -I option removed, there is no one to set the external_module flag unless KBUILD_EXTRA_SYMBOLS is passed. Now the -i option does it instead. Signed-off-by: Masahiro Yamada --- scripts/Makefile.modpost | 1 - scripts/mod/modpost.c | 9 ++------- 2 files changed, 2 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 13842693c143..20359c7887b3 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -50,7 +50,6 @@ MODPOST = scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a) \ $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ - $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d2a30a7b3f07..37fa1c65ee4d 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2561,7 +2561,7 @@ int main(int argc, char **argv) { struct module *mod; struct buffer buf = { }; - char *kernel_read = NULL, *module_read = NULL; + char *kernel_read = NULL; char *dump_write = NULL, *files_source = NULL; int opt; int err; @@ -2569,13 +2569,10 @@ int main(int argc, char **argv) struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; - while ((opt = getopt(argc, argv, "i:I:e:mnsT:o:awEd")) != -1) { + while ((opt = getopt(argc, argv, "i:e:mnsT:o:awEd")) != -1) { switch (opt) { case 'i': kernel_read = optarg; - break; - case 'I': - module_read = optarg; external_module = 1; break; case 'e': @@ -2620,8 +2617,6 @@ int main(int argc, char **argv) if (kernel_read) read_dump(kernel_read, 1); - if (module_read) - read_dump(module_read, 0); while (extsym_start) { read_dump(extsym_start->file, 0); extsym_iter = extsym_start->next; -- cgit From 203126293cd78c56578e33dfe8d517e7e83941a8 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 16 Oct 2019 14:15:46 +0900 Subject: kbuild: reduce KBUILD_SINGLE_TARGETS as descending into subdirectories KBUILD_SINGLE_TARGETS does not need to contain all the targets. Change it to keep track the targets only from the current directory and its subdirectories. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a9e47953ca53..dcbb0124dac4 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -469,15 +469,15 @@ targets += $(call intermediate_targets, .asn1.o, .asn1.c .asn1.h) \ ifdef single-build +KBUILD_SINGLE_TARGETS := $(filter $(obj)/%, $(KBUILD_SINGLE_TARGETS)) + curdir-single := $(sort $(foreach x, $(KBUILD_SINGLE_TARGETS), \ $(if $(filter $(x) $(basename $(x)).o, $(targets)), $(x)))) # Handle single targets without any rule: show "Nothing to be done for ..." or # "No rule to make target ..." depending on whether the target exists. unknown-single := $(filter-out $(addsuffix /%, $(subdir-ym)), \ - $(filter $(obj)/%, \ - $(filter-out $(curdir-single), \ - $(KBUILD_SINGLE_TARGETS)))) + $(filter-out $(curdir-single), $(KBUILD_SINGLE_TARGETS))) __build: $(curdir-single) $(subdir-ym) ifneq ($(unknown-single),) -- cgit From 2dffd23f81a365307c0edcf9cb40b6ddae2b481e Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Wed, 16 Oct 2019 14:15:47 +0900 Subject: kbuild: make single target builds much faster Since commit 394053f4a4b3 ("kbuild: make single targets work more correctly"), building single targets is really slow. Speed it up by not descending into unrelated directories. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index dcbb0124dac4..7eabbb66a65c 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -479,7 +479,10 @@ curdir-single := $(sort $(foreach x, $(KBUILD_SINGLE_TARGETS), \ unknown-single := $(filter-out $(addsuffix /%, $(subdir-ym)), \ $(filter-out $(curdir-single), $(KBUILD_SINGLE_TARGETS))) -__build: $(curdir-single) $(subdir-ym) +single-subdirs := $(foreach d, $(subdir-ym), \ + $(if $(filter $(d)/%, $(KBUILD_SINGLE_TARGETS)), $(d))) + +__build: $(curdir-single) $(single-subdirs) ifneq ($(unknown-single),) $(Q)$(MAKE) -f /dev/null $(unknown-single) endif -- cgit From 3c96bdd0ebfaf750a91016433adc7a6ee711a519 Mon Sep 17 00:00:00 2001 From: Bhaskar Chowdhury Date: Wed, 23 Oct 2019 07:24:27 +0530 Subject: scripts: setlocalversion: replace backquote to dollar parenthesis This patch replaces backquote to dollar parenthesis syntax for better readability. Signed-off-by: Bhaskar Chowdhury Acked-by: Randy Dunlap Acked-by: Nico Schottelius Signed-off-by: Masahiro Yamada --- scripts/setlocalversion | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/setlocalversion b/scripts/setlocalversion index a2998b118ef9..20f2efd57b11 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -45,11 +45,11 @@ scm_version() # Check for git and a git repo. if test -z "$(git rev-parse --show-cdup 2>/dev/null)" && - head=`git rev-parse --verify --short HEAD 2>/dev/null`; then + head=$(git rev-parse --verify --short HEAD 2>/dev/null); then # If we are at a tagged commit (like "v2.6.30-rc6"), we ignore # it, because this version is defined in the top level Makefile. - if [ -z "`git describe --exact-match 2>/dev/null`" ]; then + if [ -z "$(git describe --exact-match 2>/dev/null)" ]; then # If only the short version is requested, don't bother # running further git commands @@ -59,7 +59,7 @@ scm_version() fi # If we are past a tagged commit (like # "v2.6.30-rc5-302-g72357d5"), we pretty print it. - if atag="`git describe 2>/dev/null`"; then + if atag="$(git describe 2>/dev/null)"; then echo "$atag" | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' # If we don't have a tag at all we print -g{commitish}. @@ -70,7 +70,7 @@ scm_version() # Is this git on svn? if git config --get svn-remote.svn.url >/dev/null; then - printf -- '-svn%s' "`git svn find-rev $head`" + printf -- '-svn%s' "$(git svn find-rev $head)" fi # Check for uncommitted changes. @@ -91,15 +91,15 @@ scm_version() fi # Check for mercurial and a mercurial repo. - if test -d .hg && hgid=`hg id 2>/dev/null`; then + 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 - id=`hg log -r . --template '{latesttag}'` + if [ "$(hg log -r . --template '{latesttagdistance}')" = "1" ]; then + id=$(hg log -r . --template '{latesttag}') printf '%s%s' -hg "$id" else - tag=`printf '%s' "$hgid" | cut -d' ' -f2` + tag=$(printf '%s' "$hgid" | cut -d' ' -f2) if [ -z "$tag" -o "$tag" = tip ]; then - id=`printf '%s' "$hgid" | sed 's/[+ ].*//'` + id=$(printf '%s' "$hgid" | sed 's/[+ ].*//') printf '%s%s' -hg "$id" fi fi @@ -115,8 +115,8 @@ scm_version() fi # Check for svn and a svn repo. - if rev=`LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'`; then - rev=`echo $rev | awk '{print $NF}'` + if rev=$(LANG= LC_ALL= LC_MESSAGES=C svn info 2>/dev/null | grep '^Last Changed Rev'); then + rev=$(echo $rev | awk '{print $NF}') printf -- '-svn%s' "$rev" # All done with svn -- cgit From a64c0440dda1fff1fb5723140828983d0ca821d4 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Fri, 25 Oct 2019 13:52:32 +0200 Subject: kbuild: Wrap long "make help" text lines Some "make help" text lines extend beyond 80 characters. Wrap them before an opening parenthesis, or before 80 characters. Signed-off-by: Geert Uytterhoeven Signed-off-by: Masahiro Yamada --- scripts/Makefile.package | 3 ++- scripts/kconfig/Makefile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.package b/scripts/Makefile.package index 56eadcc48d46..ee9b368dfcf3 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -146,7 +146,8 @@ help: @echo ' binrpm-pkg - Build only the binary kernel RPM package' @echo ' deb-pkg - Build both source and binary deb kernel packages' @echo ' bindeb-pkg - Build only the binary kernel deb package' - @echo ' snap-pkg - Build only the binary kernel snap package (will connect to external hosts)' + @echo ' snap-pkg - Build only the binary kernel snap package' + @echo ' (will connect to external hosts)' @echo ' tar-pkg - Build the kernel as an uncompressed tarball' @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 1ce83269a5dc..588b55f9f618 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -137,7 +137,8 @@ help: @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' @echo ' default value without prompting' @echo ' kvmconfig - Enable additional options for kvm guest kernel support' - @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel support' + @echo ' xenconfig - Enable additional options for xen dom0 and guest kernel' + @echo ' support' @echo ' tinyconfig - Configure the tiniest possible kernel' @echo ' testconfig - Run Kconfig unit tests (requires python3 and pytest)' -- cgit From af7db99a1caf29b05a81bfee596b9d2778eb7e39 Mon Sep 17 00:00:00 2001 From: Matteo Croce Date: Mon, 4 Nov 2019 14:11:44 +0100 Subject: kbuild: Add make dir-pkg build option Add a 'dir-pkg' target which just creates the same directory structures as in tar-pkg, but doesn't package anything. Useful when the user wants to copy the kernel tree on a machine using ssh, rsync or whatever. Signed-off-by: Matteo Croce Signed-off-by: Masahiro Yamada --- scripts/Makefile.package | 3 ++- scripts/package/buildtar | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.package b/scripts/Makefile.package index ee9b368dfcf3..02135d2671a6 100644 --- a/scripts/Makefile.package +++ b/scripts/Makefile.package @@ -103,7 +103,7 @@ snap-pkg: # tarball targets # --------------------------------------------------------------------------- -tar-pkgs := tar-pkg targz-pkg tarbz2-pkg tarxz-pkg +tar-pkgs := dir-pkg tar-pkg targz-pkg tarbz2-pkg tarxz-pkg PHONY += $(tar-pkgs) $(tar-pkgs): $(MAKE) -f $(srctree)/Makefile @@ -148,6 +148,7 @@ help: @echo ' bindeb-pkg - Build only the binary kernel deb package' @echo ' snap-pkg - Build only the binary kernel snap package' @echo ' (will connect to external hosts)' + @echo ' dir-pkg - Build the kernel as a plain directory structure' @echo ' tar-pkg - Build the kernel as an uncompressed tarball' @echo ' targz-pkg - Build the kernel as a gzip compressed tarball' @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball' diff --git a/scripts/package/buildtar b/scripts/package/buildtar index 2f66c81e4021..77c7caefede1 100755 --- a/scripts/package/buildtar +++ b/scripts/package/buildtar @@ -2,7 +2,7 @@ # SPDX-License-Identifier: GPL-2.0 # -# buildtar 0.0.4 +# buildtar 0.0.5 # # (C) 2004-2006 by Jan-Benedict Glaw # @@ -24,7 +24,7 @@ tarball="${objtree}/linux-${KERNELRELEASE}-${ARCH}.tar" # Figure out how to compress, if requested at all # case "${1}" in - tar-pkg) + dir-pkg|tar-pkg) opts= ;; targz-pkg) @@ -125,6 +125,10 @@ case "${ARCH}" in ;; esac +if [ "${1}" = dir-pkg ]; then + echo "Kernel tree successfully created in $tmpdir" + exit 0 +fi # # Create the tarball -- cgit From 5d8b42aa7ccbfa09c361b3a5289c1a7e380847ff Mon Sep 17 00:00:00 2001 From: Laura Abbott Date: Mon, 4 Nov 2019 17:10:08 -0500 Subject: kconfig: Add option to get the full help text with listnewconfig make listnewconfig will list the individual options that need to be set. This is useful but there's no easy way to get the help text associated with the options at the same time. Introduce a new targe 'make helpnewconfig' which lists the full help text of all the new options as well. This makes it easier to automatically generate changes that are easy for humans to review. This command also adds markers between each option for easier parsing. Signed-off-by: Laura Abbott Acked-by: Randy Dunlap Signed-off-by: Masahiro Yamada --- scripts/kconfig/Makefile | 5 ++++- scripts/kconfig/conf.c | 13 ++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 588b55f9f618..2f1a59fa5169 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -66,7 +66,9 @@ localyesconfig localmodconfig: $(obj)/conf # syncconfig has become an internal implementation detail and is now # deprecated for external use simple-targets := oldconfig allnoconfig allyesconfig allmodconfig \ - alldefconfig randconfig listnewconfig olddefconfig syncconfig + alldefconfig randconfig listnewconfig olddefconfig syncconfig \ + helpnewconfig + PHONY += $(simple-targets) $(simple-targets): $(obj)/conf @@ -134,6 +136,7 @@ help: @echo ' alldefconfig - New config with all symbols set to default' @echo ' randconfig - New config with random answer to all options' @echo ' listnewconfig - List new options' + @echo ' helpnewconfig - List new options and help text' @echo ' olddefconfig - Same as oldconfig but sets new symbols to their' @echo ' default value without prompting' @echo ' kvmconfig - Enable additional options for kvm guest kernel support' diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 40e16e871ae2..1f89bf1558ce 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -32,6 +32,7 @@ enum input_mode { defconfig, savedefconfig, listnewconfig, + helpnewconfig, olddefconfig, }; static enum input_mode input_mode = oldaskconfig; @@ -434,6 +435,11 @@ static void check_conf(struct menu *menu) printf("%s%s=%s\n", CONFIG_, sym->name, str); } } + } else if (input_mode == helpnewconfig) { + printf("-----\n"); + print_help(menu); + printf("-----\n"); + } else { if (!conf_cnt++) printf("*\n* Restart config...\n*\n"); @@ -459,6 +465,7 @@ static struct option long_opts[] = { {"alldefconfig", no_argument, NULL, alldefconfig}, {"randconfig", no_argument, NULL, randconfig}, {"listnewconfig", no_argument, NULL, listnewconfig}, + {"helpnewconfig", no_argument, NULL, helpnewconfig}, {"olddefconfig", no_argument, NULL, olddefconfig}, {NULL, 0, NULL, 0} }; @@ -469,6 +476,7 @@ static void conf_usage(const char *progname) printf("Usage: %s [-s] [option] \n", progname); printf("[option] is _one_ of the following:\n"); printf(" --listnewconfig List new options\n"); + printf(" --helpnewconfig List new options and help text\n"); printf(" --oldaskconfig Start a new configuration using a line-oriented program\n"); printf(" --oldconfig Update a configuration using a provided .config as base\n"); printf(" --syncconfig Similar to oldconfig but generates configuration in\n" @@ -543,6 +551,7 @@ int main(int ac, char **av) case allmodconfig: case alldefconfig: case listnewconfig: + case helpnewconfig: case olddefconfig: break; case '?': @@ -576,6 +585,7 @@ int main(int ac, char **av) case oldaskconfig: case oldconfig: case listnewconfig: + case helpnewconfig: case olddefconfig: conf_read(NULL); break; @@ -657,6 +667,7 @@ int main(int ac, char **av) /* fall through */ case oldconfig: case listnewconfig: + case helpnewconfig: case syncconfig: /* Update until a loop caused no more changes */ do { @@ -675,7 +686,7 @@ int main(int ac, char **av) defconfig_file); return 1; } - } else if (input_mode != listnewconfig) { + } else if (input_mode != listnewconfig && input_mode != helpnewconfig) { if (!no_conf_write && conf_write(NULL)) { fprintf(stderr, "\n*** Error during writing of the configuration.\n\n"); exit(1); -- cgit From 46b2afa6890d0ffd234741deea2e24ee222a827f Mon Sep 17 00:00:00 2001 From: Alyssa Ross Date: Tue, 5 Nov 2019 15:07:36 +0000 Subject: kconfig: be more helpful if pkg-config is missing If ncurses is installed, but at a non-default location, the previous error message was not helpful in resolving the situation. Now it will suggest that pkg-config might need to be installed in addition to ncurses. Signed-off-by: Alyssa Ross Signed-off-by: Masahiro Yamada --- scripts/kconfig/mconf-cfg.sh | 3 +++ scripts/kconfig/nconf-cfg.sh | 3 +++ 2 files changed, 6 insertions(+) (limited to 'scripts') diff --git a/scripts/kconfig/mconf-cfg.sh b/scripts/kconfig/mconf-cfg.sh index c812872d7f9d..aa68ec95620d 100755 --- a/scripts/kconfig/mconf-cfg.sh +++ b/scripts/kconfig/mconf-cfg.sh @@ -44,4 +44,7 @@ echo >&2 "* Unable to find the ncurses package." echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev" echo >&2 "* depending on your distribution)." echo >&2 "*" +echo >&2 "* You may also need to install pkg-config to find the" +echo >&2 "* ncurses installed in a non-default location." +echo >&2 "*" exit 1 diff --git a/scripts/kconfig/nconf-cfg.sh b/scripts/kconfig/nconf-cfg.sh index 001559ef0a60..c212255070c0 100755 --- a/scripts/kconfig/nconf-cfg.sh +++ b/scripts/kconfig/nconf-cfg.sh @@ -44,4 +44,7 @@ echo >&2 "* Unable to find the ncurses package." echo >&2 "* Install ncurses (ncurses-devel or libncurses-dev" echo >&2 "* depending on your distribution)." echo >&2 "*" +echo >&2 "* You may also need to install pkg-config to find the" +echo >&2 "* ncurses installed in a non-default location." +echo >&2 "*" exit 1 -- cgit From faade9610246e9e443068be8cb24c784e9a91f2e Mon Sep 17 00:00:00 2001 From: Bhaskar Chowdhury Date: Wed, 6 Nov 2019 09:06:10 +0530 Subject: scripts/ver_linux: add Bison and Flex to the checklist Signed-off-by: Bhaskar Chowdhury Acked-by: Alexander Kapshuk Signed-off-by: Masahiro Yamada --- scripts/ver_linux | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/ver_linux b/scripts/ver_linux index 810e608baa24..85005d6b7f10 100755 --- a/scripts/ver_linux +++ b/scripts/ver_linux @@ -32,6 +32,8 @@ BEGIN { printversion("PPP", version("pppd --version")) printversion("Isdn4k-utils", version("isdnctrl")) printversion("Nfs-utils", version("showmount --version")) + printversion("Bison", version("bison --version")) + printversion("Flex", version("flex --version")) while (getline <"/proc/self/maps" > 0) { if (/libc.*\.so$/) { -- cgit From bff9c62b5d20d26f54bab81b33b6d9d1f9afcdf6 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 29 Oct 2019 21:38:06 +0900 Subject: modpost: do not invoke extra modpost for nsdeps 'make nsdeps' invokes the modpost three times at most; before linking vmlinux, before building modules, and finally for generating .ns_deps files. Running the modpost again and again is not efficient. The last two can be unified. When the -d option is given, the modpost still does the usual job, and in addition, generates .ns_deps files. Signed-off-by: Masahiro Yamada Tested-by: Matthias Maennich Reviewed-by: Matthias Maennich --- scripts/Makefile.modpost | 8 +++----- scripts/mod/modpost.c | 9 ++------- 2 files changed, 5 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 20359c7887b3..0089417760f9 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -53,8 +53,7 @@ MODPOST = scripts/mod/modpost \ $(if $(KBUILD_EXTMOD),$(addprefix -e ,$(KBUILD_EXTRA_SYMBOLS))) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(if $(CONFIG_SECTION_MISMATCH_WARN_ONLY),,-E) \ - $(if $(KBUILD_MODPOST_WARN),-w) \ - $(if $(filter nsdeps,$(MAKECMDGOALS)),-d) + $(if $(KBUILD_MODPOST_WARN),-w) ifdef MODPOST_VMLINUX @@ -66,7 +65,8 @@ __modpost: else -MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - +MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ + $(if $(KBUILD_NSDEPS),-d) ifeq ($(KBUILD_EXTMOD),) MODPOST += $(wildcard vmlinux) @@ -96,8 +96,6 @@ ifneq ($(KBUILD_MODPOST_NOFINAL),1) $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modfinal endif -nsdeps: __modpost - endif .PHONY: $(PHONY) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 37fa1c65ee4d..1de983d9a05d 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2221,8 +2221,7 @@ static int check_exports(struct module *mod) add_namespace(&mod->required_namespaces, exp->namespace); - if (!write_namespace_deps && - !module_imports_namespace(mod, exp->namespace)) { + if (!module_imports_namespace(mod, exp->namespace)) { warn("module %s uses symbol %s from namespace %s, but does not import it.\n", basename, exp->name, exp->namespace); } @@ -2642,8 +2641,6 @@ int main(int argc, char **argv) err |= check_modname_len(mod); err |= check_exports(mod); - if (write_namespace_deps) - continue; add_header(&buf, mod); add_intree_flag(&buf, !external_module); @@ -2658,10 +2655,8 @@ int main(int argc, char **argv) write_if_changed(&buf, fname); } - if (write_namespace_deps) { + if (write_namespace_deps) write_namespace_deps_files(); - return 0; - } if (dump_write) write_dump(dump_write); -- cgit From 0241ea8cae19b49fc1b1459f7bbe9a77f4f9cc89 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 7 Nov 2019 00:19:59 +0900 Subject: modpost: free ns_deps_buf.p after writing ns_deps files buf_write() allocates memory. Free it. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1de983d9a05d..95f440d217e5 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2549,6 +2549,8 @@ static void write_namespace_deps_files(void) sprintf(fname, "%s.ns_deps", mod->name); write_if_changed(&ns_deps_buf, fname); } + + free(ns_deps_buf.p); } struct ext_sym_list { -- cgit From bbc55bded4aaf47d6f2bd9389fc8d3a3821d18c0 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 29 Oct 2019 21:38:07 +0900 Subject: modpost: dump missing namespaces into a single modules.nsdeps file The modpost, with the -d option given, generates per-module .ns_deps files. Kbuild generates per-module .mod files to carry module information. This is convenient because Make handles multiple jobs in parallel when the -j option is given. On the other hand, the modpost always runs as a single thread. I do not see a strong reason to produce separate .ns_deps files. This commit changes the modpost to generate just one file, modules.nsdeps, each line of which has the following format: : Please note it contains *missing* namespaces instead of required ones. So, modules.nsdeps is empty if the namespace dependency is all good. This will work more efficiently because spatch will no longer process already imported namespaces. I removed the '(if needed)' from the nsdeps log since spatch is invoked only when needed. This also solves the stale .ns_deps problem reported by Jessica Yu: https://lkml.org/lkml/2019/10/28/467 Signed-off-by: Masahiro Yamada Tested-by: Jessica Yu Acked-by: Jessica Yu Reviewed-by: Matthias Maennich Tested-by: Matthias Maennich --- scripts/Makefile.modpost | 2 +- scripts/mod/modpost.c | 42 +++++++++++++++++------------------------- scripts/mod/modpost.h | 4 ++-- scripts/nsdeps | 21 ++++++++++----------- 4 files changed, 30 insertions(+), 39 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 0089417760f9..62e127028b48 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -66,7 +66,7 @@ __modpost: else MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ - $(if $(KBUILD_NSDEPS),-d) + $(if $(KBUILD_NSDEPS),-d modules.nsdeps) ifeq ($(KBUILD_EXTMOD),) MODPOST += $(wildcard vmlinux) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 95f440d217e5..2cdbcdf197a3 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -38,8 +38,6 @@ static int sec_mismatch_count = 0; static int sec_mismatch_fatal = 0; /* ignore missing files */ static int ignore_missing_files; -/* write namespace dependencies */ -static int write_namespace_deps; enum export { export_plain, export_unused, export_gpl, @@ -2217,14 +2215,11 @@ static int check_exports(struct module *mod) else basename = mod->name; - if (exp->namespace) { - add_namespace(&mod->required_namespaces, - exp->namespace); - - if (!module_imports_namespace(mod, exp->namespace)) { - warn("module %s uses symbol %s from namespace %s, but does not import it.\n", - basename, exp->name, exp->namespace); - } + if (exp->namespace && + !module_imports_namespace(mod, exp->namespace)) { + warn("module %s uses symbol %s from namespace %s, but does not import it.\n", + basename, exp->name, exp->namespace); + add_namespace(&mod->missing_namespaces, exp->namespace); } if (!mod->gpl_compatible) @@ -2526,30 +2521,26 @@ static void write_dump(const char *fname) free(buf.p); } -static void write_namespace_deps_files(void) +static void write_namespace_deps_files(const char *fname) { struct module *mod; struct namespace_list *ns; struct buffer ns_deps_buf = {}; for (mod = modules; mod; mod = mod->next) { - char fname[PATH_MAX]; - if (mod->skip) + if (mod->skip || !mod->missing_namespaces) continue; - ns_deps_buf.pos = 0; - - for (ns = mod->required_namespaces; ns; ns = ns->next) - buf_printf(&ns_deps_buf, "%s\n", ns->namespace); + buf_printf(&ns_deps_buf, "%s.ko:", mod->name); - if (ns_deps_buf.pos == 0) - continue; + for (ns = mod->missing_namespaces; ns; ns = ns->next) + buf_printf(&ns_deps_buf, " %s", ns->namespace); - sprintf(fname, "%s.ns_deps", mod->name); - write_if_changed(&ns_deps_buf, fname); + buf_printf(&ns_deps_buf, "\n"); } + write_if_changed(&ns_deps_buf, fname); free(ns_deps_buf.p); } @@ -2563,6 +2554,7 @@ int main(int argc, char **argv) struct module *mod; struct buffer buf = { }; char *kernel_read = NULL; + char *missing_namespace_deps = NULL; char *dump_write = NULL, *files_source = NULL; int opt; int err; @@ -2570,7 +2562,7 @@ int main(int argc, char **argv) struct ext_sym_list *extsym_iter; struct ext_sym_list *extsym_start = NULL; - while ((opt = getopt(argc, argv, "i:e:mnsT:o:awEd")) != -1) { + while ((opt = getopt(argc, argv, "i:e:mnsT:o:awEd:")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -2609,7 +2601,7 @@ int main(int argc, char **argv) sec_mismatch_fatal = 1; break; case 'd': - write_namespace_deps = 1; + missing_namespace_deps = optarg; break; default: exit(1); @@ -2657,8 +2649,8 @@ int main(int argc, char **argv) write_if_changed(&buf, fname); } - if (write_namespace_deps) - write_namespace_deps_files(); + if (missing_namespace_deps) + write_namespace_deps_files(missing_namespace_deps); if (dump_write) write_dump(dump_write); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index ad271bc6c313..fe6652535e4b 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -126,8 +126,8 @@ struct module { struct buffer dev_table_buf; char srcversion[25]; int is_dot_o; - // Required namespace dependencies - struct namespace_list *required_namespaces; + // Missing namespace dependencies + struct namespace_list *missing_namespaces; // Actual imported namespaces struct namespace_list *imported_namespaces; }; diff --git a/scripts/nsdeps b/scripts/nsdeps index 04cea0921673..f802c6f7b860 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -27,15 +27,14 @@ generate_deps_for_ns() { } generate_deps() { - local mod_name=`basename $@ .ko` - 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=${1%.ko:} + shift + local namespaces="$*" + local mod_source_files="`cat $mod.mod | sed -n 1p \ | sed -e 's/\.o/\.c/g' \ | sed "s|[^ ]* *|${srctree}/&|g"`" - for ns in `cat $ns_deps_file`; do - echo "Adding namespace $ns to module $mod_name (if needed)." + for ns in $namespaces; do + echo "Adding namespace $ns to module $mod.ko." generate_deps_for_ns $ns "$mod_source_files" # sort the imports for source_file in $mod_source_files; do @@ -52,7 +51,7 @@ generate_deps() { done } -for f in `cat $objtree/modules.order`; do - generate_deps $f -done - +while read line +do + generate_deps $line +done < modules.nsdeps -- cgit From bc35d4bda205d85bf8f87bb013a59afb6b87bc89 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 29 Oct 2019 21:38:08 +0900 Subject: scripts/nsdeps: support nsdeps for external module builds scripts/nsdeps is written to take care of only in-tree modules. Perhaps, this is not a bug, but just a design. At least, Documentation/core-api/symbol-namespaces.rst focuses on in-tree modules. Having said that, some people already tried nsdeps for external modules. So, it would be nice to support it. Reported-by: Steve French Reported-by: Jessica Yu Signed-off-by: Masahiro Yamada Tested-by: Jessica Yu Acked-by: Jessica Yu Reviewed-by: Matthias Maennich Tested-by: Matthias Maennich --- scripts/Makefile.modpost | 2 +- scripts/nsdeps | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 62e127028b48..69897d5d3a70 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -66,7 +66,7 @@ __modpost: else MODPOST += $(subst -i,-n,$(filter -i,$(MAKEFLAGS))) -s -T - \ - $(if $(KBUILD_NSDEPS),-d modules.nsdeps) + $(if $(KBUILD_NSDEPS),-d $(MODULES_NSDEPS)) ifeq ($(KBUILD_EXTMOD),) MODPOST += $(wildcard vmlinux) diff --git a/scripts/nsdeps b/scripts/nsdeps index f802c6f7b860..03a8e7cbe6c7 100644 --- a/scripts/nsdeps +++ b/scripts/nsdeps @@ -21,6 +21,12 @@ if [ "$SPATCH_VERSION_NUM" -lt "$SPATCH_REQ_VERSION_NUM" ] ; then exit 1 fi +if [ "$KBUILD_EXTMOD" ]; then + src_prefix= +else + src_prefix=$srctree/ +fi + generate_deps_for_ns() { $SPATCH --very-quiet --in-place --sp-file \ $srctree/scripts/coccinelle/misc/add_namespace.cocci -D ns=$1 $2 @@ -32,7 +38,7 @@ generate_deps() { local namespaces="$*" local mod_source_files="`cat $mod.mod | sed -n 1p \ | sed -e 's/\.o/\.c/g' \ - | sed "s|[^ ]* *|${srctree}/&|g"`" + | sed "s|[^ ]* *|${src_prefix}&|g"`" for ns in $namespaces; do echo "Adding namespace $ns to module $mod.ko." generate_deps_for_ns $ns "$mod_source_files" @@ -54,4 +60,4 @@ generate_deps() { while read line do generate_deps $line -done < modules.nsdeps +done < $MODULES_NSDEPS -- cgit From 76b54cf033c9f2effc70066a2bbb2331013889a1 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Tue, 29 Oct 2019 21:38:09 +0900 Subject: modpost: remove unneeded local variable in contains_namespace() The local variable, ns_entry, is unneeded. While I was here, I also cleaned up the comparison with NULL or 0. Signed-off-by: Masahiro Yamada Reviewed-by: Matthias Maennich --- scripts/mod/modpost.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2cdbcdf197a3..46d7f695fe7f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -239,10 +239,8 @@ static struct symbol *find_symbol(const char *name) static bool contains_namespace(struct namespace_list *list, const char *namespace) { - struct namespace_list *ns_entry; - - for (ns_entry = list; ns_entry != NULL; ns_entry = ns_entry->next) - if (strcmp(ns_entry->namespace, namespace) == 0) + for (; list; list = list->next) + if (!strcmp(list->namespace, namespace)) return true; return false; -- cgit From 2d3b1b8f0da7b1b09f42231580d88f93b803ae7f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 8 Nov 2019 00:09:44 +0900 Subject: kbuild: drop $(wildcard $^) check in if_changed* for faster rebuild The incremental build of Linux kernel is pretty slow when lots of objects are compiled. The rebuild of allmodconfig may take a few minutes even when none of the objects needs to be rebuilt. The time-consuming part in the incremental build is the evaluation of if_changed* macros since they are used in the recipes to compile C and assembly source files into objects. I notice the following code in if_changed* is expensive: $(filter-out $(PHONY) $(wildcard $^),$^) In the incremental build, every object has its .*.cmd file, which contains the auto-generated list of included headers. So, $^ are expanded into the long list of the source file + included headers, and $(wildcard $^) checks whether they exist. It may not be clear why this check exists there. Here is the record of my research. [1] The first code addition into Kbuild This code dates back to 2002. It is the pre-git era. So, I copy-pasted it from the historical git tree. | commit 4a6db0791528c220655b063cf13fefc8470dbfee (HEAD) | Author: Kai Germaschewski | Date: Mon Jun 17 00:22:37 2002 -0500 | | kbuild: Handle removed headers | | New and old way to handle dependencies would choke when a file | #include'd by other files was removed, since the dependency on it was | still recorded, but since it was gone, make has no idea what to do about | it (and would complain with "No rule to make ...") | | We now add targets for all the previously included files, so make will | just ignore them if they disappear. | | diff --git a/Rules.make b/Rules.make | index 6ef827d3df39..7db5301ea7db 100644 | --- a/Rules.make | +++ b/Rules.make | @@ -446,7 +446,7 @@ if_changed = $(if $(strip $? \ | # execute the command and also postprocess generated .d dependencies | # file | | -if_changed_dep = $(if $(strip $? \ | +if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ | $(filter-out $(cmd_$(1)),$(cmd_$@))\ | $(filter-out $(cmd_$@),$(cmd_$(1)))),\ | @set -e; \ | diff --git a/scripts/fixdep.c b/scripts/fixdep.c | index b5d7bee8efc7..db45bd1888c0 100644 | --- a/scripts/fixdep.c | +++ b/scripts/fixdep.c | @@ -292,7 +292,7 @@ void parse_dep_file(void *map, size_t len) | exit(1); | } | memcpy(s, m, p-m); s[p-m] = 0; | - printf("%s: \\\n", target); | + printf("deps_%s := \\\n", target); | m = p+1; | | clear_config(); | @@ -314,7 +314,8 @@ void parse_dep_file(void *map, size_t len) | } | m = p + 1; | } | - printf("\n"); | + printf("\n%s: $(deps_%s)\n\n", target, target); | + printf("$(deps_%s):\n", target); | } | | void print_deps(void) The "No rule to make ..." error can be solved by passing -MP to the compiler, but I think the detection of header removal is a good feature. When a header is removed, all source files that previously included it should be re-compiled. This makes sure we has correctly got rid of #include directives of it. This is also related with the behavior of $?. The GNU Make manual says: $? The names of all the prerequisites that are newer than the target, with spaces between them. This does not explain whether a non-existent prerequisite is considered to be newer than the target. At this point of time, GNU Make 3.7x was used, where the $? did not include non-existent prerequisites. Therefore, $(filter-out FORCE $(wildcard $^),$^) was useful to detect the header removal, and to rebuild the related objects if it is the case. [2] Change of $? behavior Later, the behavior of $? was changed (fixed) to include prerequisites that did not exist. First, GNU Make commit 64e16d6c00a5 ("Various changes getting ready for the release of 3.81.") changed it, but in the release test of 3.81, it turned out to break the kernel build. See these: - http://lists.gnu.org/archive/html/bug-make/2006-03/msg00003.html - https://savannah.gnu.org/bugs/?16002 - https://savannah.gnu.org/bugs/?16051 Then, GNU Make commit 6d8d9b74d9c5 ("Numerous updates to tests for issues found on Cygwin and Windows.") reverted it for the 3.81 release to give Linux kernel time to adjust to the new behavior. After the 3.81 release, GNU Make commit 7595f38f62af ("Fixed a number of documentation bugs, plus some build/install issues:") re-added it. [3] Adjustment to the new $? behavior on Kbuild side Meanwhile, the kernel build was changed by commit 4f1933620f57 ("kbuild: change kbuild to not rely on incorrect GNU make behavior") to adjust to the new $? behavior. [4] GNU Make 3.82 released in 2010 GNU Make 3.82 was the first release that integrated the correct $? behavior. At this point, Kbuild dealt with GNU Make versions with different $? behaviors. 3.81 or older: $? does not contain any non-existent prerequisite. $(filter-out $(PHONY) $(wildcard $^),$^) was useful to detect removed include headers. 3.82 or newer: $? contains non-existent prerequisites. When a header is removed, it appears in $?. $(filter-out $(PHONY) $(wildcard $^),$^) became a redundant check. With the correct $? behavior, we could have dropped the expensive check for 3.82 or later, but we did not. (Maybe nobody noticed this optimization.) [5] The .SECONDARY special target trips up $? Some time later, I noticed $? did not work as expected under some circumstances. As above, $? should contain non-existent prerequisites, but the ones specified as SECONDARY do not appear in $?. I asked this in GNU Make ML, and it seems a bug: https://lists.gnu.org/archive/html/bug-make/2019-01/msg00001.html Since commit 8e9b61b293d9 ("kbuild: move .SECONDARY special target to Kbuild.include"), all files, including headers listed in .*.cmd files, are treated as secondary. So, we are back into the incorrect $? behavior. If we Kbuild want to react to the header removal, we need to keep $(filter-out $(PHONY) $(wildcard $^),$^) but this makes the rebuild so slow. [Summary] - I believe noticing the header removal and recompiling related objects is a nice feature for the build system. - If $? worked correctly, $(filter-out $(PHONY),$?) would be enough to detect the header removal. - Currently, $? does not work correctly when used with .SECONDARY, and Kbuild is hit by this bug. - I filed a bug report for this, but not fixed yet as of writing. - Currently, the header removal is detected by the following expensive code: $(filter-out $(PHONY) $(wildcard $^),$^) - I do not want to revert commit 8e9b61b293d9 ("kbuild: move .SECONDARY special target to Kbuild.include"). Specifying .SECONDARY globally is clean, and it matches to the Kbuild policy. This commit proactively removes the expensive check since it makes the incremental build faster. A downside is Kbuild will no longer be able to notice the header removal. You can confirm it by the full-build followed by a header removal, and then re-build. $ make defconfig all [ full build ] $ rm include/linux/device.h $ make CALL scripts/checksyscalls.sh CALL scripts/atomic/check-atomics.sh DESCEND objtool CHK include/generated/compile.h Kernel: arch/x86/boot/bzImage is ready (#11) Building modules, stage 2. MODPOST 12 modules Previously, Kbuild noticed a missing header and emits a build error. Now, Kbuild is fine with it. This is an unusual corner-case, not a big deal. Once the $? bug is fixed in GNU Make, everything will work fine. Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 10ba926ae292..b58a5227ff43 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -210,9 +210,12 @@ endif # (needed for the shell) make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))) -# Find any prerequisites that is newer than target or that does not exist. +# Find any prerequisites that are newer than target or that do not exist. +# (This is not true for now; $? should contain any non-existent prerequisites, +# but it does not work as expected when .SECONDARY is present. This seems a bug +# of GNU Make.) # PHONY targets skipped in both cases. -any-prereq = $(filter-out $(PHONY),$?)$(filter-out $(PHONY) $(wildcard $^),$^) +any-prereq = $(filter-out $(PHONY),$?) # Execute command if command has changed or prerequisite(s) are updated. if_changed = $(if $(any-prereq)$(cmd-check), \ -- cgit From eba19032f99c32ecfbe23ce99bb1546db0a23bee Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 8 Nov 2019 00:09:45 +0900 Subject: kbuild: rename any-prereq to newer-prereqs GNU Make manual says: $? The names of all the prerequisites that are newer than the target, with spaces between them. To reflect this, rename any-prereq to newer-prereqs, which is clearer and more intuitive. Signed-off-by: Masahiro Yamada --- scripts/Kbuild.include | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index b58a5227ff43..bc5f25763c1b 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -215,15 +215,15 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1)))) # but it does not work as expected when .SECONDARY is present. This seems a bug # of GNU Make.) # PHONY targets skipped in both cases. -any-prereq = $(filter-out $(PHONY),$?) +newer-prereqs = $(filter-out $(PHONY),$?) # Execute command if command has changed or prerequisite(s) are updated. -if_changed = $(if $(any-prereq)$(cmd-check), \ +if_changed = $(if $(newer-prereqs)$(cmd-check), \ $(cmd); \ printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:) # Execute the command and also postprocess generated .d dependencies file. -if_changed_dep = $(if $(any-prereq)$(cmd-check),$(cmd_and_fixdep),@:) +if_changed_dep = $(if $(newer-prereqs)$(cmd-check),$(cmd_and_fixdep),@:) cmd_and_fixdep = \ $(cmd); \ @@ -233,7 +233,7 @@ cmd_and_fixdep = \ # Usage: $(call if_changed_rule,foo) # Will check if $(cmd_foo) or any of the prerequisites changed, # and if so will execute $(rule_foo). -if_changed_rule = $(if $(any-prereq)$(cmd-check),$(rule_$(1)),@:) +if_changed_rule = $(if $(newer-prereqs)$(cmd-check),$(rule_$(1)),@:) ### # why - tell why a target got built @@ -258,7 +258,7 @@ ifeq ($(KBUILD_VERBOSE),2) why = \ $(if $(filter $@, $(PHONY)),- due to target is PHONY, \ $(if $(wildcard $@), \ - $(if $(any-prereq),- due to: $(any-prereq), \ + $(if $(newer-prereqs),- due to: $(newer-prereqs), \ $(if $(cmd-check), \ $(if $(cmd_$@),- due to command line change, \ $(if $(filter $@, $(targets)), \ -- cgit From fcbb8461fd2376ba3782b5b8bd440c929b8e4980 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 7 Nov 2019 16:14:40 +0900 Subject: kbuild: remove header compile test There are both positive and negative options about this feature. At first, I thought it was a good idea, but actually Linus stated a negative opinion (https://lkml.org/lkml/2019/9/29/227). I admit it is ugly and annoying. The baseline I'd like to keep is the compile-test of uapi headers. (Otherwise, kernel developers have no way to ensure the correctness of the exported headers.) I will maintain a small build rule in usr/include/Makefile. Remove the other header test functionality. Signed-off-by: Masahiro Yamada --- scripts/Makefile.build | 9 --------- scripts/Makefile.lib | 14 -------------- 2 files changed, 23 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 7eabbb66a65c..b734ac8a654e 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -283,15 +283,6 @@ quiet_cmd_cc_lst_c = MKLST $@ $(obj)/%.lst: $(src)/%.c FORCE $(call if_changed_dep,cc_lst_c) -# header test (header-test-y, header-test-m target) -# --------------------------------------------------------------------------- - -quiet_cmd_cc_s_h = CC $@ - cmd_cc_s_h = $(CC) $(c_flags) -S -o $@ -x c /dev/null -include $< - -$(obj)/%.h.s: $(src)/%.h FORCE - $(call if_changed_dep,cc_s_h) - # Compile assembler sources (.S) # --------------------------------------------------------------------------- diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 179d55af5852..3fa32f83b2d7 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -65,20 +65,6 @@ extra-y += $(patsubst %.dtb,%.dt.yaml, $(dtb-y)) extra-$(CONFIG_OF_ALL_DTBS) += $(patsubst %.dtb,%.dt.yaml, $(dtb-)) endif -# Test self-contained headers - -# Wildcard searches in $(srctree)/$(src)/, but not in $(objtree)/$(obj)/. -# Stale generated headers are often left over, so pattern matching should -# be avoided. Please notice $(srctree)/$(src)/ and $(objtree)/$(obj) point -# to the same location for in-tree building. So, header-test-pattern-y should -# be used with care. -header-test-y += $(filter-out $(header-test-), \ - $(patsubst $(srctree)/$(src)/%, %, \ - $(wildcard $(addprefix $(srctree)/$(src)/, \ - $(header-test-pattern-y))))) - -extra-$(CONFIG_HEADER_TEST) += $(addsuffix .s, $(header-test-y) $(header-test-m)) - # Add subdir path extra-y := $(addprefix $(obj)/,$(extra-y)) -- cgit From 7ecaf069da52e472d393f03e79d721aabd724166 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Thu, 7 Nov 2019 16:14:41 +0900 Subject: kbuild: move headers_check rule to usr/include/Makefile Currently, some sanity checks for uapi headers are done by scripts/headers_check.pl, which is wired up to the 'headers_check' target in the top Makefile. It is true compiling headers has better test coverage, but there are still several headers excluded from the compile test. I like to keep headers_check.pl for a while, but we can delete a lot of code by moving the build rule to usr/include/Makefile. Signed-off-by: Masahiro Yamada --- scripts/Makefile.headersinst | 18 ------------------ 1 file changed, 18 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index 1b405a7ed14f..708fbd08a2c5 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -56,9 +56,6 @@ new-dirs := $(filter-out $(existing-dirs), $(wanted-dirs)) $(if $(new-dirs), $(shell mkdir -p $(new-dirs))) # Rules - -ifndef HDRCHECK - quiet_cmd_install = HDRINST $@ cmd_install = $(CONFIG_SHELL) $(srctree)/scripts/headers_install.sh $< $@ @@ -81,21 +78,6 @@ existing-headers := $(filter $(old-headers), $(all-headers)) -include $(foreach f,$(existing-headers),$(dir $(f)).$(notdir $(f)).cmd) -else - -quiet_cmd_check = HDRCHK $< - cmd_check = $(PERL) $(srctree)/scripts/headers_check.pl $(dst) $(SRCARCH) $<; touch $@ - -check-files := $(addsuffix .chk, $(all-headers)) - -$(check-files): $(dst)/%.chk : $(dst)/% $(srctree)/scripts/headers_check.pl - $(call cmd,check) - -__headers: $(check-files) - @: - -endif - PHONY += FORCE FORCE: -- cgit From afa0459daa7b08c7b2c879705b69d39b734a11d0 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 15 Nov 2019 02:42:21 +0900 Subject: modpost: add a helper to get data pointed by a symbol When CONFIG_MODULE_REL_CRCS is enabled, the value of __crc_* is not an absolute value, but the address to the CRC data embedded in the .rodata section. Getting the data pointed by the symbol value is somewhat complex. Split it out into a new helper, sym_get_data(). I will reuse it to refactor namespace_from_kstrtabns() in the next commit. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 46d7f695fe7f..cd885573daaf 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -308,6 +308,18 @@ static const char *sec_name(struct elf_info *elf, int secindex) return sech_name(elf, &elf->sechdrs[secindex]); } +static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym) +{ + Elf_Shdr *sechdr = &info->sechdrs[sym->st_shndx]; + unsigned long offset; + + offset = sym->st_value; + if (info->hdr->e_type != ET_REL) + offset -= sechdr->sh_addr; + + return (void *)info->hdr + sechdr->sh_offset + offset; +} + #define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0) static enum export export_from_secname(struct elf_info *elf, unsigned int sec) @@ -697,10 +709,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, unsigned int *crcp; /* symbol points to the CRC in the ELF object */ - crcp = (void *)info->hdr + sym->st_value + - info->sechdrs[sym->st_shndx].sh_offset - - (info->hdr->e_type != ET_REL ? - info->sechdrs[sym->st_shndx].sh_addr : 0); + crcp = sym_get_data(info, sym); crc = TO_NATIVE(*crcp); } sym_update_crc(symname + strlen("__crc_"), mod, crc, -- cgit From e84f9fbbece1585f45a03ccc11eeabe121cadc1b Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 15 Nov 2019 02:42:22 +0900 Subject: modpost: refactor namespace_from_kstrtabns() to not hard-code section name Currently, namespace_from_kstrtabns() relies on the fact that namespace strings are recorded in the __ksymtab_strings section. Actually, it is coded in include/linux/export.h, but modpost does not need to hard-code the section name. Elf_Sym::st_shndx holds the index of the relevant section. Using it is a more portable way to get the namespace string. Make namespace_from_kstrtabns() simply call sym_get_data(), and delete the info->ksymtab_strings . While I was here, I added more 'const' qualifiers to pointers. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 10 +++------- scripts/mod/modpost.h | 1 - 2 files changed, 3 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index cd885573daaf..d9418c58a8c0 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -356,10 +356,10 @@ static enum export export_from_sec(struct elf_info *elf, unsigned int sec) return export_unknown; } -static const char *namespace_from_kstrtabns(struct elf_info *info, - Elf_Sym *kstrtabns) +static const char *namespace_from_kstrtabns(const struct elf_info *info, + const Elf_Sym *sym) { - char *value = info->ksymtab_strings + kstrtabns->st_value; + const char *value = sym_get_data(info, sym); return value[0] ? value : NULL; } @@ -601,10 +601,6 @@ 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; diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index fe6652535e4b..64a82d2d85f6 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -143,7 +143,6 @@ 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; -- cgit From 9bd2a099d7224281dd7756efa5c79df4f3fe8daf Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 15 Nov 2019 02:42:23 +0900 Subject: modpost: rename handle_modversions() to handle_symbol() This function handles not only modversions, but also unresolved symbols, export symbols, etc. Rename it to a more proper function name. While I was here, I also added the 'const' qualifier to *sym. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d9418c58a8c0..6735ae3da4c2 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -683,8 +683,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) return 0; } -static void handle_modversions(struct module *mod, struct elf_info *info, - Elf_Sym *sym, const char *symname) +static void handle_symbol(struct module *mod, struct elf_info *info, + const Elf_Sym *sym, const char *symname) { unsigned int crc; enum export export; @@ -2051,7 +2051,7 @@ static void read_symbols(const char *modname) for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { symname = remove_dot(info.strtab + sym->st_name); - handle_modversions(mod, &info, sym, symname); + handle_symbol(mod, &info, sym, symname); handle_moddevtable(mod, &info, sym, symname); } -- cgit From 1743694eb2357b47cd9951079f9ab0d728c916bf Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 15 Nov 2019 02:42:24 +0900 Subject: modpost: stop symbol preloading for modversion CRC It is complicated to add mocked-up symbols for pre-handling CRC. Handle CRC after all the export symbols in the relevant module are registered. Call handle_modversion() after the handle_symbol() iteration. In some cases, I see atand-alone __crc_* without __ksymtab_*. For example, ARCH=arm allyesconfig produces __crc_ccitt_veneer and __crc_itu_t_veneer. I guess they come from crc_ccitt, crc_itu_t, respectively. Since __*_veneer are auto-generated symbols, just ignore them. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 71 ++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 32 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 6735ae3da4c2..1c22cf7aa732 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -169,7 +169,7 @@ struct symbol { unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ unsigned int kernel:1; /* 1 if symbol is from kernel * (only for external modules) **/ - unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */ + unsigned int preloaded:1; /* 1 if symbol from Module.symvers */ unsigned int is_static:1; /* 1 if symbol is not global */ enum export export; /* Type of export */ char name[0]; @@ -410,16 +410,17 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, return s; } -static void sym_update_crc(const char *name, struct module *mod, - unsigned int crc, enum export export) +static void sym_set_crc(const char *name, unsigned int crc) { struct symbol *s = find_symbol(name); - if (!s) { - s = new_symbol(name, mod, export); - /* Don't complain when we find it later. */ - s->preloaded = 1; - } + /* + * Ignore stand-alone __crc_*, which might be auto-generated symbols + * such as __*_veneer in ARM ELF. + */ + if (!s) + return; + s->crc = crc; s->crc_valid = 1; } @@ -683,12 +684,34 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname) return 0; } +static void handle_modversion(const struct module *mod, + const struct elf_info *info, + const Elf_Sym *sym, const char *symname) +{ + unsigned int crc; + + if (sym->st_shndx == SHN_UNDEF) { + warn("EXPORT symbol \"%s\" [%s%s] version generation failed, symbol will not be versioned.\n", + symname, mod->name, is_vmlinux(mod->name) ? "":".ko"); + return; + } + + if (sym->st_shndx == SHN_ABS) { + crc = sym->st_value; + } else { + unsigned int *crcp; + + /* symbol points to the CRC in the ELF object */ + crcp = sym_get_data(info, sym); + crc = TO_NATIVE(*crcp); + } + sym_set_crc(symname, crc); +} + static void handle_symbol(struct module *mod, struct elf_info *info, const Elf_Sym *sym, const char *symname) { - unsigned int crc; enum export export; - bool is_crc = false; const char *name; if ((!is_vmlinux(mod->name) || mod->is_dot_o) && @@ -697,21 +720,6 @@ static void handle_symbol(struct module *mod, struct elf_info *info, else export = export_from_sec(info, get_secindex(info, sym)); - /* CRC'd symbol */ - if (strstarts(symname, "__crc_")) { - is_crc = true; - crc = (unsigned int) sym->st_value; - if (sym->st_shndx != SHN_UNDEF && sym->st_shndx != SHN_ABS) { - unsigned int *crcp; - - /* symbol points to the CRC in the ELF object */ - crcp = sym_get_data(info, sym); - crc = TO_NATIVE(*crcp); - } - sym_update_crc(symname + strlen("__crc_"), mod, crc, - export); - } - switch (sym->st_shndx) { case SHN_COMMON: if (strstarts(symname, "__gnu_lto_")) { @@ -746,11 +754,6 @@ static void handle_symbol(struct module *mod, struct elf_info *info, } #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_"), mod->name, e); - } mod->unres = alloc_symbol(symname, ELF_ST_BIND(sym->st_info) == STB_WEAK, mod->unres); @@ -2055,14 +2058,18 @@ static void read_symbols(const char *modname) handle_moddevtable(mod, &info, sym, symname); } - /* Apply symbol namespaces from __kstrtabns_ entries. */ for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { symname = remove_dot(info.strtab + sym->st_name); + /* Apply symbol namespaces from __kstrtabns_ entries. */ if (strstarts(symname, "__kstrtabns_")) sym_update_namespace(symname + strlen("__kstrtabns_"), namespace_from_kstrtabns(&info, sym)); + + if (strstarts(symname, "__crc_")) + handle_modversion(mod, &info, sym, + symname + strlen("__crc_")); } // check for static EXPORT_SYMBOL_* functions && global vars @@ -2476,7 +2483,7 @@ static void read_dump(const char *fname, unsigned int kernel) s->kernel = kernel; s->preloaded = 1; s->is_static = 0; - sym_update_crc(symname, mod, crc, export_no(export)); + sym_set_crc(symname, crc); sym_update_namespace(symname, namespace); } release_file(file, size); -- cgit From e4b26c9f75e48b5ef9e31ac6c8a445d4479b469c Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 15 Nov 2019 02:42:25 +0900 Subject: modpost: do not set ->preloaded for symbols from Module.symvers Now that there is no overwrap between symbols from ELF files and ones from Module.symvers. So, the 'exported twice' warning should be reported irrespective of where the symbol in question came from. The exceptional case is external module; in some cases, we build an external module to provide a different version/variant of the corresponding in-kernel module, overriding the same set of exported symbols. You can see this use-case in upstream; tools/testing/nvdimm/libnvdimm.ko replaces drivers/nvdimm/libnvdimm.ko in order to link it against mocked version of core kernel symbols. So, let's relax the 'exported twice' warning when building external modules. The multiple export from external modules is warned only when the previous one is from vmlinux or itself. With this refactoring, the ugly preloading goes away. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1c22cf7aa732..2fa58fbbd10b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -169,7 +169,6 @@ struct symbol { unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ unsigned int kernel:1; /* 1 if symbol is from kernel * (only for external modules) **/ - unsigned int preloaded:1; /* 1 if symbol from Module.symvers */ unsigned int is_static:1; /* 1 if symbol is not global */ enum export export; /* Type of export */ char name[0]; @@ -394,7 +393,8 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, if (!s) { s = new_symbol(name, mod, export); } else { - if (!s->preloaded) { + if (!external_module || is_vmlinux(s->module->name) || + s->module == mod) { warn("%s: '%s' exported twice. Previous export was in %s%s\n", mod->name, name, s->module->name, is_vmlinux(s->module->name) ? "" : ".ko"); @@ -403,7 +403,6 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, s->module = mod; } } - s->preloaded = 0; s->vmlinux = is_vmlinux(mod->name); s->kernel = 0; s->export = export; @@ -2481,7 +2480,6 @@ static void read_dump(const char *fname, unsigned int kernel) } s = sym_add_exported(symname, mod, export_no(export)); s->kernel = kernel; - s->preloaded = 1; s->is_static = 0; sym_set_crc(symname, crc); sym_update_namespace(symname, namespace); -- cgit From 7ef9ab3b32b4bb72a7d70b832d2eb12ceb93d9fd Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Fri, 15 Nov 2019 02:42:26 +0900 Subject: modpost: respect the previous export when 'exported twice' is warned When 'exported twice' is warned, let sym_add_exported() return without updating the symbol info. This respects the previous export, which is ordered first in modules.order This simplifies the code too. Signed-off-by: Masahiro Yamada --- scripts/mod/modpost.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2fa58fbbd10b..6e892c93d104 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -211,13 +211,11 @@ static struct symbol *new_symbol(const char *name, struct module *module, enum export export) { unsigned int hash; - struct symbol *new; hash = tdb_hash(name) % SYMBOL_HASH_SIZE; - new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]); - new->module = module; - new->export = export; - return new; + symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]); + + return symbolhash[hash]; } static struct symbol *find_symbol(const char *name) @@ -392,17 +390,15 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod, if (!s) { s = new_symbol(name, mod, export); - } else { - if (!external_module || is_vmlinux(s->module->name) || - s->module == mod) { - warn("%s: '%s' exported twice. Previous export was in %s%s\n", - mod->name, name, s->module->name, - is_vmlinux(s->module->name) ? "" : ".ko"); - } else { - /* In case Module.symvers was out of date */ - s->module = mod; - } + } else if (!external_module || is_vmlinux(s->module->name) || + s->module == mod) { + warn("%s: '%s' exported twice. Previous export was in %s%s\n", + mod->name, name, s->module->name, + is_vmlinux(s->module->name) ? "" : ".ko"); + return s; } + + s->module = mod; s->vmlinux = is_vmlinux(mod->name); s->kernel = 0; s->export = export; -- cgit From 1ef26b7c948128dc9240939da06690bfd90f4607 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:29 +0900 Subject: scripts/kallsyms: remove unneeded #ifndef ARRAY_SIZE This is not defined in the standard headers. #ifndef is unneeded. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index ae6504d07fd6..918c2ba071b5 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -24,9 +24,7 @@ #include #include -#ifndef ARRAY_SIZE #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(arr[0])) -#endif #define KSYM_NAME_LEN 128 -- cgit From 21915eca088dc271c970e8351290e83d938114ac Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:30 +0900 Subject: scripts/kallsyms: fix definitely-lost memory leak build_initial_tok_table() overwrites unused sym_entry to shrink the table size. Before the entry is overwritten, table[i].sym must be freed since it is malloc'ed data. This fixes the 'definitely lost' report from valgrind. I ran valgrind against x86_64_defconfig of v5.4-rc8 kernel, and here is the summary: [Before the fix] LEAK SUMMARY: definitely lost: 53,184 bytes in 2,874 blocks [After the fix] LEAK SUMMARY: definitely lost: 0 bytes in 0 blocks Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 918c2ba071b5..79641874d860 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -487,6 +487,8 @@ static void build_initial_tok_table(void) table[pos] = table[i]; learn_symbol(table[pos].sym, table[pos].len); pos++; + } else { + free(table[i].sym); } } table_cnt = pos; -- cgit From 5e5c4fa787453292d3deefd59129384d391b7f45 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:31 +0900 Subject: scripts/kallsyms: shrink table before sorting it Currently, build_initial_tok_table() trims unused symbols, but it is called after sort_symbols(). It is not efficient to sort the huge table that contains unused entries. Shrink the table before sorting it. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 49 +++++++++++++++++++++++++++++-------------------- 1 file changed, 29 insertions(+), 20 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 79641874d860..de986eda41a6 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -268,6 +268,30 @@ static int symbol_valid(struct sym_entry *s) return 1; } +/* remove all the invalid symbols from the table */ +static void shrink_table(void) +{ + unsigned int i, pos; + + pos = 0; + for (i = 0; i < table_cnt; i++) { + if (symbol_valid(&table[i])) { + if (pos != i) + table[pos] = table[i]; + pos++; + } else { + free(table[i].sym); + } + } + table_cnt = pos; + + /* When valid symbol is not registered, exit to error */ + if (!table_cnt) { + fprintf(stderr, "No valid symbol.\n"); + exit(1); + } +} + static void read_map(FILE *in) { while (!feof(in)) { @@ -475,23 +499,13 @@ static void forget_symbol(unsigned char *symbol, int len) token_profit[ symbol[i] + (symbol[i + 1] << 8) ]--; } -/* remove all the invalid symbols from the table and do the initial token count */ +/* do the initial token count */ static void build_initial_tok_table(void) { - unsigned int i, pos; + unsigned int i; - pos = 0; - for (i = 0; i < table_cnt; i++) { - if ( symbol_valid(&table[i]) ) { - if (pos != i) - table[pos] = table[i]; - learn_symbol(table[pos].sym, table[pos].len); - pos++; - } else { - free(table[i].sym); - } - } - table_cnt = pos; + for (i = 0; i < table_cnt; i++) + learn_symbol(table[i].sym, table[i].len); } static void *find_token(unsigned char *str, int len, unsigned char *token) @@ -614,12 +628,6 @@ static void optimize_token_table(void) insert_real_symbols_in_table(); - /* When valid symbol is not registered, exit to error */ - if (!table_cnt) { - fprintf(stderr, "No valid symbol.\n"); - exit(1); - } - optimize_result(); } @@ -756,6 +764,7 @@ int main(int argc, char **argv) usage(); read_map(stdin); + shrink_table(); if (absolute_percpu) make_percpus_absolute(); if (base_relative) -- cgit From f34ea0291029781810ca4c213713dc6b4a686322 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:32 +0900 Subject: scripts/kallsyms: set relative_base more effectively Currently, record_relative_base() iterates over the entire table to find the minimum address, but it is not efficient because we sort the table anyway. After sort_symbol(), the table is sorted by address. (kallsyms parses the 'nm -n' output, so the data is already sorted by address, but this commit does not rely on it.) Move record_relative_base() after sort_symbols(), and take the first non-absolute symbol value. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index de986eda41a6..c9efb67c6ecb 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -739,11 +739,15 @@ static void record_relative_base(void) { unsigned int i; - relative_base = -1ULL; for (i = 0; i < table_cnt; i++) - if (!symbol_absolute(&table[i]) && - table[i].addr < relative_base) + if (!symbol_absolute(&table[i])) { + /* + * The table is sorted by address. + * Take the first non-absolute symbol value. + */ relative_base = table[i].addr; + return; + } } int main(int argc, char **argv) @@ -767,9 +771,9 @@ int main(int argc, char **argv) shrink_table(); if (absolute_percpu) make_percpus_absolute(); + sort_symbols(); if (base_relative) record_relative_base(); - sort_symbols(); optimize_token_table(); write_src(); -- cgit From e0109042cc4ee12b3689e29c872c1436e0424c69 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:33 +0900 Subject: scripts/kallsyms: remove redundant is_arm_mapping_symbol() Since commit 6f00df24ee39 ("[PATCH] Strip local symbols from kallsyms"), all symbols starting '$' are ignored. is_arm_mapping_symbol() particularly ignores $a, $t, etc. but it is redundant. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index c9efb67c6ecb..14a50c8d3f34 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -74,16 +74,6 @@ static void usage(void) exit(1); } -/* - * This ignores the intensely annoying "mapping symbols" found - * in ARM ELF files: $a, $t and $d. - */ -static int is_arm_mapping_symbol(const char *str) -{ - return str[0] == '$' && strchr("axtd", str[1]) - && (str[2] == '\0' || str[2] == '.'); -} - static int check_symbol_range(const char *sym, unsigned long long addr, struct addr_range *ranges, int entries) { @@ -139,10 +129,13 @@ static int read_symbol(FILE *in, struct sym_entry *s) return -1; } - else if (toupper(stype) == 'U' || - is_arm_mapping_symbol(sym)) + else if (toupper(stype) == 'U') return -1; - /* exclude also MIPS ELF local symbols ($L123 instead of .L123) */ + /* + * Ignore generated symbols such as: + * - mapping symbols in ARM ELF files ($a, $t, and $d) + * - MIPS ELF local symbols ($L123 instead of .L123) + */ else if (sym[0] == '$') return -1; /* exclude debugging symbols */ -- cgit From c5e5002f3603e01f50d8d61878a4ca8ffca7bd15 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:34 +0900 Subject: scripts/kallsyms: remove unneeded length check for prefix matching l <= strlen(sym_name) is unnecessary for prefix matching. strncmp() will do. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 14a50c8d3f34..a57636c6f84f 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -246,8 +246,7 @@ static int symbol_valid(struct sym_entry *s) for (i = 0; special_prefixes[i]; i++) { int l = strlen(special_prefixes[i]); - if (l <= strlen(sym_name) && - strncmp(sym_name, special_prefixes[i], l) == 0) + if (strncmp(sym_name, special_prefixes[i], l) == 0) return 0; } -- cgit From 29e55ad3d5f50eca6f8762749da85d6fa1250061 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:35 +0900 Subject: scripts/kallsyms: add sym_name() to mitigate cast ugliness sym_entry::sym is (unsigned char *) instead of (char *) because kallsyms exploits the MSB for compression, and the characters are used as the index of token_profit array. However, it requires casting (unsigned char *) to (char *) in some places since standard library functions such as strcmp(), strlen() expect (char *). Introduce a new helper, sym_name(), which advances the given pointer by 1 and casts it to (char *). Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index a57636c6f84f..baa2fa5692b0 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -74,6 +74,11 @@ static void usage(void) exit(1); } +static char *sym_name(const struct sym_entry *s) +{ + return (char *)s->sym + 1; +} + static int check_symbol_range(const char *sym, unsigned long long addr, struct addr_range *ranges, int entries) { @@ -154,7 +159,7 @@ static int read_symbol(FILE *in, struct sym_entry *s) "unable to allocate required amount of memory\n"); exit(EXIT_FAILURE); } - strcpy((char *)s->sym + 1, sym); + strcpy(sym_name(s), sym); s->sym[0] = stype; s->percpu_absolute = 0; @@ -215,7 +220,7 @@ static int symbol_valid(struct sym_entry *s) NULL }; int i; - char *sym_name = (char *)s->sym + 1; + const char *name = sym_name(s); /* if --all-symbols is not specified, then symbols outside the text * and inittext sections are discarded */ @@ -230,30 +235,28 @@ static int symbol_valid(struct sym_entry *s) * rules. */ if ((s->addr == text_range_text->end && - strcmp(sym_name, - text_range_text->end_sym)) || + strcmp(name, text_range_text->end_sym)) || (s->addr == text_range_inittext->end && - strcmp(sym_name, - text_range_inittext->end_sym))) + strcmp(name, text_range_inittext->end_sym))) return 0; } /* Exclude symbols which vary between passes. */ for (i = 0; special_symbols[i]; i++) - if (strcmp(sym_name, special_symbols[i]) == 0) + if (strcmp(name, special_symbols[i]) == 0) return 0; for (i = 0; special_prefixes[i]; i++) { int l = strlen(special_prefixes[i]); - if (strncmp(sym_name, special_prefixes[i], l) == 0) + if (strncmp(name, special_prefixes[i], l) == 0) return 0; } for (i = 0; special_suffixes[i]; i++) { - int l = strlen(sym_name) - strlen(special_suffixes[i]); + int l = strlen(name) - strlen(special_suffixes[i]); - if (l >= 0 && strcmp(sym_name + l, special_suffixes[i]) == 0) + if (l >= 0 && strcmp(name + l, special_suffixes[i]) == 0) return 0; } @@ -626,7 +629,7 @@ static void optimize_token_table(void) /* guess for "linker script provide" symbol */ static int may_be_linker_script_provide_symbol(const struct sym_entry *se) { - const char *symbol = (char *)se->sym + 1; + const char *symbol = sym_name(se); int len = se->len - 1; if (len < 8) @@ -696,8 +699,8 @@ static int compare_symbols(const void *a, const void *b) return wa - wb; /* sort by the number of prefix underscores */ - wa = prefix_underscores_count((const char *)sa->sym + 1); - wb = prefix_underscores_count((const char *)sb->sym + 1); + wa = prefix_underscores_count(sym_name(sa)); + wb = prefix_underscores_count(sym_name(sb)); if (wa != wb) return wa - wb; -- cgit From aa915245005bdb45ccbc96964853b4a27646390f Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:36 +0900 Subject: scripts/kallsyms: replace prefix_underscores_count() with strspn() You can do equivalent things with strspn(). I do not see noticeable performance difference. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index baa2fa5692b0..89cc7c098c51 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -661,16 +661,6 @@ static int may_be_linker_script_provide_symbol(const struct sym_entry *se) return 0; } -static int prefix_underscores_count(const char *str) -{ - const char *tail = str; - - while (*tail == '_') - tail++; - - return tail - str; -} - static int compare_symbols(const void *a, const void *b) { const struct sym_entry *sa; @@ -699,8 +689,8 @@ static int compare_symbols(const void *a, const void *b) return wa - wb; /* sort by the number of prefix underscores */ - wa = prefix_underscores_count(sym_name(sa)); - wb = prefix_underscores_count(sym_name(sb)); + wa = strspn(sym_name(sa), "_"); + wb = strspn(sym_name(sb), "_"); if (wa != wb) return wa - wb; -- cgit From 2558c138aca75e5fc435e20fd37f0b0eea61bb65 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:37 +0900 Subject: scripts/kallsyms: make find_token() return (unsigned char *) The callers of this function expect (unsigned char *). I do not see a good reason to make this function return (void *). Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 89cc7c098c51..274a77bfbd63 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -503,7 +503,8 @@ static void build_initial_tok_table(void) learn_symbol(table[i].sym, table[i].len); } -static void *find_token(unsigned char *str, int len, unsigned char *token) +static unsigned char *find_token(unsigned char *str, int len, + unsigned char *token) { int i; -- cgit From 4bfe2b7816a6e97fba7b4125166b33db4b31d29d Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:38 +0900 Subject: scripts/kallsyms: add const qualifiers where possible Add 'const' where a function does not write to the pointer dereferenes. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 274a77bfbd63..056bde436540 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -170,11 +170,11 @@ static int read_symbol(FILE *in, struct sym_entry *s) return 0; } -static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges, - int entries) +static int symbol_in_range(const struct sym_entry *s, + const struct addr_range *ranges, int entries) { size_t i; - struct addr_range *ar; + const struct addr_range *ar; for (i = 0; i < entries; ++i) { ar = &ranges[i]; @@ -186,14 +186,14 @@ static int symbol_in_range(struct sym_entry *s, struct addr_range *ranges, return 0; } -static int symbol_valid(struct sym_entry *s) +static int symbol_valid(const struct sym_entry *s) { /* Symbols which vary between passes. Passes 1 and 2 must have * identical symbol lists. The kallsyms_* symbols below are only added * after pass 1, they would be included in pass 2 when --all-symbols is * specified so exclude them to get a stable symbol list. */ - static char *special_symbols[] = { + static const char * const special_symbols[] = { "kallsyms_addresses", "kallsyms_offsets", "kallsyms_relative_base", @@ -208,12 +208,12 @@ static int symbol_valid(struct sym_entry *s) "_SDA2_BASE_", /* ppc */ NULL }; - static char *special_prefixes[] = { + static const char * const special_prefixes[] = { "__crc_", /* modversions */ "__efistub_", /* arm64 EFI stub namespace */ NULL }; - static char *special_suffixes[] = { + static const char * const special_suffixes[] = { "_veneer", /* arm */ "_from_arm", /* arm */ "_from_thumb", /* arm */ @@ -305,7 +305,7 @@ static void read_map(FILE *in) } } -static void output_label(char *label) +static void output_label(const char *label) { printf(".globl %s\n", label); printf("\tALGN\n"); @@ -314,7 +314,7 @@ static void output_label(char *label) /* uncompress a compressed symbol. When this function is called, the best table * might still be compressed itself, so the function needs to be recursive */ -static int expand_symbol(unsigned char *data, int len, char *result) +static int expand_symbol(const unsigned char *data, int len, char *result) { int c, rlen, total=0; @@ -339,7 +339,7 @@ static int expand_symbol(unsigned char *data, int len, char *result) return total; } -static int symbol_absolute(struct sym_entry *s) +static int symbol_absolute(const struct sym_entry *s) { return s->percpu_absolute; } @@ -477,7 +477,7 @@ static void write_src(void) /* table lookup compression functions */ /* count all the possible tokens in a symbol */ -static void learn_symbol(unsigned char *symbol, int len) +static void learn_symbol(const unsigned char *symbol, int len) { int i; @@ -486,7 +486,7 @@ static void learn_symbol(unsigned char *symbol, int len) } /* decrease the count for all the possible tokens in a symbol */ -static void forget_symbol(unsigned char *symbol, int len) +static void forget_symbol(const unsigned char *symbol, int len) { int i; @@ -504,7 +504,7 @@ static void build_initial_tok_table(void) } static unsigned char *find_token(unsigned char *str, int len, - unsigned char *token) + const unsigned char *token) { int i; @@ -517,7 +517,7 @@ static unsigned char *find_token(unsigned char *str, int len, /* replace a given token in all the valid symbols. Use the sampled symbols * to update the counts */ -static void compress_symbols(unsigned char *str, int idx) +static void compress_symbols(const unsigned char *str, int idx) { unsigned int i, len, size; unsigned char *p1, *p2; -- cgit From a41333e06acd1b37f3a3248fb90cd417218f9439 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:39 +0900 Subject: scripts/kallsyms: skip ignored symbols very early Unless the address range matters, symbols can be ignored earlier, which avoids unneeded memory allocation. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 113 +++++++++++++++++++++++++++++------------------------ 1 file changed, 62 insertions(+), 51 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 056bde436540..843615c1d384 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -18,6 +18,7 @@ * */ +#include #include #include #include @@ -79,6 +80,64 @@ static char *sym_name(const struct sym_entry *s) return (char *)s->sym + 1; } +static bool is_ignored_symbol(const char *name, char type) +{ + static const char * const ignored_symbols[] = { + /* + * Symbols which vary between passes. Passes 1 and 2 must have + * identical symbol lists. The kallsyms_* symbols below are + * only added after pass 1, they would be included in pass 2 + * when --all-symbols is specified so exclude them to get a + * stable symbol list. + */ + "kallsyms_addresses", + "kallsyms_offsets", + "kallsyms_relative_base", + "kallsyms_num_syms", + "kallsyms_names", + "kallsyms_markers", + "kallsyms_token_table", + "kallsyms_token_index", + /* Exclude linker generated symbols which vary between passes */ + "_SDA_BASE_", /* ppc */ + "_SDA2_BASE_", /* ppc */ + NULL + }; + + static const char * const ignored_prefixes[] = { + "__crc_", /* modversions */ + "__efistub_", /* arm64 EFI stub namespace */ + NULL + }; + + static const char * const ignored_suffixes[] = { + "_from_arm", /* arm */ + "_from_thumb", /* arm */ + "_veneer", /* arm */ + NULL + }; + + const char * const *p; + + /* Exclude symbols which vary between passes. */ + for (p = ignored_symbols; *p; p++) + if (!strcmp(name, *p)) + return true; + + for (p = ignored_prefixes; *p; p++) + if (!strncmp(name, *p, strlen(*p))) + return true; + + for (p = ignored_suffixes; *p; p++) { + int l = strlen(name) - strlen(*p); + + if (l >= 0 && !strcmp(name + l, *p)) + return true; + } + + return false; +} + static int check_symbol_range(const char *sym, unsigned long long addr, struct addr_range *ranges, int entries) { @@ -118,6 +177,9 @@ static int read_symbol(FILE *in, struct sym_entry *s) return -1; } + if (is_ignored_symbol(sym, stype)) + return -1; + /* Ignore most absolute/undefined (?) symbols. */ if (strcmp(sym, "_text") == 0) _text = s->addr; @@ -188,38 +250,6 @@ static int symbol_in_range(const struct sym_entry *s, static int symbol_valid(const struct sym_entry *s) { - /* Symbols which vary between passes. Passes 1 and 2 must have - * identical symbol lists. The kallsyms_* symbols below are only added - * after pass 1, they would be included in pass 2 when --all-symbols is - * specified so exclude them to get a stable symbol list. - */ - static const char * const special_symbols[] = { - "kallsyms_addresses", - "kallsyms_offsets", - "kallsyms_relative_base", - "kallsyms_num_syms", - "kallsyms_names", - "kallsyms_markers", - "kallsyms_token_table", - "kallsyms_token_index", - - /* Exclude linker generated symbols which vary between passes */ - "_SDA_BASE_", /* ppc */ - "_SDA2_BASE_", /* ppc */ - NULL }; - - static const char * const special_prefixes[] = { - "__crc_", /* modversions */ - "__efistub_", /* arm64 EFI stub namespace */ - NULL }; - - static const char * const special_suffixes[] = { - "_veneer", /* arm */ - "_from_arm", /* arm */ - "_from_thumb", /* arm */ - NULL }; - - int i; const char *name = sym_name(s); /* if --all-symbols is not specified, then symbols outside the text @@ -241,25 +271,6 @@ static int symbol_valid(const struct sym_entry *s) return 0; } - /* Exclude symbols which vary between passes. */ - for (i = 0; special_symbols[i]; i++) - if (strcmp(name, special_symbols[i]) == 0) - return 0; - - for (i = 0; special_prefixes[i]; i++) { - int l = strlen(special_prefixes[i]); - - if (strncmp(name, special_prefixes[i], l) == 0) - return 0; - } - - for (i = 0; special_suffixes[i]; i++) { - int l = strlen(name) - strlen(special_suffixes[i]); - - if (l >= 0 && strcmp(name + l, special_suffixes[i]) == 0) - return 0; - } - return 1; } -- cgit From 97261e1e2240f627e27e93f7e410be1a7c97c80a Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:40 +0900 Subject: scripts/kallsyms: move more patterns to the ignored_prefixes array Refactoring for shortening the code. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 843615c1d384..04a1dd16edcf 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -105,6 +105,8 @@ static bool is_ignored_symbol(const char *name, char type) }; static const char * const ignored_prefixes[] = { + "$", /* local symbols for ARM, MIPS, etc. */ + ".LASANPC", /* s390 kasan local symbols */ "__crc_", /* modversions */ "__efistub_", /* arm64 EFI stub namespace */ NULL @@ -198,19 +200,9 @@ static int read_symbol(FILE *in, struct sym_entry *s) } else if (toupper(stype) == 'U') return -1; - /* - * Ignore generated symbols such as: - * - mapping symbols in ARM ELF files ($a, $t, and $d) - * - MIPS ELF local symbols ($L123 instead of .L123) - */ - else if (sym[0] == '$') - return -1; /* exclude debugging symbols */ else if (stype == 'N' || stype == 'n') return -1; - /* exclude s390 kasan local symbols */ - else if (!strncmp(sym, ".LASANPC", 8)) - return -1; /* include the type field in the symbol name, so that it gets * compressed together */ -- cgit From 887df76de67f5a6dd423e5763c22ff07f0e50048 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:41 +0900 Subject: scripts/kallsyms: move ignored symbol types to is_ignored_symbol() Collect the ignored patterns to is_ignored_symbol(). Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 04a1dd16edcf..d90a6133d7b8 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -137,6 +137,21 @@ static bool is_ignored_symbol(const char *name, char type) return true; } + if (type == 'U' || type == 'u') + return true; + /* exclude debugging symbols */ + if (type == 'N' || type == 'n') + return true; + + if (toupper(type) == 'A') { + /* Keep these useful absolute symbols */ + if (strcmp(name, "__kernel_syscall_via_break") && + strcmp(name, "__kernel_syscall_via_epc") && + strcmp(name, "__kernel_sigtramp") && + strcmp(name, "__gp")) + return true; + } + return false; } @@ -188,21 +203,6 @@ static int read_symbol(FILE *in, struct sym_entry *s) else if (check_symbol_range(sym, s->addr, text_ranges, ARRAY_SIZE(text_ranges)) == 0) /* nothing to do */; - else if (toupper(stype) == 'A') - { - /* Keep these useful absolute symbols */ - if (strcmp(sym, "__kernel_syscall_via_break") && - strcmp(sym, "__kernel_syscall_via_epc") && - strcmp(sym, "__kernel_sigtramp") && - strcmp(sym, "__gp")) - return -1; - - } - else if (toupper(stype) == 'U') - return -1; - /* exclude debugging symbols */ - else if (stype == 'N' || stype == 'n') - return -1; /* include the type field in the symbol name, so that it gets * compressed together */ -- cgit From b6233d0ded3391a33bb0047edafe15169131eadb Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:42 +0900 Subject: scripts/kallsyms: make check_symbol_range() void function There is no more reason to check the return value of check_symbol_range(). Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index d90a6133d7b8..f4d5f131556d 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -155,8 +155,8 @@ static bool is_ignored_symbol(const char *name, char type) return false; } -static int check_symbol_range(const char *sym, unsigned long long addr, - struct addr_range *ranges, int entries) +static void check_symbol_range(const char *sym, unsigned long long addr, + struct addr_range *ranges, int entries) { size_t i; struct addr_range *ar; @@ -166,14 +166,12 @@ static int check_symbol_range(const char *sym, unsigned long long addr, if (strcmp(sym, ar->start_sym) == 0) { ar->start = addr; - return 0; + return; } else if (strcmp(sym, ar->end_sym) == 0) { ar->end = addr; - return 0; + return; } } - - return 1; } static int read_symbol(FILE *in, struct sym_entry *s) @@ -200,9 +198,8 @@ static int read_symbol(FILE *in, struct sym_entry *s) /* Ignore most absolute/undefined (?) symbols. */ if (strcmp(sym, "_text") == 0) _text = s->addr; - else if (check_symbol_range(sym, s->addr, text_ranges, - ARRAY_SIZE(text_ranges)) == 0) - /* nothing to do */; + + check_symbol_range(sym, s->addr, text_ranges, ARRAY_SIZE(text_ranges)); /* include the type field in the symbol name, so that it gets * compressed together */ -- cgit From d44270fc976b6c3b9e742e398580e4af8c69f7bd Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:43 +0900 Subject: scripts/kallsyms: put check_symbol_range() calls close together Put the relevant code close together. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index f4d5f131556d..b9b1a4cf1c65 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -200,6 +200,7 @@ static int read_symbol(FILE *in, struct sym_entry *s) _text = s->addr; check_symbol_range(sym, s->addr, text_ranges, ARRAY_SIZE(text_ranges)); + check_symbol_range(sym, s->addr, &percpu_range, 1); /* include the type field in the symbol name, so that it gets * compressed together */ @@ -215,9 +216,6 @@ static int read_symbol(FILE *in, struct sym_entry *s) s->percpu_absolute = 0; - /* Record if we've found __per_cpu_start/end. */ - check_symbol_range(sym, s->addr, &percpu_range, 1); - return 0; } -- cgit From 831362fc317ae60413879deacdcc9617d9ce9e20 Mon Sep 17 00:00:00 2001 From: Masahiro Yamada Date: Sun, 24 Nov 2019 01:04:44 +0900 Subject: scripts/kallsyms: remove redundant initializers These are set to zero without the explicit initializers. Signed-off-by: Masahiro Yamada --- scripts/kallsyms.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index b9b1a4cf1c65..fb55f262f42d 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -57,9 +57,9 @@ static struct addr_range percpu_range = { static struct sym_entry *table; static unsigned int table_size, table_cnt; -static int all_symbols = 0; -static int absolute_percpu = 0; -static int base_relative = 0; +static int all_symbols; +static int absolute_percpu; +static int base_relative; static int token_profit[0x10000]; -- cgit