diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-28 16:22:35 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-28 16:22:35 -0400 |
commit | ac747c0715f29c2be3848b719a1b7e65b07f7b21 (patch) | |
tree | 600d57fa0f71b545fea3eb5fe3f47a7124c713e3 | |
parent | f8cab69be0a8a756a7409f6d2bd1e6e96ce46482 (diff) | |
parent | c2b1a9226fe7c1cee8f0ae42496f3eb282d73ebb (diff) |
Merge tag 'kbuild-v4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada:
- optimize kallsyms slightly
- remove check for old CFLAGS usage
- add some compiler flags unconditionally instead of evaluating
$(call cc-option,...)
- fix variable shadowing in host tools
- refactor scripts/mkmakefile
- refactor various makefiles
* tag 'kbuild-v4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
modpost: Create macro to avoid variable shadowing
ASN.1: Remove unnecessary shadowed local variable
kbuild: use 'else ifeq' for checksrc to improve readability
kbuild: remove unneeded link_multi_deps
kbuild: add -Wno-unused-but-set-variable flag unconditionally
kbuild: add -Wdeclaration-after-statement flag unconditionally
kbuild: add -Wno-pointer-sign flag unconditionally
modpost: remove leftover symbol prefix handling for module device table
kbuild: simplify command line creation in scripts/mkmakefile
kbuild: do not pass $(objtree) to scripts/mkmakefile
kbuild: remove user ID check in scripts/mkmakefile
kbuild: remove VERSION and PATCHLEVEL from $(objtree)/Makefile
kbuild: add --include-dir flag only for out-of-tree build
kbuild: remove dead code in cmd_files calculation in top Makefile
kbuild: hide most of targets when running config or mixed targets
kbuild: remove old check for CFLAGS use
kbuild: prefix Makefile.dtbinst path with $(srctree) unconditionally
kallsyms: remove left-over Blackfin code
kallsyms: reduce size a little on 64-bit
-rw-r--r-- | Makefile | 31 | ||||
-rw-r--r-- | kernel/kallsyms.c | 4 | ||||
-rw-r--r-- | scripts/Kbuild.include | 2 | ||||
-rw-r--r-- | scripts/Makefile.build | 44 | ||||
-rw-r--r-- | scripts/asn1_compiler.c | 2 | ||||
-rw-r--r-- | scripts/kallsyms.c | 6 | ||||
-rwxr-xr-x | scripts/mkmakefile | 22 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 26 |
8 files changed, 53 insertions, 84 deletions
@@ -15,10 +15,9 @@ NAME = "People's Front" | |||
15 | PHONY := _all | 15 | PHONY := _all |
16 | _all: | 16 | _all: |
17 | 17 | ||
18 | # o Do not use make's built-in rules and variables | 18 | # Do not use make's built-in rules and variables |
19 | # (this increases performance and avoids hard-to-debug behaviour); | 19 | # (this increases performance and avoids hard-to-debug behaviour) |
20 | # o Look for make include files relative to root of kernel src | 20 | MAKEFLAGS += -rR |
21 | MAKEFLAGS += -rR --include-dir=$(CURDIR) | ||
22 | 21 | ||
23 | # Avoid funny character set dependencies | 22 | # Avoid funny character set dependencies |
24 | unexport LC_ALL | 23 | unexport LC_ALL |
@@ -136,6 +135,13 @@ KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \ | |||
136 | $(if $(KBUILD_OUTPUT),, \ | 135 | $(if $(KBUILD_OUTPUT),, \ |
137 | $(error failed to create output directory "$(saved-output)")) | 136 | $(error failed to create output directory "$(saved-output)")) |
138 | 137 | ||
138 | # Look for make include files relative to root of kernel src | ||
139 | # | ||
140 | # This does not become effective immediately because MAKEFLAGS is re-parsed | ||
141 | # once after the Makefile is read. It is OK since we are going to invoke | ||
142 | # 'sub-make' below. | ||
143 | MAKEFLAGS += --include-dir=$(CURDIR) | ||
144 | |||
139 | PHONY += $(MAKECMDGOALS) sub-make | 145 | PHONY += $(MAKECMDGOALS) sub-make |
140 | 146 | ||
141 | $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make | 147 | $(filter-out _all sub-make $(CURDIR)/Makefile, $(MAKECMDGOALS)) _all: sub-make |
@@ -476,8 +482,7 @@ PHONY += outputmakefile | |||
476 | outputmakefile: | 482 | outputmakefile: |
477 | ifneq ($(KBUILD_SRC),) | 483 | ifneq ($(KBUILD_SRC),) |
478 | $(Q)ln -fsn $(srctree) source | 484 | $(Q)ln -fsn $(srctree) source |
479 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile \ | 485 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/mkmakefile $(srctree) |
480 | $(srctree) $(objtree) $(VERSION) $(PATCHLEVEL) | ||
481 | endif | 486 | endif |
482 | 487 | ||
483 | ifeq ($(cc-name),clang) | 488 | ifeq ($(cc-name),clang) |
@@ -713,7 +718,7 @@ else | |||
713 | 718 | ||
714 | # These warnings generated too much noise in a regular build. | 719 | # These warnings generated too much noise in a regular build. |
715 | # Use make W=1 to enable them (see scripts/Makefile.extrawarn) | 720 | # Use make W=1 to enable them (see scripts/Makefile.extrawarn) |
716 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable) | 721 | KBUILD_CFLAGS += -Wno-unused-but-set-variable |
717 | endif | 722 | endif |
718 | 723 | ||
719 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) | 724 | KBUILD_CFLAGS += $(call cc-disable-warning, unused-const-variable) |
@@ -794,10 +799,10 @@ endif | |||
794 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) | 799 | NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
795 | 800 | ||
796 | # warn about C99 declaration after statement | 801 | # warn about C99 declaration after statement |
797 | KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,) | 802 | KBUILD_CFLAGS += -Wdeclaration-after-statement |
798 | 803 | ||
799 | # disable pointer signed / unsigned warnings in gcc 4.0 | 804 | # disable pointer signed / unsigned warnings in gcc 4.0 |
800 | KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign) | 805 | KBUILD_CFLAGS += -Wno-pointer-sign |
801 | 806 | ||
802 | # disable stringop warnings in gcc 8+ | 807 | # disable stringop warnings in gcc 8+ |
803 | KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) | 808 | KBUILD_CFLAGS += $(call cc-disable-warning, stringop-truncation) |
@@ -1647,9 +1652,6 @@ namespacecheck: | |||
1647 | export_report: | 1652 | export_report: |
1648 | $(PERL) $(srctree)/scripts/export_report.pl | 1653 | $(PERL) $(srctree)/scripts/export_report.pl |
1649 | 1654 | ||
1650 | endif #ifeq ($(config-targets),1) | ||
1651 | endif #ifeq ($(mixed-targets),1) | ||
1652 | |||
1653 | PHONY += checkstack kernelrelease kernelversion image_name | 1655 | PHONY += checkstack kernelrelease kernelversion image_name |
1654 | 1656 | ||
1655 | # UML needs a little special treatment here. It wants to use the host | 1657 | # UML needs a little special treatment here. It wants to use the host |
@@ -1756,14 +1758,15 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \ | |||
1756 | $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) | 1758 | $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*) |
1757 | 1759 | ||
1758 | # read all saved command lines | 1760 | # read all saved command lines |
1759 | 1761 | cmd_files := $(wildcard .*.cmd) | |
1760 | cmd_files := $(wildcard .*.cmd $(foreach f,$(sort $(targets)),$(dir $(f)).$(notdir $(f)).cmd)) | ||
1761 | 1762 | ||
1762 | ifneq ($(cmd_files),) | 1763 | ifneq ($(cmd_files),) |
1763 | $(cmd_files): ; # Do not try to update included dependency files | 1764 | $(cmd_files): ; # Do not try to update included dependency files |
1764 | include $(cmd_files) | 1765 | include $(cmd_files) |
1765 | endif | 1766 | endif |
1766 | 1767 | ||
1768 | endif # ifeq ($(config-targets),1) | ||
1769 | endif # ifeq ($(mixed-targets),1) | ||
1767 | endif # skip-makefile | 1770 | endif # skip-makefile |
1768 | 1771 | ||
1769 | PHONY += FORCE | 1772 | PHONY += FORCE |
diff --git a/kernel/kallsyms.c b/kernel/kallsyms.c index 02a0b01380d8..f3a04994e063 100644 --- a/kernel/kallsyms.c +++ b/kernel/kallsyms.c | |||
@@ -37,7 +37,7 @@ extern const u8 kallsyms_names[] __weak; | |||
37 | * Tell the compiler that the count isn't in the small data section if the arch | 37 | * Tell the compiler that the count isn't in the small data section if the arch |
38 | * has one (eg: FRV). | 38 | * has one (eg: FRV). |
39 | */ | 39 | */ |
40 | extern const unsigned long kallsyms_num_syms | 40 | extern const unsigned int kallsyms_num_syms |
41 | __attribute__((weak, section(".rodata"))); | 41 | __attribute__((weak, section(".rodata"))); |
42 | 42 | ||
43 | extern const unsigned long kallsyms_relative_base | 43 | extern const unsigned long kallsyms_relative_base |
@@ -46,7 +46,7 @@ __attribute__((weak, section(".rodata"))); | |||
46 | extern const u8 kallsyms_token_table[] __weak; | 46 | extern const u8 kallsyms_token_table[] __weak; |
47 | extern const u16 kallsyms_token_index[] __weak; | 47 | extern const u16 kallsyms_token_index[] __weak; |
48 | 48 | ||
49 | extern const unsigned long kallsyms_markers[] __weak; | 49 | extern const unsigned int kallsyms_markers[] __weak; |
50 | 50 | ||
51 | /* | 51 | /* |
52 | * Expand a compressed symbol data into the resulting uncompressed string, | 52 | * Expand a compressed symbol data into the resulting uncompressed string, |
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 8aeb60eb6ee3..ca21a35fa244 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
@@ -195,7 +195,7 @@ modbuiltin := -f $(srctree)/scripts/Makefile.modbuiltin obj | |||
195 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= | 195 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.dtbinst obj= |
196 | # Usage: | 196 | # Usage: |
197 | # $(Q)$(MAKE) $(dtbinst)=dir | 197 | # $(Q)$(MAKE) $(dtbinst)=dir |
198 | dtbinst := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.dtbinst obj | 198 | dtbinst := -f $(srctree)/scripts/Makefile.dtbinst obj |
199 | 199 | ||
200 | ### | 200 | ### |
201 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj= | 201 | # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.clean obj= |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 54da4b070db3..a8e7ba9f73e8 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
@@ -36,21 +36,11 @@ subdir-ccflags-y := | |||
36 | 36 | ||
37 | include scripts/Kbuild.include | 37 | include scripts/Kbuild.include |
38 | 38 | ||
39 | # For backward compatibility check that these variables do not change | ||
40 | save-cflags := $(CFLAGS) | ||
41 | |||
42 | # The filename Kbuild has precedence over Makefile | 39 | # The filename Kbuild has precedence over Makefile |
43 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) | 40 | kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) |
44 | kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) | 41 | kbuild-file := $(if $(wildcard $(kbuild-dir)/Kbuild),$(kbuild-dir)/Kbuild,$(kbuild-dir)/Makefile) |
45 | include $(kbuild-file) | 42 | include $(kbuild-file) |
46 | 43 | ||
47 | # If the save-* variables changed error out | ||
48 | ifeq ($(KBUILD_NOPEDANTIC),) | ||
49 | ifneq ("$(save-cflags)","$(CFLAGS)") | ||
50 | $(error CFLAGS was changed in "$(kbuild-file)". Fix it to use ccflags-y) | ||
51 | endif | ||
52 | endif | ||
53 | |||
54 | include scripts/Makefile.lib | 44 | include scripts/Makefile.lib |
55 | 45 | ||
56 | # Do not include host rules unless needed | 46 | # Do not include host rules unless needed |
@@ -83,14 +73,12 @@ __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \ | |||
83 | @: | 73 | @: |
84 | 74 | ||
85 | # Linus' kernel sanity checking tool | 75 | # Linus' kernel sanity checking tool |
86 | ifneq ($(KBUILD_CHECKSRC),0) | 76 | ifeq ($(KBUILD_CHECKSRC),1) |
87 | ifeq ($(KBUILD_CHECKSRC),2) | 77 | quiet_cmd_checksrc = CHECK $< |
88 | quiet_cmd_force_checksrc = CHECK $< | 78 | cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; |
89 | cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; | 79 | else ifeq ($(KBUILD_CHECKSRC),2) |
90 | else | 80 | quiet_cmd_force_checksrc = CHECK $< |
91 | quiet_cmd_checksrc = CHECK $< | 81 | cmd_force_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; |
92 | cmd_checksrc = $(CHECK) $(CHECKFLAGS) $(c_flags) $< ; | ||
93 | endif | ||
94 | endif | 82 | endif |
95 | 83 | ||
96 | ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) | 84 | ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),) |
@@ -495,28 +483,12 @@ targets += $(obj)/lib-ksyms.o | |||
495 | 483 | ||
496 | endif | 484 | endif |
497 | 485 | ||
498 | # | ||
499 | # Rule to link composite objects | ||
500 | # | ||
501 | # Composite objects are specified in kbuild makefile as follows: | ||
502 | # <composite-object>-objs := <list of .o files> | ||
503 | # or | ||
504 | # <composite-object>-y := <list of .o files> | ||
505 | # or | ||
506 | # <composite-object>-m := <list of .o files> | ||
507 | # The -m syntax only works if <composite object> is a module | ||
508 | link_multi_deps = \ | ||
509 | $(filter $(addprefix $(obj)/, \ | ||
510 | $($(subst $(obj)/,,$(@:.o=-objs))) \ | ||
511 | $($(subst $(obj)/,,$(@:.o=-y))) \ | ||
512 | $($(subst $(obj)/,,$(@:.o=-m)))), $^) | ||
513 | |||
514 | quiet_cmd_link_multi-m = LD [M] $@ | 486 | quiet_cmd_link_multi-m = LD [M] $@ |
515 | cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis) | 487 | cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^) $(cmd_secanalysis) |
516 | 488 | ||
517 | $(multi-used-m): FORCE | 489 | $(multi-used-m): FORCE |
518 | $(call if_changed,link_multi-m) | 490 | $(call if_changed,link_multi-m) |
519 | @{ echo $(@:.o=.ko); echo $(link_multi_deps); \ | 491 | @{ echo $(@:.o=.ko); echo $(filter %.o,$^); \ |
520 | $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) | 492 | $(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod) |
521 | $(call multi_depend, $(multi-used-m), .o, -objs -y -m) | 493 | $(call multi_depend, $(multi-used-m), .o, -objs -y -m) |
522 | 494 | ||
diff --git a/scripts/asn1_compiler.c b/scripts/asn1_compiler.c index c146020fc783..1b28787028d3 100644 --- a/scripts/asn1_compiler.c +++ b/scripts/asn1_compiler.c | |||
@@ -413,7 +413,7 @@ static void tokenise(char *buffer, char *end) | |||
413 | 413 | ||
414 | /* Handle string tokens */ | 414 | /* Handle string tokens */ |
415 | if (isalpha(*p)) { | 415 | if (isalpha(*p)) { |
416 | const char **dir, *start = p; | 416 | const char **dir; |
417 | 417 | ||
418 | /* Can be a directive, type name or element | 418 | /* Can be a directive, type name or element |
419 | * name. Find the end of the name. | 419 | * name. Find the end of the name. |
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index a9186a98a37d..109a1af7e444 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
@@ -48,8 +48,6 @@ static unsigned long long relative_base; | |||
48 | static struct addr_range text_ranges[] = { | 48 | static struct addr_range text_ranges[] = { |
49 | { "_stext", "_etext" }, | 49 | { "_stext", "_etext" }, |
50 | { "_sinittext", "_einittext" }, | 50 | { "_sinittext", "_einittext" }, |
51 | { "_stext_l1", "_etext_l1" }, /* Blackfin on-chip L1 inst SRAM */ | ||
52 | { "_stext_l2", "_etext_l2" }, /* Blackfin on-chip L2 SRAM */ | ||
53 | }; | 51 | }; |
54 | #define text_range_text (&text_ranges[0]) | 52 | #define text_range_text (&text_ranges[0]) |
55 | #define text_range_inittext (&text_ranges[1]) | 53 | #define text_range_inittext (&text_ranges[1]) |
@@ -405,7 +403,7 @@ static void write_src(void) | |||
405 | } | 403 | } |
406 | 404 | ||
407 | output_label("kallsyms_num_syms"); | 405 | output_label("kallsyms_num_syms"); |
408 | printf("\tPTR\t%u\n", table_cnt); | 406 | printf("\t.long\t%u\n", table_cnt); |
409 | printf("\n"); | 407 | printf("\n"); |
410 | 408 | ||
411 | /* table of offset markers, that give the offset in the compressed stream | 409 | /* table of offset markers, that give the offset in the compressed stream |
@@ -434,7 +432,7 @@ static void write_src(void) | |||
434 | 432 | ||
435 | output_label("kallsyms_markers"); | 433 | output_label("kallsyms_markers"); |
436 | for (i = 0; i < ((table_cnt + 255) >> 8); i++) | 434 | for (i = 0; i < ((table_cnt + 255) >> 8); i++) |
437 | printf("\tPTR\t%d\n", markers[i]); | 435 | printf("\t.long\t%u\n", markers[i]); |
438 | printf("\n"); | 436 | printf("\n"); |
439 | 437 | ||
440 | free(markers); | 438 | free(markers); |
diff --git a/scripts/mkmakefile b/scripts/mkmakefile index e19d6565f245..412f13fdff52 100755 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile | |||
@@ -6,31 +6,20 @@ | |||
6 | 6 | ||
7 | # Usage | 7 | # Usage |
8 | # $1 - Kernel src directory | 8 | # $1 - Kernel src directory |
9 | # $2 - Output directory | ||
10 | # $3 - version | ||
11 | # $4 - patchlevel | ||
12 | 9 | ||
13 | |||
14 | test ! -r $2/Makefile -o -O $2/Makefile || exit 0 | ||
15 | # Only overwrite automatically generated Makefiles | 10 | # Only overwrite automatically generated Makefiles |
16 | # (so we do not overwrite kernel Makefile) | 11 | # (so we do not overwrite kernel Makefile) |
17 | if test -e $2/Makefile && ! grep -q Automatically $2/Makefile | 12 | if test -e Makefile && ! grep -q Automatically Makefile |
18 | then | 13 | then |
19 | exit 0 | 14 | exit 0 |
20 | fi | 15 | fi |
21 | if [ "${quiet}" != "silent_" ]; then | 16 | if [ "${quiet}" != "silent_" ]; then |
22 | echo " GEN $2/Makefile" | 17 | echo " GEN Makefile" |
23 | fi | 18 | fi |
24 | 19 | ||
25 | cat << EOF > $2/Makefile | 20 | cat << EOF > Makefile |
26 | # Automatically generated by $0: don't edit | 21 | # Automatically generated by $0: don't edit |
27 | 22 | ||
28 | VERSION = $3 | ||
29 | PATCHLEVEL = $4 | ||
30 | |||
31 | lastword = \$(word \$(words \$(1)),\$(1)) | ||
32 | makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST))) | ||
33 | |||
34 | ifeq ("\$(origin V)", "command line") | 23 | ifeq ("\$(origin V)", "command line") |
35 | VERBOSE := \$(V) | 24 | VERBOSE := \$(V) |
36 | endif | 25 | endif |
@@ -38,15 +27,12 @@ ifneq (\$(VERBOSE),1) | |||
38 | Q := @ | 27 | Q := @ |
39 | endif | 28 | endif |
40 | 29 | ||
41 | MAKEARGS := -C $1 | ||
42 | MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir)) | ||
43 | |||
44 | MAKEFLAGS += --no-print-directory | 30 | MAKEFLAGS += --no-print-directory |
45 | 31 | ||
46 | .PHONY: __sub-make \$(MAKECMDGOALS) | 32 | .PHONY: __sub-make \$(MAKECMDGOALS) |
47 | 33 | ||
48 | __sub-make: | 34 | __sub-make: |
49 | \$(Q)\$(MAKE) \$(MAKEARGS) \$(MAKECMDGOALS) | 35 | \$(Q)\$(MAKE) -C $1 O=\$(CURDIR) \$(MAKECMDGOALS) |
50 | 36 | ||
51 | \$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make | 37 | \$(filter-out __sub-make, \$(MAKECMDGOALS)): __sub-make |
52 | @: | 38 | @: |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 7be43697ff84..28a61665bb9c 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -95,12 +95,20 @@ extern struct devtable *__start___devtable[], *__stop___devtable[]; | |||
95 | */ | 95 | */ |
96 | #define DEF_FIELD(m, devid, f) \ | 96 | #define DEF_FIELD(m, devid, f) \ |
97 | typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f)) | 97 | typeof(((struct devid *)0)->f) f = TO_NATIVE(*(typeof(f) *)((m) + OFF_##devid##_##f)) |
98 | |||
99 | /* Define a variable v that holds the address of field f of struct devid | ||
100 | * based at address m. Due to the way typeof works, for a field of type | ||
101 | * T[N] the variable has type T(*)[N], _not_ T*. | ||
102 | */ | ||
103 | #define DEF_FIELD_ADDR_VAR(m, devid, f, v) \ | ||
104 | typeof(((struct devid *)0)->f) *v = ((m) + OFF_##devid##_##f) | ||
105 | |||
98 | /* Define a variable f that holds the address of field f of struct devid | 106 | /* Define a variable f that holds the address of field f of struct devid |
99 | * based at address m. Due to the way typeof works, for a field of type | 107 | * based at address m. Due to the way typeof works, for a field of type |
100 | * T[N] the variable has type T(*)[N], _not_ T*. | 108 | * T[N] the variable has type T(*)[N], _not_ T*. |
101 | */ | 109 | */ |
102 | #define DEF_FIELD_ADDR(m, devid, f) \ | 110 | #define DEF_FIELD_ADDR(m, devid, f) \ |
103 | typeof(((struct devid *)0)->f) *f = ((m) + OFF_##devid##_##f) | 111 | DEF_FIELD_ADDR_VAR(m, devid, f, f) |
104 | 112 | ||
105 | /* Add a table entry. We test function type matches while we're here. */ | 113 | /* Add a table entry. We test function type matches while we're here. */ |
106 | #define ADD_TO_DEVTABLE(device_id, type, function) \ | 114 | #define ADD_TO_DEVTABLE(device_id, type, function) \ |
@@ -644,7 +652,7 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
644 | 652 | ||
645 | for (i = 0; i < count; i++) { | 653 | for (i = 0; i < count; i++) { |
646 | unsigned int j; | 654 | unsigned int j; |
647 | DEF_FIELD_ADDR(symval + i*id_size, pnp_card_device_id, devs); | 655 | DEF_FIELD_ADDR(symval + i * id_size, pnp_card_device_id, devs); |
648 | 656 | ||
649 | for (j = 0; j < PNP_MAX_DEVICES; j++) { | 657 | for (j = 0; j < PNP_MAX_DEVICES; j++) { |
650 | const char *id = (char *)(*devs)[j].id; | 658 | const char *id = (char *)(*devs)[j].id; |
@@ -656,10 +664,13 @@ static void do_pnp_card_entries(void *symval, unsigned long size, | |||
656 | 664 | ||
657 | /* find duplicate, already added value */ | 665 | /* find duplicate, already added value */ |
658 | for (i2 = 0; i2 < i && !dup; i2++) { | 666 | for (i2 = 0; i2 < i && !dup; i2++) { |
659 | DEF_FIELD_ADDR(symval + i2*id_size, pnp_card_device_id, devs); | 667 | DEF_FIELD_ADDR_VAR(symval + i2 * id_size, |
668 | pnp_card_device_id, | ||
669 | devs, devs_dup); | ||
660 | 670 | ||
661 | for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { | 671 | for (j2 = 0; j2 < PNP_MAX_DEVICES; j2++) { |
662 | const char *id2 = (char *)(*devs)[j2].id; | 672 | const char *id2 = |
673 | (char *)(*devs_dup)[j2].id; | ||
663 | 674 | ||
664 | if (!id2[0]) | 675 | if (!id2[0]) |
665 | break; | 676 | break; |
@@ -1415,11 +1426,10 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, | |||
1415 | if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) | 1426 | if (ELF_ST_TYPE(sym->st_info) != STT_OBJECT) |
1416 | return; | 1427 | return; |
1417 | 1428 | ||
1418 | /* All our symbols are of form <prefix>__mod_<name>__<identifier>_device_table. */ | 1429 | /* All our symbols are of form __mod_<name>__<identifier>_device_table. */ |
1419 | name = strstr(symname, "__mod_"); | 1430 | if (strncmp(symname, "__mod_", strlen("__mod_"))) |
1420 | if (!name) | ||
1421 | return; | 1431 | return; |
1422 | name += strlen("__mod_"); | 1432 | name = symname + strlen("__mod_"); |
1423 | namelen = strlen(name); | 1433 | namelen = strlen(name); |
1424 | if (namelen < strlen("_device_table")) | 1434 | if (namelen < strlen("_device_table")) |
1425 | return; | 1435 | return; |