GIT b3f4c151d03f394fec79352b359dcb9d707197a8 git+ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild.git commit Author: Sam Ravnborg Date: Fri Apr 13 23:07:00 2007 +0200 kbuild: fix make mrproper for Documentation/DocBook/man "make mandocs" generate > 2000 files in Documentation/DocBook/man and this caused kbuild to barf out during make mrproper like this: make -f scripts/Makefile.clean obj=Documentation/DocBook make -f scripts/Makefile.clean obj=Documentation/DocBook/man/ make[2]: execvp: /bin/sh: Argument list too long make[2]: *** [__clean] Error 127 make[1]: *** [Documentation/DocBook/man/] Error 2 make: *** [_mrproper_Documentation/DocBook] Error 2 The man directory were solely used for output so the fix is to remove it entirely during the make mrproper process. Signed-off-by: Sam Ravnborg Acked-by: Randy Dunlap commit c428e4cd1fdddb5c1a33d6cd229148497ae03893 Author: Sam Ravnborg Date: Sun Apr 1 23:14:11 2007 +0200 kbuild: remove kconfig binaries during make mrproper Nigel Cunningham noticed that 'make mrproper' did not remove mconf. Fixed so we now remove all relevant binaries. Signed-off-by: Sam Ravnborg Cc: Nigel Cunningham commit 8331b61edfa6e3bb51f92b7821db6ee9641a00b4 Author: Sam Ravnborg Date: Sun Apr 1 22:29:38 2007 +0200 kconfig/menuconfig: do not hardcode '.config' Export and use the function conf_get_configname() to retreive the default configuration filename. Suggested by: Roman Zippel Signed-off-by: Sam Ravnborg commit d3a8624159353efc1aaa73c75210f1136d371084 Author: Sam Ravnborg Date: Sun Apr 1 21:49:27 2007 +0200 kbuild: override build timestamp & version Introduce KBUILD_BUILD_VERSION to make it possible to override kernel build version during build time. Introduce KBUILD_BUILD_TIMESTAMP to make it possible to override kernel build timestamp during build time. But variables are useful mainly by distros that want to pass info from an SCM when building the kernel. Timestamp could be last checkin date for a file etc. The idea came from Olaf Hering Cc: Olaf Hering Signed-off-by: Sam Ravnborg commit 05a3ab3e2d0d0b7163be4d1d86e60f03df7c53b5 Author: Andreas Dilger Date: Tue Mar 27 15:21:33 2007 -0600 kconfig.debug: clarify CONFIG_DEBUG_INFO help text The following patch adds some extra clarification to the CONFIG_DEBUG_INFO Kconfig help text. The current text is mostly a recursive definition and doesn't really say much of anything. When I first read this I thought it was going to enable extra verbosity in debug messages or something, but it is only enabling the "gcc -g" compile option in the Makefile. Signed-off-by: Andreas Dilger Signed-off-by: Sam Ravnborg commit 7d2fd4638ceed15136af87f834b11015b437907d Author: Uwe Kleine-König Date: Wed Mar 28 16:55:55 2007 +0200 kbuild/mkuboot.sh: allow spaces in CROSS_COMPILE I'm currently using CROSS_COMPILE="ccache arm-linux-". With that the bash builtin command "type" searches for ccache and arm-linux-mkimage and so sets MKIMAGE="/path/to/ccache" as I don't have arm-linux-mkimage. Then the script dies with an error, that ccache doesn't support the argument -A. This patch adds some quoting such that it works again for me. Please note that this patch doesn't help you if you use ${CROSSCOMPILE}-mkimage and ccache as mkuboot.sh now searches for the command "ccache arm-linux-mkimage". Signed-off-by: Uwe Kleine-König Signed-off-by: Sam Ravnborg commit 3271e981869ca0b7fe37d90d7fba399c206052ce Author: Sam Ravnborg Date: Tue Mar 27 22:50:29 2007 +0200 kbuild: complain about missing system calls Most system calls seems to get added to i386 first. This patch automatically generates a warning for any new system call which is implemented on i386 but not the architecture currently being compiled. On PowerPC at the moment, for example, it results in these warnings: init/missing_syscalls.h:935:3: warning: #warning syscall sync_file_range not implemented init/missing_syscalls.h:947:3: warning: #warning syscall getcpu not implemented init/missing_syscalls.h:950:3: warning: #warning syscall epoll_pwait not implemented The file scripts/checksyscalls.sh list a number of legacy system calls that are ignored because they only makes sense on i386 systems. Other contributors to this patch are Russell King and Stéphane Jourdois Signed-off-by: David Woodhouse Signed-off-by: Sam Ravnborg commit 08eca4c5b3fa61d74a9925c634cc0a24a93618b9 Author: Anton Blanchard Date: Tue Mar 20 09:47:47 2007 -0500 kbuild: small documentation fix in Documentation/kbuild/modules.txt The Makefile fragment in Documentation/kbuild/modules.txt looks to be missing some braces. Signed-off-by: Anton Blanchard Signed-off-by: Sam Ravnborg commit dcbb13011b60e95d2a156d8e21f9ec654215fe94 Author: Sam Ravnborg Date: Fri Mar 23 20:05:30 2007 +0100 kbuild: ignore section mismatch warning for references from .paravirtprobe to .init.text Added on request from: Rusty Russell Signed-off-by: Sam Ravnborg Cc: Rusty Russell commit 1b37fb82aed9340de0d9fff2cc722e73db089845 Author: Sam Ravnborg Date: Tue Mar 20 21:30:23 2007 +0100 kbuild: do not emit src version warning for non-modules modpost is now called with .o files that are not modules. So do not warn if there is no corresponding .mod file listing .o files (in .tmp_versions/). Signed-off-by: Sam Ravnborg commit 577330416f75b7912346abcb6c873e3758570c8c Author: Sam Ravnborg Date: Sun Mar 18 10:48:46 2007 +0100 menuconfig: remember alternate config filename When loading an alternate configuration use that file as current configuration filename. Make the filename visible in the dialog. Default continue to be .config. Inspired by patch from: Cyrill Gorcunov Signed-off-by: Sam Ravnborg Cc: Cyrill Gorcunov commit 17364576b49fe1e0d849ac698c55a2c750cc3a08 Author: Don Mullis Date: Thu Jan 4 10:14:52 2007 -0800 kbuild: move tags from ARCH and include/ ahead of drivers Move tags extracted from the ARCH and include/ sub-trees ahead of those from device drivers, so that the former will appear first during searches. Saves user time during interactive searches for certain patterns that happen to find unwanted matches in driver files. Example in emacs: "M-x find-tag PAGE_SIZE" "M-1 M-." (repeated until definition from asm-i386/page.h appears) Signed-off-by: Don Mullis Signed-off-by: Sam Ravnborg commit f26f70ca46efebc9a9ee258cc396a0552bc34124 Author: Matthew Wilcox Date: Sat Oct 7 05:35:32 2006 -0600 kbuild: distinguish between errors and warnings in modpost Some of modpost's warnings are fatal, and some are not. Adopt the compiler distinction between errors and warnings by calling merror() for fatal diagnostics and warn() for non-fatal ones. merror() was used as replacemtn for error() to avoid clash with glibc Signed-off-by: Matthew Wilcox Signed-off-by: Sam Ravnborg commit 5f7690a09a3904254619508d93c52dbce3598a96 Author: Marco Costalba Date: Thu Oct 5 19:12:59 2006 +0200 kconfig/xconfig: sync main view with search dialog current menu When changing current menu in search dialog update also main view Signed-off-by: Marco Costalba Signed-off-by: Sam Ravnborg commit b7bf3c3c5605344d8533bf33f21fa4bd604b65fa Author: Uwe Zeisberger Date: Thu Oct 5 16:24:45 2006 +0200 kbuild: add a missing slash in the comments Signed-off-by: Uwe Zeisberger Signed-off-by: Sam Ravnborg commit 5e4e572ab22bbdac3a53a76c4a1835a0b9a82b58 Author: Mike Frysinger Date: Sat Mar 17 02:37:07 2007 -0400 menuconfig: dont use obsolete index() function in lxdialog The index() function is obsolete, use strchr() instead. Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg commit 518c643107a64b2a042612973abea1fba6d2c250 Author: H. Peter Anvin Date: Fri Mar 16 14:45:06 2007 -0700 cleanpatch: a script to clean up stealth whitespace added by a patch This script is a companion to the "cleanfile" script. This cleans up a patch in unified diff format *before* it is applied. Note that the empty lines at the end of file detection *requires* that the diff was taken with at least one line of context around each hunk, or bad things will happen. This script cleans up various classes of stealth whitespace. In particular, it cleans up: - Whitespace (spaces or tabs)before newline; - DOS line endings (CR before LF); - Space before tab (spaces are deleted or converted to tabs); - Empty lines at end of file. Signed-off-by: H. Peter Anvin Signed-off-by: Sam Ravnborg commit 557de6c72823375377c4e2c9a497c2c51d04b1fc Author: H. Peter Anvin Date: Mon Mar 12 12:16:30 2007 -0700 cleanfile: a script to clean up stealth whitespace This script cleans up various classes of stealth whitespace. In particular, it cleans up: - Whitespace (spaces or tabs)before newline; - DOS line endings (CR before LF); - Space before tab (spaces are deleted or converted to tabs); - Empty lines at end of file. Signed-off-by: H. Peter Anvin Signed-off-by: Sam Ravnborg commit 08f283f7c4828f80aa444ab3a10d815abaa736ab Author: Sam Ravnborg Date: Fri Mar 9 19:59:06 2007 +0100 kbuild: remove dependency on input.h from file2alias Almost all definitions used by file2alias was already present in mod_devicetable.h. Added the last definition and killed the input.h usage. The errornous include was pointed out by: Jan Engelhardt Signed-off-by: Sam Ravnborg Cc: Jan Engelhardt Cc: Deepak Saxena commit 9a36e50369a349a4f10ecd4d301650b99f7ea112 Author: Sam Ravnborg Date: Sat Mar 3 19:34:23 2007 +0100 kbuild: silence section mismatch warnings for exported functions There are legitime cases of exported functions which is marked __init. Some examples are in drivers/pci/ where the pci subsystem export symbols to be used by other __init functions. So ignore references from ksymtab* to .init.text Signed-off-by: Sam Ravnborg commit 3a57f46d152bb180b8cc52eb01d20aa4895778eb Author: Sam Ravnborg Date: Tue Feb 27 09:14:58 2007 +0100 kbuild: whitelist logo references from .text to .init.data drivers/video/logo has references from .text to .init.data but function is only used during early init. So reference is OK and we do not want to warn about them => whitelist the reference. Signed-off-by: Sam Ravnborg commit e00d86a157a5048df2603a3b9ac902409f5404ca Author: Sam Ravnborg Date: Mon Feb 26 19:46:52 2007 +0100 kbuild: fix segmentation fault in modpost If modpost was called manually with filenames without '/' then modpost would segfault. Signed-off-by: Sam Ravnborg commit c0e69007eb7b3031afb5e0e93521c97b670fa3f0 Author: Sam Ravnborg Date: Mon Feb 26 17:49:06 2007 +0100 kbuild: fix warnings from .pci_fixup section Now where we do not pass vmlinux to modpost we started to see section mismatch warnings from .pci_fixup. Refactored code a little to include these in the whitelist again. Signed-off-by: Sam Ravnborg commit 3917f61874d27f397f93f2ddb299b0c2d57b1531 Author: Sam Ravnborg Date: Mon Feb 26 16:45:41 2007 +0100 kbuild: whitelist section mismatch in init/main.c In init/main.c we have a reference from rest_init() to .init.text which is intentional. Rename the function 'init' to 'kernel_init' to make it a kernel wide unique symbol and whitelist the reference. Signed-off-by: Sam Ravnborg commit 087165a4637534447e899f09a489bb9495953a14 Author: Sam Ravnborg Date: Mon Feb 26 15:33:52 2007 +0100 kbuild: fix section mismatch check for vmlinux vmlinux does not contain relocation entries which is used by the section mismatch checks. Reported by: Atsushi Nemoto Use the individual objects as inputs to overcome this limitation. In modpost check the .o files and skip non-ELF files. Signed-off-by: Sam Ravnborg Documentation/DocBook/Makefile | 7 - Documentation/DocBook/man/Makefile | 3 - Documentation/kbuild/modules.txt | 2 Kbuild | 11 ++ Makefile | 15 ++- include/linux/input.h | 4 + include/linux/mod_devicetable.h | 1 init/main.c | 6 + lib/Kconfig.debug | 3 + scripts/Makefile.modpost | 8 + scripts/checksyscalls.sh | 118 +++++++++++++++++++++ scripts/cleanfile | 126 ++++++++++++++++++++++ scripts/cleanpatch | 206 ++++++++++++++++++++++++++++++++++++ scripts/kconfig/Makefile | 1 scripts/kconfig/lkc.h | 1 scripts/kconfig/lxdialog/dialog.h | 1 scripts/kconfig/lxdialog/util.c | 9 +- scripts/kconfig/mconf.c | 43 +++++--- scripts/kconfig/qconf.cc | 5 + scripts/kconfig/qconf.h | 2 scripts/mkcompile_h | 27 +++-- scripts/mkuboot.sh | 2 scripts/mod/file2alias.c | 21 ++-- scripts/mod/modpost.c | 153 +++++++++++++++++++++------ scripts/mod/modpost.h | 1 scripts/mod/sumversion.c | 5 - 26 files changed, 689 insertions(+), 92 deletions(-) diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile index 867608a..960f402 100644 --- a/Documentation/DocBook/Makefile +++ b/Documentation/DocBook/Makefile @@ -152,6 +152,7 @@ quiet_cmd_db2man = MAN $@ @(which xmlto > /dev/null 2>&1) || \ (echo "*** You need to install xmlto ***"; \ exit 1) + $(Q)mkdir -p $(obj)/man $(call cmd,db2man) @touch $@ @@ -212,11 +213,7 @@ clean-files := $(DOCBOOKS) \ $(patsubst %.xml, %.9, $(DOCBOOKS)) \ $(C-procfs-example) -clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) - -#man put files in man subdir - traverse down -subdir- := man/ - +clean-dirs := $(patsubst %.xml,%,$(DOCBOOKS)) man # Declare the contents of the .PHONY variable as phony. We keep that # information in a variable se we can use it in if_changed and friends. diff --git a/Documentation/DocBook/man/Makefile b/Documentation/DocBook/man/Makefile deleted file mode 100644 index 4fb7ea0..0000000 --- a/Documentation/DocBook/man/Makefile +++ /dev/null @@ -1,3 +0,0 @@ -# Rules are put in Documentation/DocBook - -clean-files := *.9.gz *.sgml manpage.links manpage.refs diff --git a/Documentation/kbuild/modules.txt b/Documentation/kbuild/modules.txt index 769ee05..1d247d5 100644 --- a/Documentation/kbuild/modules.txt +++ b/Documentation/kbuild/modules.txt @@ -249,7 +249,7 @@ following files: --> filename: Makefile KERNELDIR := /lib/modules/`uname -r`/build all:: - $(MAKE) -C $KERNELDIR M=`pwd` $@ + $(MAKE) -C $(KERNELDIR) M=`pwd` $@ # Module specific targets genbin: diff --git a/Kbuild b/Kbuild index 0451f69..163f8cb 100644 --- a/Kbuild +++ b/Kbuild @@ -2,6 +2,7 @@ # # Kbuild for top-level directory of the kernel # This file takes care of the following: # 1) Generate asm-offsets.h +# 2) Check for missing system calls ##### # 1) Generate asm-offsets.h @@ -46,3 +47,13 @@ arch/$(ARCH)/kernel/asm-offsets.s: arch/ $(Q)mkdir -p $(dir $@) $(call cmd,offsets) +##### +# 2) Check for missing system calls +# + +quiet_cmd_syscalls = CALL $< + cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) + +PHONY += missing-syscalls +missing-syscalls: scripts/checksyscalls.sh FORCE + $(call cmd,syscalls) diff --git a/Makefile b/Makefile index 234bae6..9757af8 100644 --- a/Makefile +++ b/Makefile @@ -576,7 +576,7 @@ # Build vmlinux # --------------------------------------------------------------------------- # vmlinux is built from the objects selected by $(vmlinux-init) and # $(vmlinux-main). Most are built-in.o files from top-level directories -# in the kernel tree, others are specified in arch/$(ARCH)Makefile. +# in the kernel tree, others are specified in arch/$(ARCH)/Makefile. # Ordering when linking is important, and $(vmlinux-init) must be first. # # vmlinux @@ -603,6 +603,7 @@ vmlinux-init := $(head-y) $(init-y) vmlinux-main := $(core-y) $(libs-y) $(drivers-y) $(net-y) vmlinux-all := $(vmlinux-init) $(vmlinux-main) vmlinux-lds := arch/$(ARCH)/kernel/vmlinux.lds +export KBUILD_VMLINUX_OBJS := $(vmlinux-all) # Rule to link vmlinux - also used during CONFIG_KALLSYMS # May be overridden by arch/$(ARCH)/Makefile @@ -855,6 +856,7 @@ archprepare: prepare1 scripts_basic prepare0: archprepare FORCE $(Q)$(MAKE) $(build)=. + $(Q)$(MAKE) $(build)=. missing-syscalls # All the preparing.. prepare: prepare0 @@ -1277,10 +1279,7 @@ endif ALLSOURCE_ARCHS := $(ARCH) define find-sources - ( find $(__srctree) $(RCS_FIND_IGNORE) \ - \( -name include -o -name arch \) -prune -o \ - -name $1 -print; \ - for ARCH in $(ALLSOURCE_ARCHS) ; do \ + ( for ARCH in $(ALLSOURCE_ARCHS) ; do \ find $(__srctree)arch/$${ARCH} $(RCS_FIND_IGNORE) \ -name $1 -print; \ done ; \ @@ -1294,7 +1293,11 @@ define find-sources -name $1 -print; \ done ; \ find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \ - -name $1 -print ) + -name $1 -print; \ + find $(__srctree) $(RCS_FIND_IGNORE) \ + \( -name include -o -name arch \) -prune -o \ + -name $1 -print; \ + ) endef define all-sources diff --git a/include/linux/input.h b/include/linux/input.h index bde65c8..13d510c 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -1010,6 +1010,10 @@ #if EV_MAX != INPUT_DEVICE_ID_EV_MAX #error "EV_MAX and INPUT_DEVICE_ID_EV_MAX do not match" #endif +#if KEY_MIN_INTERESTING != INPUT_DEVICE_ID_KEY_MIN_INTERESTING +#error "KEY_MIN_INTERESTING and INPUT_DEVICE_ID_KEY_MIN_INTERESTING do not match" +#endif + #if KEY_MAX != INPUT_DEVICE_ID_KEY_MAX #error "KEY_MAX and INPUT_DEVICE_ID_KEY_MAX do not match" #endif diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index e96b2de..af04a55 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -262,6 +262,7 @@ struct i2c_device_id { /* Input */ #define INPUT_DEVICE_ID_EV_MAX 0x1f +#define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71 #define INPUT_DEVICE_ID_KEY_MAX 0x1ff #define INPUT_DEVICE_ID_REL_MAX 0x0f #define INPUT_DEVICE_ID_ABS_MAX 0x3f diff --git a/init/main.c b/init/main.c index a92989e..7a92b4c 100644 --- a/init/main.c +++ b/init/main.c @@ -82,7 +82,7 @@ #if __GNUC__ == 4 && __GNUC_MINOR__ == 1 #warning gcc-4.1.0 is known to miscompile the kernel. A different compiler version is recommended. #endif -static int init(void *); +static int kernel_init(void *); extern void init_IRQ(void); extern void fork_init(unsigned long); @@ -435,7 +435,7 @@ static void __init setup_command_line(ch static void noinline rest_init(void) __releases(kernel_lock) { - kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND); + kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); numa_default_policy(); unlock_kernel(); @@ -772,7 +772,7 @@ static int noinline init_post(void) panic("No init found. Try passing init= option to kernel."); } -static int __init init(void * unused) +static int __init kernel_init(void * unused) { lock_kernel(); /* diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 3f3e740..a98fe11 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -333,6 +333,9 @@ config DEBUG_INFO help If you say Y here the resulting kernel image will include debugging info resulting in a larger kernel image. + This adds debug symbols to the kernel and modules (gcc -g), and + is needed if you intend to use kernel crashdump or binary object + tools like crash, kgdb, LKCD, gdb, etc on the kernel. Say Y here only if you plan to debug the kernel. If unsure, say N. diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 65e0a79..d5bbbcc 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -63,16 +63,16 @@ quiet_cmd_modpost = MODPOST $(words $(fi $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ - $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ - $(wildcard vmlinux) $(filter-out FORCE,$^) + $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) PHONY += __modpost __modpost: $(modules:.ko=.o) FORCE - $(call cmd,modpost) + $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) quiet_cmd_kernel-mod = MODPOST $@ - cmd_kernel-mod = $(cmd_modpost) + cmd_kernel-mod = $(cmd_modpost) $(KBUILD_VMLINUX_OBJS) +PHONY += vmlinux vmlinux: FORCE $(call cmd,kernel-mod) diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh new file mode 100755 index 0000000..f98171f --- /dev/null +++ b/scripts/checksyscalls.sh @@ -0,0 +1,118 @@ +#!/bin/sh +# +# Check if current architecture are missing any function calls compared +# to i386. +# i386 define a number of legacy system calls that are i386 specific +# and listed below so they are ignored. +# +# Usage: +# syscallchk gcc gcc-options +# + +ignore_list() { +cat << EOF +#include +#include + +/* System calls for 32-bit kernels only */ +#if BITS_PER_LONG == 64 +#define __IGNORE_sendfile64 +#define __IGNORE_ftruncate64 +#define __IGNORE_truncate64 +#define __IGNORE_stat64 +#define __IGNORE_lstat64 +#define __IGNORE_fstat64 +#define __IGNORE_fcntl64 +#define __IGNORE_fadvise64_64 +#define __IGNORE_fstatat64 +#define __IGNORE_fstatfs64 +#define __IGNORE_statfs64 +#endif + +/* i386-specific or historical system calls */ +#define __IGNORE_break +#define __IGNORE_stty +#define __IGNORE_gtty +#define __IGNORE_ftime +#define __IGNORE_prof +#define __IGNORE_lock +#define __IGNORE_mpx +#define __IGNORE_ulimit +#define __IGNORE_profil +#define __IGNORE_ioperm +#define __IGNORE_iopl +#define __IGNORE_idle +#define __IGNORE_modify_ldt +#define __IGNORE_ugetrlimit +#define __IGNORE_mmap2 +#define __IGNORE_vm86 +#define __IGNORE_vm86old +#define __IGNORE_set_thread_area +#define __IGNORE_get_thread_area +#define __IGNORE_madvise1 +#define __IGNORE_oldstat +#define __IGNORE_oldfstat +#define __IGNORE_oldlstat +#define __IGNORE_oldolduname +#define __IGNORE_olduname +#define __IGNORE_umount2 +#define __IGNORE_umount +#define __IGNORE_waitpid +#define __IGNORE_stime +#define __IGNORE_nice +#define __IGNORE_signal +#define __IGNORE_sigaction +#define __IGNORE_sgetmask +#define __IGNORE_sigsuspend +#define __IGNORE_sigpending +#define __IGNORE_ssetmask +#define __IGNORE_readdir +#define __IGNORE_socketcall +#define __IGNORE_ipc +#define __IGNORE_sigreturn +#define __IGNORE_sigprocmask +#define __IGNORE_bdflush +#define __IGNORE__llseek +#define __IGNORE__newselect +#define __IGNORE_create_module +#define __IGNORE_delete_module +#define __IGNORE_query_module +#define __IGNORE_get_kernel_syms +/* ... including the "new" 32-bit uid syscalls */ +#define __IGNORE_lchown32 +#define __IGNORE_getuid32 +#define __IGNORE_getgid32 +#define __IGNORE_geteuid32 +#define __IGNORE_getegid32 +#define __IGNORE_setreuid32 +#define __IGNORE_setregid32 +#define __IGNORE_getgroups32 +#define __IGNORE_setgroups32 +#define __IGNORE_fchown32 +#define __IGNORE_setresuid32 +#define __IGNORE_getresuid32 +#define __IGNORE_setresgid32 +#define __IGNORE_getresgid32 +#define __IGNORE_chown32 +#define __IGNORE_setuid32 +#define __IGNORE_setgid32 +#define __IGNORE_setfsuid32 +#define __IGNORE_setfsgid32 + +/* Unmerged syscalls for AFS, STREAMS, etc. */ +#define __IGNORE_afs_syscall +#define __IGNORE_getpmsg +#define __IGNORE_putpmsg +#define __IGNORE_vserver +EOF +} + +syscall_list() { +sed -n -e '/^\#define/ { s/[^_]*__NR_\([^[:space:]]*\).*/\ +\#if !defined \(__NR_\1\) \&\& !defined \(__IGNORE_\1\)\ +\#warning syscall \1 not implemented\ +\#endif/p }' $1 +} + +(ignore_list && syscall_list ${srctree}/include/asm-i386/unistd.h) | \ +$* -E -x c - > /dev/null diff --git a/scripts/cleanfile b/scripts/cleanfile new file mode 100755 index 0000000..f1ba8aa --- /dev/null +++ b/scripts/cleanfile @@ -0,0 +1,126 @@ +#!/usr/bin/perl -w +# +# Clean a text file -- or directory of text files -- of stealth whitespace. +# WARNING: this can be a highly destructive operation. Use with caution. +# + +use bytes; +use File::Basename; + +# +# Clean up space-tab sequences, either by removing spaces or +# replacing them with tabs. +sub clean_space_tabs($) +{ + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($lo) = ''; + my $pos = 0; + my $nsp = 0; + my($i, $c); + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li, $i, 1); + if ($c eq "\t") { + my $npos = ($pos+$nsp+8) & ~7; + my $ntab = ($npos >> 3) - ($pos >> 3); + $lo .= "\t" x $ntab; + $pos = $npos; + $nsp = 0; + } elsif ($c eq "\n" || $c eq "\r") { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos = 0; + } elsif ($c eq " ") { + $nsp++; + } else { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos++; + } + } + $lo .= " " x $nsp; + return $lo; +} + +$name = basename($0); + +foreach $f ( @ARGV ) { + print STDERR "$name: $f\n"; + + if (! -f $f) { + print STDERR "$f: not a file\n"; + next; + } + + if (!open(FILE, '+<', $f)) { + print STDERR "$name: Cannot open file: $f: $!\n"; + next; + } + + binmode FILE; + + # First, verify that it is not a binary file; consider any file + # with a zero byte to be a binary file. Is there any better, or + # additional, heuristic that should be applied? + $is_binary = 0; + + while (read(FILE, $data, 65536) > 0) { + if ($data =~ /\0/) { + $is_binary = 1; + last; + } + } + + if ($is_binary) { + print STDERR "$name: $f: binary file\n"; + next; + } + + seek(FILE, 0, 0); + + $in_bytes = 0; + $out_bytes = 0; + $blank_bytes = 0; + + @blanks = (); + @lines = (); + + while ( defined($line = ) ) { + $in_bytes += length($line); + $line =~ s/[ \t\r]*$//; # Remove trailing spaces + $line = clean_space_tabs($line); + + if ( $line eq "\n" ) { + push(@blanks, $line); + $blank_bytes += length($line); + } else { + push(@lines, @blanks); + $out_bytes += $blank_bytes; + push(@lines, $line); + $out_bytes += length($line); + @blanks = (); + $blank_bytes = 0; + } + } + + # Any blanks at the end of the file are discarded + + if ($in_bytes != $out_bytes) { + # Only write to the file if changed + seek(FILE, 0, 0); + print FILE @lines; + + if ( !defined($where = tell(FILE)) || + !truncate(FILE, $where) ) { + die "$name: Failed to truncate modified file: $f: $!\n"; + } + } + + close(FILE); +} diff --git a/scripts/cleanpatch b/scripts/cleanpatch new file mode 100755 index 0000000..a53f987 --- /dev/null +++ b/scripts/cleanpatch @@ -0,0 +1,206 @@ +#!/usr/bin/perl -w +# +# Clean a patch file -- or directory of patch files -- of stealth whitespace. +# WARNING: this can be a highly destructive operation. Use with caution. +# + +use bytes; +use File::Basename; + +# +# Clean up space-tab sequences, either by removing spaces or +# replacing them with tabs. +sub clean_space_tabs($) +{ + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($lo) = ''; + my $pos = 0; + my $nsp = 0; + my($i, $c); + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li, $i, 1); + if ($c eq "\t") { + my $npos = ($pos+$nsp+8) & ~7; + my $ntab = ($npos >> 3) - ($pos >> 3); + $lo .= "\t" x $ntab; + $pos = $npos; + $nsp = 0; + } elsif ($c eq "\n" || $c eq "\r") { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos = 0; + } elsif ($c eq " ") { + $nsp++; + } else { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos++; + } + } + $lo .= " " x $nsp; + return $lo; +} + +$name = basename($0); + +foreach $f ( @ARGV ) { + print STDERR "$name: $f\n"; + + if (! -f $f) { + print STDERR "$f: not a file\n"; + next; + } + + if (!open(FILE, '+<', $f)) { + print STDERR "$name: Cannot open file: $f: $!\n"; + next; + } + + binmode FILE; + + # First, verify that it is not a binary file; consider any file + # with a zero byte to be a binary file. Is there any better, or + # additional, heuristic that should be applied? + $is_binary = 0; + + while (read(FILE, $data, 65536) > 0) { + if ($data =~ /\0/) { + $is_binary = 1; + last; + } + } + + if ($is_binary) { + print STDERR "$name: $f: binary file\n"; + next; + } + + seek(FILE, 0, 0); + + $in_bytes = 0; + $out_bytes = 0; + + @lines = (); + + $in_hunk = 0; + $err = 0; + + while ( defined($line = ) ) { + $in_bytes += length($line); + + if (!$in_hunk) { + if ($line =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { + $minus_lines = $2; + $plus_lines = $4; + if ($minus_lines || $plus_lines) { + $in_hunk = 1; + @hunk_lines = ($line); + } + } else { + push(@lines, $line); + $out_bytes += length($line); + } + } else { + # We're in a hunk + + if ($line =~ /^\+/) { + $plus_lines--; + + $text = substr($line, 1); + $text =~ s/[ \t\r]*$//; # Remove trailing spaces + $text = clean_space_tabs($text); + + push(@hunk_lines, '+'.$text); + } elsif ($line =~ /^\-/) { + $minus_lines--; + push(@hunk_lines, $line); + } elsif ($line =~ /^ /) { + $plus_lines--; + $minus_lines--; + push(@hunk_lines, $line); + } else { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + last; + } + + if ($plus_lines < 0 || $minus_lines < 0) { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + last; + } elsif ($plus_lines == 0 && $minus_lines == 0) { + # End of a hunk. Process this hunk. + my $i; + my $l; + my @h = (); + my $adj = 0; + my $done = 0; + + for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) { + $l = $hunk_lines[$i]; + if (!$done && $l eq "+\n") { + $adj++; # Skip this line + } elsif ($l =~ /^[ +]/) { + $done = 1; + unshift(@h, $l); + } else { + unshift(@h, $l); + } + } + + $l = $hunk_lines[0]; # Hunk header + undef @hunk_lines; # Free memory + + if ($adj) { + die unless + ($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/); + my $mstart = $1; + my $mlin = $2; + my $pstart = $3; + my $plin = $4; + my $tail = $5; # doesn't include the final newline + + $l = sprintf("@@ -%d,%d +%d,%d @@%s\n", + $mstart, $mlin, $pstart, $plin-$adj, + $tail); + } + unshift(@h, $l); + + # Transfer to the output array + foreach $l (@h) { + $out_bytes += length($l); + push(@lines, $l); + } + + $in_hunk = 0; + } + } + } + + if ($in_hunk) { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + } + + if (!$err) { + if ($in_bytes != $out_bytes) { + # Only write to the file if changed + seek(FILE, 0, 0); + print FILE @lines; + + if ( !defined($where = tell(FILE)) || + !truncate(FILE, $where) ) { + die "$name: Failed to truncate modified file: $f: $!\n"; + } + } + } + + close(FILE); +} diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 7e7e147..2e421bd 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -140,6 +140,7 @@ endif clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c +clean-files += mconf qconf gconf # Needed for systems without gettext KBUILD_HAVE_NLS := $(shell \ diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 9b2706a..8a07ee4 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -64,6 +64,7 @@ int zconf_lineno(void); char *zconf_curname(void); /* confdata.c */ +const char *conf_get_configname(void); char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index fd695e1..7e17eba 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -188,6 +188,7 @@ int on_key_esc(WINDOW *win); int on_key_resize(void); void init_dialog(const char *backtitle); +void set_dialog_backtitle(const char *backtitle); void reset_dialog(void); void end_dialog(void); void attr_clear(WINDOW * win, int height, int width, chtype attr); diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index d54440f..a1bddef 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -272,6 +272,11 @@ void init_dialog(const char *backtitle) color_setup(getenv("MENUCONFIG_COLOR")); } +void set_dialog_backtitle(const char *backtitle) +{ + dlg.backtitle = backtitle; +} + void reset_dialog(void) { initscr(); /* Init curses */ @@ -336,7 +341,7 @@ void print_autowrap(WINDOW * win, const newl = 1; word = tempstr; while (word && *word) { - sp = index(word, ' '); + sp = strchr(word, ' '); if (sp) *sp++ = 0; @@ -348,7 +353,7 @@ void print_autowrap(WINDOW * win, const if (wlen > room || (newl && wlen < 4 && sp && wlen + 1 + strlen(sp) > room - && (!(sp2 = index(sp, ' ')) + && (!(sp2 = strchr(sp, ' ')) || wlen + 1 + (sp2 - sp) > room))) { cur_y++; cur_x = x; diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 3f9a132..d0e4fa5 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -26,7 +26,6 @@ #define LKC_DIRECT_LINK #include "lkc.h" #include "lxdialog/dialog.h" -static char menu_backtitle[128]; static const char mconf_readme[] = N_( "Overview\n" "--------\n" @@ -271,7 +270,6 @@ search_help[] = N_( " USB$ => find all CONFIG_ symbols ending with USB\n" "\n"); -static char filename[PATH_MAX+1] = ".config"; static int indent; static struct termios ios_org; static int rows = 0, cols = 0; @@ -395,6 +393,28 @@ static struct gstr get_relations_str(str return res; } +static char filename[PATH_MAX+1]; +static void set_config_filename(const char *config_filename) +{ + static char menu_backtitle[PATH_MAX+128]; + int size; + struct symbol *sym; + + sym = sym_lookup("KERNELVERSION", 0); + sym_calc_value(sym); + size = snprintf(menu_backtitle, sizeof(menu_backtitle), + _("%s - Linux Kernel v%s Configuration"), + config_filename, sym_get_string_value(sym)); + if (size >= sizeof(menu_backtitle)) + menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + set_dialog_backtitle(menu_backtitle); + + size = snprintf(filename, sizeof(filename), "%s", config_filename); + if (size >= sizeof(filename)) + filename[sizeof(filename)-1] = '\0'; +} + + static void search_conf(void) { struct symbol **sym_arr; @@ -816,8 +836,10 @@ static void conf_load(void) case 0: if (!dialog_input_result[0]) return; - if (!conf_read(dialog_input_result)) + if (!conf_read(dialog_input_result)) { + set_config_filename(dialog_input_result); return; + } show_textbox(NULL, _("File does not exist!"), 5, 38); break; case 1: @@ -840,8 +862,10 @@ static void conf_save(void) case 0: if (!dialog_input_result[0]) return; - if (!conf_write(dialog_input_result)) + if (!conf_write(dialog_input_result)) { + set_config_filename(dialog_input_result); return; + } show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); break; case 1: @@ -860,7 +884,6 @@ static void conf_cleanup(void) int main(int ac, char **av) { - struct symbol *sym; char *mode; int res; @@ -871,11 +894,6 @@ int main(int ac, char **av) conf_parse(av[1]); conf_read(NULL); - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); - sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), - sym_get_string_value(sym)); - mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) @@ -886,7 +904,8 @@ int main(int ac, char **av) atexit(conf_cleanup); init_wsize(); reset_dialog(); - init_dialog(menu_backtitle); + init_dialog(NULL); + set_config_filename(conf_get_configname()); do { conf(&rootmenu); dialog_clear(); @@ -903,7 +922,7 @@ int main(int ac, char **av) switch (res) { case 0: - if (conf_write(NULL)) { + if (conf_write(filename)) { fprintf(stderr, _("\n\n" "Error during writing of the kernel configuration.\n" "Your kernel configuration changes were NOT saved." diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 512c2f5..f2a23a9 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1182,7 +1182,7 @@ void ConfigInfoView::contentsContextMenu Parent::contentsContextMenuEvent(e); } -ConfigSearchWindow::ConfigSearchWindow(QWidget* parent, const char *name) +ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) : Parent(parent, name), result(NULL) { setCaption("Search Config"); @@ -1206,6 +1206,9 @@ ConfigSearchWindow::ConfigSearchWindow(Q info = new ConfigInfoView(split, name); connect(list->list, SIGNAL(menuChanged(struct menu *)), info, SLOT(setInfo(struct menu *))); + connect(list->list, SIGNAL(menuChanged(struct menu *)), + parent, SLOT(setMenuLink(struct menu *))); + layout1->addWidget(split); if (name) { diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 6fc1c5f..b3b5657 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -279,7 +279,7 @@ class ConfigSearchWindow : public QDialo Q_OBJECT typedef class QDialog Parent; public: - ConfigSearchWindow(QWidget* parent, const char *name = 0); + ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); public slots: void saveSettings(void); diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index 82d0af4..a8740df 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -18,19 +18,32 @@ fi # Do not expand names set -f -if [ -r .version ]; then - VERSION=`cat .version` +# Fix the language to get consistent output +LC_ALL=C +export LC_ALL + +if [ -z "$KBUILD_BUILD_VERSION" ]; then + if [ -r .version ]; then + VERSION=`cat .version` + else + VERSION=0 + echo 0 > .version + fi else - VERSION=0 - echo 0 > .version + VERSION=$KBUILD_BUILD_VERSION fi +if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then + TIMESTAMP=`date` +else + TIMESTAMP=$KBUILD_BUILD_TIMESTAMP +fi UTS_VERSION="#$VERSION" CONFIG_FLAGS="" if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi -UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS `LC_ALL=C LANG=C date`" +UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP" # Truncate to maximum length @@ -46,7 +59,7 @@ ( echo /\* This file is auto generated, echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" - echo \#define LINUX_COMPILE_TIME \"`LC_ALL=C LANG=C date +%T`\" + echo \#define LINUX_COMPILE_TIME \"`date +%T`\" echo \#define LINUX_COMPILE_BY \"`whoami`\" echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\" @@ -58,7 +71,7 @@ ( echo /\* This file is auto generated, echo \#define LINUX_COMPILE_DOMAIN fi - echo \#define LINUX_COMPILER \"`LC_ALL=C LANG=C $CC -v 2>&1 | tail -n 1`\" + echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" ) > .tmpcompile # Only replace the real compile.h if the new one is different, diff --git a/scripts/mkuboot.sh b/scripts/mkuboot.sh index 4b06c5e..2e3d3cd 100755 --- a/scripts/mkuboot.sh +++ b/scripts/mkuboot.sh @@ -4,7 +4,7 @@ # # Build U-Boot image when `mkimage' tool is available. # -MKIMAGE=$(type -path ${CROSS_COMPILE}mkimage) +MKIMAGE=$(type -path "${CROSS_COMPILE}mkimage") if [ -z "${MKIMAGE}" ]; then MKIMAGE=$(type -path mkimage) diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b2f73ff..ed1244d 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -37,7 +37,6 @@ typedef unsigned char __u8; * even potentially has different endianness and word sizes, since * we handle those differences explicitly below */ #include "../../include/linux/mod_devicetable.h" -#include "../../include/linux/input.h" #define ADD(str, sep, cond, field) \ do { \ @@ -416,31 +415,33 @@ static int do_input_entry(const char *fi sprintf(alias + strlen(alias), "-e*"); if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT) - do_input(alias, id->evbit, 0, EV_MAX); + do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX); sprintf(alias + strlen(alias), "k*"); if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT) - do_input(alias, id->keybit, KEY_MIN_INTERESTING, KEY_MAX); + do_input(alias, id->keybit, + INPUT_DEVICE_ID_KEY_MIN_INTERESTING, + INPUT_DEVICE_ID_KEY_MAX); sprintf(alias + strlen(alias), "r*"); if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT) - do_input(alias, id->relbit, 0, REL_MAX); + do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX); sprintf(alias + strlen(alias), "a*"); if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT) - do_input(alias, id->absbit, 0, ABS_MAX); + do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX); sprintf(alias + strlen(alias), "m*"); if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT) - do_input(alias, id->mscbit, 0, MSC_MAX); + do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); sprintf(alias + strlen(alias), "l*"); if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT) - do_input(alias, id->ledbit, 0, LED_MAX); + do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX); sprintf(alias + strlen(alias), "s*"); if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT) - do_input(alias, id->sndbit, 0, SND_MAX); + do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX); sprintf(alias + strlen(alias), "f*"); if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT) - do_input(alias, id->ffbit, 0, FF_MAX); + do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX); sprintf(alias + strlen(alias), "w*"); if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT) - do_input(alias, id->swbit, 0, SW_MAX); + do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); return 1; } diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 65bdfdb..e7d3d53 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -55,6 +55,17 @@ void warn(const char *fmt, ...) va_end(arglist); } +void merror(const char *fmt, ...) +{ + va_list arglist; + + fprintf(stderr, "ERROR: "); + + va_start(arglist, fmt); + vfprintf(stderr, fmt, arglist); + va_end(arglist); +} + static int is_vmlinux(const char *modname) { const char *myname; @@ -333,10 +344,10 @@ void release_file(void *file, unsigned l munmap(file, size); } -static void parse_elf(struct elf_info *info, const char *filename) +static int parse_elf(struct elf_info *info, const char *filename) { unsigned int i; - Elf_Ehdr *hdr = info->hdr; + Elf_Ehdr *hdr; Elf_Shdr *sechdrs; Elf_Sym *sym; @@ -346,9 +357,18 @@ static void parse_elf(struct elf_info *i exit(1); } info->hdr = hdr; - if (info->size < sizeof(*hdr)) - goto truncated; - + if (info->size < sizeof(*hdr)) { + /* file too small, assume this is an empty .o file */ + return 0; + } + /* Is this a valid ELF file? */ + if ((hdr->e_ident[EI_MAG0] != ELFMAG0) || + (hdr->e_ident[EI_MAG1] != ELFMAG1) || + (hdr->e_ident[EI_MAG2] != ELFMAG2) || + (hdr->e_ident[EI_MAG3] != ELFMAG3)) { + /* Not an ELF file - silently ignore it */ + return 0; + } /* Fix endianness in ELF header */ hdr->e_shoff = TO_NATIVE(hdr->e_shoff); hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); @@ -371,8 +391,10 @@ static void parse_elf(struct elf_info *i = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; const char *secname; - if (sechdrs[i].sh_offset > info->size) - goto truncated; + if (sechdrs[i].sh_offset > info->size) { + fatal("%s is truncated. sechdrs[i].sh_offset=%u > sizeof(*hrd)=%ul\n", filename, (unsigned int)sechdrs[i].sh_offset, sizeof(*hdr)); + return 0; + } secname = secstrings + sechdrs[i].sh_name; if (strcmp(secname, ".modinfo") == 0) { info->modinfo = (void *)hdr + sechdrs[i].sh_offset; @@ -407,10 +429,7 @@ static void parse_elf(struct elf_info *i sym->st_value = TO_NATIVE(sym->st_value); sym->st_size = TO_NATIVE(sym->st_size); } - return; - - truncated: - fatal("%s is truncated.\n", filename); + return 1; } static void parse_elf_finish(struct elf_info *info) @@ -581,9 +600,17 @@ static int strrcmp(const char *s, const * the pattern is identified by: * tosec = .init.text | .exit.text | .init.data * fromsec = .data - * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one + * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console * * Pattern 3: + * Whitelist all references from .pci_fixup* section to .init.text + * This is part of the PCI init when built-in + * + * Pattern 4: + * Whitelist all refereces from .text.head to .init.data + * Whitelist all refereces from .text.head to .init.text + * + * Pattern 5: * Some symbols belong to init section but still it is ok to reference * these from non-init sections as these symbols don't have any memory * allocated for them and symbol address and value are same. So even @@ -591,6 +618,37 @@ static int strrcmp(const char *s, const * For ex. symbols marking the init section boundaries. * This pattern is identified by * refsymname = __init_begin, _sinittext, _einittext + * + * Pattern 6: + * During the early init phase we have references from .init.text to + * .text we have an intended section mismatch - do not warn about it. + * See kernel_init() in init/main.c + * tosec = .init.text + * fromsec = .text + * atsym = kernel_init + * + * Pattern 7: + * Logos used in drivers/video/logo reside in __initdata but the + * funtion that references them are EXPORT_SYMBOL() so cannot be + * marker __init. So we whitelist them here. + * The pattern is: + * tosec = .init.data + * fromsec = .text* + * refsymname = logo_ + * + * Pattern 8: + * Symbols exported may be marked __init because we need to + * export functions that are only used by init function. + * The pattern is: + * tosec = .init.text + * fromsec = __ksymtab* + * + * Pattern 9: + * Symbols contained in .paravirtprobe amy safely reference + * .init.text. + * The pattern is: + * tosec = .init.text + * fromsec = .paravirtprobe **/ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, @@ -641,25 +699,44 @@ static int secref_whitelist(const char * if (f1 && f2) return 1; - /* Whitelist all references from .pci_fixup section if vmlinux - * Whitelist all refereces from .text.head to .init.data if vmlinux - * Whitelist all refereces from .text.head to .init.text if vmlinux - */ - if (is_vmlinux(modname)) { - if ((strcmp(fromsec, ".pci_fixup") == 0) && - (strcmp(tosec, ".init.text") == 0)) + /* Check for pattern 3 */ + if ((strncmp(fromsec, ".pci_fixup", strlen(".pci_fixup")) == 0) && + (strcmp(tosec, ".init.text") == 0)) + return 1; + + /* Check for pattern 4 */ + if ((strcmp(fromsec, ".text.head") == 0) && + ((strcmp(tosec, ".init.data") == 0) || + (strcmp(tosec, ".init.text") == 0))) + return 1; + + /* Check for pattern 5 */ + for (s = pat3refsym; *s; s++) + if (strcmp(refsymname, *s) == 0) + return 1; + + /* Check for pattern 6 */ + if ((strcmp(tosec, ".init.text") == 0) && + (strcmp(fromsec, ".text") == 0) && + (strcmp(refsymname, "kernel_init") == 0)) return 1; - if ((strcmp(fromsec, ".text.head") == 0) && - ((strcmp(tosec, ".init.data") == 0) || - (strcmp(tosec, ".init.text") == 0))) + /* Check for pattern 7 */ + if ((strcmp(tosec, ".init.data") == 0) && + (strncmp(fromsec, ".text", strlen(".text")) == 0) && + (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) + return 1; + + /* Check for pattern 8 */ + if ((strcmp(tosec, ".init.text") == 0) && + (strncmp(fromsec, "__ksymtab", strlen("__ksymtab")) == 0)) + return 1; + + /* Check for pattern 9 */ + if ((strcmp(tosec, ".init.text") == 0) && + (strcmp(fromsec, ".paravirtprobe") == 0)) return 1; - /* Check for pattern 3 */ - for (s = pat3refsym; *s; s++) - if (strcmp(refsymname, *s) == 0) - return 1; - } return 0; } @@ -1089,7 +1166,8 @@ static void read_symbols(char *modname) struct elf_info info = { }; Elf_Sym *sym; - parse_elf(&info, modname); + if (!parse_elf(&info, modname)) + return; mod = new_module(modname); @@ -1264,9 +1342,14 @@ static int add_versions(struct buffer *b exp = find_symbol(s->name); if (!exp || exp->module == mod) { if (have_vmlinux && !s->weak) { - warn("\"%s\" [%s.ko] undefined!\n", - s->name, mod->name); - err = warn_unresolved ? 0 : 1; + if (warn_unresolved) { + warn("\"%s\" [%s.ko] undefined!\n", + s->name, mod->name); + } else { + merror("\"%s\" [%s.ko] undefined!\n", + s->name, mod->name); + err = 1; + } } continue; } @@ -1317,6 +1400,7 @@ static void add_depends(struct buffer *b buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n"); buf_printf(b, "\"depends="); for (s = mod->unres; s; s = s->next) { + const char *p; if (!s->module) continue; @@ -1324,8 +1408,11 @@ static void add_depends(struct buffer *b continue; s->module->seen = 1; - buf_printf(b, "%s%s", first ? "" : ",", - strrchr(s->module->name, '/') + 1); + if ((p = strrchr(s->module->name, '/')) != NULL) + p++; + else + p = s->module->name; + buf_printf(b, "%s%s", first ? "" : ",", p); first = 0; } buf_printf(b, "\";\n"); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index d398c61..0858caa 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -145,3 +145,4 @@ void release_file(void *file, unsigned l void fatal(const char *fmt, ...); void warn(const char *fmt, ...); +void merror(const char *fmt, ...); diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 8a28756..6873d5a 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -397,10 +397,9 @@ void get_src_version(const char *modname (int) strlen(basename) - 2, basename); file = grab_file(filelist, &len); - if (!file) { - warn("could not find versions for %s\n", filelist); + if (!file) + /* not a module or .mod file missing - ignore */ return; - } sources = strchr(file, '\n'); if (!sources) {