aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:48:48 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-03-25 11:48:48 -0500
commit2e1ca21d46aaef95101723fa402f39d3a95aba59 (patch)
treecd95efefb9ccb6ab4ac0589d01c06cdfc22cc989
parent315ab19a6d12d6af7b6957090822f3057ab7e80f (diff)
parenteae0f536f640bb95f2ad437a57c40c7d5683d1ac (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/sam/kbuild
* master.kernel.org:/pub/scm/linux/kernel/git/sam/kbuild: (46 commits) kbuild: remove obsoleted scripts/reference_* files kbuild: fix make help & make *pkg kconfig: fix time ordering of writes to .kconfig.d and include/linux/autoconf.h Kconfig: remove the CONFIG_CC_ALIGN_* options kbuild: add -fverbose-asm to i386 Makefile kbuild: clean-up genksyms kbuild: Lindent genksyms.c kbuild: fix genksyms build error kbuild: in makefile.txt note that Makefile is preferred name for kbuild files kbuild: replace PHONY with FORCE kbuild: Fix bug in crc symbol generating of kernel and modules kbuild: change kbuild to not rely on incorrect GNU make behavior kbuild: when warning symbols exported twice now tell user this is the problem kbuild: fix make dir/file.xx when asm symlink is missing kbuild: in the section mismatch check try harder to find symbols kbuild: fix section mismatch check for unwind on IA64 kbuild: kill false positives from section mismatch warnings for powerpc kbuild: kill trailing whitespace in modpost & friends kbuild: small update of allnoconfig description kbuild: make namespace.pl CROSS_COMPILE happy ... Trivial conflict in arch/ppc/boot/Makefile manually fixed up
-rw-r--r--Documentation/DocBook/Makefile8
-rw-r--r--Documentation/kbuild/makefiles.txt172
-rw-r--r--Documentation/kbuild/modules.txt98
-rw-r--r--Documentation/smart-config.txt4
-rw-r--r--Makefile197
-rw-r--r--arch/arm/Makefile5
-rw-r--r--arch/arm/boot/Makefile5
-rw-r--r--arch/arm/boot/bootp/Makefile5
-rw-r--r--arch/arm26/Makefile7
-rw-r--r--arch/arm26/boot/Makefile5
-rw-r--r--arch/i386/Makefile4
-rw-r--r--arch/i386/kernel/vmlinux.lds.S3
-rw-r--r--arch/ia64/Makefile5
-rw-r--r--arch/m32r/Makefile5
-rw-r--r--arch/powerpc/Makefile2
-rw-r--r--arch/ppc/Makefile2
-rw-r--r--arch/ppc/boot/Makefile8
-rw-r--r--arch/ppc/boot/openfirmware/Makefile7
-rw-r--r--arch/sh/Makefile2
-rw-r--r--arch/um/Makefile7
-rw-r--r--arch/x86_64/Makefile4
-rw-r--r--drivers/atm/.gitignore5
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.c1
-rw-r--r--drivers/video/matrox/matroxfb_DAC1064.h1
-rw-r--r--drivers/video/matrox/matroxfb_Ti3026.c1
-rw-r--r--drivers/video/matrox/matroxfb_Ti3026.h1
-rw-r--r--drivers/video/matrox/matroxfb_base.c1
-rw-r--r--drivers/video/matrox/matroxfb_misc.c1
-rw-r--r--init/Kconfig37
-rw-r--r--scripts/Kbuild.include65
-rw-r--r--scripts/Makefile.build27
-rw-r--r--scripts/Makefile.clean10
-rw-r--r--scripts/Makefile.modinst10
-rw-r--r--scripts/Makefile.modpost19
-rw-r--r--scripts/basic/fixdep.c14
-rwxr-xr-xscripts/checkconfig.pl65
-rw-r--r--scripts/genksyms/genksyms.c843
-rw-r--r--scripts/genksyms/genksyms.h57
-rw-r--r--scripts/kconfig/Makefile6
-rw-r--r--scripts/kconfig/confdata.c2
-rw-r--r--scripts/kconfig/lxdialog/Makefile6
-rw-r--r--scripts/mkmakefile8
-rw-r--r--scripts/mod/file2alias.c17
-rw-r--r--scripts/mod/mk_elfconfig.c4
-rw-r--r--scripts/mod/modpost.c698
-rw-r--r--scripts/mod/modpost.h25
-rw-r--r--scripts/mod/sumversion.c32
-rw-r--r--scripts/namespace.pl4
-rw-r--r--scripts/package/Makefile20
-rw-r--r--scripts/reference_discarded.pl112
-rw-r--r--scripts/reference_init.pl108
-rw-r--r--sound/oss/.gitignore4
52 files changed, 1500 insertions, 1259 deletions
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 2975291e296a..7d87dd73cbe4 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -28,7 +28,7 @@ PS_METHOD = $(prefer-db2x)
28 28
29### 29###
30# The targets that may be used. 30# The targets that may be used.
31.PHONY: xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs 31PHONY += xmldocs sgmldocs psdocs pdfdocs htmldocs mandocs installmandocs
32 32
33BOOKS := $(addprefix $(obj)/,$(DOCBOOKS)) 33BOOKS := $(addprefix $(obj)/,$(DOCBOOKS))
34xmldocs: $(BOOKS) 34xmldocs: $(BOOKS)
@@ -211,3 +211,9 @@ clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS))
211 211
212#man put files in man subdir - traverse down 212#man put files in man subdir - traverse down
213subdir- := man/ 213subdir- := man/
214
215
216# Declare the contents of the .PHONY variable as phony. We keep that
217# information in a variable se we can use it in if_changed and friends.
218
219.PHONY: $(PHONY)
diff --git a/Documentation/kbuild/makefiles.txt b/Documentation/kbuild/makefiles.txt
index 443230b43e09..a9c00facdf40 100644
--- a/Documentation/kbuild/makefiles.txt
+++ b/Documentation/kbuild/makefiles.txt
@@ -17,6 +17,7 @@ This document describes the Linux kernel Makefiles.
17 --- 3.8 Command line dependency 17 --- 3.8 Command line dependency
18 --- 3.9 Dependency tracking 18 --- 3.9 Dependency tracking
19 --- 3.10 Special Rules 19 --- 3.10 Special Rules
20 --- 3.11 $(CC) support functions
20 21
21 === 4 Host Program support 22 === 4 Host Program support
22 --- 4.1 Simple Host Program 23 --- 4.1 Simple Host Program
@@ -38,7 +39,6 @@ This document describes the Linux kernel Makefiles.
38 --- 6.6 Commands useful for building a boot image 39 --- 6.6 Commands useful for building a boot image
39 --- 6.7 Custom kbuild commands 40 --- 6.7 Custom kbuild commands
40 --- 6.8 Preprocessing linker scripts 41 --- 6.8 Preprocessing linker scripts
41 --- 6.9 $(CC) support functions
42 42
43 === 7 Kbuild Variables 43 === 7 Kbuild Variables
44 === 8 Makefile language 44 === 8 Makefile language
@@ -106,9 +106,9 @@ This document is aimed towards normal developers and arch developers.
106Most Makefiles within the kernel are kbuild Makefiles that use the 106Most Makefiles within the kernel are kbuild Makefiles that use the
107kbuild infrastructure. This chapter introduce the syntax used in the 107kbuild infrastructure. This chapter introduce the syntax used in the
108kbuild makefiles. 108kbuild makefiles.
109The preferred name for the kbuild files is 'Kbuild' but 'Makefile' will 109The preferred name for the kbuild files are 'Makefile' but 'Kbuild' can
110continue to be supported. All new developmen is expected to use the 110be used and if both a 'Makefile' and a 'Kbuild' file exists then the 'Kbuild'
111Kbuild filename. 111file will be used.
112 112
113Section 3.1 "Goal definitions" is a quick intro, further chapters provide 113Section 3.1 "Goal definitions" is a quick intro, further chapters provide
114more details, with real examples. 114more details, with real examples.
@@ -385,6 +385,102 @@ more details, with real examples.
385 to prerequisites are referenced with $(src) (because they are not 385 to prerequisites are referenced with $(src) (because they are not
386 generated files). 386 generated files).
387 387
388--- 3.11 $(CC) support functions
389
390 The kernel may be build with several different versions of
391 $(CC), each supporting a unique set of features and options.
392 kbuild provide basic support to check for valid options for $(CC).
393 $(CC) is useally the gcc compiler, but other alternatives are
394 available.
395
396 as-option
397 as-option is used to check if $(CC) when used to compile
398 assembler (*.S) files supports the given option. An optional
399 second option may be specified if first option are not supported.
400
401 Example:
402 #arch/sh/Makefile
403 cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)
404
405 In the above example cflags-y will be assinged the the option
406 -Wa$(comma)-isa=$(isa-y) if it is supported by $(CC).
407 The second argument is optional, and if supplied will be used
408 if first argument is not supported.
409
410 cc-option
411 cc-option is used to check if $(CC) support a given option, and not
412 supported to use an optional second option.
413
414 Example:
415 #arch/i386/Makefile
416 cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
417
418 In the above example cflags-y will be assigned the option
419 -march=pentium-mmx if supported by $(CC), otherwise -march-i586.
420 The second argument to cc-option is optional, and if omitted
421 cflags-y will be assigned no value if first option is not supported.
422
423 cc-option-yn
424 cc-option-yn is used to check if gcc supports a given option
425 and return 'y' if supported, otherwise 'n'.
426
427 Example:
428 #arch/ppc/Makefile
429 biarch := $(call cc-option-yn, -m32)
430 aflags-$(biarch) += -a32
431 cflags-$(biarch) += -m32
432
433 In the above example $(biarch) is set to y if $(CC) supports the -m32
434 option. When $(biarch) equals to y the expanded variables $(aflags-y)
435 and $(cflags-y) will be assigned the values -a32 and -m32.
436
437 cc-option-align
438 gcc version >= 3.0 shifted type of options used to speify
439 alignment of functions, loops etc. $(cc-option-align) whrn used
440 as prefix to the align options will select the right prefix:
441 gcc < 3.00
442 cc-option-align = -malign
443 gcc >= 3.00
444 cc-option-align = -falign
445
446 Example:
447 CFLAGS += $(cc-option-align)-functions=4
448
449 In the above example the option -falign-functions=4 is used for
450 gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
451
452 cc-version
453 cc-version return a numerical version of the $(CC) compiler version.
454 The format is <major><minor> where both are two digits. So for example
455 gcc 3.41 would return 0341.
456 cc-version is useful when a specific $(CC) version is faulty in one
457 area, for example the -mregparm=3 were broken in some gcc version
458 even though the option was accepted by gcc.
459
460 Example:
461 #arch/i386/Makefile
462 cflags-y += $(shell \
463 if [ $(call cc-version) -ge 0300 ] ; then \
464 echo "-mregparm=3"; fi ;)
465
466 In the above example -mregparm=3 is only used for gcc version greater
467 than or equal to gcc 3.0.
468
469 cc-ifversion
470 cc-ifversion test the version of $(CC) and equals last argument if
471 version expression is true.
472
473 Example:
474 #fs/reiserfs/Makefile
475 EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0402, -O1)
476
477 In this example EXTRA_CFLAGS will be assigned the value -O1 if the
478 $(CC) version is less than 4.2.
479 cc-ifversion takes all the shell operators:
480 -eq, -ne, -lt, -le, -gt, and -ge
481 The third parameter may be a text as in this example, but it may also
482 be an expanded variable or a macro.
483
388 484
389=== 4 Host Program support 485=== 4 Host Program support
390 486
@@ -973,74 +1069,6 @@ When kbuild executes the following steps are followed (roughly):
973 architecture specific files. 1069 architecture specific files.
974 1070
975 1071
976--- 6.9 $(CC) support functions
977
978 The kernel may be build with several different versions of
979 $(CC), each supporting a unique set of features and options.
980 kbuild provide basic support to check for valid options for $(CC).
981 $(CC) is useally the gcc compiler, but other alternatives are
982 available.
983
984 cc-option
985 cc-option is used to check if $(CC) support a given option, and not
986 supported to use an optional second option.
987
988 Example:
989 #arch/i386/Makefile
990 cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
991
992 In the above example cflags-y will be assigned the option
993 -march=pentium-mmx if supported by $(CC), otherwise -march-i586.
994 The second argument to cc-option is optional, and if omitted
995 cflags-y will be assigned no value if first option is not supported.
996
997 cc-option-yn
998 cc-option-yn is used to check if gcc supports a given option
999 and return 'y' if supported, otherwise 'n'.
1000
1001 Example:
1002 #arch/ppc/Makefile
1003 biarch := $(call cc-option-yn, -m32)
1004 aflags-$(biarch) += -a32
1005 cflags-$(biarch) += -m32
1006
1007 In the above example $(biarch) is set to y if $(CC) supports the -m32
1008 option. When $(biarch) equals to y the expanded variables $(aflags-y)
1009 and $(cflags-y) will be assigned the values -a32 and -m32.
1010
1011 cc-option-align
1012 gcc version >= 3.0 shifted type of options used to speify
1013 alignment of functions, loops etc. $(cc-option-align) whrn used
1014 as prefix to the align options will select the right prefix:
1015 gcc < 3.00
1016 cc-option-align = -malign
1017 gcc >= 3.00
1018 cc-option-align = -falign
1019
1020 Example:
1021 CFLAGS += $(cc-option-align)-functions=4
1022
1023 In the above example the option -falign-functions=4 is used for
1024 gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
1025
1026 cc-version
1027 cc-version return a numerical version of the $(CC) compiler version.
1028 The format is <major><minor> where both are two digits. So for example
1029 gcc 3.41 would return 0341.
1030 cc-version is useful when a specific $(CC) version is faulty in one
1031 area, for example the -mregparm=3 were broken in some gcc version
1032 even though the option was accepted by gcc.
1033
1034 Example:
1035 #arch/i386/Makefile
1036 cflags-y += $(shell \
1037 if [ $(call cc-version) -ge 0300 ] ; then \
1038 echo "-mregparm=3"; fi ;)
1039
1040 In the above example -mregparm=3 is only used for gcc version greater
1041 than or equal to gcc 3.0.
1042
1043
1044=== 7 Kbuild Variables 1072=== 7 Kbuild Variables
1045 1073
1046The top Makefile exports the following variables: 1074The top Makefile exports the following variables:
diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt
index 7e77f93634ea..fcccf2432f98 100644
--- a/Documentation/kbuild/modules.txt
+++ b/Documentation/kbuild/modules.txt
@@ -13,6 +13,7 @@ In this document you will find information about:
13 --- 2.2 Available targets 13 --- 2.2 Available targets
14 --- 2.3 Available options 14 --- 2.3 Available options
15 --- 2.4 Preparing the kernel tree for module build 15 --- 2.4 Preparing the kernel tree for module build
16 --- 2.5 Building separate files for a module
16 === 3. Example commands 17 === 3. Example commands
17 === 4. Creating a kbuild file for an external module 18 === 4. Creating a kbuild file for an external module
18 === 5. Include files 19 === 5. Include files
@@ -22,7 +23,10 @@ In this document you will find information about:
22 === 6. Module installation 23 === 6. Module installation
23 --- 6.1 INSTALL_MOD_PATH 24 --- 6.1 INSTALL_MOD_PATH
24 --- 6.2 INSTALL_MOD_DIR 25 --- 6.2 INSTALL_MOD_DIR
25 === 7. Module versioning 26 === 7. Module versioning & Module.symvers
27 --- 7.1 Symbols fron the kernel (vmlinux + modules)
28 --- 7.2 Symbols and external modules
29 --- 7.3 Symbols from another external module
26 === 8. Tips & Tricks 30 === 8. Tips & Tricks
27 --- 8.1 Testing for CONFIG_FOO_BAR 31 --- 8.1 Testing for CONFIG_FOO_BAR
28 32
@@ -88,7 +92,8 @@ when building an external module.
88 make -C $KDIR M=$PWD modules_install 92 make -C $KDIR M=$PWD modules_install
89 Install the external module(s). 93 Install the external module(s).
90 Installation default is in /lib/modules/<kernel-version>/extra, 94 Installation default is in /lib/modules/<kernel-version>/extra,
91 but may be prefixed with INSTALL_MOD_PATH - see separate chapter. 95 but may be prefixed with INSTALL_MOD_PATH - see separate
96 chapter.
92 97
93 make -C $KDIR M=$PWD clean 98 make -C $KDIR M=$PWD clean
94 Remove all generated files for the module - the kernel 99 Remove all generated files for the module - the kernel
@@ -131,6 +136,16 @@ when building an external module.
131 Therefore a full kernel build needs to be executed to make 136 Therefore a full kernel build needs to be executed to make
132 module versioning work. 137 module versioning work.
133 138
139--- 2.5 Building separate files for a module
140 It is possible to build single files which is part of a module.
141 This works equal for the kernel, a module and even for external
142 modules.
143 Examples (module foo.ko, consist of bar.o, baz.o):
144 make -C $KDIR M=`pwd` bar.lst
145 make -C $KDIR M=`pwd` bar.o
146 make -C $KDIR M=`pwd` foo.ko
147 make -C $KDIR M=`pwd` /
148
134 149
135=== 3. Example commands 150=== 3. Example commands
136 151
@@ -422,7 +437,7 @@ External modules are installed in the directory:
422 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf 437 => Install dir: /lib/modules/$(KERNELRELEASE)/gandalf
423 438
424 439
425=== 7. Module versioning 440=== 7. Module versioning & Module.symvers
426 441
427Module versioning is enabled by the CONFIG_MODVERSIONS tag. 442Module versioning is enabled by the CONFIG_MODVERSIONS tag.
428 443
@@ -432,11 +447,80 @@ when a module is loaded/used then the CRC values contained in the kernel are
432compared with similar values in the module. If they are not equal then the 447compared with similar values in the module. If they are not equal then the
433kernel refuses to load the module. 448kernel refuses to load the module.
434 449
435During a kernel build a file named Module.symvers will be generated. This 450Module.symvers contains a list of all exported symbols from a kernel build.
436file includes the symbol version of all symbols within the kernel. If the 451
437Module.symvers file is saved from the last full kernel compile one does not 452--- 7.1 Symbols fron the kernel (vmlinux + modules)
438have to do a full kernel compile to build a module version's compatible module. 453
454 During a kernel build a file named Module.symvers will be generated.
455 Module.symvers contains all exported symbols from the kernel and
456 compiled modules. For each symbols the corresponding CRC value
457 is stored too.
458
459 The syntax of the Module.symvers file is:
460 <CRC> <Symbol> <module>
461 Sample:
462 0x2d036834 scsi_remove_host drivers/scsi/scsi_mod
439 463
464 For a kernel build without CONFIG_MODVERSIONING enabled the crc
465 would read: 0x00000000
466
467 Module.symvers serve two purposes.
468 1) It list all exported symbols both from vmlinux and all modules
469 2) It list CRC if CONFIG_MODVERSION is enabled
470
471--- 7.2 Symbols and external modules
472
473 When building an external module the build system needs access to
474 the symbols from the kernel to check if all external symbols are
475 defined. This is done in the MODPOST step and to obtain all
476 symbols modpost reads Module.symvers from the kernel.
477 If a Module.symvers file is present in the directory where
478 the external module is being build this file will be read too.
479 During the MODPOST step a new Module.symvers file will be written
480 containing all exported symbols that was not defined in the kernel.
481
482--- 7.3 Symbols from another external module
483
484 Sometimes one external module uses exported symbols from another
485 external module. Kbuild needs to have full knowledge on all symbols
486 to avoid spitting out warnings about undefined symbols.
487 Two solutions exist to let kbuild know all symbols of more than
488 one external module.
489 The method with a top-level kbuild file is recommended but may be
490 impractical in certain situations.
491
492 Use a top-level Kbuild file
493 If you have two modules: 'foo', 'bar' and 'foo' needs symbols
494 from 'bar' then one can use a common top-level kbuild file so
495 both modules are compiled in same build.
496
497 Consider following directory layout:
498 ./foo/ <= contains the foo module
499 ./bar/ <= contains the bar module
500 The top-level Kbuild file would then look like:
501
502 #./Kbuild: (this file may also be named Makefile)
503 obj-y := foo/ bar/
504
505 Executing:
506 make -C $KDIR M=`pwd`
507
508 will then do the expected and compile both modules with full
509 knowledge on symbols from both modules.
510
511 Use an extra Module.symvers file
512 When an external module is build a Module.symvers file is
513 generated containing all exported symbols which are not
514 defined in the kernel.
515 To get access to symbols from module 'bar' one can copy the
516 Module.symvers file from the compilation of the 'bar' module
517 to the directory where the 'foo' module is build.
518 During the module build kbuild will read the Module.symvers
519 file in the directory of the external module and when the
520 build is finished a new Module.symvers file is created
521 containing the sum of all symbols defined and not part of the
522 kernel.
523
440=== 8. Tips & Tricks 524=== 8. Tips & Tricks
441 525
442--- 8.1 Testing for CONFIG_FOO_BAR 526--- 8.1 Testing for CONFIG_FOO_BAR
diff --git a/Documentation/smart-config.txt b/Documentation/smart-config.txt
index c9bed4cf8773..8467447b5a87 100644
--- a/Documentation/smart-config.txt
+++ b/Documentation/smart-config.txt
@@ -56,10 +56,6 @@ Here is the solution:
56 writing one file per option. It updates only the files for options 56 writing one file per option. It updates only the files for options
57 that have changed. 57 that have changed.
58 58
59 mkdep.c no longer generates warning messages for missing or unneeded
60 <linux/config.h> lines. The new top-level target 'make checkconfig'
61 checks for these problems.
62
63Flag Dependencies 59Flag Dependencies
64 60
65 Martin Von Loewis contributed another feature to this patch: 61 Martin Von Loewis contributed another feature to this patch:
diff --git a/Makefile b/Makefile
index 14781f36e327..7bc2f4ad8093 100644
--- a/Makefile
+++ b/Makefile
@@ -95,7 +95,7 @@ ifdef O
95endif 95endif
96 96
97# That's our default target when none is given on the command line 97# That's our default target when none is given on the command line
98.PHONY: _all 98PHONY := _all
99_all: 99_all:
100 100
101ifneq ($(KBUILD_OUTPUT),) 101ifneq ($(KBUILD_OUTPUT),)
@@ -106,7 +106,7 @@ KBUILD_OUTPUT := $(shell cd $(KBUILD_OUTPUT) && /bin/pwd)
106$(if $(KBUILD_OUTPUT),, \ 106$(if $(KBUILD_OUTPUT),, \
107 $(error output directory "$(saved-output)" does not exist)) 107 $(error output directory "$(saved-output)" does not exist))
108 108
109.PHONY: $(MAKECMDGOALS) 109PHONY += $(MAKECMDGOALS)
110 110
111$(filter-out _all,$(MAKECMDGOALS)) _all: 111$(filter-out _all,$(MAKECMDGOALS)) _all:
112 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \ 112 $(if $(KBUILD_VERBOSE:1=),@)$(MAKE) -C $(KBUILD_OUTPUT) \
@@ -123,7 +123,7 @@ ifeq ($(skip-makefile),)
123 123
124# If building an external module we do not care about the all: rule 124# If building an external module we do not care about the all: rule
125# but instead _all depend on modules 125# but instead _all depend on modules
126.PHONY: all 126PHONY += all
127ifeq ($(KBUILD_EXTMOD),) 127ifeq ($(KBUILD_EXTMOD),)
128_all: all 128_all: all
129else 129else
@@ -137,7 +137,7 @@ objtree := $(CURDIR)
137src := $(srctree) 137src := $(srctree)
138obj := $(objtree) 138obj := $(objtree)
139 139
140VPATH := $(srctree) 140VPATH := $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
141 141
142export srctree objtree VPATH TOPDIR 142export srctree objtree VPATH TOPDIR
143 143
@@ -151,7 +151,7 @@ export srctree objtree VPATH TOPDIR
151SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ 151SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
152 -e s/arm.*/arm/ -e s/sa110/arm/ \ 152 -e s/arm.*/arm/ -e s/sa110/arm/ \
153 -e s/s390x/s390/ -e s/parisc64/parisc/ \ 153 -e s/s390x/s390/ -e s/parisc64/parisc/ \
154 -e s/ppc.*/powerpc/ ) 154 -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
155 155
156# Cross compiling and selecting different set of gcc/bin-utils 156# Cross compiling and selecting different set of gcc/bin-utils
157# --------------------------------------------------------------------------- 157# ---------------------------------------------------------------------------
@@ -258,38 +258,6 @@ endif
258 258
259export quiet Q KBUILD_VERBOSE 259export quiet Q KBUILD_VERBOSE
260 260
261######
262# cc support functions to be used (only) in arch/$(ARCH)/Makefile
263# See documentation in Documentation/kbuild/makefiles.txt
264
265# as-option
266# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
267
268as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
269 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
270 else echo "$(2)"; fi ;)
271
272# cc-option
273# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
274
275cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
276 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
277
278# cc-option-yn
279# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
280cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
281 > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
282
283# cc-option-align
284# Prefix align with either -falign or -malign
285cc-option-align = $(subst -functions=0,,\
286 $(call cc-option,-falign-functions=0,-malign-functions=0))
287
288# cc-version
289# Usage gcc-ver := $(call cc-version $(CC))
290cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
291 $(if $(1), $(1), $(CC)))
292
293 261
294# Look for make include files relative to root of kernel src 262# Look for make include files relative to root of kernel src
295MAKEFLAGS += --include-dir=$(srctree) 263MAKEFLAGS += --include-dir=$(srctree)
@@ -369,14 +337,14 @@ export RCS_TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exc
369# Rules shared between *config targets and build targets 337# Rules shared between *config targets and build targets
370 338
371# Basic helpers built in scripts/ 339# Basic helpers built in scripts/
372.PHONY: scripts_basic 340PHONY += scripts_basic
373scripts_basic: 341scripts_basic:
374 $(Q)$(MAKE) $(build)=scripts/basic 342 $(Q)$(MAKE) $(build)=scripts/basic
375 343
376# To avoid any implicit rule to kick in, define an empty command. 344# To avoid any implicit rule to kick in, define an empty command.
377scripts/basic/%: scripts_basic ; 345scripts/basic/%: scripts_basic ;
378 346
379.PHONY: outputmakefile 347PHONY += outputmakefile
380# outputmakefile generate a Makefile to be placed in output directory, if 348# outputmakefile generate a Makefile to be placed in output directory, if
381# using a seperate output directory. This allows convinient use 349# using a seperate output directory. This allows convinient use
382# of make in output directory 350# of make in output directory
@@ -452,7 +420,7 @@ ifeq ($(KBUILD_EXTMOD),)
452# Additional helpers built in scripts/ 420# Additional helpers built in scripts/
453# Carefully list dependencies so we do not try to build scripts twice 421# Carefully list dependencies so we do not try to build scripts twice
454# in parrallel 422# in parrallel
455.PHONY: scripts 423PHONY += scripts
456scripts: scripts_basic include/config/MARKER 424scripts: scripts_basic include/config/MARKER
457 $(Q)$(MAKE) $(build)=$(@) 425 $(Q)$(MAKE) $(build)=$(@)
458 426
@@ -504,13 +472,6 @@ else
504CFLAGS += -O2 472CFLAGS += -O2
505endif 473endif
506 474
507#Add align options if CONFIG_CC_* is not equal to 0
508add-align = $(if $(filter-out 0,$($(1))),$(cc-option-align)$(2)=$($(1)))
509CFLAGS += $(call add-align,CONFIG_CC_ALIGN_FUNCTIONS,-functions)
510CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LABELS,-labels)
511CFLAGS += $(call add-align,CONFIG_CC_ALIGN_LOOPS,-loops)
512CFLAGS += $(call add-align,CONFIG_CC_ALIGN_JUMPS,-jumps)
513
514ifdef CONFIG_FRAME_POINTER 475ifdef CONFIG_FRAME_POINTER
515CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) 476CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,)
516else 477else
@@ -756,7 +717,7 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
756# make menuconfig etc. 717# make menuconfig etc.
757# Error messages still appears in the original language 718# Error messages still appears in the original language
758 719
759.PHONY: $(vmlinux-dirs) 720PHONY += $(vmlinux-dirs)
760$(vmlinux-dirs): prepare scripts 721$(vmlinux-dirs): prepare scripts
761 $(Q)$(MAKE) $(build)=$@ 722 $(Q)$(MAKE) $(build)=$@
762 723
@@ -809,10 +770,10 @@ kernelrelease = $(KERNELVERSION)$(localver-full)
809# version.h and scripts_basic is processed / created. 770# version.h and scripts_basic is processed / created.
810 771
811# Listed in dependency order 772# Listed in dependency order
812.PHONY: prepare archprepare prepare0 prepare1 prepare2 prepare3 773PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
813 774
814# prepare-all is deprecated, use prepare as valid replacement 775# prepare-all is deprecated, use prepare as valid replacement
815.PHONY: prepare-all 776PHONY += prepare-all
816 777
817# prepare3 is used to check if we are building in a separate output directory, 778# prepare3 is used to check if we are building in a separate output directory,
818# and if so do: 779# and if so do:
@@ -853,27 +814,6 @@ prepare prepare-all: prepare0
853 814
854export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH) 815export CPPFLAGS_vmlinux.lds += -P -C -U$(ARCH)
855 816
856# Single targets
857# ---------------------------------------------------------------------------
858
859%.s: %.c scripts FORCE
860 $(Q)$(MAKE) $(build)=$(@D) $@
861%.i: %.c scripts FORCE
862 $(Q)$(MAKE) $(build)=$(@D) $@
863%.o: %.c scripts FORCE
864 $(Q)$(MAKE) $(build)=$(@D) $@
865%.ko: scripts FORCE
866 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D) $(@:.ko=.o)
867 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
868%/: scripts prepare FORCE
869 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) $(build)=$(@D)
870%.lst: %.c scripts FORCE
871 $(Q)$(MAKE) $(build)=$(@D) $@
872%.s: %.S scripts FORCE
873 $(Q)$(MAKE) $(build)=$(@D) $@
874%.o: %.S scripts FORCE
875 $(Q)$(MAKE) $(build)=$(@D) $@
876
877# FIXME: The asm symlink changes when $(ARCH) changes. That's 817# FIXME: The asm symlink changes when $(ARCH) changes. That's
878# hard to detect, but I suppose "make mrproper" is a good idea 818# hard to detect, but I suppose "make mrproper" is a good idea
879# before switching between archs anyway. 819# before switching between archs anyway.
@@ -914,7 +854,7 @@ include/linux/version.h: $(srctree)/Makefile .config .kernelrelease FORCE
914 854
915# --------------------------------------------------------------------------- 855# ---------------------------------------------------------------------------
916 856
917.PHONY: depend dep 857PHONY += depend dep
918depend dep: 858depend dep:
919 @echo '*** Warning: make $@ is unnecessary now.' 859 @echo '*** Warning: make $@ is unnecessary now.'
920 860
@@ -929,21 +869,21 @@ all: modules
929 869
930# Build modules 870# Build modules
931 871
932.PHONY: modules 872PHONY += modules
933modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) 873modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
934 @echo ' Building modules, stage 2.'; 874 @echo ' Building modules, stage 2.';
935 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost 875 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
936 876
937 877
938# Target to prepare building external modules 878# Target to prepare building external modules
939.PHONY: modules_prepare 879PHONY += modules_prepare
940modules_prepare: prepare scripts 880modules_prepare: prepare scripts
941 881
942# Target to install modules 882# Target to install modules
943.PHONY: modules_install 883PHONY += modules_install
944modules_install: _modinst_ _modinst_post 884modules_install: _modinst_ _modinst_post
945 885
946.PHONY: _modinst_ 886PHONY += _modinst_
947_modinst_: 887_modinst_:
948 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ 888 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
949 echo "Warning: you may need to install module-init-tools"; \ 889 echo "Warning: you may need to install module-init-tools"; \
@@ -970,7 +910,7 @@ depmod_opts :=
970else 910else
971depmod_opts := -b $(INSTALL_MOD_PATH) -r 911depmod_opts := -b $(INSTALL_MOD_PATH) -r
972endif 912endif
973.PHONY: _modinst_post 913PHONY += _modinst_post
974_modinst_post: _modinst_ 914_modinst_post: _modinst_
975 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi 915 if [ -r System.map -a -x $(DEPMOD) ]; then $(DEPMOD) -ae -F System.map $(depmod_opts) $(KERNELRELEASE); fi
976 916
@@ -1013,7 +953,7 @@ clean: rm-dirs := $(CLEAN_DIRS)
1013clean: rm-files := $(CLEAN_FILES) 953clean: rm-files := $(CLEAN_FILES)
1014clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs)) 954clean-dirs := $(addprefix _clean_,$(srctree) $(vmlinux-alldirs))
1015 955
1016.PHONY: $(clean-dirs) clean archclean 956PHONY += $(clean-dirs) clean archclean
1017$(clean-dirs): 957$(clean-dirs):
1018 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 958 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1019 959
@@ -1031,7 +971,7 @@ mrproper: rm-dirs := $(wildcard $(MRPROPER_DIRS))
1031mrproper: rm-files := $(wildcard $(MRPROPER_FILES)) 971mrproper: rm-files := $(wildcard $(MRPROPER_FILES))
1032mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts) 972mrproper-dirs := $(addprefix _mrproper_,Documentation/DocBook scripts)
1033 973
1034.PHONY: $(mrproper-dirs) mrproper archmrproper 974PHONY += $(mrproper-dirs) mrproper archmrproper
1035$(mrproper-dirs): 975$(mrproper-dirs):
1036 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@) 976 $(Q)$(MAKE) $(clean)=$(patsubst _mrproper_%,%,$@)
1037 977
@@ -1041,7 +981,7 @@ mrproper: clean archmrproper $(mrproper-dirs)
1041 981
1042# distclean 982# distclean
1043# 983#
1044.PHONY: distclean 984PHONY += distclean
1045 985
1046distclean: mrproper 986distclean: mrproper
1047 @find $(srctree) $(RCS_FIND_IGNORE) \ 987 @find $(srctree) $(RCS_FIND_IGNORE) \
@@ -1057,12 +997,10 @@ distclean: mrproper
1057# rpm target kept for backward compatibility 997# rpm target kept for backward compatibility
1058package-dir := $(srctree)/scripts/package 998package-dir := $(srctree)/scripts/package
1059 999
1060.PHONY: %-pkg rpm
1061
1062%pkg: FORCE 1000%pkg: FORCE
1063 $(Q)$(MAKE) -f $(package-dir)/Makefile $@ 1001 $(Q)$(MAKE) $(build)=$(package-dir) $@
1064rpm: FORCE 1002rpm: FORCE
1065 $(Q)$(MAKE) -f $(package-dir)/Makefile $@ 1003 $(Q)$(MAKE) $(build)=$(package-dir) $@
1066 1004
1067 1005
1068# Brief documentation of the typical targets used 1006# Brief documentation of the typical targets used
@@ -1094,13 +1032,11 @@ help:
1094 @echo ' kernelversion - Output the version stored in Makefile' 1032 @echo ' kernelversion - Output the version stored in Makefile'
1095 @echo '' 1033 @echo ''
1096 @echo 'Static analysers' 1034 @echo 'Static analysers'
1097 @echo ' buildcheck - List dangling references to vmlinux discarded sections'
1098 @echo ' and init sections from non-init sections'
1099 @echo ' checkstack - Generate a list of stack hogs' 1035 @echo ' checkstack - Generate a list of stack hogs'
1100 @echo ' namespacecheck - Name space analysis on compiled kernel' 1036 @echo ' namespacecheck - Name space analysis on compiled kernel'
1101 @echo '' 1037 @echo ''
1102 @echo 'Kernel packaging:' 1038 @echo 'Kernel packaging:'
1103 @$(MAKE) -f $(package-dir)/Makefile help 1039 @$(MAKE) $(build)=$(package-dir) help
1104 @echo '' 1040 @echo ''
1105 @echo 'Documentation targets:' 1041 @echo 'Documentation targets:'
1106 @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp 1042 @$(MAKE) -f $(srctree)/Documentation/DocBook/Makefile dochelp
@@ -1149,11 +1085,12 @@ else # KBUILD_EXTMOD
1149 1085
1150# We are always building modules 1086# We are always building modules
1151KBUILD_MODULES := 1 1087KBUILD_MODULES := 1
1152.PHONY: crmodverdir 1088PHONY += crmodverdir
1153crmodverdir: 1089crmodverdir:
1090 $(Q)rm -rf $(MODVERDIR)
1154 $(Q)mkdir -p $(MODVERDIR) 1091 $(Q)mkdir -p $(MODVERDIR)
1155 1092
1156.PHONY: $(objtree)/Module.symvers 1093PHONY += $(objtree)/Module.symvers
1157$(objtree)/Module.symvers: 1094$(objtree)/Module.symvers:
1158 @test -e $(objtree)/Module.symvers || ( \ 1095 @test -e $(objtree)/Module.symvers || ( \
1159 echo; \ 1096 echo; \
@@ -1162,7 +1099,7 @@ $(objtree)/Module.symvers:
1162 echo ) 1099 echo )
1163 1100
1164module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD)) 1101module-dirs := $(addprefix _module_,$(KBUILD_EXTMOD))
1165.PHONY: $(module-dirs) modules 1102PHONY += $(module-dirs) modules
1166$(module-dirs): crmodverdir $(objtree)/Module.symvers 1103$(module-dirs): crmodverdir $(objtree)/Module.symvers
1167 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@) 1104 $(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
1168 1105
@@ -1170,13 +1107,32 @@ modules: $(module-dirs)
1170 @echo ' Building modules, stage 2.'; 1107 @echo ' Building modules, stage 2.';
1171 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost 1108 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1172 1109
1173.PHONY: modules_install 1110PHONY += modules_install
1174modules_install: 1111modules_install: _emodinst_ _emodinst_post
1112
1113install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)
1114PHONY += _emodinst_
1115_emodinst_:
1116 $(Q)rm -rf $(MODLIB)/$(install-dir)
1117 $(Q)mkdir -p $(MODLIB)/$(install-dir)
1175 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst 1118 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
1176 1119
1120# Run depmod only is we have System.map and depmod is executable
1121quiet_cmd_depmod = DEPMOD $(KERNELRELEASE)
1122 cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \
1123 $(DEPMOD) -ae -F System.map \
1124 $(if $(strip $(INSTALL_MOD_PATH)), \
1125 -b $(INSTALL_MOD_PATH) -r) \
1126 $(KERNELRELEASE); \
1127 fi
1128
1129PHONY += _emodinst_post
1130_emodinst_post: _emodinst_
1131 $(call cmd,depmod)
1132
1177clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD)) 1133clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
1178 1134
1179.PHONY: $(clean-dirs) clean 1135PHONY += $(clean-dirs) clean
1180$(clean-dirs): 1136$(clean-dirs):
1181 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@) 1137 $(Q)$(MAKE) $(clean)=$(patsubst _clean_%,%,$@)
1182 1138
@@ -1196,6 +1152,11 @@ help:
1196 @echo ' modules_install - install the module' 1152 @echo ' modules_install - install the module'
1197 @echo ' clean - remove generated files in module directory only' 1153 @echo ' clean - remove generated files in module directory only'
1198 @echo '' 1154 @echo ''
1155
1156# Dummies...
1157PHONY += prepare scripts
1158prepare: ;
1159scripts: ;
1199endif # KBUILD_EXTMOD 1160endif # KBUILD_EXTMOD
1200 1161
1201# Generate tags for editors 1162# Generate tags for editors
@@ -1296,17 +1257,13 @@ versioncheck:
1296 -name '*.[hcS]' -type f -print | sort \ 1257 -name '*.[hcS]' -type f -print | sort \
1297 | xargs $(PERL) -w scripts/checkversion.pl 1258 | xargs $(PERL) -w scripts/checkversion.pl
1298 1259
1299buildcheck:
1300 $(PERL) $(srctree)/scripts/reference_discarded.pl
1301 $(PERL) $(srctree)/scripts/reference_init.pl
1302
1303namespacecheck: 1260namespacecheck:
1304 $(PERL) $(srctree)/scripts/namespace.pl 1261 $(PERL) $(srctree)/scripts/namespace.pl
1305 1262
1306endif #ifeq ($(config-targets),1) 1263endif #ifeq ($(config-targets),1)
1307endif #ifeq ($(mixed-targets),1) 1264endif #ifeq ($(mixed-targets),1)
1308 1265
1309.PHONY: checkstack 1266PHONY += checkstack
1310checkstack: 1267checkstack:
1311 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \ 1268 $(OBJDUMP) -d vmlinux $$(find . -name '*.ko') | \
1312 $(PERL) $(src)/scripts/checkstack.pl $(ARCH) 1269 $(PERL) $(src)/scripts/checkstack.pl $(ARCH)
@@ -1317,6 +1274,44 @@ kernelrelease:
1317kernelversion: 1274kernelversion:
1318 @echo $(KERNELVERSION) 1275 @echo $(KERNELVERSION)
1319 1276
1277# Single targets
1278# ---------------------------------------------------------------------------
1279# The directory part is taken from first prerequisite, so this
1280# works even with external modules
1281%.s: %.c prepare scripts FORCE
1282 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1283%.i: %.c prepare scripts FORCE
1284 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1285%.o: %.c prepare scripts FORCE
1286 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1287%.lst: %.c prepare scripts FORCE
1288 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1289%.s: %.S prepare scripts FORCE
1290 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1291%.o: %.S prepare scripts FORCE
1292 $(Q)$(MAKE) $(build)=$(dir $<) $(dir $<)$(notdir $@)
1293
1294# For external modules we shall include any directory of the target,
1295# but usual case there is no directory part.
1296# make M=`pwd` module.o => $(dir $@)=./
1297# make M=`pwd` foo/module.o => $(dir $@)=foo/
1298# make M=`pwd` / => $(dir $@)=/
1299
1300ifeq ($(KBUILD_EXTMOD),)
1301 target-dir = $(@D)
1302else
1303 zap-slash=$(filter-out .,$(patsubst %/,%,$(dir $@)))
1304 target-dir = $(KBUILD_EXTMOD)$(if $(zap-slash),/$(zap-slash))
1305endif
1306
1307/ %/: scripts prepare FORCE
1308 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1309 $(build)=$(target-dir)
1310%.ko: scripts FORCE
1311 $(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
1312 $(build)=$(target-dir) $(@:.ko=.o)
1313 $(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
1314
1320# FIXME Should go into a make.lib or something 1315# FIXME Should go into a make.lib or something
1321# =========================================================================== 1316# ===========================================================================
1322 1317
@@ -1351,4 +1346,10 @@ clean := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.clean obj
1351 1346
1352endif # skip-makefile 1347endif # skip-makefile
1353 1348
1349PHONY += FORCE
1354FORCE: 1350FORCE:
1351
1352
1353# Declare the contents of the .PHONY variable as phony. We keep that
1354# information in a variable se we can use it in if_changed and friends.
1355.PHONY: $(PHONY)
diff --git a/arch/arm/Makefile b/arch/arm/Makefile
index b5b1e4087516..99c0d323719a 100644
--- a/arch/arm/Makefile
+++ b/arch/arm/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# arch/arm/Makefile 2# arch/arm/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -177,7 +180,7 @@ endif
177 180
178archprepare: maketools 181archprepare: maketools
179 182
180.PHONY: maketools FORCE 183PHONY += maketools FORCE
181maketools: include/linux/version.h include/asm-arm/.arch FORCE 184maketools: include/linux/version.h include/asm-arm/.arch FORCE
182 $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h 185 $(Q)$(MAKE) $(build)=arch/arm/tools include/asm-arm/mach-types.h
183 186
diff --git a/arch/arm/boot/Makefile b/arch/arm/boot/Makefile
index a174d63395ea..ec9c400c7f82 100644
--- a/arch/arm/boot/Makefile
+++ b/arch/arm/boot/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# arch/arm/boot/Makefile 2# arch/arm/boot/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -73,7 +76,7 @@ $(obj)/bootpImage: $(obj)/bootp/bootp FORCE
73 $(call if_changed,objcopy) 76 $(call if_changed,objcopy)
74 @echo ' Kernel: $@ is ready' 77 @echo ' Kernel: $@ is ready'
75 78
76.PHONY: initrd FORCE 79PHONY += initrd FORCE
77initrd: 80initrd:
78 @test "$(INITRD_PHYS)" != "" || \ 81 @test "$(INITRD_PHYS)" != "" || \
79 (echo This machine does not support INITRD; exit -1) 82 (echo This machine does not support INITRD; exit -1)
diff --git a/arch/arm/boot/bootp/Makefile b/arch/arm/boot/bootp/Makefile
index 8e8879b6b3d7..c394e305447c 100644
--- a/arch/arm/boot/bootp/Makefile
+++ b/arch/arm/boot/bootp/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# linux/arch/arm/boot/bootp/Makefile 2# linux/arch/arm/boot/bootp/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4 7
5LDFLAGS_bootp :=-p --no-undefined -X \ 8LDFLAGS_bootp :=-p --no-undefined -X \
6 --defsym initrd_phys=$(INITRD_PHYS) \ 9 --defsym initrd_phys=$(INITRD_PHYS) \
@@ -21,4 +24,4 @@ $(obj)/kernel.o: arch/arm/boot/zImage FORCE
21 24
22$(obj)/initrd.o: $(INITRD) FORCE 25$(obj)/initrd.o: $(INITRD) FORCE
23 26
24.PHONY: $(INITRD) FORCE 27PHONY += $(INITRD) FORCE
diff --git a/arch/arm26/Makefile b/arch/arm26/Makefile
index 844a9e46886e..fe91eda98a94 100644
--- a/arch/arm26/Makefile
+++ b/arch/arm26/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# arch/arm26/Makefile 2# arch/arm26/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -49,9 +52,9 @@ all: zImage
49 52
50boot := arch/arm26/boot 53boot := arch/arm26/boot
51 54
52.PHONY: maketools FORCE 55PHONY += maketools FORCE
53maketools: FORCE 56maketools: FORCE
54 57
55 58
56# Convert bzImage to zImage 59# Convert bzImage to zImage
57bzImage: vmlinux 60bzImage: vmlinux
diff --git a/arch/arm26/boot/Makefile b/arch/arm26/boot/Makefile
index b5c2277654d4..68acb7b0d47f 100644
--- a/arch/arm26/boot/Makefile
+++ b/arch/arm26/boot/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# arch/arm26/boot/Makefile 2# arch/arm26/boot/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -60,7 +63,7 @@ $(obj)/xipImage: vmlinux FORCE
60 @echo ' Kernel: $@ is ready' 63 @echo ' Kernel: $@ is ready'
61endif 64endif
62 65
63.PHONY: initrd 66PHONY += initrd
64initrd: 67initrd:
65 @test "$(INITRD_PHYS)" != "" || \ 68 @test "$(INITRD_PHYS)" != "" || \
66 (echo This machine does not support INITRD; exit -1) 69 (echo This machine does not support INITRD; exit -1)
diff --git a/arch/i386/Makefile b/arch/i386/Makefile
index 36bef6543ac1..ff6973a85c8f 100644
--- a/arch/i386/Makefile
+++ b/arch/i386/Makefile
@@ -99,8 +99,8 @@ AFLAGS += $(mflags-y)
99 99
100boot := arch/i386/boot 100boot := arch/i386/boot
101 101
102.PHONY: zImage bzImage compressed zlilo bzlilo \ 102PHONY += zImage bzImage compressed zlilo bzlilo \
103 zdisk bzdisk fdimage fdimage144 fdimage288 install 103 zdisk bzdisk fdimage fdimage144 fdimage288 install
104 104
105all: bzImage 105all: bzImage
106 106
diff --git a/arch/i386/kernel/vmlinux.lds.S b/arch/i386/kernel/vmlinux.lds.S
index 3f21c6f6466d..8831303a473f 100644
--- a/arch/i386/kernel/vmlinux.lds.S
+++ b/arch/i386/kernel/vmlinux.lds.S
@@ -7,6 +7,7 @@
7#include <asm-generic/vmlinux.lds.h> 7#include <asm-generic/vmlinux.lds.h>
8#include <asm/thread_info.h> 8#include <asm/thread_info.h>
9#include <asm/page.h> 9#include <asm/page.h>
10#include <asm/cache.h>
10 11
11OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386") 12OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
12OUTPUT_ARCH(i386) 13OUTPUT_ARCH(i386)
@@ -135,7 +136,7 @@ SECTIONS
135 __initramfs_start = .; 136 __initramfs_start = .;
136 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) } 137 .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
137 __initramfs_end = .; 138 __initramfs_end = .;
138 . = ALIGN(32); 139 . = ALIGN(L1_CACHE_BYTES);
139 __per_cpu_start = .; 140 __per_cpu_start = .;
140 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) } 141 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
141 __per_cpu_end = .; 142 __per_cpu_end = .;
diff --git a/arch/ia64/Makefile b/arch/ia64/Makefile
index f722e1a25948..80ea7506fa1a 100644
--- a/arch/ia64/Makefile
+++ b/arch/ia64/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# ia64/Makefile 2# ia64/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
5# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
6# for more details. 9# for more details.
@@ -62,7 +65,7 @@ drivers-$(CONFIG_OPROFILE) += arch/ia64/oprofile/
62 65
63boot := arch/ia64/hp/sim/boot 66boot := arch/ia64/hp/sim/boot
64 67
65.PHONY: boot compressed check 68PHONY += boot compressed check
66 69
67all: compressed unwcheck 70all: compressed unwcheck
68 71
diff --git a/arch/m32r/Makefile b/arch/m32r/Makefile
index 4b3c90ba926c..f219c47d334f 100644
--- a/arch/m32r/Makefile
+++ b/arch/m32r/Makefile
@@ -1,6 +1,9 @@
1# 1#
2# m32r/Makefile 2# m32r/Makefile
3# 3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
4 7
5LDFLAGS := 8LDFLAGS :=
6OBJCOPYFLAGS := -O binary -R .note -R .comment -S 9OBJCOPYFLAGS := -O binary -R .note -R .comment -S
@@ -39,7 +42,7 @@ drivers-$(CONFIG_OPROFILE) += arch/m32r/oprofile/
39 42
40boot := arch/m32r/boot 43boot := arch/m32r/boot
41 44
42.PHONY: zImage 45PHONY += zImage
43 46
44all: zImage 47all: zImage
45 48
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index a3fc7a23158f..829e017b8a54 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -150,7 +150,7 @@ CPPFLAGS_vmlinux.lds := -Upowerpc
150 150
151BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage vmlinux.bin 151BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm uImage vmlinux.bin
152 152
153.PHONY: $(BOOT_TARGETS) 153PHONY += $(BOOT_TARGETS)
154 154
155boot := arch/$(ARCH)/boot 155boot := arch/$(ARCH)/boot
156 156
diff --git a/arch/ppc/Makefile b/arch/ppc/Makefile
index 98e940beeb3b..9fbdf54ba2be 100644
--- a/arch/ppc/Makefile
+++ b/arch/ppc/Makefile
@@ -82,7 +82,7 @@ drivers-$(CONFIG_OPROFILE) += arch/powerpc/oprofile/
82 82
83BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm 83BOOT_TARGETS = zImage zImage.initrd znetboot znetboot.initrd vmlinux.sm
84 84
85.PHONY: $(BOOT_TARGETS) 85PHONY += $(BOOT_TARGETS)
86 86
87all: uImage zImage 87all: uImage zImage
88 88
diff --git a/arch/ppc/boot/Makefile b/arch/ppc/boot/Makefile
index f565699a9fe0..84eec0bef93c 100644
--- a/arch/ppc/boot/Makefile
+++ b/arch/ppc/boot/Makefile
@@ -1,3 +1,9 @@
1#
2# arch/ppc/boot/Makefile
3#
4# This file is included by the global makefile so that you can add your own
5# architecture-specific flags and dependencies.
6#
1# This file is subject to the terms and conditions of the GNU General Public 7# This file is subject to the terms and conditions of the GNU General Public
2# License. See the file "COPYING" in the main directory of this archive 8# License. See the file "COPYING" in the main directory of this archive
3# for more details. 9# for more details.
@@ -22,7 +28,7 @@ subdir- += simple openfirmware
22 28
23hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree) 29hostprogs-y := $(addprefix utils/, addnote mknote hack-coff mkprep mkbugboot mktree)
24 30
25.PHONY: $(BOOT_TARGETS) $(bootdir-y) 31PHONY += $(BOOT_TARGETS) $(bootdir-y)
26 32
27$(BOOT_TARGETS): $(bootdir-y) 33$(BOOT_TARGETS): $(bootdir-y)
28 34
diff --git a/arch/ppc/boot/openfirmware/Makefile b/arch/ppc/boot/openfirmware/Makefile
index 2a411ec2e650..66b739743759 100644
--- a/arch/ppc/boot/openfirmware/Makefile
+++ b/arch/ppc/boot/openfirmware/Makefile
@@ -1,5 +1,8 @@
1# Makefile for making bootable images on various OpenFirmware machines. 1# Makefile for making bootable images on various OpenFirmware machines.
2# 2#
3# This file is included by the global makefile so that you can add your own
4# architecture-specific flags and dependencies.
5#
3# Paul Mackerras January 1997 6# Paul Mackerras January 1997
4# XCOFF bootable images for PowerMacs 7# XCOFF bootable images for PowerMacs
5# Geert Uytterhoeven September 1997 8# Geert Uytterhoeven September 1997
@@ -86,7 +89,7 @@ $(images)/zImage.chrp-rs6k $(images)/zImage.initrd.chrp-rs6k: \
86 89
87# The targets used on the make command-line 90# The targets used on the make command-line
88 91
89.PHONY: zImage zImage.initrd 92PHONY += zImage zImage.initrd
90zImage: $(images)/zImage.chrp \ 93zImage: $(images)/zImage.chrp \
91 $(images)/zImage.chrp-rs6k 94 $(images)/zImage.chrp-rs6k
92 @echo ' kernel: $@ is ready ($<)' 95 @echo ' kernel: $@ is ready ($<)'
@@ -96,7 +99,7 @@ zImage.initrd: $(images)/zImage.initrd.chrp \
96 99
97TFTPIMAGE := /tftpboot/zImage 100TFTPIMAGE := /tftpboot/zImage
98 101
99.PHONY: znetboot znetboot.initrd 102PHONY += znetboot znetboot.initrd
100znetboot: $(images)/zImage.chrp 103znetboot: $(images)/zImage.chrp
101 cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END) 104 cp $(images)/zImage.chrp $(TFTPIMAGE).chrp$(END)
102 @echo ' kernel: $@ is ready ($<)' 105 @echo ' kernel: $@ is ready ($<)'
diff --git a/arch/sh/Makefile b/arch/sh/Makefile
index 08c9515c4806..c72e17a96eed 100644
--- a/arch/sh/Makefile
+++ b/arch/sh/Makefile
@@ -172,7 +172,7 @@ include/asm-sh/.mach: $(wildcard include/config/sh/*.h) include/config/MARKER
172 172
173archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach 173archprepare: maketools include/asm-sh/.cpu include/asm-sh/.mach
174 174
175.PHONY: maketools FORCE 175PHONY += maketools FORCE
176maketools: include/linux/version.h FORCE 176maketools: include/linux/version.h FORCE
177 $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h 177 $(Q)$(MAKE) $(build)=arch/sh/tools include/asm-sh/machtypes.h
178 178
diff --git a/arch/um/Makefile b/arch/um/Makefile
index c58b657f0097..8d14c7a831be 100644
--- a/arch/um/Makefile
+++ b/arch/um/Makefile
@@ -1,4 +1,7 @@
1# 1#
2# This file is included by the global makefile so that you can add your own
3# architecture-specific flags and dependencies.
4#
2# Copyright (C) 2002 Jeff Dike (jdike@karaya.com) 5# Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3# Licensed under the GPL 6# Licensed under the GPL
4# 7#
@@ -88,7 +91,7 @@ CONFIG_KERNEL_HALF_GIGS ?= 0
88 91
89SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) 92SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000)
90 93
91.PHONY: linux 94PHONY += linux
92 95
93all: linux 96all: linux
94 97
diff --git a/arch/x86_64/Makefile b/arch/x86_64/Makefile
index d7fd46479c55..7405dfd6522b 100644
--- a/arch/x86_64/Makefile
+++ b/arch/x86_64/Makefile
@@ -67,8 +67,8 @@ drivers-$(CONFIG_OPROFILE) += arch/x86_64/oprofile/
67 67
68boot := arch/x86_64/boot 68boot := arch/x86_64/boot
69 69
70.PHONY: bzImage bzlilo install archmrproper \ 70PHONY += bzImage bzlilo install archmrproper \
71 fdimage fdimage144 fdimage288 archclean 71 fdimage fdimage144 fdimage288 archclean
72 72
73#Default target when executing "make" 73#Default target when executing "make"
74all: bzImage 74all: bzImage
diff --git a/drivers/atm/.gitignore b/drivers/atm/.gitignore
new file mode 100644
index 000000000000..a165b7167714
--- /dev/null
+++ b/drivers/atm/.gitignore
@@ -0,0 +1,5 @@
1# Ignore generated files
2fore200e_mkfirm
3fore200e_pca_fw.c
4pca200e.bin
5
diff --git a/drivers/video/matrox/matroxfb_DAC1064.c b/drivers/video/matrox/matroxfb_DAC1064.c
index 0fbd9b5149f1..a456e67a5b00 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.c
+++ b/drivers/video/matrox/matroxfb_DAC1064.c
@@ -12,7 +12,6 @@
12 * 12 *
13 */ 13 */
14 14
15/* make checkconfig does not walk through include tree :-( */
16#include <linux/config.h> 15#include <linux/config.h>
17 16
18#include "matroxfb_DAC1064.h" 17#include "matroxfb_DAC1064.h"
diff --git a/drivers/video/matrox/matroxfb_DAC1064.h b/drivers/video/matrox/matroxfb_DAC1064.h
index a6a470127289..2e7238aa2432 100644
--- a/drivers/video/matrox/matroxfb_DAC1064.h
+++ b/drivers/video/matrox/matroxfb_DAC1064.h
@@ -1,7 +1,6 @@
1#ifndef __MATROXFB_DAC1064_H__ 1#ifndef __MATROXFB_DAC1064_H__
2#define __MATROXFB_DAC1064_H__ 2#define __MATROXFB_DAC1064_H__
3 3
4/* make checkconfig does not walk through include tree */
5#include <linux/config.h> 4#include <linux/config.h>
6 5
7#include "matroxfb_base.h" 6#include "matroxfb_base.h"
diff --git a/drivers/video/matrox/matroxfb_Ti3026.c b/drivers/video/matrox/matroxfb_Ti3026.c
index 537ade5d8b21..23ebad0a12d8 100644
--- a/drivers/video/matrox/matroxfb_Ti3026.c
+++ b/drivers/video/matrox/matroxfb_Ti3026.c
@@ -78,7 +78,6 @@
78 * 78 *
79 */ 79 */
80 80
81/* make checkconfig does not verify included files... */
82#include <linux/config.h> 81#include <linux/config.h>
83 82
84#include "matroxfb_Ti3026.h" 83#include "matroxfb_Ti3026.h"
diff --git a/drivers/video/matrox/matroxfb_Ti3026.h b/drivers/video/matrox/matroxfb_Ti3026.h
index 541933d7e4ea..536e5f69de9f 100644
--- a/drivers/video/matrox/matroxfb_Ti3026.h
+++ b/drivers/video/matrox/matroxfb_Ti3026.h
@@ -1,7 +1,6 @@
1#ifndef __MATROXFB_TI3026_H__ 1#ifndef __MATROXFB_TI3026_H__
2#define __MATROXFB_TI3026_H__ 2#define __MATROXFB_TI3026_H__
3 3
4/* make checkconfig does not walk through whole include tree */
5#include <linux/config.h> 4#include <linux/config.h>
6 5
7#include "matroxfb_base.h" 6#include "matroxfb_base.h"
diff --git a/drivers/video/matrox/matroxfb_base.c b/drivers/video/matrox/matroxfb_base.c
index 4055ff6f5a81..951c9974a1d3 100644
--- a/drivers/video/matrox/matroxfb_base.c
+++ b/drivers/video/matrox/matroxfb_base.c
@@ -99,7 +99,6 @@
99 * 99 *
100 */ 100 */
101 101
102/* make checkconfig does not check included files... */
103#include <linux/config.h> 102#include <linux/config.h>
104#include <linux/version.h> 103#include <linux/version.h>
105 104
diff --git a/drivers/video/matrox/matroxfb_misc.c b/drivers/video/matrox/matroxfb_misc.c
index 455a46ce840c..263d801ef78f 100644
--- a/drivers/video/matrox/matroxfb_misc.c
+++ b/drivers/video/matrox/matroxfb_misc.c
@@ -84,7 +84,6 @@
84 * 84 *
85 */ 85 */
86 86
87/* make checkconfig does not check includes for this... */
88#include <linux/config.h> 87#include <linux/config.h>
89 88
90#include "matroxfb_misc.h" 89#include "matroxfb_misc.h"
diff --git a/init/Kconfig b/init/Kconfig
index 05951c1d654e..3b36a1d53656 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -365,43 +365,6 @@ config SHMEM
365 option replaces shmem and tmpfs with the much simpler ramfs code, 365 option replaces shmem and tmpfs with the much simpler ramfs code,
366 which may be appropriate on small systems without swap. 366 which may be appropriate on small systems without swap.
367 367
368config CC_ALIGN_FUNCTIONS
369 int "Function alignment" if EMBEDDED
370 default 0
371 help
372 Align the start of functions to the next power-of-two greater than n,
373 skipping up to n bytes. For instance, 32 aligns functions
374 to the next 32-byte boundary, but 24 would align to the next
375 32-byte boundary only if this can be done by skipping 23 bytes or less.
376 Zero means use compiler's default.
377
378config CC_ALIGN_LABELS
379 int "Label alignment" if EMBEDDED
380 default 0
381 help
382 Align all branch targets to a power-of-two boundary, skipping
383 up to n bytes like ALIGN_FUNCTIONS. This option can easily
384 make code slower, because it must insert dummy operations for
385 when the branch target is reached in the usual flow of the code.
386 Zero means use compiler's default.
387
388config CC_ALIGN_LOOPS
389 int "Loop alignment" if EMBEDDED
390 default 0
391 help
392 Align loops to a power-of-two boundary, skipping up to n bytes.
393 Zero means use compiler's default.
394
395config CC_ALIGN_JUMPS
396 int "Jump alignment" if EMBEDDED
397 default 0
398 help
399 Align branch targets to a power-of-two boundary, for branch
400 targets where the targets can only be reached by jumping,
401 skipping up to n bytes like ALIGN_FUNCTIONS. In this case,
402 no dummy operations need be executed.
403 Zero means use compiler's default.
404
405config SLAB 368config SLAB
406 default y 369 default y
407 bool "Use full SLAB allocator" if EMBEDDED 370 bool "Use full SLAB allocator" if EMBEDDED
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 0168d6c37075..59620b1554e0 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -44,6 +44,43 @@ define filechk
44 fi 44 fi
45endef 45endef
46 46
47######
48# gcc support functions
49# See documentation in Documentation/kbuild/makefiles.txt
50
51# as-option
52# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,)
53
54as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \
55 -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \
56 else echo "$(2)"; fi ;)
57
58# cc-option
59# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586)
60
61cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
62 > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;)
63
64# cc-option-yn
65# Usage: flag := $(call cc-option-yn, -march=winchip-c6)
66cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \
67 > /dev/null 2>&1; then echo "y"; else echo "n"; fi;)
68
69# cc-option-align
70# Prefix align with either -falign or -malign
71cc-option-align = $(subst -functions=0,,\
72 $(call cc-option,-falign-functions=0,-malign-functions=0))
73
74# cc-version
75# Usage gcc-ver := $(call cc-version, $(CC))
76cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \
77 $(if $(1), $(1), $(CC)))
78
79# cc-ifversion
80# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
81cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \
82 echo $(3); fi;)
83
47### 84###
48# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= 85# Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj=
49# Usage: 86# Usage:
@@ -51,8 +88,7 @@ endef
51build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj 88build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
52 89
53# If quiet is set, only print short version of command 90# If quiet is set, only print short version of command
54cmd = @$(if $($(quiet)cmd_$(1)),\ 91cmd = @$(echo-cmd) $(cmd_$(1))
55 echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1))
56 92
57# Add $(obj)/ for paths that is not absolute 93# Add $(obj)/ for paths that is not absolute
58objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) 94objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o)))
@@ -75,30 +111,33 @@ endif
75echo-cmd = $(if $($(quiet)cmd_$(1)), \ 111echo-cmd = $(if $($(quiet)cmd_$(1)), \
76 echo ' $(call escsq,$($(quiet)cmd_$(1)))';) 112 echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
77 113
114make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))
115
78# function to only execute the passed command if necessary 116# function to only execute the passed command if necessary
79# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file 117# >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file
80# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars 118# note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars
81# 119#
82if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ 120if_changed = $(if $(strip $(filter-out $(PHONY),$?) \
121 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
83 @set -e; \ 122 @set -e; \
84 $(echo-cmd) \ 123 $(echo-cmd) $(cmd_$(1)); \
85 $(cmd_$(1)); \ 124 echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd)
86 echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd)
87 125
88# execute the command and also postprocess generated .d dependencies 126# execute the command and also postprocess generated .d dependencies
89# file 127# file
90if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ 128if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \
91 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ 129 $(filter-out FORCE $(wildcard $^),$^) \
130 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \
92 @set -e; \ 131 @set -e; \
93 $(echo-cmd) \ 132 $(echo-cmd) $(cmd_$(1)); \
94 $(cmd_$(1)); \ 133 scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \
95 scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \
96 rm -f $(depfile); \ 134 rm -f $(depfile); \
97 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) 135 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd)
98 136
99# Usage: $(call if_changed_rule,foo) 137# Usage: $(call if_changed_rule,foo)
100# will check if $(cmd_foo) changed, or any of the prequisites changed, 138# will check if $(cmd_foo) changed, or any of the prequisites changed,
101# and if so will execute $(rule_foo) 139# and if so will execute $(rule_foo)
102if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ 140if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \
141 $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\
103 @set -e; \ 142 @set -e; \
104 $(rule_$(1))) 143 $(rule_$(1)))
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index c33e62bde6b0..e48e60da3040 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -4,17 +4,18 @@
4 4
5src := $(obj) 5src := $(obj)
6 6
7.PHONY: __build 7PHONY := __build
8__build: 8__build:
9 9
10# Read .config if it exist, otherwise ignore 10# Read .config if it exist, otherwise ignore
11-include .config 11-include .config
12 12
13include scripts/Kbuild.include
14
13# The filename Kbuild has precedence over Makefile 15# The filename Kbuild has precedence over Makefile
14kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) 16kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src))
15include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) 17include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile)
16 18
17include scripts/Kbuild.include
18include scripts/Makefile.lib 19include scripts/Makefile.lib
19 20
20ifdef host-progs 21ifdef host-progs
@@ -128,7 +129,7 @@ $(multi-objs-y:.o=.s) : modname = $(modname-multi)
128$(multi-objs-y:.o=.lst) : modname = $(modname-multi) 129$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
129 130
130quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 131quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
131cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $< 132cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $<
132 133
133%.s: %.c FORCE 134%.s: %.c FORCE
134 $(call if_changed_dep,cc_s_c) 135 $(call if_changed_dep,cc_s_c)
@@ -165,7 +166,7 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
165cmd_modversions = \ 166cmd_modversions = \
166 if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ 167 if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
167 $(CPP) -D__GENKSYMS__ $(c_flags) $< \ 168 $(CPP) -D__GENKSYMS__ $(c_flags) $< \
168 | $(GENKSYMS) \ 169 | $(GENKSYMS) -a $(ARCH) \
169 > $(@D)/.tmp_$(@F:.o=.ver); \ 170 > $(@D)/.tmp_$(@F:.o=.ver); \
170 \ 171 \
171 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ 172 $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
@@ -177,12 +178,10 @@ cmd_modversions = \
177endif 178endif
178 179
179define rule_cc_o_c 180define rule_cc_o_c
180 $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \ 181 $(call echo-cmd,checksrc) $(cmd_checksrc) \
181 $(cmd_checksrc) \ 182 $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \
182 $(if $($(quiet)cmd_cc_o_c),echo ' $(call escsq,$($(quiet)cmd_cc_o_c))';) \
183 $(cmd_cc_o_c); \
184 $(cmd_modversions) \ 183 $(cmd_modversions) \
185 scripts/basic/fixdep $(depfile) $@ '$(call escsq,$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \ 184 scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \
186 rm -f $(depfile); \ 185 rm -f $(depfile); \
187 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd 186 mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd
188endef 187endef
@@ -309,14 +308,14 @@ targets += $(multi-used-y) $(multi-used-m)
309# Descending 308# Descending
310# --------------------------------------------------------------------------- 309# ---------------------------------------------------------------------------
311 310
312.PHONY: $(subdir-ym) 311PHONY += $(subdir-ym)
313$(subdir-ym): 312$(subdir-ym):
314 $(Q)$(MAKE) $(build)=$@ 313 $(Q)$(MAKE) $(build)=$@
315 314
316# Add FORCE to the prequisites of a target to force it to be always rebuilt. 315# Add FORCE to the prequisites of a target to force it to be always rebuilt.
317# --------------------------------------------------------------------------- 316# ---------------------------------------------------------------------------
318 317
319.PHONY: FORCE 318PHONY += FORCE
320 319
321FORCE: 320FORCE:
322 321
@@ -331,3 +330,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
331ifneq ($(cmd_files),) 330ifneq ($(cmd_files),)
332 include $(cmd_files) 331 include $(cmd_files)
333endif 332endif
333
334
335# Declare the contents of the .PHONY variable as phony. We keep that
336# information in a variable se we can use it in if_changed and friends.
337
338.PHONY: $(PHONY)
diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean
index 8974ea5fc878..cff33498fa16 100644
--- a/scripts/Makefile.clean
+++ b/scripts/Makefile.clean
@@ -4,7 +4,7 @@
4 4
5src := $(obj) 5src := $(obj)
6 6
7.PHONY: __clean 7PHONY := __clean
8__clean: 8__clean:
9 9
10# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir 10# Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir
@@ -87,10 +87,16 @@ endif
87# Descending 87# Descending
88# --------------------------------------------------------------------------- 88# ---------------------------------------------------------------------------
89 89
90.PHONY: $(subdir-ymn) 90PHONY += $(subdir-ymn)
91$(subdir-ymn): 91$(subdir-ymn):
92 $(Q)$(MAKE) $(clean)=$@ 92 $(Q)$(MAKE) $(clean)=$@
93 93
94# If quiet is set, only print short version of command 94# If quiet is set, only print short version of command
95 95
96cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) 96cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1))
97
98
99# Declare the contents of the .PHONY variable as phony. We keep that
100# information in a variable se we can use it in if_changed and friends.
101
102.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index 23fd1bdc25ce..2686dd5dce8c 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -2,7 +2,7 @@
2# Installing modules 2# Installing modules
3# ========================================================================== 3# ==========================================================================
4 4
5.PHONY: __modinst 5PHONY := __modinst
6__modinst: 6__modinst:
7 7
8include scripts/Kbuild.include 8include scripts/Kbuild.include
@@ -12,7 +12,7 @@ include scripts/Kbuild.include
12__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 12__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
13modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) 13modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o)))
14 14
15.PHONY: $(modules) 15PHONY += $(modules)
16__modinst: $(modules) 16__modinst: $(modules)
17 @: 17 @:
18 18
@@ -27,3 +27,9 @@ modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
27 27
28$(modules): 28$(modules):
29 $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) 29 $(call cmd,modules_install,$(MODLIB)/$(modinst_dir))
30
31
32# Declare the contents of the .PHONY variable as phony. We keep that
33# information in a variable se we can use it in if_changed and friends.
34
35.PHONY: $(PHONY)
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index 9a3ec20b0be2..0e056cffffdb 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -32,14 +32,15 @@
32# Step 4 is solely used to allow module versioning in external modules, 32# Step 4 is solely used to allow module versioning in external modules,
33# where the CRC of each module is retrieved from the Module.symers file. 33# where the CRC of each module is retrieved from the Module.symers file.
34 34
35.PHONY: _modpost 35PHONY := _modpost
36_modpost: __modpost 36_modpost: __modpost
37 37
38include .config 38include .config
39include scripts/Kbuild.include 39include scripts/Kbuild.include
40include scripts/Makefile.lib 40include scripts/Makefile.lib
41 41
42symverfile := $(objtree)/Module.symvers 42kernelsymfile := $(objtree)/Module.symvers
43modulesymfile := $(KBUILD_EXTMOD)/Modules.symvers
43 44
44# Step 1), find all modules listed in $(MODVERDIR)/ 45# Step 1), find all modules listed in $(MODVERDIR)/
45__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 46__modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod)))
@@ -54,10 +55,12 @@ quiet_cmd_modpost = MODPOST
54 cmd_modpost = scripts/mod/modpost \ 55 cmd_modpost = scripts/mod/modpost \
55 $(if $(CONFIG_MODVERSIONS),-m) \ 56 $(if $(CONFIG_MODVERSIONS),-m) \
56 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ 57 $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \
57 $(if $(KBUILD_EXTMOD),-i,-o) $(symverfile) \ 58 $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
59 $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
60 $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
58 $(filter-out FORCE,$^) 61 $(filter-out FORCE,$^)
59 62
60.PHONY: __modpost 63PHONY += __modpost
61__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE 64__modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE
62 $(call cmd,modpost) 65 $(call cmd,modpost)
63 66
@@ -94,7 +97,7 @@ targets += $(modules)
94# Add FORCE to the prequisites of a target to force it to be always rebuilt. 97# Add FORCE to the prequisites of a target to force it to be always rebuilt.
95# --------------------------------------------------------------------------- 98# ---------------------------------------------------------------------------
96 99
97.PHONY: FORCE 100PHONY += FORCE
98 101
99FORCE: 102FORCE:
100 103
@@ -109,3 +112,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
109ifneq ($(cmd_files),) 112ifneq ($(cmd_files),)
110 include $(cmd_files) 113 include $(cmd_files)
111endif 114endif
115
116
117# Declare the contents of the .PHONY variable as phony. We keep that
118# information in a variable se we can use it in if_changed and friends.
119
120.PHONY: $(PHONY)
diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c
index 679124b11e12..668a11a8b383 100644
--- a/scripts/basic/fixdep.c
+++ b/scripts/basic/fixdep.c
@@ -132,20 +132,10 @@ void usage(void)
132 132
133/* 133/*
134 * Print out the commandline prefixed with cmd_<target filename> := 134 * Print out the commandline prefixed with cmd_<target filename> :=
135 * If commandline contains '#' escape with '\' so make to not see 135 */
136 * the '#' as a start-of-comment symbol
137 **/
138void print_cmdline(void) 136void print_cmdline(void)
139{ 137{
140 char *p = cmdline; 138 printf("cmd_%s := %s\n\n", target, cmdline);
141
142 printf("cmd_%s := ", target);
143 for (; *p; p++) {
144 if (*p == '#')
145 printf("\\");
146 printf("%c", *p);
147 }
148 printf("\n\n");
149} 139}
150 140
151char * str_config = NULL; 141char * str_config = NULL;
diff --git a/scripts/checkconfig.pl b/scripts/checkconfig.pl
deleted file mode 100755
index ca1f231b15a6..000000000000
--- a/scripts/checkconfig.pl
+++ /dev/null
@@ -1,65 +0,0 @@
1#! /usr/bin/perl
2#
3# checkconfig: find uses of CONFIG_* names without matching definitions.
4# Copyright abandoned, 1998, Michael Elizabeth Chastain <mailto:mec@shout.net>.
5
6use integer;
7
8$| = 1;
9
10foreach $file (@ARGV)
11{
12 # Open this file.
13 open(FILE, $file) || die "Can't open $file: $!\n";
14
15 # Initialize variables.
16 my $fInComment = 0;
17 my $fInString = 0;
18 my $fUseConfig = 0;
19 my $iLinuxConfig = 0;
20 my %configList = ();
21
22 LINE: while ( <FILE> )
23 {
24 # Strip comments.
25 $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
26 m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
27
28 # Pick up definitions.
29 if ( m/^\s*#/o )
30 {
31 $iLinuxConfig = $. if m/^\s*#\s*include\s*"linux\/config\.h"/o;
32 $configList{uc $1} = 1 if m/^\s*#\s*include\s*"config\/(\S*)\.h"/o;
33 }
34
35 # Strip strings.
36 $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next);
37 m+"+o && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1)));
38
39 # Pick up definitions.
40 if ( m/^\s*#/o )
41 {
42 $iLinuxConfig = $. if m/^\s*#\s*include\s*<linux\/config\.h>/o;
43 $configList{uc $1} = 1 if m/^\s*#\s*include\s*<config\/(\S*)\.h>/o;
44 $configList{$1} = 1 if m/^\s*#\s*define\s+CONFIG_(\w*)/o;
45 $configList{$1} = 1 if m/^\s*#\s*undef\s+CONFIG_(\w*)/o;
46 }
47
48 # Look for usages.
49 next unless m/CONFIG_/o;
50 WORD: while ( m/\bCONFIG_(\w+)/og )
51 {
52 $fUseConfig = 1;
53 last LINE if $iLinuxConfig;
54 next WORD if exists $configList{$1};
55 print "$file: $.: need CONFIG_$1.\n";
56 $configList{$1} = 0;
57 }
58 }
59
60 # Report superfluous includes.
61 if ( $iLinuxConfig && ! $fUseConfig )
62 { print "$file: $iLinuxConfig: linux/config.h not needed.\n"; }
63
64 close(FILE);
65}
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index 416a694b0998..5b0344e20d61 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -29,481 +29,421 @@
29#include <stdarg.h> 29#include <stdarg.h>
30#ifdef __GNU_LIBRARY__ 30#ifdef __GNU_LIBRARY__
31#include <getopt.h> 31#include <getopt.h>
32#endif /* __GNU_LIBRARY__ */ 32#endif /* __GNU_LIBRARY__ */
33 33
34#include "genksyms.h" 34#include "genksyms.h"
35
36/*----------------------------------------------------------------------*/ 35/*----------------------------------------------------------------------*/
37 36
38#define HASH_BUCKETS 4096 37#define HASH_BUCKETS 4096
39 38
40static struct symbol *symtab[HASH_BUCKETS]; 39static struct symbol *symtab[HASH_BUCKETS];
41FILE *debugfile; 40static FILE *debugfile;
42 41
43int cur_line = 1; 42int cur_line = 1;
44char *cur_filename, *output_directory; 43char *cur_filename;
45 44
46int flag_debug, flag_dump_defs, flag_warnings; 45static int flag_debug, flag_dump_defs, flag_warnings;
46static const char *arch = "";
47static const char *mod_prefix = "";
47 48
48static int errors; 49static int errors;
49static int nsyms; 50static int nsyms;
50 51
51static struct symbol *expansion_trail; 52static struct symbol *expansion_trail;
52 53
53static const char * const symbol_type_name[] = { 54static const char *const symbol_type_name[] = {
54 "normal", "typedef", "enum", "struct", "union" 55 "normal", "typedef", "enum", "struct", "union"
55}; 56};
56 57
58static int equal_list(struct string_list *a, struct string_list *b);
59static void print_list(FILE * f, struct string_list *list);
60
57/*----------------------------------------------------------------------*/ 61/*----------------------------------------------------------------------*/
58 62
59static const unsigned int crctab32[] = 63static const unsigned int crctab32[] = {
60{ 64 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U,
61 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, 65 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U,
62 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, 66 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U,
63 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, 67 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU,
64 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, 68 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U,
65 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, 69 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U,
66 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, 70 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U,
67 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, 71 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU,
68 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, 72 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U,
69 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, 73 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU,
70 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, 74 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U,
71 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, 75 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U,
72 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, 76 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U,
73 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, 77 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU,
74 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, 78 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU,
75 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, 79 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U,
76 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, 80 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU,
77 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, 81 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U,
78 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, 82 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U,
79 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, 83 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U,
80 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, 84 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU,
81 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, 85 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U,
82 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, 86 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U,
83 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, 87 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU,
84 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, 88 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U,
85 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, 89 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U,
86 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, 90 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U,
87 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, 91 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U,
88 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, 92 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U,
89 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, 93 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU,
90 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, 94 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU,
91 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, 95 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U,
92 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, 96 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U,
93 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, 97 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU,
94 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, 98 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU,
95 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, 99 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U,
96 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, 100 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU,
97 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, 101 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U,
98 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, 102 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU,
99 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, 103 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U,
100 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, 104 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU,
101 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, 105 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U,
102 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, 106 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U,
103 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, 107 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU,
104 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, 108 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U,
105 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, 109 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U,
106 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, 110 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U,
107 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, 111 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U,
108 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, 112 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U,
109 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, 113 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U,
110 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, 114 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU,
111 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, 115 0x2d02ef8dU
112 0x2d02ef8dU
113}; 116};
114 117
115static inline unsigned long 118static unsigned long partial_crc32_one(unsigned char c, unsigned long crc)
116partial_crc32_one(unsigned char c, unsigned long crc)
117{ 119{
118 return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8); 120 return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8);
119} 121}
120 122
121static inline unsigned long 123static unsigned long partial_crc32(const char *s, unsigned long crc)
122partial_crc32(const char *s, unsigned long crc)
123{ 124{
124 while (*s) 125 while (*s)
125 crc = partial_crc32_one(*s++, crc); 126 crc = partial_crc32_one(*s++, crc);
126 return crc; 127 return crc;
127} 128}
128 129
129static inline unsigned long 130static unsigned long crc32(const char *s)
130crc32(const char *s)
131{ 131{
132 return partial_crc32(s, 0xffffffff) ^ 0xffffffff; 132 return partial_crc32(s, 0xffffffff) ^ 0xffffffff;
133} 133}
134 134
135
136/*----------------------------------------------------------------------*/ 135/*----------------------------------------------------------------------*/
137 136
138static inline enum symbol_type 137static enum symbol_type map_to_ns(enum symbol_type t)
139map_to_ns(enum symbol_type t)
140{ 138{
141 if (t == SYM_TYPEDEF) 139 if (t == SYM_TYPEDEF)
142 t = SYM_NORMAL; 140 t = SYM_NORMAL;
143 else if (t == SYM_UNION) 141 else if (t == SYM_UNION)
144 t = SYM_STRUCT; 142 t = SYM_STRUCT;
145 return t; 143 return t;
146} 144}
147 145
148struct symbol * 146struct symbol *find_symbol(const char *name, enum symbol_type ns)
149find_symbol(const char *name, enum symbol_type ns)
150{ 147{
151 unsigned long h = crc32(name) % HASH_BUCKETS; 148 unsigned long h = crc32(name) % HASH_BUCKETS;
152 struct symbol *sym; 149 struct symbol *sym;
153 150
154 for (sym = symtab[h]; sym ; sym = sym->hash_next) 151 for (sym = symtab[h]; sym; sym = sym->hash_next)
155 if (map_to_ns(sym->type) == map_to_ns(ns) && strcmp(name, sym->name) == 0) 152 if (map_to_ns(sym->type) == map_to_ns(ns) &&
156 break; 153 strcmp(name, sym->name) == 0)
154 break;
157 155
158 return sym; 156 return sym;
159} 157}
160 158
161struct symbol * 159struct symbol *add_symbol(const char *name, enum symbol_type type,
162add_symbol(const char *name, enum symbol_type type, struct string_list *defn, int is_extern) 160 struct string_list *defn, int is_extern)
163{ 161{
164 unsigned long h = crc32(name) % HASH_BUCKETS; 162 unsigned long h = crc32(name) % HASH_BUCKETS;
165 struct symbol *sym; 163 struct symbol *sym;
166 164
167 for (sym = symtab[h]; sym ; sym = sym->hash_next) 165 for (sym = symtab[h]; sym; sym = sym->hash_next) {
168 if (map_to_ns(sym->type) == map_to_ns(type) 166 if (map_to_ns(sym->type) == map_to_ns(type)
169 && strcmp(name, sym->name) == 0) 167 && strcmp(name, sym->name) == 0) {
170 { 168 if (!equal_list(sym->defn, defn))
171 if (!equal_list(sym->defn, defn)) 169 error_with_pos("redefinition of %s", name);
172 error_with_pos("redefinition of %s", name); 170 return sym;
171 }
172 }
173
174 sym = xmalloc(sizeof(*sym));
175 sym->name = name;
176 sym->type = type;
177 sym->defn = defn;
178 sym->expansion_trail = NULL;
179 sym->is_extern = is_extern;
180
181 sym->hash_next = symtab[h];
182 symtab[h] = sym;
183
184 if (flag_debug) {
185 fprintf(debugfile, "Defn for %s %s == <",
186 symbol_type_name[type], name);
187 if (is_extern)
188 fputs("extern ", debugfile);
189 print_list(debugfile, defn);
190 fputs(">\n", debugfile);
191 }
192
193 ++nsyms;
173 return sym; 194 return sym;
174 }
175
176 sym = xmalloc(sizeof(*sym));
177 sym->name = name;
178 sym->type = type;
179 sym->defn = defn;
180 sym->expansion_trail = NULL;
181 sym->is_extern = is_extern;
182
183 sym->hash_next = symtab[h];
184 symtab[h] = sym;
185
186 if (flag_debug)
187 {
188 fprintf(debugfile, "Defn for %s %s == <", symbol_type_name[type], name);
189 if (is_extern)
190 fputs("extern ", debugfile);
191 print_list(debugfile, defn);
192 fputs(">\n", debugfile);
193 }
194
195 ++nsyms;
196 return sym;
197} 195}
198 196
199
200/*----------------------------------------------------------------------*/ 197/*----------------------------------------------------------------------*/
201 198
202inline void 199void free_node(struct string_list *node)
203free_node(struct string_list *node)
204{ 200{
205 free(node->string); 201 free(node->string);
206 free(node); 202 free(node);
207} 203}
208 204
209void 205void free_list(struct string_list *s, struct string_list *e)
210free_list(struct string_list *s, struct string_list *e)
211{ 206{
212 while (s != e) 207 while (s != e) {
213 { 208 struct string_list *next = s->next;
214 struct string_list *next = s->next; 209 free_node(s);
215 free_node(s); 210 s = next;
216 s = next; 211 }
217 }
218} 212}
219 213
220inline struct string_list * 214struct string_list *copy_node(struct string_list *node)
221copy_node(struct string_list *node)
222{ 215{
223 struct string_list *newnode; 216 struct string_list *newnode;
224 217
225 newnode = xmalloc(sizeof(*newnode)); 218 newnode = xmalloc(sizeof(*newnode));
226 newnode->string = xstrdup(node->string); 219 newnode->string = xstrdup(node->string);
227 newnode->tag = node->tag; 220 newnode->tag = node->tag;
228 221
229 return newnode; 222 return newnode;
230} 223}
231 224
232struct string_list * 225static int equal_list(struct string_list *a, struct string_list *b)
233copy_list(struct string_list *s, struct string_list *e)
234{ 226{
235 struct string_list *h, *p; 227 while (a && b) {
236 228 if (a->tag != b->tag || strcmp(a->string, b->string))
237 if (s == e) 229 return 0;
238 return NULL; 230 a = a->next;
239 231 b = b->next;
240 p = h = copy_node(s); 232 }
241 while ((s = s->next) != e)
242 p = p->next = copy_node(s);
243 p->next = NULL;
244
245 return h;
246}
247 233
248int 234 return !a && !b;
249equal_list(struct string_list *a, struct string_list *b)
250{
251 while (a && b)
252 {
253 if (a->tag != b->tag || strcmp(a->string, b->string))
254 return 0;
255 a = a->next;
256 b = b->next;
257 }
258
259 return !a && !b;
260} 235}
261 236
262static inline void 237static void print_node(FILE * f, struct string_list *list)
263print_node(FILE *f, struct string_list *list)
264{ 238{
265 switch (list->tag) 239 switch (list->tag) {
266 { 240 case SYM_STRUCT:
267 case SYM_STRUCT: 241 putc('s', f);
268 putc('s', f); 242 goto printit;
269 goto printit; 243 case SYM_UNION:
270 case SYM_UNION: 244 putc('u', f);
271 putc('u', f); 245 goto printit;
272 goto printit; 246 case SYM_ENUM:
273 case SYM_ENUM: 247 putc('e', f);
274 putc('e', f); 248 goto printit;
275 goto printit; 249 case SYM_TYPEDEF:
276 case SYM_TYPEDEF: 250 putc('t', f);
277 putc('t', f); 251 goto printit;
278 goto printit;
279
280 printit:
281 putc('#', f);
282 case SYM_NORMAL:
283 fputs(list->string, f);
284 break;
285 }
286}
287 252
288void 253 printit:
289print_list(FILE *f, struct string_list *list) 254 putc('#', f);
290{ 255 case SYM_NORMAL:
291 struct string_list **e, **b; 256 fputs(list->string, f);
292 struct string_list *tmp, **tmp2; 257 break;
293 int elem = 1; 258 }
294
295 if (list == NULL)
296 {
297 fputs("(nil)", f);
298 return;
299 }
300
301 tmp = list;
302 while((tmp = tmp->next) != NULL)
303 elem++;
304
305 b = alloca(elem * sizeof(*e));
306 e = b + elem;
307 tmp2 = e - 1;
308
309 (*tmp2--) = list;
310 while((list = list->next) != NULL)
311 *(tmp2--) = list;
312
313 while (b != e)
314 {
315 print_node(f, *b++);
316 putc(' ', f);
317 }
318} 259}
319 260
320static unsigned long 261static void print_list(FILE * f, struct string_list *list)
321expand_and_crc_list(struct string_list *list, unsigned long crc)
322{ 262{
323 struct string_list **e, **b; 263 struct string_list **e, **b;
324 struct string_list *tmp, **tmp2; 264 struct string_list *tmp, **tmp2;
325 int elem = 1; 265 int elem = 1;
326
327 if (!list)
328 return crc;
329 266
330 tmp = list; 267 if (list == NULL) {
331 while((tmp = tmp->next) != NULL) 268 fputs("(nil)", f);
332 elem++; 269 return;
333 270 }
334 b = alloca(elem * sizeof(*e));
335 e = b + elem;
336 tmp2 = e - 1;
337 271
338 *(tmp2--) = list; 272 tmp = list;
339 while ((list = list->next) != NULL) 273 while ((tmp = tmp->next) != NULL)
340 *(tmp2--) = list; 274 elem++;
341 275
342 while (b != e) 276 b = alloca(elem * sizeof(*e));
343 { 277 e = b + elem;
344 struct string_list *cur; 278 tmp2 = e - 1;
345 struct symbol *subsym;
346 279
347 cur = *(b++); 280 (*tmp2--) = list;
348 switch (cur->tag) 281 while ((list = list->next) != NULL)
349 { 282 *(tmp2--) = list;
350 case SYM_NORMAL:
351 if (flag_dump_defs)
352 fprintf(debugfile, "%s ", cur->string);
353 crc = partial_crc32(cur->string, crc);
354 crc = partial_crc32_one(' ', crc);
355 break;
356 283
357 case SYM_TYPEDEF: 284 while (b != e) {
358 subsym = find_symbol(cur->string, cur->tag); 285 print_node(f, *b++);
359 if (subsym->expansion_trail) 286 putc(' ', f);
360 { 287 }
361 if (flag_dump_defs) 288}
362 fprintf(debugfile, "%s ", cur->string);
363 crc = partial_crc32(cur->string, crc);
364 crc = partial_crc32_one(' ', crc);
365 }
366 else
367 {
368 subsym->expansion_trail = expansion_trail;
369 expansion_trail = subsym;
370 crc = expand_and_crc_list(subsym->defn, crc);
371 }
372 break;
373 289
374 case SYM_STRUCT: 290static unsigned long expand_and_crc_list(struct string_list *list,
375 case SYM_UNION: 291 unsigned long crc)
376 case SYM_ENUM: 292{
377 subsym = find_symbol(cur->string, cur->tag); 293 struct string_list **e, **b;
378 if (!subsym) 294 struct string_list *tmp, **tmp2;
379 { 295 int elem = 1;
380 struct string_list *n, *t = NULL; 296
381 297 if (!list)
382 error_with_pos("expand undefined %s %s", 298 return crc;
383 symbol_type_name[cur->tag], cur->string); 299
384 300 tmp = list;
385 n = xmalloc(sizeof(*n)); 301 while ((tmp = tmp->next) != NULL)
386 n->string = xstrdup(symbol_type_name[cur->tag]); 302 elem++;
387 n->tag = SYM_NORMAL; 303
388 n->next = t; 304 b = alloca(elem * sizeof(*e));
389 t = n; 305 e = b + elem;
390 306 tmp2 = e - 1;
391 n = xmalloc(sizeof(*n)); 307
392 n->string = xstrdup(cur->string); 308 *(tmp2--) = list;
393 n->tag = SYM_NORMAL; 309 while ((list = list->next) != NULL)
394 n->next = t; 310 *(tmp2--) = list;
395 t = n; 311
396 312 while (b != e) {
397 n = xmalloc(sizeof(*n)); 313 struct string_list *cur;
398 n->string = xstrdup("{ UNKNOWN }"); 314 struct symbol *subsym;
399 n->tag = SYM_NORMAL; 315
400 n->next = t; 316 cur = *(b++);
401 317 switch (cur->tag) {
402 subsym = add_symbol(cur->string, cur->tag, n, 0); 318 case SYM_NORMAL:
403 } 319 if (flag_dump_defs)
404 if (subsym->expansion_trail) 320 fprintf(debugfile, "%s ", cur->string);
405 { 321 crc = partial_crc32(cur->string, crc);
406 if (flag_dump_defs) 322 crc = partial_crc32_one(' ', crc);
407 { 323 break;
408 fprintf(debugfile, "%s %s ", symbol_type_name[cur->tag], 324
409 cur->string); 325 case SYM_TYPEDEF:
326 subsym = find_symbol(cur->string, cur->tag);
327 if (subsym->expansion_trail) {
328 if (flag_dump_defs)
329 fprintf(debugfile, "%s ", cur->string);
330 crc = partial_crc32(cur->string, crc);
331 crc = partial_crc32_one(' ', crc);
332 } else {
333 subsym->expansion_trail = expansion_trail;
334 expansion_trail = subsym;
335 crc = expand_and_crc_list(subsym->defn, crc);
336 }
337 break;
338
339 case SYM_STRUCT:
340 case SYM_UNION:
341 case SYM_ENUM:
342 subsym = find_symbol(cur->string, cur->tag);
343 if (!subsym) {
344 struct string_list *n, *t = NULL;
345
346 error_with_pos("expand undefined %s %s",
347 symbol_type_name[cur->tag],
348 cur->string);
349
350 n = xmalloc(sizeof(*n));
351 n->string = xstrdup(symbol_type_name[cur->tag]);
352 n->tag = SYM_NORMAL;
353 n->next = t;
354 t = n;
355
356 n = xmalloc(sizeof(*n));
357 n->string = xstrdup(cur->string);
358 n->tag = SYM_NORMAL;
359 n->next = t;
360 t = n;
361
362 n = xmalloc(sizeof(*n));
363 n->string = xstrdup("{ UNKNOWN }");
364 n->tag = SYM_NORMAL;
365 n->next = t;
366
367 subsym =
368 add_symbol(cur->string, cur->tag, n, 0);
369 }
370 if (subsym->expansion_trail) {
371 if (flag_dump_defs) {
372 fprintf(debugfile, "%s %s ",
373 symbol_type_name[cur->tag],
374 cur->string);
375 }
376
377 crc = partial_crc32(symbol_type_name[cur->tag],
378 crc);
379 crc = partial_crc32_one(' ', crc);
380 crc = partial_crc32(cur->string, crc);
381 crc = partial_crc32_one(' ', crc);
382 } else {
383 subsym->expansion_trail = expansion_trail;
384 expansion_trail = subsym;
385 crc = expand_and_crc_list(subsym->defn, crc);
386 }
387 break;
410 } 388 }
411
412 crc = partial_crc32(symbol_type_name[cur->tag], crc);
413 crc = partial_crc32_one(' ', crc);
414 crc = partial_crc32(cur->string, crc);
415 crc = partial_crc32_one(' ', crc);
416 }
417 else
418 {
419 subsym->expansion_trail = expansion_trail;
420 expansion_trail = subsym;
421 crc = expand_and_crc_list(subsym->defn, crc);
422 }
423 break;
424 } 389 }
425 }
426 390
427 return crc; 391 return crc;
428} 392}
429 393
430void 394void export_symbol(const char *name)
431export_symbol(const char *name)
432{ 395{
433 struct symbol *sym; 396 struct symbol *sym;
434 397
435 sym = find_symbol(name, SYM_NORMAL); 398 sym = find_symbol(name, SYM_NORMAL);
436 if (!sym) 399 if (!sym)
437 error_with_pos("export undefined symbol %s", name); 400 error_with_pos("export undefined symbol %s", name);
438 else 401 else {
439 { 402 unsigned long crc;
440 unsigned long crc;
441 403
442 if (flag_dump_defs) 404 if (flag_dump_defs)
443 fprintf(debugfile, "Export %s == <", name); 405 fprintf(debugfile, "Export %s == <", name);
444 406
445 expansion_trail = (struct symbol *)-1L; 407 expansion_trail = (struct symbol *)-1L;
446 408
447 crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff; 409 crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff;
448 410
449 sym = expansion_trail; 411 sym = expansion_trail;
450 while (sym != (struct symbol *)-1L) 412 while (sym != (struct symbol *)-1L) {
451 { 413 struct symbol *n = sym->expansion_trail;
452 struct symbol *n = sym->expansion_trail; 414 sym->expansion_trail = 0;
453 sym->expansion_trail = 0; 415 sym = n;
454 sym = n; 416 }
455 }
456 417
457 if (flag_dump_defs) 418 if (flag_dump_defs)
458 fputs(">\n", debugfile); 419 fputs(">\n", debugfile);
459 420
460 /* Used as a linker script. */ 421 /* Used as a linker script. */
461 printf("__crc_%s = 0x%08lx ;\n", name, crc); 422 printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc);
462 } 423 }
463} 424}
464 425
465/*----------------------------------------------------------------------*/ 426/*----------------------------------------------------------------------*/
466 427void error_with_pos(const char *fmt, ...)
467void
468error(const char *fmt, ...)
469{
470 va_list args;
471
472 if (flag_warnings)
473 {
474 va_start(args, fmt);
475 vfprintf(stderr, fmt, args);
476 va_end(args);
477 putc('\n', stderr);
478
479 errors++;
480 }
481}
482
483void
484error_with_pos(const char *fmt, ...)
485{ 428{
486 va_list args; 429 va_list args;
487 430
488 if (flag_warnings) 431 if (flag_warnings) {
489 { 432 fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>",
490 fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>", cur_line); 433 cur_line);
491 434
492 va_start(args, fmt); 435 va_start(args, fmt);
493 vfprintf(stderr, fmt, args); 436 vfprintf(stderr, fmt, args);
494 va_end(args); 437 va_end(args);
495 putc('\n', stderr); 438 putc('\n', stderr);
496 439
497 errors++; 440 errors++;
498 } 441 }
499} 442}
500 443
501 444static void genksyms_usage(void)
502void genksyms_usage(void)
503{ 445{
504 fputs("Usage:\n" 446 fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n"
505 "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n"
506 "\n"
507#ifdef __GNU_LIBRARY__ 447#ifdef __GNU_LIBRARY__
508 " -d, --debug Increment the debug level (repeatable)\n" 448 " -d, --debug Increment the debug level (repeatable)\n"
509 " -D, --dump Dump expanded symbol defs (for debugging only)\n" 449 " -D, --dump Dump expanded symbol defs (for debugging only)\n"
@@ -511,81 +451,84 @@ void genksyms_usage(void)
511 " -q, --quiet Disable warnings (default)\n" 451 " -q, --quiet Disable warnings (default)\n"
512 " -h, --help Print this message\n" 452 " -h, --help Print this message\n"
513 " -V, --version Print the release version\n" 453 " -V, --version Print the release version\n"
514#else /* __GNU_LIBRARY__ */ 454#else /* __GNU_LIBRARY__ */
515 " -d Increment the debug level (repeatable)\n" 455 " -d Increment the debug level (repeatable)\n"
516 " -D Dump expanded symbol defs (for debugging only)\n" 456 " -D Dump expanded symbol defs (for debugging only)\n"
517 " -w Enable warnings\n" 457 " -w Enable warnings\n"
518 " -q Disable warnings (default)\n" 458 " -q Disable warnings (default)\n"
519 " -h Print this message\n" 459 " -h Print this message\n"
520 " -V Print the release version\n" 460 " -V Print the release version\n"
521#endif /* __GNU_LIBRARY__ */ 461#endif /* __GNU_LIBRARY__ */
522 , stderr); 462 , stderr);
523} 463}
524 464
525int 465int main(int argc, char **argv)
526main(int argc, char **argv)
527{ 466{
528 int o; 467 int o;
529 468
530#ifdef __GNU_LIBRARY__ 469#ifdef __GNU_LIBRARY__
531 struct option long_opts[] = { 470 struct option long_opts[] = {
532 {"debug", 0, 0, 'd'}, 471 {"arch", 1, 0, 'a'},
533 {"warnings", 0, 0, 'w'}, 472 {"debug", 0, 0, 'd'},
534 {"quiet", 0, 0, 'q'}, 473 {"warnings", 0, 0, 'w'},
535 {"dump", 0, 0, 'D'}, 474 {"quiet", 0, 0, 'q'},
536 {"version", 0, 0, 'V'}, 475 {"dump", 0, 0, 'D'},
537 {"help", 0, 0, 'h'}, 476 {"version", 0, 0, 'V'},
538 {0, 0, 0, 0} 477 {"help", 0, 0, 'h'},
539 }; 478 {0, 0, 0, 0}
540 479 };
541 while ((o = getopt_long(argc, argv, "dwqVDk:p:", 480
542 &long_opts[0], NULL)) != EOF) 481 while ((o = getopt_long(argc, argv, "a:dwqVDk:p:",
543#else /* __GNU_LIBRARY__ */ 482 &long_opts[0], NULL)) != EOF)
544 while ((o = getopt(argc, argv, "dwqVDk:p:")) != EOF) 483#else /* __GNU_LIBRARY__ */
545#endif /* __GNU_LIBRARY__ */ 484 while ((o = getopt(argc, argv, "a:dwqVDk:p:")) != EOF)
546 switch (o) 485#endif /* __GNU_LIBRARY__ */
547 { 486 switch (o) {
548 case 'd': 487 case 'a':
549 flag_debug++; 488 arch = optarg;
550 break; 489 break;
551 case 'w': 490 case 'd':
552 flag_warnings = 1; 491 flag_debug++;
553 break; 492 break;
554 case 'q': 493 case 'w':
555 flag_warnings = 0; 494 flag_warnings = 1;
556 break; 495 break;
557 case 'V': 496 case 'q':
558 fputs("genksyms version 2.5.60\n", stderr); 497 flag_warnings = 0;
559 break; 498 break;
560 case 'D': 499 case 'V':
561 flag_dump_defs = 1; 500 fputs("genksyms version 2.5.60\n", stderr);
562 break; 501 break;
563 case 'h': 502 case 'D':
564 genksyms_usage(); 503 flag_dump_defs = 1;
565 return 0; 504 break;
566 default: 505 case 'h':
567 genksyms_usage(); 506 genksyms_usage();
568 return 1; 507 return 0;
569 } 508 default:
570 509 genksyms_usage();
571 { 510 return 1;
572 extern int yydebug; 511 }
573 extern int yy_flex_debug; 512 if ((strcmp(arch, "v850") == 0) || (strcmp(arch, "h8300") == 0))
574 513 mod_prefix = "_";
575 yydebug = (flag_debug > 1); 514 {
576 yy_flex_debug = (flag_debug > 2); 515 extern int yydebug;
577 516 extern int yy_flex_debug;
578 debugfile = stderr; 517
579 /* setlinebuf(debugfile); */ 518 yydebug = (flag_debug > 1);
580 } 519 yy_flex_debug = (flag_debug > 2);
581 520
582 yyparse(); 521 debugfile = stderr;
583 522 /* setlinebuf(debugfile); */
584 if (flag_debug) 523 }
585 { 524
586 fprintf(debugfile, "Hash table occupancy %d/%d = %g\n", 525 yyparse();
587 nsyms, HASH_BUCKETS, (double)nsyms / (double)HASH_BUCKETS); 526
588 } 527 if (flag_debug) {
589 528 fprintf(debugfile, "Hash table occupancy %d/%d = %g\n",
590 return errors != 0; 529 nsyms, HASH_BUCKETS,
530 (double)nsyms / (double)HASH_BUCKETS);
531 }
532
533 return errors != 0;
591} 534}
diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h
index f09af47ab281..ab6f34f38735 100644
--- a/scripts/genksyms/genksyms.h
+++ b/scripts/genksyms/genksyms.h
@@ -20,74 +20,51 @@
20 along with this program; if not, write to the Free Software Foundation, 20 along with this program; if not, write to the Free Software Foundation,
21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
22 22
23
24#ifndef MODUTILS_GENKSYMS_H 23#ifndef MODUTILS_GENKSYMS_H
25#define MODUTILS_GENKSYMS_H 1 24#define MODUTILS_GENKSYMS_H 1
26 25
27#include <stdio.h> 26#include <stdio.h>
28 27
29 28enum symbol_type {
30enum symbol_type 29 SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
31{
32 SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
33}; 30};
34 31
35struct string_list 32struct string_list {
36{ 33 struct string_list *next;
37 struct string_list *next; 34 enum symbol_type tag;
38 enum symbol_type tag; 35 char *string;
39 char *string;
40}; 36};
41 37
42struct symbol 38struct symbol {
43{ 39 struct symbol *hash_next;
44 struct symbol *hash_next; 40 const char *name;
45 const char *name; 41 enum symbol_type type;
46 enum symbol_type type; 42 struct string_list *defn;
47 struct string_list *defn; 43 struct symbol *expansion_trail;
48 struct symbol *expansion_trail; 44 int is_extern;
49 int is_extern;
50}; 45};
51 46
52typedef struct string_list **yystype; 47typedef struct string_list **yystype;
53#define YYSTYPE yystype 48#define YYSTYPE yystype
54 49
55extern FILE *outfile, *debugfile;
56
57extern int cur_line; 50extern int cur_line;
58extern char *cur_filename, *output_directory; 51extern char *cur_filename;
59
60extern int flag_debug, flag_dump_defs, flag_warnings;
61extern int checksum_version, kernel_version;
62
63extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents;
64extern struct string_list *current_list, *next_list;
65
66 52
67struct symbol *find_symbol(const char *name, enum symbol_type ns); 53struct symbol *find_symbol(const char *name, enum symbol_type ns);
68struct symbol *add_symbol(const char *name, enum symbol_type type, 54struct symbol *add_symbol(const char *name, enum symbol_type type,
69 struct string_list *defn, int is_extern); 55 struct string_list *defn, int is_extern);
70void export_symbol(const char *); 56void export_symbol(const char *);
71 57
72struct string_list *reset_list(void);
73void free_list(struct string_list *s, struct string_list *e);
74void free_node(struct string_list *list); 58void free_node(struct string_list *list);
59void free_list(struct string_list *s, struct string_list *e);
75struct string_list *copy_node(struct string_list *); 60struct string_list *copy_node(struct string_list *);
76struct string_list *copy_list(struct string_list *s, struct string_list *e);
77int equal_list(struct string_list *a, struct string_list *b);
78void print_list(FILE *, struct string_list *list);
79 61
80int yylex(void); 62int yylex(void);
81int yyparse(void); 63int yyparse(void);
82 64
83void error_with_pos(const char *, ...); 65void error_with_pos(const char *, ...);
84 66
85#define version(a,b,c) ((a << 16) | (b << 8) | (c))
86
87/*----------------------------------------------------------------------*/ 67/*----------------------------------------------------------------------*/
88
89#define MODUTILS_VERSION "<in-kernel>"
90
91#define xmalloc(size) ({ void *__ptr = malloc(size); \ 68#define xmalloc(size) ({ void *__ptr = malloc(size); \
92 if(!__ptr && size != 0) { \ 69 if(!__ptr && size != 0) { \
93 fprintf(stderr, "out of memory\n"); \ 70 fprintf(stderr, "out of memory\n"); \
@@ -101,4 +78,4 @@ void error_with_pos(const char *, ...);
101 } \ 78 } \
102 __str; }) 79 __str; })
103 80
104#endif /* genksyms.h */ 81#endif /* genksyms.h */
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 5760e057ecba..e6499db4c8cc 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -2,7 +2,7 @@
2# Kernel configuration targets 2# Kernel configuration targets
3# These targets are used from top-level makefile 3# These targets are used from top-level makefile
4 4
5.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config 5PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config
6 6
7xconfig: $(obj)/qconf 7xconfig: $(obj)/qconf
8 $< arch/$(ARCH)/Kconfig 8 $< arch/$(ARCH)/Kconfig
@@ -42,7 +42,7 @@ update-po-config: $(obj)/kxgettext
42 $(Q)rm -f arch/um/Kconfig_arch 42 $(Q)rm -f arch/um/Kconfig_arch
43 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot 43 $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot
44 44
45.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig 45PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig
46 46
47randconfig: $(obj)/conf 47randconfig: $(obj)/conf
48 $< -r arch/$(ARCH)/Kconfig 48 $< -r arch/$(ARCH)/Kconfig
@@ -78,7 +78,7 @@ help:
78 @echo ' defconfig - New config with default answer to all options' 78 @echo ' defconfig - New config with default answer to all options'
79 @echo ' allmodconfig - New config selecting modules when possible' 79 @echo ' allmodconfig - New config selecting modules when possible'
80 @echo ' allyesconfig - New config where all options are accepted with yes' 80 @echo ' allyesconfig - New config where all options are accepted with yes'
81 @echo ' allnoconfig - New minimal config' 81 @echo ' allnoconfig - New config where all options are answered with no'
82 82
83# =========================================================================== 83# ===========================================================================
84# Shared Makefile for the various kconfig executables: 84# Shared Makefile for the various kconfig executables:
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index b0cbbe2e41bb..1b8882ddbc74 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -374,6 +374,7 @@ int conf_write(const char *name)
374 out_h = fopen(".tmpconfig.h", "w"); 374 out_h = fopen(".tmpconfig.h", "w");
375 if (!out_h) 375 if (!out_h)
376 return 1; 376 return 1;
377 file_write_dep(NULL);
377 } 378 }
378 sym = sym_lookup("KERNELVERSION", 0); 379 sym = sym_lookup("KERNELVERSION", 0);
379 sym_calc_value(sym); 380 sym_calc_value(sym);
@@ -512,7 +513,6 @@ int conf_write(const char *name)
512 if (out_h) { 513 if (out_h) {
513 fclose(out_h); 514 fclose(out_h);
514 rename(".tmpconfig.h", "include/linux/autoconf.h"); 515 rename(".tmpconfig.h", "include/linux/autoconf.h");
515 file_write_dep(NULL);
516 } 516 }
517 if (!name || basename != conf_def_filename) { 517 if (!name || basename != conf_def_filename) {
518 if (!name) 518 if (!name)
diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile
index bbf4887cff74..a8b026326247 100644
--- a/scripts/kconfig/lxdialog/Makefile
+++ b/scripts/kconfig/lxdialog/Makefile
@@ -7,10 +7,10 @@ check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh
7# we really need to do so. (Do not call gcc as part of make mrproper) 7# we really need to do so. (Do not call gcc as part of make mrproper)
8HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) 8HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags)
9HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) 9HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
10
11HOST_EXTRACFLAGS += -DLOCALE
12 10
13.PHONY: dochecklxdialog 11HOST_EXTRACFLAGS += -DLOCALE
12
13PHONY += dochecklxdialog
14$(obj)/dochecklxdialog: 14$(obj)/dochecklxdialog:
15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) 15 $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
16 16
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index c4d621b30d0d..a22cbedd3b3e 100644
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -21,11 +21,13 @@ KERNELOUTPUT := $2
21 21
22MAKEFLAGS += --no-print-directory 22MAKEFLAGS += --no-print-directory
23 23
24.PHONY: all \$(MAKECMDGOALS)
25
24all: 26all:
25 \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) 27 \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT)
26 28
27%:: 29Makefile:;
28 \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
29 30
31\$(filter-out all Makefile,\$(MAKECMDGOALS)) %/:
32 \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@
30EOF 33EOF
31
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index c164b230ad6f..84e21201f3c0 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -34,7 +34,7 @@ typedef uint16_t __u16;
34typedef unsigned char __u8; 34typedef unsigned char __u8;
35 35
36/* Big exception to the "don't include kernel headers into userspace, which 36/* Big exception to the "don't include kernel headers into userspace, which
37 * even potentially has different endianness and word sizes, since 37 * even potentially has different endianness and word sizes, since
38 * we handle those differences explicitly below */ 38 * we handle those differences explicitly below */
39#include "../../include/linux/mod_devicetable.h" 39#include "../../include/linux/mod_devicetable.h"
40#include "../../include/linux/input.h" 40#include "../../include/linux/input.h"
@@ -153,8 +153,8 @@ static void do_usb_table(void *symval, unsigned long size,
153 const unsigned long id_size = sizeof(struct usb_device_id); 153 const unsigned long id_size = sizeof(struct usb_device_id);
154 154
155 if (size % id_size || size < id_size) { 155 if (size % id_size || size < id_size) {
156 fprintf(stderr, "*** Warning: %s ids %lu bad size " 156 warn("%s ids %lu bad size "
157 "(each on %lu)\n", mod->name, size, id_size); 157 "(each on %lu)\n", mod->name, size, id_size);
158 } 158 }
159 /* Leave last one: it's the terminator. */ 159 /* Leave last one: it's the terminator. */
160 size -= id_size; 160 size -= id_size;
@@ -217,9 +217,8 @@ static int do_pci_entry(const char *filename,
217 if ((baseclass_mask != 0 && baseclass_mask != 0xFF) 217 if ((baseclass_mask != 0 && baseclass_mask != 0xFF)
218 || (subclass_mask != 0 && subclass_mask != 0xFF) 218 || (subclass_mask != 0 && subclass_mask != 0xFF)
219 || (interface_mask != 0 && interface_mask != 0xFF)) { 219 || (interface_mask != 0 && interface_mask != 0xFF)) {
220 fprintf(stderr, 220 warn("Can't handle masks in %s:%04X\n",
221 "*** Warning: Can't handle masks in %s:%04X\n", 221 filename, id->class_mask);
222 filename, id->class_mask);
223 return 0; 222 return 0;
224 } 223 }
225 224
@@ -229,7 +228,7 @@ static int do_pci_entry(const char *filename,
229 return 1; 228 return 1;
230} 229}
231 230
232/* looks like: "ccw:tNmNdtNdmN" */ 231/* looks like: "ccw:tNmNdtNdmN" */
233static int do_ccw_entry(const char *filename, 232static int do_ccw_entry(const char *filename,
234 struct ccw_device_id *id, char *alias) 233 struct ccw_device_id *id, char *alias)
235{ 234{
@@ -445,8 +444,8 @@ static void do_table(void *symval, unsigned long size,
445 int (*do_entry)(const char *, void *entry, char *alias) = function; 444 int (*do_entry)(const char *, void *entry, char *alias) = function;
446 445
447 if (size % id_size || size < id_size) { 446 if (size % id_size || size < id_size) {
448 fprintf(stderr, "*** Warning: %s ids %lu bad size " 447 warn("%s ids %lu bad size "
449 "(each on %lu)\n", mod->name, size, id_size); 448 "(each on %lu)\n", mod->name, size, id_size);
450 } 449 }
451 /* Leave last one: it's the terminator. */ 450 /* Leave last one: it's the terminator. */
452 size -= id_size; 451 size -= id_size;
diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c
index de2aabf89fb3..3c92c83733f4 100644
--- a/scripts/mod/mk_elfconfig.c
+++ b/scripts/mod/mk_elfconfig.c
@@ -6,7 +6,7 @@
6int 6int
7main(int argc, char **argv) 7main(int argc, char **argv)
8{ 8{
9 unsigned char ei[EI_NIDENT]; 9 unsigned char ei[EI_NIDENT];
10 union { short s; char c[2]; } endian_test; 10 union { short s; char c[2]; } endian_test;
11 11
12 if (argc != 2) { 12 if (argc != 2) {
@@ -57,7 +57,7 @@ main(int argc, char **argv)
57 57
58 if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0)) 58 if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0))
59 printf("#define MODULE_SYMBOL_PREFIX \"_\"\n"); 59 printf("#define MODULE_SYMBOL_PREFIX \"_\"\n");
60 else 60 else
61 printf("#define MODULE_SYMBOL_PREFIX \"\"\n"); 61 printf("#define MODULE_SYMBOL_PREFIX \"\"\n");
62 62
63 return 0; 63 return 0;
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index b8b2a560b26b..0b92ddff26fd 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2,7 +2,7 @@
2 * 2 *
3 * Copyright 2003 Kai Germaschewski 3 * Copyright 2003 Kai Germaschewski
4 * Copyright 2002-2004 Rusty Russell, IBM Corporation 4 * Copyright 2002-2004 Rusty Russell, IBM Corporation
5 * 5 * Copyright 2006 Sam Ravnborg
6 * Based in part on module-init-tools/depmod.c,file2alias 6 * Based in part on module-init-tools/depmod.c,file2alias
7 * 7 *
8 * This software may be used and distributed according to the terms 8 * This software may be used and distributed according to the terms
@@ -20,9 +20,10 @@ int modversions = 0;
20int have_vmlinux = 0; 20int have_vmlinux = 0;
21/* Is CONFIG_MODULE_SRCVERSION_ALL set? */ 21/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
22static int all_versions = 0; 22static int all_versions = 0;
23/* If we are modposting external module set to 1 */
24static int external_module = 0;
23 25
24void 26void fatal(const char *fmt, ...)
25fatal(const char *fmt, ...)
26{ 27{
27 va_list arglist; 28 va_list arglist;
28 29
@@ -35,8 +36,7 @@ fatal(const char *fmt, ...)
35 exit(1); 36 exit(1);
36} 37}
37 38
38void 39void warn(const char *fmt, ...)
39warn(const char *fmt, ...)
40{ 40{
41 va_list arglist; 41 va_list arglist;
42 42
@@ -47,6 +47,18 @@ warn(const char *fmt, ...)
47 va_end(arglist); 47 va_end(arglist);
48} 48}
49 49
50static int is_vmlinux(const char *modname)
51{
52 const char *myname;
53
54 if ((myname = strrchr(modname, '/')))
55 myname++;
56 else
57 myname = modname;
58
59 return strcmp(myname, "vmlinux") == 0;
60}
61
50void *do_nofail(void *ptr, const char *expr) 62void *do_nofail(void *ptr, const char *expr)
51{ 63{
52 if (!ptr) { 64 if (!ptr) {
@@ -59,8 +71,7 @@ void *do_nofail(void *ptr, const char *expr)
59 71
60static struct module *modules; 72static struct module *modules;
61 73
62struct module * 74static struct module *find_module(char *modname)
63find_module(char *modname)
64{ 75{
65 struct module *mod; 76 struct module *mod;
66 77
@@ -70,12 +81,11 @@ find_module(char *modname)
70 return mod; 81 return mod;
71} 82}
72 83
73struct module * 84static struct module *new_module(char *modname)
74new_module(char *modname)
75{ 85{
76 struct module *mod; 86 struct module *mod;
77 char *p, *s; 87 char *p, *s;
78 88
79 mod = NOFAIL(malloc(sizeof(*mod))); 89 mod = NOFAIL(malloc(sizeof(*mod)));
80 memset(mod, 0, sizeof(*mod)); 90 memset(mod, 0, sizeof(*mod));
81 p = NOFAIL(strdup(modname)); 91 p = NOFAIL(strdup(modname));
@@ -104,6 +114,10 @@ struct symbol {
104 unsigned int crc; 114 unsigned int crc;
105 int crc_valid; 115 int crc_valid;
106 unsigned int weak:1; 116 unsigned int weak:1;
117 unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */
118 unsigned int kernel:1; /* 1 if symbol is from kernel
119 * (only for external modules) **/
120 unsigned int preloaded:1; /* 1 if symbol from Module.symvers */
107 char name[0]; 121 char name[0];
108}; 122};
109 123
@@ -122,11 +136,12 @@ static inline unsigned int tdb_hash(const char *name)
122 return (1103515243 * value + 12345); 136 return (1103515243 * value + 12345);
123} 137}
124 138
125/* Allocate a new symbols for use in the hash of exported symbols or 139/**
126 * the list of unresolved symbols per module */ 140 * Allocate a new symbols for use in the hash of exported symbols or
127 141 * the list of unresolved symbols per module
128struct symbol * 142 **/
129alloc_symbol(const char *name, unsigned int weak, struct symbol *next) 143static struct symbol *alloc_symbol(const char *name, unsigned int weak,
144 struct symbol *next)
130{ 145{
131 struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1)); 146 struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1));
132 147
@@ -138,9 +153,7 @@ alloc_symbol(const char *name, unsigned int weak, struct symbol *next)
138} 153}
139 154
140/* For the hash of exported symbols */ 155/* For the hash of exported symbols */
141 156static struct symbol *new_symbol(const char *name, struct module *module)
142void
143new_symbol(const char *name, struct module *module, unsigned int *crc)
144{ 157{
145 unsigned int hash; 158 unsigned int hash;
146 struct symbol *new; 159 struct symbol *new;
@@ -148,14 +161,10 @@ new_symbol(const char *name, struct module *module, unsigned int *crc)
148 hash = tdb_hash(name) % SYMBOL_HASH_SIZE; 161 hash = tdb_hash(name) % SYMBOL_HASH_SIZE;
149 new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]); 162 new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]);
150 new->module = module; 163 new->module = module;
151 if (crc) { 164 return new;
152 new->crc = *crc;
153 new->crc_valid = 1;
154 }
155} 165}
156 166
157struct symbol * 167static struct symbol *find_symbol(const char *name)
158find_symbol(const char *name)
159{ 168{
160 struct symbol *s; 169 struct symbol *s;
161 170
@@ -170,25 +179,42 @@ find_symbol(const char *name)
170 return NULL; 179 return NULL;
171} 180}
172 181
173/* Add an exported symbol - it may have already been added without a 182/**
174 * CRC, in this case just update the CRC */ 183 * Add an exported symbol - it may have already been added without a
175void 184 * CRC, in this case just update the CRC
176add_exported_symbol(const char *name, struct module *module, unsigned int *crc) 185 **/
186static struct symbol *sym_add_exported(const char *name, struct module *mod)
177{ 187{
178 struct symbol *s = find_symbol(name); 188 struct symbol *s = find_symbol(name);
179 189
180 if (!s) { 190 if (!s) {
181 new_symbol(name, module, crc); 191 s = new_symbol(name, mod);
182 return; 192 } else {
183 } 193 if (!s->preloaded) {
184 if (crc) { 194 warn("%s: '%s' exported twice. Previous export "
185 s->crc = *crc; 195 "was in %s%s\n", mod->name, name,
186 s->crc_valid = 1; 196 s->module->name,
197 is_vmlinux(s->module->name) ?"":".ko");
198 }
187 } 199 }
200 s->preloaded = 0;
201 s->vmlinux = is_vmlinux(mod->name);
202 s->kernel = 0;
203 return s;
204}
205
206static void sym_update_crc(const char *name, struct module *mod,
207 unsigned int crc)
208{
209 struct symbol *s = find_symbol(name);
210
211 if (!s)
212 s = new_symbol(name, mod);
213 s->crc = crc;
214 s->crc_valid = 1;
188} 215}
189 216
190void * 217void *grab_file(const char *filename, unsigned long *size)
191grab_file(const char *filename, unsigned long *size)
192{ 218{
193 struct stat st; 219 struct stat st;
194 void *map; 220 void *map;
@@ -207,13 +233,12 @@ grab_file(const char *filename, unsigned long *size)
207 return map; 233 return map;
208} 234}
209 235
210/* 236/**
211 Return a copy of the next line in a mmap'ed file. 237 * Return a copy of the next line in a mmap'ed file.
212 spaces in the beginning of the line is trimmed away. 238 * spaces in the beginning of the line is trimmed away.
213 Return a pointer to a static buffer. 239 * Return a pointer to a static buffer.
214*/ 240 **/
215char* 241char* get_next_line(unsigned long *pos, void *file, unsigned long size)
216get_next_line(unsigned long *pos, void *file, unsigned long size)
217{ 242{
218 static char line[4096]; 243 static char line[4096];
219 int skip = 1; 244 int skip = 1;
@@ -243,14 +268,12 @@ get_next_line(unsigned long *pos, void *file, unsigned long size)
243 return NULL; 268 return NULL;
244} 269}
245 270
246void 271void release_file(void *file, unsigned long size)
247release_file(void *file, unsigned long size)
248{ 272{
249 munmap(file, size); 273 munmap(file, size);
250} 274}
251 275
252void 276static void parse_elf(struct elf_info *info, const char *filename)
253parse_elf(struct elf_info *info, const char *filename)
254{ 277{
255 unsigned int i; 278 unsigned int i;
256 Elf_Ehdr *hdr = info->hdr; 279 Elf_Ehdr *hdr = info->hdr;
@@ -297,14 +320,13 @@ parse_elf(struct elf_info *info, const char *filename)
297 continue; 320 continue;
298 321
299 info->symtab_start = (void *)hdr + sechdrs[i].sh_offset; 322 info->symtab_start = (void *)hdr + sechdrs[i].sh_offset;
300 info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset 323 info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset
301 + sechdrs[i].sh_size; 324 + sechdrs[i].sh_size;
302 info->strtab = (void *)hdr + 325 info->strtab = (void *)hdr +
303 sechdrs[sechdrs[i].sh_link].sh_offset; 326 sechdrs[sechdrs[i].sh_link].sh_offset;
304 } 327 }
305 if (!info->symtab_start) { 328 if (!info->symtab_start) {
306 fprintf(stderr, "modpost: %s no symtab?\n", filename); 329 fatal("%s has no symtab?\n", filename);
307 abort();
308 } 330 }
309 /* Fix endianness in symbols */ 331 /* Fix endianness in symbols */
310 for (sym = info->symtab_start; sym < info->symtab_stop; sym++) { 332 for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
@@ -316,36 +338,31 @@ parse_elf(struct elf_info *info, const char *filename)
316 return; 338 return;
317 339
318 truncated: 340 truncated:
319 fprintf(stderr, "modpost: %s is truncated.\n", filename); 341 fatal("%s is truncated.\n", filename);
320 abort();
321} 342}
322 343
323void 344static void parse_elf_finish(struct elf_info *info)
324parse_elf_finish(struct elf_info *info)
325{ 345{
326 release_file(info->hdr, info->size); 346 release_file(info->hdr, info->size);
327} 347}
328 348
329#define CRC_PFX "__crc_" 349#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_"
330#define KSYMTAB_PFX "__ksymtab_" 350#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_"
331 351
332void 352static void handle_modversions(struct module *mod, struct elf_info *info,
333handle_modversions(struct module *mod, struct elf_info *info, 353 Elf_Sym *sym, const char *symname)
334 Elf_Sym *sym, const char *symname)
335{ 354{
336 unsigned int crc; 355 unsigned int crc;
337 356
338 switch (sym->st_shndx) { 357 switch (sym->st_shndx) {
339 case SHN_COMMON: 358 case SHN_COMMON:
340 fprintf(stderr, "*** Warning: \"%s\" [%s] is COMMON symbol\n", 359 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
341 symname, mod->name);
342 break; 360 break;
343 case SHN_ABS: 361 case SHN_ABS:
344 /* CRC'd symbol */ 362 /* CRC'd symbol */
345 if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { 363 if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) {
346 crc = (unsigned int) sym->st_value; 364 crc = (unsigned int) sym->st_value;
347 add_exported_symbol(symname + strlen(CRC_PFX), 365 sym_update_crc(symname + strlen(CRC_PFX), mod, crc);
348 mod, &crc);
349 } 366 }
350 break; 367 break;
351 case SHN_UNDEF: 368 case SHN_UNDEF:
@@ -370,15 +387,15 @@ handle_modversions(struct module *mod, struct elf_info *info,
370 /* Ignore register directives. */ 387 /* Ignore register directives. */
371 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER) 388 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER)
372 break; 389 break;
373 if (symname[0] == '.') { 390 if (symname[0] == '.') {
374 char *munged = strdup(symname); 391 char *munged = strdup(symname);
375 munged[0] = '_'; 392 munged[0] = '_';
376 munged[1] = toupper(munged[1]); 393 munged[1] = toupper(munged[1]);
377 symname = munged; 394 symname = munged;
378 } 395 }
379 } 396 }
380#endif 397#endif
381 398
382 if (memcmp(symname, MODULE_SYMBOL_PREFIX, 399 if (memcmp(symname, MODULE_SYMBOL_PREFIX,
383 strlen(MODULE_SYMBOL_PREFIX)) == 0) 400 strlen(MODULE_SYMBOL_PREFIX)) == 0)
384 mod->unres = alloc_symbol(symname + 401 mod->unres = alloc_symbol(symname +
@@ -389,8 +406,7 @@ handle_modversions(struct module *mod, struct elf_info *info,
389 default: 406 default:
390 /* All exported symbols */ 407 /* All exported symbols */
391 if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { 408 if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) {
392 add_exported_symbol(symname + strlen(KSYMTAB_PFX), 409 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod);
393 mod, NULL);
394 } 410 }
395 if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0) 411 if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0)
396 mod->has_init = 1; 412 mod->has_init = 1;
@@ -400,20 +416,9 @@ handle_modversions(struct module *mod, struct elf_info *info,
400 } 416 }
401} 417}
402 418
403int 419/**
404is_vmlinux(const char *modname) 420 * Parse tag=value strings from .modinfo section
405{ 421 **/
406 const char *myname;
407
408 if ((myname = strrchr(modname, '/')))
409 myname++;
410 else
411 myname = modname;
412
413 return strcmp(myname, "vmlinux") == 0;
414}
415
416/* Parse tag=value strings from .modinfo section */
417static char *next_string(char *string, unsigned long *secsize) 422static char *next_string(char *string, unsigned long *secsize)
418{ 423{
419 /* Skip non-zero chars */ 424 /* Skip non-zero chars */
@@ -446,8 +451,418 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
446 return NULL; 451 return NULL;
447} 452}
448 453
449void 454/**
450read_symbols(char *modname) 455 * Test if string s ends in string sub
456 * return 0 if match
457 **/
458static int strrcmp(const char *s, const char *sub)
459{
460 int slen, sublen;
461
462 if (!s || !sub)
463 return 1;
464
465 slen = strlen(s);
466 sublen = strlen(sub);
467
468 if ((slen == 0) || (sublen == 0))
469 return 1;
470
471 if (sublen > slen)
472 return 1;
473
474 return memcmp(s + slen - sublen, sub, sublen);
475}
476
477/**
478 * Whitelist to allow certain references to pass with no warning.
479 * Pattern 1:
480 * If a module parameter is declared __initdata and permissions=0
481 * then this is legal despite the warning generated.
482 * We cannot see value of permissions here, so just ignore
483 * this pattern.
484 * The pattern is identified by:
485 * tosec = .init.data
486 * fromsec = .data*
487 * atsym =__param*
488 *
489 * Pattern 2:
490 * Many drivers utilise a *_driver container with references to
491 * add, remove, probe functions etc.
492 * These functions may often be marked __init and we do not want to
493 * warn here.
494 * the pattern is identified by:
495 * tosec = .init.text | .exit.text
496 * fromsec = .data
497 * atsym = *_driver, *_ops, *_probe, *probe_one
498 **/
499static int secref_whitelist(const char *tosec, const char *fromsec,
500 const char *atsym)
501{
502 int f1 = 1, f2 = 1;
503 const char **s;
504 const char *pat2sym[] = {
505 "_driver",
506 "_ops",
507 "_probe",
508 "_probe_one",
509 NULL
510 };
511
512 /* Check for pattern 1 */
513 if (strcmp(tosec, ".init.data") != 0)
514 f1 = 0;
515 if (strncmp(fromsec, ".data", strlen(".data")) != 0)
516 f1 = 0;
517 if (strncmp(atsym, "__param", strlen("__param")) != 0)
518 f1 = 0;
519
520 if (f1)
521 return f1;
522
523 /* Check for pattern 2 */
524 if ((strcmp(tosec, ".init.text") != 0) &&
525 (strcmp(tosec, ".exit.text") != 0))
526 f2 = 0;
527 if (strcmp(fromsec, ".data") != 0)
528 f2 = 0;
529
530 for (s = pat2sym; *s; s++)
531 if (strrcmp(atsym, *s) == 0)
532 f1 = 1;
533
534 return f1 && f2;
535}
536
537/**
538 * Find symbol based on relocation record info.
539 * In some cases the symbol supplied is a valid symbol so
540 * return refsym. If st_name != 0 we assume this is a valid symbol.
541 * In other cases the symbol needs to be looked up in the symbol table
542 * based on section and address.
543 * **/
544static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
545 Elf_Sym *relsym)
546{
547 Elf_Sym *sym;
548
549 if (relsym->st_name != 0)
550 return relsym;
551 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
552 if (sym->st_shndx != relsym->st_shndx)
553 continue;
554 if (sym->st_value == addr)
555 return sym;
556 }
557 return NULL;
558}
559
560/*
561 * Find symbols before or equal addr and after addr - in the section sec.
562 * If we find two symbols with equal offset prefer one with a valid name.
563 * The ELF format may have a better way to detect what type of symbol
564 * it is, but this works for now.
565 **/
566static void find_symbols_between(struct elf_info *elf, Elf_Addr addr,
567 const char *sec,
568 Elf_Sym **before, Elf_Sym **after)
569{
570 Elf_Sym *sym;
571 Elf_Ehdr *hdr = elf->hdr;
572 Elf_Addr beforediff = ~0;
573 Elf_Addr afterdiff = ~0;
574 const char *secstrings = (void *)hdr +
575 elf->sechdrs[hdr->e_shstrndx].sh_offset;
576
577 *before = NULL;
578 *after = NULL;
579
580 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
581 const char *symsec;
582
583 if (sym->st_shndx >= SHN_LORESERVE)
584 continue;
585 symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name;
586 if (strcmp(symsec, sec) != 0)
587 continue;
588 if (sym->st_value <= addr) {
589 if ((addr - sym->st_value) < beforediff) {
590 beforediff = addr - sym->st_value;
591 *before = sym;
592 }
593 else if ((addr - sym->st_value) == beforediff) {
594 /* equal offset, valid name? */
595 const char *name = elf->strtab + sym->st_name;
596 if (name && strlen(name))
597 *before = sym;
598 }
599 }
600 else
601 {
602 if ((sym->st_value - addr) < afterdiff) {
603 afterdiff = sym->st_value - addr;
604 *after = sym;
605 }
606 else if ((sym->st_value - addr) == afterdiff) {
607 /* equal offset, valid name? */
608 const char *name = elf->strtab + sym->st_name;
609 if (name && strlen(name))
610 *after = sym;
611 }
612 }
613 }
614}
615
616/**
617 * Print a warning about a section mismatch.
618 * Try to find symbols near it so user can find it.
619 * Check whitelist before warning - it may be a false positive.
620 **/
621static void warn_sec_mismatch(const char *modname, const char *fromsec,
622 struct elf_info *elf, Elf_Sym *sym, Elf_Rela r)
623{
624 const char *refsymname = "";
625 Elf_Sym *before, *after;
626 Elf_Sym *refsym;
627 Elf_Ehdr *hdr = elf->hdr;
628 Elf_Shdr *sechdrs = elf->sechdrs;
629 const char *secstrings = (void *)hdr +
630 sechdrs[hdr->e_shstrndx].sh_offset;
631 const char *secname = secstrings + sechdrs[sym->st_shndx].sh_name;
632
633 find_symbols_between(elf, r.r_offset, fromsec, &before, &after);
634
635 refsym = find_elf_symbol(elf, r.r_addend, sym);
636 if (refsym && strlen(elf->strtab + refsym->st_name))
637 refsymname = elf->strtab + refsym->st_name;
638
639 /* check whitelist - we may ignore it */
640 if (before &&
641 secref_whitelist(secname, fromsec, elf->strtab + before->st_name))
642 return;
643
644 if (before && after) {
645 warn("%s - Section mismatch: reference to %s:%s from %s "
646 "between '%s' (at offset 0x%llx) and '%s'\n",
647 modname, secname, refsymname, fromsec,
648 elf->strtab + before->st_name,
649 (long long)r.r_offset,
650 elf->strtab + after->st_name);
651 } else if (before) {
652 warn("%s - Section mismatch: reference to %s:%s from %s "
653 "after '%s' (at offset 0x%llx)\n",
654 modname, secname, refsymname, fromsec,
655 elf->strtab + before->st_name,
656 (long long)r.r_offset);
657 } else if (after) {
658 warn("%s - Section mismatch: reference to %s:%s from %s "
659 "before '%s' (at offset -0x%llx)\n",
660 modname, secname, refsymname, fromsec,
661 elf->strtab + before->st_name,
662 (long long)r.r_offset);
663 } else {
664 warn("%s - Section mismatch: reference to %s:%s from %s "
665 "(offset 0x%llx)\n",
666 modname, secname, fromsec, refsymname,
667 (long long)r.r_offset);
668 }
669}
670
671/**
672 * A module includes a number of sections that are discarded
673 * either when loaded or when used as built-in.
674 * For loaded modules all functions marked __init and all data
675 * marked __initdata will be discarded when the module has been intialized.
676 * Likewise for modules used built-in the sections marked __exit
677 * are discarded because __exit marked function are supposed to be called
678 * only when a moduel is unloaded which never happes for built-in modules.
679 * The check_sec_ref() function traverses all relocation records
680 * to find all references to a section that reference a section that will
681 * be discarded and warns about it.
682 **/
683static void check_sec_ref(struct module *mod, const char *modname,
684 struct elf_info *elf,
685 int section(const char*),
686 int section_ref_ok(const char *))
687{
688 int i;
689 Elf_Sym *sym;
690 Elf_Ehdr *hdr = elf->hdr;
691 Elf_Shdr *sechdrs = elf->sechdrs;
692 const char *secstrings = (void *)hdr +
693 sechdrs[hdr->e_shstrndx].sh_offset;
694
695 /* Walk through all sections */
696 for (i = 0; i < hdr->e_shnum; i++) {
697 Elf_Rela *rela;
698 Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
699 Elf_Rela *stop = (void*)start + sechdrs[i].sh_size;
700 const char *name = secstrings + sechdrs[i].sh_name +
701 strlen(".rela");
702 /* We want to process only relocation sections and not .init */
703 if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA))
704 continue;
705
706 for (rela = start; rela < stop; rela++) {
707 Elf_Rela r;
708 const char *secname;
709 r.r_offset = TO_NATIVE(rela->r_offset);
710 r.r_info = TO_NATIVE(rela->r_info);
711 r.r_addend = TO_NATIVE(rela->r_addend);
712 sym = elf->symtab_start + ELF_R_SYM(r.r_info);
713 /* Skip special sections */
714 if (sym->st_shndx >= SHN_LORESERVE)
715 continue;
716
717 secname = secstrings + sechdrs[sym->st_shndx].sh_name;
718 if (section(secname))
719 warn_sec_mismatch(modname, name, elf, sym, r);
720 }
721 }
722}
723
724/**
725 * Functions used only during module init is marked __init and is stored in
726 * a .init.text section. Likewise data is marked __initdata and stored in
727 * a .init.data section.
728 * If this section is one of these sections return 1
729 * See include/linux/init.h for the details
730 **/
731static int init_section(const char *name)
732{
733 if (strcmp(name, ".init") == 0)
734 return 1;
735 if (strncmp(name, ".init.", strlen(".init.")) == 0)
736 return 1;
737 return 0;
738}
739
740/**
741 * Identify sections from which references to a .init section is OK.
742 *
743 * Unfortunately references to read only data that referenced .init
744 * sections had to be excluded. Almost all of these are false
745 * positives, they are created by gcc. The downside of excluding rodata
746 * is that there really are some user references from rodata to
747 * init code, e.g. drivers/video/vgacon.c:
748 *
749 * const struct consw vga_con = {
750 * con_startup: vgacon_startup,
751 *
752 * where vgacon_startup is __init. If you want to wade through the false
753 * positives, take out the check for rodata.
754 **/
755static int init_section_ref_ok(const char *name)
756{
757 const char **s;
758 /* Absolute section names */
759 const char *namelist1[] = {
760 ".init",
761 ".opd", /* see comment [OPD] at exit_section_ref_ok() */
762 ".toc1", /* used by ppc64 */
763 ".stab",
764 ".rodata",
765 ".text.lock",
766 "__bug_table", /* used by powerpc for BUG() */
767 ".pci_fixup_header",
768 ".pci_fixup_final",
769 ".pdr",
770 "__param",
771 NULL
772 };
773 /* Start of section names */
774 const char *namelist2[] = {
775 ".init.",
776 ".altinstructions",
777 ".eh_frame",
778 ".debug",
779 NULL
780 };
781 /* part of section name */
782 const char *namelist3 [] = {
783 ".unwind", /* sample: IA_64.unwind.init.text */
784 NULL
785 };
786
787 for (s = namelist1; *s; s++)
788 if (strcmp(*s, name) == 0)
789 return 1;
790 for (s = namelist2; *s; s++)
791 if (strncmp(*s, name, strlen(*s)) == 0)
792 return 1;
793 for (s = namelist3; *s; s++)
794 if (strstr(name, *s) != NULL)
795 return 1;
796 return 0;
797}
798
799/*
800 * Functions used only during module exit is marked __exit and is stored in
801 * a .exit.text section. Likewise data is marked __exitdata and stored in
802 * a .exit.data section.
803 * If this section is one of these sections return 1
804 * See include/linux/init.h for the details
805 **/
806static int exit_section(const char *name)
807{
808 if (strcmp(name, ".exit.text") == 0)
809 return 1;
810 if (strcmp(name, ".exit.data") == 0)
811 return 1;
812 return 0;
813
814}
815
816/*
817 * Identify sections from which references to a .exit section is OK.
818 *
819 * [OPD] Keith Ownes <kaos@sgi.com> commented:
820 * For our future {in}sanity, add a comment that this is the ppc .opd
821 * section, not the ia64 .opd section.
822 * ia64 .opd should not point to discarded sections.
823 **/
824static int exit_section_ref_ok(const char *name)
825{
826 const char **s;
827 /* Absolute section names */
828 const char *namelist1[] = {
829 ".exit.text",
830 ".exit.data",
831 ".init.text",
832 ".opd", /* See comment [OPD] */
833 ".toc1", /* used by ppc64 */
834 ".altinstructions",
835 ".pdr",
836 "__bug_table", /* used by powerpc for BUG() */
837 ".exitcall.exit",
838 ".eh_frame",
839 ".stab",
840 NULL
841 };
842 /* Start of section names */
843 const char *namelist2[] = {
844 ".debug",
845 NULL
846 };
847 /* part of section name */
848 const char *namelist3 [] = {
849 ".unwind", /* Sample: IA_64.unwind.exit.text */
850 NULL
851 };
852
853 for (s = namelist1; *s; s++)
854 if (strcmp(*s, name) == 0)
855 return 1;
856 for (s = namelist2; *s; s++)
857 if (strncmp(*s, name, strlen(*s)) == 0)
858 return 1;
859 for (s = namelist3; *s; s++)
860 if (strstr(name, *s) != NULL)
861 return 1;
862 return 0;
863}
864
865static void read_symbols(char *modname)
451{ 866{
452 const char *symname; 867 const char *symname;
453 char *version; 868 char *version;
@@ -462,9 +877,7 @@ read_symbols(char *modname)
462 /* When there's no vmlinux, don't print warnings about 877 /* When there's no vmlinux, don't print warnings about
463 * unresolved symbols (since there'll be too many ;) */ 878 * unresolved symbols (since there'll be too many ;) */
464 if (is_vmlinux(modname)) { 879 if (is_vmlinux(modname)) {
465 unsigned int fake_crc = 0;
466 have_vmlinux = 1; 880 have_vmlinux = 1;
467 add_exported_symbol("struct_module", mod, &fake_crc);
468 mod->skip = 1; 881 mod->skip = 1;
469 } 882 }
470 883
@@ -474,6 +887,8 @@ read_symbols(char *modname)
474 handle_modversions(mod, &info, sym, symname); 887 handle_modversions(mod, &info, sym, symname);
475 handle_moddevtable(mod, &info, sym, symname); 888 handle_moddevtable(mod, &info, sym, symname);
476 } 889 }
890 check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok);
891 check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok);
477 892
478 version = get_modinfo(info.modinfo, info.modinfo_len, "version"); 893 version = get_modinfo(info.modinfo, info.modinfo_len, "version");
479 if (version) 894 if (version)
@@ -499,21 +914,20 @@ read_symbols(char *modname)
499 * following helper, then compare to the file on disk and 914 * following helper, then compare to the file on disk and
500 * only update the later if anything changed */ 915 * only update the later if anything changed */
501 916
502void __attribute__((format(printf, 2, 3))) 917void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf,
503buf_printf(struct buffer *buf, const char *fmt, ...) 918 const char *fmt, ...)
504{ 919{
505 char tmp[SZ]; 920 char tmp[SZ];
506 int len; 921 int len;
507 va_list ap; 922 va_list ap;
508 923
509 va_start(ap, fmt); 924 va_start(ap, fmt);
510 len = vsnprintf(tmp, SZ, fmt, ap); 925 len = vsnprintf(tmp, SZ, fmt, ap);
511 buf_write(buf, tmp, len); 926 buf_write(buf, tmp, len);
512 va_end(ap); 927 va_end(ap);
513} 928}
514 929
515void 930void buf_write(struct buffer *buf, const char *s, int len)
516buf_write(struct buffer *buf, const char *s, int len)
517{ 931{
518 if (buf->size - buf->pos < len) { 932 if (buf->size - buf->pos < len) {
519 buf->size += len + SZ; 933 buf->size += len + SZ;
@@ -523,10 +937,10 @@ buf_write(struct buffer *buf, const char *s, int len)
523 buf->pos += len; 937 buf->pos += len;
524} 938}
525 939
526/* Header for the generated file */ 940/**
527 941 * Header for the generated file
528void 942 **/
529add_header(struct buffer *b, struct module *mod) 943static void add_header(struct buffer *b, struct module *mod)
530{ 944{
531 buf_printf(b, "#include <linux/module.h>\n"); 945 buf_printf(b, "#include <linux/module.h>\n");
532 buf_printf(b, "#include <linux/vermagic.h>\n"); 946 buf_printf(b, "#include <linux/vermagic.h>\n");
@@ -546,10 +960,10 @@ add_header(struct buffer *b, struct module *mod)
546 buf_printf(b, "};\n"); 960 buf_printf(b, "};\n");
547} 961}
548 962
549/* Record CRCs for unresolved symbols */ 963/**
550 964 * Record CRCs for unresolved symbols
551void 965 **/
552add_versions(struct buffer *b, struct module *mod) 966static void add_versions(struct buffer *b, struct module *mod)
553{ 967{
554 struct symbol *s, *exp; 968 struct symbol *s, *exp;
555 969
@@ -557,8 +971,8 @@ add_versions(struct buffer *b, struct module *mod)
557 exp = find_symbol(s->name); 971 exp = find_symbol(s->name);
558 if (!exp || exp->module == mod) { 972 if (!exp || exp->module == mod) {
559 if (have_vmlinux && !s->weak) 973 if (have_vmlinux && !s->weak)
560 fprintf(stderr, "*** Warning: \"%s\" [%s.ko] " 974 warn("\"%s\" [%s.ko] undefined!\n",
561 "undefined!\n", s->name, mod->name); 975 s->name, mod->name);
562 continue; 976 continue;
563 } 977 }
564 s->module = exp->module; 978 s->module = exp->module;
@@ -579,8 +993,7 @@ add_versions(struct buffer *b, struct module *mod)
579 continue; 993 continue;
580 } 994 }
581 if (!s->crc_valid) { 995 if (!s->crc_valid) {
582 fprintf(stderr, "*** Warning: \"%s\" [%s.ko] " 996 warn("\"%s\" [%s.ko] has no CRC!\n",
583 "has no CRC!\n",
584 s->name, mod->name); 997 s->name, mod->name);
585 continue; 998 continue;
586 } 999 }
@@ -590,8 +1003,8 @@ add_versions(struct buffer *b, struct module *mod)
590 buf_printf(b, "};\n"); 1003 buf_printf(b, "};\n");
591} 1004}
592 1005
593void 1006static void add_depends(struct buffer *b, struct module *mod,
594add_depends(struct buffer *b, struct module *mod, struct module *modules) 1007 struct module *modules)
595{ 1008{
596 struct symbol *s; 1009 struct symbol *s;
597 struct module *m; 1010 struct module *m;
@@ -621,8 +1034,7 @@ add_depends(struct buffer *b, struct module *mod, struct module *modules)
621 buf_printf(b, "\";\n"); 1034 buf_printf(b, "\";\n");
622} 1035}
623 1036
624void 1037static void add_srcversion(struct buffer *b, struct module *mod)
625add_srcversion(struct buffer *b, struct module *mod)
626{ 1038{
627 if (mod->srcversion[0]) { 1039 if (mod->srcversion[0]) {
628 buf_printf(b, "\n"); 1040 buf_printf(b, "\n");
@@ -631,8 +1043,7 @@ add_srcversion(struct buffer *b, struct module *mod)
631 } 1043 }
632} 1044}
633 1045
634void 1046static void write_if_changed(struct buffer *b, const char *fname)
635write_if_changed(struct buffer *b, const char *fname)
636{ 1047{
637 char *tmp; 1048 char *tmp;
638 FILE *file; 1049 FILE *file;
@@ -676,8 +1087,7 @@ write_if_changed(struct buffer *b, const char *fname)
676 fclose(file); 1087 fclose(file);
677} 1088}
678 1089
679void 1090static void read_dump(const char *fname, unsigned int kernel)
680read_dump(const char *fname)
681{ 1091{
682 unsigned long size, pos = 0; 1092 unsigned long size, pos = 0;
683 void *file = grab_file(fname, &size); 1093 void *file = grab_file(fname, &size);
@@ -691,6 +1101,7 @@ read_dump(const char *fname)
691 char *symname, *modname, *d; 1101 char *symname, *modname, *d;
692 unsigned int crc; 1102 unsigned int crc;
693 struct module *mod; 1103 struct module *mod;
1104 struct symbol *s;
694 1105
695 if (!(symname = strchr(line, '\t'))) 1106 if (!(symname = strchr(line, '\t')))
696 goto fail; 1107 goto fail;
@@ -711,15 +1122,30 @@ read_dump(const char *fname)
711 mod = new_module(NOFAIL(strdup(modname))); 1122 mod = new_module(NOFAIL(strdup(modname)));
712 mod->skip = 1; 1123 mod->skip = 1;
713 } 1124 }
714 add_exported_symbol(symname, mod, &crc); 1125 s = sym_add_exported(symname, mod);
1126 s->kernel = kernel;
1127 s->preloaded = 1;
1128 sym_update_crc(symname, mod, crc);
715 } 1129 }
716 return; 1130 return;
717fail: 1131fail:
718 fatal("parse error in symbol dump file\n"); 1132 fatal("parse error in symbol dump file\n");
719} 1133}
720 1134
721void 1135/* For normal builds always dump all symbols.
722write_dump(const char *fname) 1136 * For external modules only dump symbols
1137 * that are not read from kernel Module.symvers.
1138 **/
1139static int dump_sym(struct symbol *sym)
1140{
1141 if (!external_module)
1142 return 1;
1143 if (sym->vmlinux || sym->kernel)
1144 return 0;
1145 return 1;
1146}
1147
1148static void write_dump(const char *fname)
723{ 1149{
724 struct buffer buf = { }; 1150 struct buffer buf = { };
725 struct symbol *symbol; 1151 struct symbol *symbol;
@@ -728,34 +1154,33 @@ write_dump(const char *fname)
728 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) { 1154 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
729 symbol = symbolhash[n]; 1155 symbol = symbolhash[n];
730 while (symbol) { 1156 while (symbol) {
731 symbol = symbol->next; 1157 if (dump_sym(symbol))
732 } 1158 buf_printf(&buf, "0x%08x\t%s\t%s\n",
733 } 1159 symbol->crc, symbol->name,
734 1160 symbol->module->name);
735 for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
736 symbol = symbolhash[n];
737 while (symbol) {
738 buf_printf(&buf, "0x%08x\t%s\t%s\n", symbol->crc,
739 symbol->name, symbol->module->name);
740 symbol = symbol->next; 1161 symbol = symbol->next;
741 } 1162 }
742 } 1163 }
743 write_if_changed(&buf, fname); 1164 write_if_changed(&buf, fname);
744} 1165}
745 1166
746int 1167int main(int argc, char **argv)
747main(int argc, char **argv)
748{ 1168{
749 struct module *mod; 1169 struct module *mod;
750 struct buffer buf = { }; 1170 struct buffer buf = { };
751 char fname[SZ]; 1171 char fname[SZ];
752 char *dump_read = NULL, *dump_write = NULL; 1172 char *kernel_read = NULL, *module_read = NULL;
1173 char *dump_write = NULL;
753 int opt; 1174 int opt;
754 1175
755 while ((opt = getopt(argc, argv, "i:mo:a")) != -1) { 1176 while ((opt = getopt(argc, argv, "i:I:mo:a")) != -1) {
756 switch(opt) { 1177 switch(opt) {
757 case 'i': 1178 case 'i':
758 dump_read = optarg; 1179 kernel_read = optarg;
1180 break;
1181 case 'I':
1182 module_read = optarg;
1183 external_module = 1;
759 break; 1184 break;
760 case 'm': 1185 case 'm':
761 modversions = 1; 1186 modversions = 1;
@@ -771,8 +1196,10 @@ main(int argc, char **argv)
771 } 1196 }
772 } 1197 }
773 1198
774 if (dump_read) 1199 if (kernel_read)
775 read_dump(dump_read); 1200 read_dump(kernel_read, 1);
1201 if (module_read)
1202 read_dump(module_read, 0);
776 1203
777 while (optind < argc) { 1204 while (optind < argc) {
778 read_symbols(argv[optind++]); 1205 read_symbols(argv[optind++]);
@@ -799,4 +1226,3 @@ main(int argc, char **argv)
799 1226
800 return 0; 1227 return 0;
801} 1228}
802
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 7334d839145d..b14255c72a37 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -13,20 +13,30 @@
13 13
14#if KERNEL_ELFCLASS == ELFCLASS32 14#if KERNEL_ELFCLASS == ELFCLASS32
15 15
16#define Elf_Ehdr Elf32_Ehdr 16#define Elf_Ehdr Elf32_Ehdr
17#define Elf_Shdr Elf32_Shdr 17#define Elf_Shdr Elf32_Shdr
18#define Elf_Sym Elf32_Sym 18#define Elf_Sym Elf32_Sym
19#define Elf_Addr Elf32_Addr
20#define Elf_Section Elf32_Section
19#define ELF_ST_BIND ELF32_ST_BIND 21#define ELF_ST_BIND ELF32_ST_BIND
20#define ELF_ST_TYPE ELF32_ST_TYPE 22#define ELF_ST_TYPE ELF32_ST_TYPE
21 23
24#define Elf_Rela Elf32_Rela
25#define ELF_R_SYM ELF32_R_SYM
26#define ELF_R_TYPE ELF32_R_TYPE
22#else 27#else
23 28
24#define Elf_Ehdr Elf64_Ehdr 29#define Elf_Ehdr Elf64_Ehdr
25#define Elf_Shdr Elf64_Shdr 30#define Elf_Shdr Elf64_Shdr
26#define Elf_Sym Elf64_Sym 31#define Elf_Sym Elf64_Sym
32#define Elf_Addr Elf64_Addr
33#define Elf_Section Elf64_Section
27#define ELF_ST_BIND ELF64_ST_BIND 34#define ELF_ST_BIND ELF64_ST_BIND
28#define ELF_ST_TYPE ELF64_ST_TYPE 35#define ELF_ST_TYPE ELF64_ST_TYPE
29 36
37#define Elf_Rela Elf64_Rela
38#define ELF_R_SYM ELF64_R_SYM
39#define ELF_R_TYPE ELF64_R_TYPE
30#endif 40#endif
31 41
32#if KERNEL_ELFDATA != HOST_ELFDATA 42#if KERNEL_ELFDATA != HOST_ELFDATA
@@ -91,17 +101,22 @@ struct elf_info {
91 unsigned int modinfo_len; 101 unsigned int modinfo_len;
92}; 102};
93 103
104/* file2alias.c */
94void handle_moddevtable(struct module *mod, struct elf_info *info, 105void handle_moddevtable(struct module *mod, struct elf_info *info,
95 Elf_Sym *sym, const char *symname); 106 Elf_Sym *sym, const char *symname);
96
97void add_moddevtable(struct buffer *buf, struct module *mod); 107void add_moddevtable(struct buffer *buf, struct module *mod);
98 108
109/* sumversion.c */
99void maybe_frob_rcs_version(const char *modfilename, 110void maybe_frob_rcs_version(const char *modfilename,
100 char *version, 111 char *version,
101 void *modinfo, 112 void *modinfo,
102 unsigned long modinfo_offset); 113 unsigned long modinfo_offset);
103void get_src_version(const char *modname, char sum[], unsigned sumlen); 114void get_src_version(const char *modname, char sum[], unsigned sumlen);
104 115
116/* from modpost.c */
105void *grab_file(const char *filename, unsigned long *size); 117void *grab_file(const char *filename, unsigned long *size);
106char* get_next_line(unsigned long *pos, void *file, unsigned long size); 118char* get_next_line(unsigned long *pos, void *file, unsigned long size);
107void release_file(void *file, unsigned long size); 119void release_file(void *file, unsigned long size);
120
121void fatal(const char *fmt, ...);
122void warn(const char *fmt, ...);
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c
index 43271a1ca01e..8a2875689e4d 100644
--- a/scripts/mod/sumversion.c
+++ b/scripts/mod/sumversion.c
@@ -316,8 +316,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
316 316
317 file = grab_file(cmd, &flen); 317 file = grab_file(cmd, &flen);
318 if (!file) { 318 if (!file) {
319 fprintf(stderr, "Warning: could not find %s for %s\n", 319 warn("could not find %s for %s\n", cmd, objfile);
320 cmd, objfile);
321 goto out; 320 goto out;
322 } 321 }
323 322
@@ -355,9 +354,8 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md)
355 /* Check if this file is in same dir as objfile */ 354 /* Check if this file is in same dir as objfile */
356 if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) { 355 if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) {
357 if (!parse_file(line, md)) { 356 if (!parse_file(line, md)) {
358 fprintf(stderr, 357 warn("could not open %s: %s\n",
359 "Warning: could not open %s: %s\n", 358 line, strerror(errno));
360 line, strerror(errno));
361 goto out_file; 359 goto out_file;
362 } 360 }
363 361
@@ -383,8 +381,11 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
383 struct md4_ctx md; 381 struct md4_ctx md;
384 char *sources, *end, *fname; 382 char *sources, *end, *fname;
385 const char *basename; 383 const char *basename;
386 char filelist[strlen(getenv("MODVERDIR")) + strlen("/") + 384 char filelist[PATH_MAX + 1];
387 strlen(modname) - strlen(".o") + strlen(".mod") + 1 ]; 385 char *modverdir = getenv("MODVERDIR");
386
387 if (!modverdir)
388 modverdir = ".";
388 389
389 /* Source files for module are in .tmp_versions/modname.mod, 390 /* Source files for module are in .tmp_versions/modname.mod,
390 after the first line. */ 391 after the first line. */
@@ -392,28 +393,25 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen)
392 basename = strrchr(modname, '/') + 1; 393 basename = strrchr(modname, '/') + 1;
393 else 394 else
394 basename = modname; 395 basename = modname;
395 sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"), 396 sprintf(filelist, "%s/%.*s.mod", modverdir,
396 (int) strlen(basename) - 2, basename); 397 (int) strlen(basename) - 2, basename);
397 398
398 file = grab_file(filelist, &len); 399 file = grab_file(filelist, &len);
399 if (!file) { 400 if (!file) {
400 fprintf(stderr, "Warning: could not find versions for %s\n", 401 warn("could not find versions for %s\n", filelist);
401 filelist);
402 return; 402 return;
403 } 403 }
404 404
405 sources = strchr(file, '\n'); 405 sources = strchr(file, '\n');
406 if (!sources) { 406 if (!sources) {
407 fprintf(stderr, "Warning: malformed versions file for %s\n", 407 warn("malformed versions file for %s\n", modname);
408 modname);
409 goto release; 408 goto release;
410 } 409 }
411 410
412 sources++; 411 sources++;
413 end = strchr(sources, '\n'); 412 end = strchr(sources, '\n');
414 if (!end) { 413 if (!end) {
415 fprintf(stderr, "Warning: bad ending versions file for %s\n", 414 warn("bad ending versions file for %s\n", modname);
416 modname);
417 goto release; 415 goto release;
418 } 416 }
419 *end = '\0'; 417 *end = '\0';
@@ -438,19 +436,19 @@ static void write_version(const char *filename, const char *sum,
438 436
439 fd = open(filename, O_RDWR); 437 fd = open(filename, O_RDWR);
440 if (fd < 0) { 438 if (fd < 0) {
441 fprintf(stderr, "Warning: changing sum in %s failed: %s\n", 439 warn("changing sum in %s failed: %s\n",
442 filename, strerror(errno)); 440 filename, strerror(errno));
443 return; 441 return;
444 } 442 }
445 443
446 if (lseek(fd, offset, SEEK_SET) == (off_t)-1) { 444 if (lseek(fd, offset, SEEK_SET) == (off_t)-1) {
447 fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n", 445 warn("changing sum in %s:%lu failed: %s\n",
448 filename, offset, strerror(errno)); 446 filename, offset, strerror(errno));
449 goto out; 447 goto out;
450 } 448 }
451 449
452 if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) { 450 if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) {
453 fprintf(stderr, "Warning: writing sum in %s failed: %s\n", 451 warn("writing sum in %s failed: %s\n",
454 filename, strerror(errno)); 452 filename, strerror(errno));
455 goto out; 453 goto out;
456 } 454 }
diff --git a/scripts/namespace.pl b/scripts/namespace.pl
index 88e30e82f1ca..f34373853ef8 100644
--- a/scripts/namespace.pl
+++ b/scripts/namespace.pl
@@ -66,8 +66,8 @@ require 5; # at least perl 5
66use strict; 66use strict;
67use File::Find; 67use File::Find;
68 68
69my $nm = "/usr/bin/nm -p"; 69my $nm = ($ENV{'NM'} || "nm") . " -p";
70my $objdump = "/usr/bin/objdump -s -j .comment"; 70my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment";
71my $srctree = ""; 71my $srctree = "";
72my $objtree = ""; 72my $objtree = "";
73$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); 73$srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'}));
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index c201ef001f09..7c434e037e7f 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -32,12 +32,11 @@ MKSPEC := $(srctree)/scripts/package/mkspec
32PREV := set -e; cd ..; 32PREV := set -e; cd ..;
33 33
34# rpm-pkg 34# rpm-pkg
35.PHONY: rpm-pkg rpm 35# ---------------------------------------------------------------------------
36
37$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile 36$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
38 $(CONFIG_SHELL) $(MKSPEC) > $@ 37 $(CONFIG_SHELL) $(MKSPEC) > $@
39 38
40rpm-pkg rpm: $(objtree)/kernel.spec 39rpm-pkg rpm: $(objtree)/kernel.spec FORCE
41 $(MAKE) clean 40 $(MAKE) clean
42 $(PREV) ln -sf $(srctree) $(KERNELPATH) 41 $(PREV) ln -sf $(srctree) $(KERNELPATH)
43 $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. 42 $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.
@@ -54,11 +53,11 @@ rpm-pkg rpm: $(objtree)/kernel.spec
54clean-files := $(objtree)/kernel.spec 53clean-files := $(objtree)/kernel.spec
55 54
56# binrpm-pkg 55# binrpm-pkg
57.PHONY: binrpm-pkg 56# ---------------------------------------------------------------------------
58$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile 57$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
59 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ 58 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
60 59
61binrpm-pkg: $(objtree)/binkernel.spec 60binrpm-pkg: $(objtree)/binkernel.spec FORCE
62 $(MAKE) KBUILD_SRC= 61 $(MAKE) KBUILD_SRC=
63 set -e; \ 62 set -e; \
64 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version 63 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
@@ -71,9 +70,7 @@ clean-files += $(objtree)/binkernel.spec
71 70
72# Deb target 71# Deb target
73# --------------------------------------------------------------------------- 72# ---------------------------------------------------------------------------
74# 73deb-pkg: FORCE
75.PHONY: deb-pkg
76deb-pkg:
77 $(MAKE) KBUILD_SRC= 74 $(MAKE) KBUILD_SRC=
78 $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb 75 $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
79 76
@@ -82,8 +79,7 @@ clean-dirs += $(objtree)/debian/
82 79
83# tarball targets 80# tarball targets
84# --------------------------------------------------------------------------- 81# ---------------------------------------------------------------------------
85.PHONY: tar%pkg 82tar%pkg: FORCE
86tar%pkg:
87 $(MAKE) KBUILD_SRC= 83 $(MAKE) KBUILD_SRC=
88 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ 84 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
89 85
@@ -92,7 +88,7 @@ clean-dirs += $(objtree)/tar-install/
92 88
93# Help text displayed when executing 'make help' 89# Help text displayed when executing 'make help'
94# --------------------------------------------------------------------------- 90# ---------------------------------------------------------------------------
95help: 91help: FORCE
96 @echo ' rpm-pkg - Build the kernel as an RPM package' 92 @echo ' rpm-pkg - Build the kernel as an RPM package'
97 @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel' 93 @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel'
98 @echo ' and modules' 94 @echo ' and modules'
diff --git a/scripts/reference_discarded.pl b/scripts/reference_discarded.pl
deleted file mode 100644
index 4ee6ab2135b3..000000000000
--- a/scripts/reference_discarded.pl
+++ /dev/null
@@ -1,112 +0,0 @@
1#!/usr/bin/perl -w
2#
3# reference_discarded.pl (C) Keith Owens 2001 <kaos@ocs.com.au>
4#
5# Released under GPL V2.
6#
7# List dangling references to vmlinux discarded sections.
8
9use strict;
10die($0 . " takes no arguments\n") if($#ARGV >= 0);
11
12my %object;
13my $object;
14my $line;
15my $ignore;
16my $errorcount;
17
18$| = 1;
19
20# printf("Finding objects, ");
21open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed";
22while (defined($line = <OBJDUMP_LIST>)) {
23 chomp($line);
24 if ($line =~ /:\s+file format/) {
25 ($object = $line) =~ s/:.*//;
26 $object{$object}->{'module'} = 0;
27 $object{$object}->{'size'} = 0;
28 $object{$object}->{'off'} = 0;
29 }
30 if ($line =~ /^\s*\d+\s+\.modinfo\s+/) {
31 $object{$object}->{'module'} = 1;
32 }
33 if ($line =~ /^\s*\d+\s+\.comment\s+/) {
34 ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5];
35 }
36}
37close(OBJDUMP_LIST);
38# printf("%d objects, ", scalar keys(%object));
39$ignore = 0;
40foreach $object (keys(%object)) {
41 if ($object{$object}->{'module'}) {
42 ++$ignore;
43 delete($object{$object});
44 }
45}
46# printf("ignoring %d module(s)\n", $ignore);
47
48# Ignore conglomerate objects, they have been built from multiple objects and we
49# only care about the individual objects. If an object has more than one GCC:
50# string in the comment section then it is conglomerate. This does not filter
51# out conglomerates that consist of exactly one object, can't be helped.
52
53# printf("Finding conglomerates, ");
54$ignore = 0;
55foreach $object (keys(%object)) {
56 if (exists($object{$object}->{'off'})) {
57 my ($off, $size, $comment, $l);
58 $off = hex($object{$object}->{'off'});
59 $size = hex($object{$object}->{'size'});
60 open(OBJECT, "<$object") || die "cannot read $object";
61 seek(OBJECT, $off, 0) || die "seek to $off in $object failed";
62 $l = read(OBJECT, $comment, $size);
63 die "read $size bytes from $object .comment failed" if ($l != $size);
64 close(OBJECT);
65 if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) {
66 ++$ignore;
67 delete($object{$object});
68 }
69 }
70}
71# printf("ignoring %d conglomerate(s)\n", $ignore);
72
73# printf("Scanning objects\n");
74
75# Keith Ownes <kaos@sgi.com> commented:
76# For our future {in}sanity, add a comment that this is the ppc .opd
77# section, not the ia64 .opd section.
78# ia64 .opd should not point to discarded sections.
79$errorcount = 0;
80foreach $object (keys(%object)) {
81 my $from;
82 open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object";
83 while (defined($line = <OBJDUMP>)) {
84 chomp($line);
85 if ($line =~ /RELOCATION RECORDS FOR /) {
86 ($from = $line) =~ s/.*\[([^]]*).*/$1/;
87 }
88 if (($line =~ /\.text\.exit$/ ||
89 $line =~ /\.exit\.text$/ ||
90 $line =~ /\.data\.exit$/ ||
91 $line =~ /\.exit\.data$/ ||
92 $line =~ /\.exitcall\.exit$/) &&
93 ($from !~ /\.text\.exit$/ &&
94 $from !~ /\.exit\.text$/ &&
95 $from !~ /\.data\.exit$/ &&
96 $from !~ /\.opd$/ &&
97 $from !~ /\.exit\.data$/ &&
98 $from !~ /\.altinstructions$/ &&
99 $from !~ /\.pdr$/ &&
100 $from !~ /\.debug_.*$/ &&
101 $from !~ /\.exitcall\.exit$/ &&
102 $from !~ /\.eh_frame$/ &&
103 $from !~ /\.stab$/)) {
104 printf("Error: %s %s refers to %s\n", $object, $from, $line);
105 $errorcount = $errorcount + 1;
106 }
107 }
108 close(OBJDUMP);
109}
110# printf("Done\n");
111
112exit(0);
diff --git a/scripts/reference_init.pl b/scripts/reference_init.pl
deleted file mode 100644
index 7f6960b175a2..000000000000
--- a/scripts/reference_init.pl
+++ /dev/null
@@ -1,108 +0,0 @@
1#!/usr/bin/perl -w
2#
3# reference_init.pl (C) Keith Owens 2002 <kaos@ocs.com.au>
4#
5# List references to vmlinux init sections from non-init sections.
6
7# Unfortunately I had to exclude references from read only data to .init
8# sections, almost all of these are false positives, they are created by
9# gcc. The downside of excluding rodata is that there really are some
10# user references from rodata to init code, e.g. drivers/video/vgacon.c
11#
12# const struct consw vga_con = {
13# con_startup: vgacon_startup,
14#
15# where vgacon_startup is __init. If you want to wade through the false
16# positives, take out the check for rodata.
17
18use strict;
19die($0 . " takes no arguments\n") if($#ARGV >= 0);
20
21my %object;
22my $object;
23my $line;
24my $ignore;
25
26$| = 1;
27
28printf("Finding objects, ");
29open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed";
30while (defined($line = <OBJDUMP_LIST>)) {
31 chomp($line);
32 if ($line =~ /:\s+file format/) {
33 ($object = $line) =~ s/:.*//;
34 $object{$object}->{'module'} = 0;
35 $object{$object}->{'size'} = 0;
36 $object{$object}->{'off'} = 0;
37 }
38 if ($line =~ /^\s*\d+\s+\.modinfo\s+/) {
39 $object{$object}->{'module'} = 1;
40 }
41 if ($line =~ /^\s*\d+\s+\.comment\s+/) {
42 ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5];
43 }
44}
45close(OBJDUMP_LIST);
46printf("%d objects, ", scalar keys(%object));
47$ignore = 0;
48foreach $object (keys(%object)) {
49 if ($object{$object}->{'module'}) {
50 ++$ignore;
51 delete($object{$object});
52 }
53}
54printf("ignoring %d module(s)\n", $ignore);
55
56# Ignore conglomerate objects, they have been built from multiple objects and we
57# only care about the individual objects. If an object has more than one GCC:
58# string in the comment section then it is conglomerate. This does not filter
59# out conglomerates that consist of exactly one object, can't be helped.
60
61printf("Finding conglomerates, ");
62$ignore = 0;
63foreach $object (keys(%object)) {
64 if (exists($object{$object}->{'off'})) {
65 my ($off, $size, $comment, $l);
66 $off = hex($object{$object}->{'off'});
67 $size = hex($object{$object}->{'size'});
68 open(OBJECT, "<$object") || die "cannot read $object";
69 seek(OBJECT, $off, 0) || die "seek to $off in $object failed";
70 $l = read(OBJECT, $comment, $size);
71 die "read $size bytes from $object .comment failed" if ($l != $size);
72 close(OBJECT);
73 if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) {
74 ++$ignore;
75 delete($object{$object});
76 }
77 }
78}
79printf("ignoring %d conglomerate(s)\n", $ignore);
80
81printf("Scanning objects\n");
82foreach $object (sort(keys(%object))) {
83 my $from;
84 open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object";
85 while (defined($line = <OBJDUMP>)) {
86 chomp($line);
87 if ($line =~ /RELOCATION RECORDS FOR /) {
88 ($from = $line) =~ s/.*\[([^]]*).*/$1/;
89 }
90 if (($line =~ /\.init$/ || $line =~ /\.init\./) &&
91 ($from !~ /\.init$/ &&
92 $from !~ /\.init\./ &&
93 $from !~ /\.stab$/ &&
94 $from !~ /\.rodata$/ &&
95 $from !~ /\.text\.lock$/ &&
96 $from !~ /\.pci_fixup_header$/ &&
97 $from !~ /\.pci_fixup_final$/ &&
98 $from !~ /\.pdr$/ &&
99 $from !~ /\__param$/ &&
100 $from !~ /\.altinstructions/ &&
101 $from !~ /\.eh_frame/ &&
102 $from !~ /\.debug_/)) {
103 printf("Error: %s %s refers to %s\n", $object, $from, $line);
104 }
105 }
106 close(OBJDUMP);
107}
108printf("Done\n");
diff --git a/sound/oss/.gitignore b/sound/oss/.gitignore
new file mode 100644
index 000000000000..7efb12b45502
--- /dev/null
+++ b/sound/oss/.gitignore
@@ -0,0 +1,4 @@
1#Ignore generated files
2maui_boot.h
3pss_boot.h
4trix_boot.h