Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

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