aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-06-01 11:55:52 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-06-01 11:55:52 -0400
commit1f73897861b8ef0be64ff4b801f8d6f830f683b5 (patch)
treeb4bae8f12e1422113910d8cb00a19d010dc4a52f
parentb904d7131d116900524bd36ec170dcd97846bfd3 (diff)
parent64ffc9ff424c65adcffe7d590018cc75e2d5d42a (diff)
Merge branch 'for-35' of git://repo.or.cz/linux-kbuild
* 'for-35' of git://repo.or.cz/linux-kbuild: (81 commits) kbuild: Revert part of e8d400a to resolve a conflict kbuild: Fix checking of scm-identifier variable gconfig: add support to show hidden options that have prompts menuconfig: add support to show hidden options which have prompts gconfig: remove show_debug option gconfig: remove dbg_print_ptype() and dbg_print_stype() kconfig: fix zconfdump() kconfig: some small fixes add random binaries to .gitignore kbuild: Include gen_initramfs_list.sh and the file list in the .d file kconfig: recalc symbol value before showing search results .gitignore: ignore *.lzo files headerdep: perlcritic warning scripts/Makefile.lib: Align the output of LZO kbuild: Generate modules.builtin in make modules_install Revert "kbuild: specify absolute paths for cscope" kbuild: Do not unnecessarily regenerate modules.builtin headers_install: use local file handles headers_check: fix perl warnings export_report: fix perl warnings ...
-rw-r--r--.gitignore1
-rw-r--r--Documentation/.gitignore7
-rw-r--r--Documentation/kbuild/kbuild.txt6
-rw-r--r--Documentation/mutex-design.txt4
-rw-r--r--MAINTAINERS5
-rw-r--r--Makefile65
-rw-r--r--arch/frv/kernel/break.S4
-rw-r--r--arch/frv/kernel/entry.S2
-rw-r--r--arch/frv/kernel/head.S2
-rw-r--r--arch/frv/kernel/vmlinux.lds.S10
-rw-r--r--arch/frv/mm/tlb-miss.S2
-rw-r--r--arch/h8300/boot/compressed/head.S2
-rw-r--r--arch/h8300/boot/compressed/vmlinux.lds2
-rw-r--r--arch/ia64/include/asm/asmmacro.h12
-rw-r--r--arch/ia64/include/asm/cache.h2
-rw-r--r--arch/ia64/include/asm/percpu.h2
-rw-r--r--arch/ia64/kernel/Makefile.gate2
-rw-r--r--arch/ia64/kernel/gate-data.S2
-rw-r--r--arch/ia64/kernel/gate.S8
-rw-r--r--arch/ia64/kernel/gate.lds.S10
-rw-r--r--arch/ia64/kernel/init_task.c2
-rw-r--r--arch/ia64/kernel/ivt.S2
-rw-r--r--arch/ia64/kernel/minstate.h4
-rw-r--r--arch/ia64/kernel/paravirtentry.S2
-rw-r--r--arch/ia64/kernel/vmlinux.lds.S28
-rw-r--r--arch/ia64/kvm/vmm_ivt.S2
-rw-r--r--arch/ia64/scripts/unwcheck.py2
-rw-r--r--arch/ia64/xen/gate-data.S2
-rw-r--r--arch/ia64/xen/xensetup.S2
-rw-r--r--arch/m68knommu/kernel/vmlinux.lds.S4
-rw-r--r--arch/m68knommu/platform/68360/head-ram.S2
-rw-r--r--arch/m68knommu/platform/68360/head-rom.S2
-rw-r--r--arch/mips/lasat/image/head.S2
-rw-r--r--arch/mips/lasat/image/romscript.normal2
-rw-r--r--arch/parisc/include/asm/cache.h2
-rw-r--r--arch/parisc/include/asm/system.h2
-rw-r--r--arch/parisc/kernel/head.S2
-rw-r--r--arch/parisc/kernel/init_task.c6
-rw-r--r--arch/parisc/kernel/vmlinux.lds.S12
-rw-r--r--arch/powerpc/Makefile5
-rw-r--r--arch/powerpc/include/asm/cache.h2
-rw-r--r--arch/powerpc/include/asm/page_64.h8
-rw-r--r--arch/powerpc/kernel/vmlinux.lds.S10
-rw-r--r--arch/s390/include/asm/cache.h2
-rw-r--r--arch/s390/kernel/swsusp_asm64.S2
-rw-r--r--arch/sh/boot/compressed/vmlinux.scr2
-rw-r--r--arch/sh/include/asm/cache.h2
-rw-r--r--arch/sparc/boot/btfixupprep.c2
-rw-r--r--arch/sparc/include/asm/cache.h2
-rw-r--r--arch/um/kernel/dyn.lds.S2
-rw-r--r--arch/um/kernel/init_task.c2
-rw-r--r--arch/um/kernel/uml.lds.S2
-rw-r--r--arch/x86/.gitignore3
-rw-r--r--arch/x86/boot/compressed/mkpiggy.c2
-rw-r--r--arch/x86/boot/compressed/vmlinux.lds.S4
-rw-r--r--arch/x86/include/asm/cache.h2
-rw-r--r--arch/x86/kernel/acpi/wakeup_32.S2
-rw-r--r--arch/x86/kernel/init_task.c2
-rw-r--r--arch/x86/kernel/setup_percpu.c2
-rw-r--r--arch/x86/kernel/vmlinux.lds.S4
-rw-r--r--include/asm-generic/percpu.h10
-rw-r--r--include/asm-generic/vmlinux.lds.h38
-rw-r--r--include/linux/cache.h2
-rw-r--r--include/linux/init.h2
-rw-r--r--include/linux/init_task.h2
-rw-r--r--include/linux/linkage.h8
-rw-r--r--include/linux/percpu-defs.h4
-rw-r--r--include/linux/spinlock.h2
-rw-r--r--init/Kconfig8
-rw-r--r--kernel/module.c2
-rw-r--r--scripts/Makefile.build2
-rw-r--r--scripts/Makefile.lib2
-rwxr-xr-xscripts/checkincludes.pl24
-rwxr-xr-xscripts/checkstack.pl16
-rwxr-xr-xscripts/checkversion.pl23
-rwxr-xr-xscripts/decodecode48
-rw-r--r--scripts/export_report.pl37
-rw-r--r--scripts/gen_initramfs_list.sh3
-rw-r--r--scripts/genksyms/genksyms.c4
-rwxr-xr-xscripts/headerdep.pl3
-rw-r--r--scripts/headers_check.pl11
-rw-r--r--scripts/headers_install.pl19
-rw-r--r--scripts/kallsyms.c6
-rw-r--r--scripts/kconfig/Makefile16
-rw-r--r--scripts/kconfig/expr.c27
-rw-r--r--scripts/kconfig/expr.h5
-rw-r--r--scripts/kconfig/gconf.c113
-rw-r--r--scripts/kconfig/gconf.glade26
-rw-r--r--scripts/kconfig/lkc.h7
-rw-r--r--scripts/kconfig/lkc_proto.h6
-rw-r--r--scripts/kconfig/lxdialog/inputbox.c4
-rw-r--r--scripts/kconfig/lxdialog/menubox.c22
-rw-r--r--scripts/kconfig/mconf.c36
-rw-r--r--scripts/kconfig/menu.c28
-rw-r--r--scripts/kconfig/nconf.c1568
-rw-r--r--scripts/kconfig/nconf.gui.c617
-rw-r--r--scripts/kconfig/nconf.h95
-rw-r--r--scripts/kconfig/symbol.c30
-rw-r--r--scripts/kconfig/util.c2
-rw-r--r--scripts/kconfig/zconf.tab.c_shipped25
-rw-r--r--scripts/kconfig/zconf.y25
-rw-r--r--scripts/markup_oops.pl54
-rwxr-xr-xscripts/mkcompile_h5
-rw-r--r--scripts/mod/modpost.c152
-rwxr-xr-xscripts/namespace.pl65
-rw-r--r--scripts/package/builddeb2
-rwxr-xr-xscripts/package/mkspec2
-rw-r--r--scripts/profile2linkerlist.pl8
-rw-r--r--scripts/rt-tester/rt-tester.py2
-rwxr-xr-xscripts/show_delta2
-rwxr-xr-xscripts/tags.sh45
111 files changed, 3023 insertions, 538 deletions
diff --git a/.gitignore b/.gitignore
index a2939fc10b22..8faa6c02b39e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,7 @@ modules.builtin
28*.gz 28*.gz
29*.bz2 29*.bz2
30*.lzma 30*.lzma
31*.lzo
31*.patch 32*.patch
32*.gcno 33*.gcno
33 34
diff --git a/Documentation/.gitignore b/Documentation/.gitignore
new file mode 100644
index 000000000000..bcd907b4141f
--- /dev/null
+++ b/Documentation/.gitignore
@@ -0,0 +1,7 @@
1filesystems/dnotify_test
2laptops/dslm
3timers/hpet_example
4vm/hugepage-mmap
5vm/hugepage-shm
6vm/map_hugetlb
7
diff --git a/Documentation/kbuild/kbuild.txt b/Documentation/kbuild/kbuild.txt
index 6f8c1cabbc5d..634c625da8ce 100644
--- a/Documentation/kbuild/kbuild.txt
+++ b/Documentation/kbuild/kbuild.txt
@@ -65,7 +65,7 @@ CROSS_COMPILE
65Specify an optional fixed part of the binutils filename. 65Specify an optional fixed part of the binutils filename.
66CROSS_COMPILE can be a part of the filename or the full path. 66CROSS_COMPILE can be a part of the filename or the full path.
67 67
68CROSS_COMPILE is also used for ccache is some setups. 68CROSS_COMPILE is also used for ccache in some setups.
69 69
70CF 70CF
71-------------------------------------------------- 71--------------------------------------------------
@@ -162,3 +162,7 @@ For tags/TAGS/cscope targets, you can specify more than one arch
162to be included in the databases, separated by blank space. E.g.: 162to be included in the databases, separated by blank space. E.g.:
163 163
164 $ make ALLSOURCE_ARCHS="x86 mips arm" tags 164 $ make ALLSOURCE_ARCHS="x86 mips arm" tags
165
166To get all available archs you can also specify all. E.g.:
167
168 $ make ALLSOURCE_ARCHS=all tags
diff --git a/Documentation/mutex-design.txt b/Documentation/mutex-design.txt
index aa60d1f627e5..c91ccc0720fa 100644
--- a/Documentation/mutex-design.txt
+++ b/Documentation/mutex-design.txt
@@ -66,14 +66,14 @@ of advantages of mutexes:
66 66
67 c0377ccb <mutex_lock>: 67 c0377ccb <mutex_lock>:
68 c0377ccb: f0 ff 08 lock decl (%eax) 68 c0377ccb: f0 ff 08 lock decl (%eax)
69 c0377cce: 78 0e js c0377cde <.text.lock.mutex> 69 c0377cce: 78 0e js c0377cde <.text..lock.mutex>
70 c0377cd0: c3 ret 70 c0377cd0: c3 ret
71 71
72 the unlocking fastpath is equally tight: 72 the unlocking fastpath is equally tight:
73 73
74 c0377cd1 <mutex_unlock>: 74 c0377cd1 <mutex_unlock>:
75 c0377cd1: f0 ff 00 lock incl (%eax) 75 c0377cd1: f0 ff 00 lock incl (%eax)
76 c0377cd4: 7e 0f jle c0377ce5 <.text.lock.mutex+0x7> 76 c0377cd4: 7e 0f jle c0377ce5 <.text..lock.mutex+0x7>
77 c0377cd6: c3 ret 77 c0377cd6: c3 ret
78 78
79 - 'struct mutex' semantics are well-defined and are enforced if 79 - 'struct mutex' semantics are well-defined and are enforced if
diff --git a/MAINTAINERS b/MAINTAINERS
index 13608bd2e791..2652ebc5ab40 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -3242,7 +3242,7 @@ L: autofs@linux.kernel.org
3242S: Maintained 3242S: Maintained
3243F: fs/autofs4/ 3243F: fs/autofs4/
3244 3244
3245KERNEL BUILD 3245KERNEL BUILD + files below scripts/ (unless maintained elsewhere)
3246M: Michal Marek <mmarek@suse.cz> 3246M: Michal Marek <mmarek@suse.cz>
3247T: git git://repo.or.cz/linux-kbuild.git for-next 3247T: git git://repo.or.cz/linux-kbuild.git for-next
3248T: git git://repo.or.cz/linux-kbuild.git for-linus 3248T: git git://repo.or.cz/linux-kbuild.git for-linus
@@ -3251,6 +3251,9 @@ S: Maintained
3251F: Documentation/kbuild/ 3251F: Documentation/kbuild/
3252F: Makefile 3252F: Makefile
3253F: scripts/Makefile.* 3253F: scripts/Makefile.*
3254F: scripts/basic/
3255F: scripts/mk*
3256F: scripts/package/
3254 3257
3255KERNEL JANITORS 3258KERNEL JANITORS
3256L: kernel-janitors@vger.kernel.org 3259L: kernel-janitors@vger.kernel.org
diff --git a/Makefile b/Makefile
index 6e39ec701cbf..efdc3d0d8e60 100644
--- a/Makefile
+++ b/Makefile
@@ -183,11 +183,14 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
183# CROSS_COMPILE can be set on the command line 183# CROSS_COMPILE can be set on the command line
184# make CROSS_COMPILE=ia64-linux- 184# make CROSS_COMPILE=ia64-linux-
185# Alternatively CROSS_COMPILE can be set in the environment. 185# Alternatively CROSS_COMPILE can be set in the environment.
186# A third alternative is to store a setting in .config so that plain
187# "make" in the configured kernel build directory always uses that.
186# Default value for CROSS_COMPILE is not to prefix executables 188# Default value for CROSS_COMPILE is not to prefix executables
187# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile 189# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
188export KBUILD_BUILDHOST := $(SUBARCH) 190export KBUILD_BUILDHOST := $(SUBARCH)
189ARCH ?= $(SUBARCH) 191ARCH ?= $(SUBARCH)
190CROSS_COMPILE ?= 192CROSS_COMPILE ?=
193CROSS_COMPILE ?= $(CONFIG_CROSS_COMPILE:"%"=%)
191 194
192# Architecture as present in compile.h 195# Architecture as present in compile.h
193UTS_MACHINE := $(ARCH) 196UTS_MACHINE := $(ARCH)
@@ -576,9 +579,6 @@ KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
576# disable invalid "can't wrap" optimizations for signed / pointers 579# disable invalid "can't wrap" optimizations for signed / pointers
577KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow) 580KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
578 581
579# revert to pre-gcc-4.4 behaviour of .eh_frame
580KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
581
582# conserve stack if available 582# conserve stack if available
583KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) 583KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
584 584
@@ -882,9 +882,6 @@ $(sort $(vmlinux-init) $(vmlinux-main)) $(vmlinux-lds): $(vmlinux-dirs) ;
882PHONY += $(vmlinux-dirs) 882PHONY += $(vmlinux-dirs)
883$(vmlinux-dirs): prepare scripts 883$(vmlinux-dirs): prepare scripts
884 $(Q)$(MAKE) $(build)=$@ 884 $(Q)$(MAKE) $(build)=$@
885ifdef CONFIG_MODULES
886 $(Q)$(MAKE) $(modbuiltin)=$@
887endif
888 885
889# Build the kernel release string 886# Build the kernel release string
890# 887#
@@ -907,14 +904,19 @@ endif
907# $(localver) 904# $(localver)
908# localversion* (files without backups, containing '~') 905# localversion* (files without backups, containing '~')
909# $(CONFIG_LOCALVERSION) (from kernel config setting) 906# $(CONFIG_LOCALVERSION) (from kernel config setting)
910# $(localver-auto) (only if CONFIG_LOCALVERSION_AUTO is set) 907# $(LOCALVERSION) (from make command line, if provided)
911# ./scripts/setlocalversion (SCM tag, if one exists) 908# $(localver-extra)
912# $(LOCALVERSION) (from make command line if provided) 909# $(scm-identifier) (unique SCM tag, if one exists)
910# ./scripts/setlocalversion (only with CONFIG_LOCALVERSION_AUTO)
911# .scmversion (only with CONFIG_LOCALVERSION_AUTO)
912# + (only without CONFIG_LOCALVERSION_AUTO
913# and without LOCALVERSION= and
914# repository is at non-tagged commit)
913# 915#
914# Note how the final $(localver-auto) string is included *only* if the 916# For kernels without CONFIG_LOCALVERSION_AUTO compiled from an SCM that has
915# kernel config option CONFIG_LOCALVERSION_AUTO is selected. Also, at the 917# been revised beyond a tagged commit, `+' is appended to the version string
916# moment, only git is supported but other SCMs can edit the script 918# when not overridden by using "make LOCALVERSION=". This indicates that the
917# scripts/setlocalversion and add the appropriate checks as needed. 919# kernel is not a vanilla release version and has been modified.
918 920
919pattern = ".*/localversion[^~]*" 921pattern = ".*/localversion[^~]*"
920string = $(shell cat /dev/null \ 922string = $(shell cat /dev/null \
@@ -923,26 +925,32 @@ string = $(shell cat /dev/null \
923localver = $(subst $(space),, $(string) \ 925localver = $(subst $(space),, $(string) \
924 $(patsubst "%",%,$(CONFIG_LOCALVERSION))) 926 $(patsubst "%",%,$(CONFIG_LOCALVERSION)))
925 927
926# If CONFIG_LOCALVERSION_AUTO is set scripts/setlocalversion is called 928# scripts/setlocalversion is called to create a unique identifier if the source
927# and if the SCM is know a tag from the SCM is appended. 929# is managed by a known SCM and the repository has been revised since the last
928# The appended tag is determined by the SCM used. 930# tagged (release) commit. The format of the identifier is determined by the
931# SCM's implementation.
929# 932#
930# .scmversion is used when generating rpm packages so we do not loose 933# .scmversion is used when generating rpm packages so we do not loose
931# the version information from the SCM when we do the build of the kernel 934# the version information from the SCM when we do the build of the kernel
932# from the copied source 935# from the copied source
933ifdef CONFIG_LOCALVERSION_AUTO
934
935ifeq ($(wildcard .scmversion),) 936ifeq ($(wildcard .scmversion),)
936 _localver-auto = $(shell $(CONFIG_SHELL) \ 937 scm-identifier = $(shell $(CONFIG_SHELL) \
937 $(srctree)/scripts/setlocalversion $(srctree)) 938 $(srctree)/scripts/setlocalversion $(srctree))
938else 939else
939 _localver-auto = $(shell cat .scmversion 2> /dev/null) 940 scm-identifier = $(shell cat .scmversion 2> /dev/null)
940endif 941endif
941 942
942 localver-auto = $(LOCALVERSION)$(_localver-auto) 943ifdef CONFIG_LOCALVERSION_AUTO
944 localver-extra = $(scm-identifier)
945else
946 ifneq ($(scm-identifier),)
947 ifeq ($(LOCALVERSION),)
948 localver-extra = +
949 endif
950 endif
943endif 951endif
944 952
945localver-full = $(localver)$(localver-auto) 953localver-full = $(localver)$(LOCALVERSION)$(localver-extra)
946 954
947# Store (new) KERNELRELASE string in include/config/kernel.release 955# Store (new) KERNELRELASE string in include/config/kernel.release
948kernelrelease = $(KERNELVERSION)$(localver-full) 956kernelrelease = $(KERNELVERSION)$(localver-full)
@@ -1089,11 +1097,16 @@ all: modules
1089PHONY += modules 1097PHONY += modules
1090modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) 1098modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
1091 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order 1099 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
1092 $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.builtin) > $(objtree)/modules.builtin
1093 @$(kecho) ' Building modules, stage 2.'; 1100 @$(kecho) ' Building modules, stage 2.';
1094 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost 1101 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
1095 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild 1102 $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
1096 1103
1104modules.builtin: $(vmlinux-dirs:%=%/modules.builtin)
1105 $(Q)$(AWK) '!x[$$0]++' $^ > $(objtree)/modules.builtin
1106
1107%/modules.builtin: include/config/auto.conf
1108 $(Q)$(MAKE) $(modbuiltin)=$*
1109
1097 1110
1098# Target to prepare building external modules 1111# Target to prepare building external modules
1099PHONY += modules_prepare 1112PHONY += modules_prepare
@@ -1104,7 +1117,7 @@ PHONY += modules_install
1104modules_install: _modinst_ _modinst_post 1117modules_install: _modinst_ _modinst_post
1105 1118
1106PHONY += _modinst_ 1119PHONY += _modinst_
1107_modinst_: 1120_modinst_: modules.builtin
1108 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \ 1121 @if [ -z "`$(DEPMOD) -V 2>/dev/null | grep module-init-tools`" ]; then \
1109 echo "Warning: you may need to install module-init-tools"; \ 1122 echo "Warning: you may need to install module-init-tools"; \
1110 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\ 1123 echo "See http://www.codemonkey.org.uk/docs/post-halloween-2.6.txt";\
@@ -1247,7 +1260,9 @@ help:
1247 @echo ' firmware_install- Install all firmware to INSTALL_FW_PATH' 1260 @echo ' firmware_install- Install all firmware to INSTALL_FW_PATH'
1248 @echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)' 1261 @echo ' (default: $$(INSTALL_MOD_PATH)/lib/firmware)'
1249 @echo ' dir/ - Build all files in dir and below' 1262 @echo ' dir/ - Build all files in dir and below'
1250 @echo ' dir/file.[ois] - Build specified target only' 1263 @echo ' dir/file.[oisS] - Build specified target only'
1264 @echo ' dir/file.lst - Build specified mixed source/assembly target only'
1265 @echo ' (requires a recent binutils and recent build (System.map))'
1251 @echo ' dir/file.ko - Build module including final link' 1266 @echo ' dir/file.ko - Build module including final link'
1252 @echo ' modules_prepare - Set up for building external modules' 1267 @echo ' modules_prepare - Set up for building external modules'
1253 @echo ' tags/TAGS - Generate tags file for editors' 1268 @echo ' tags/TAGS - Generate tags file for editors'
diff --git a/arch/frv/kernel/break.S b/arch/frv/kernel/break.S
index bd0bdf908d93..cbb6958a3147 100644
--- a/arch/frv/kernel/break.S
+++ b/arch/frv/kernel/break.S
@@ -21,7 +21,7 @@
21# 21#
22# the break handler has its own stack 22# the break handler has its own stack
23# 23#
24 .section .bss.stack 24 .section .bss..stack
25 .globl __break_user_context 25 .globl __break_user_context
26 .balign THREAD_SIZE 26 .balign THREAD_SIZE
27__break_stack: 27__break_stack:
@@ -63,7 +63,7 @@ __break_trace_through_exceptions:
63# entry point for Break Exceptions/Interrupts 63# entry point for Break Exceptions/Interrupts
64# 64#
65############################################################################### 65###############################################################################
66 .section .text.break 66 .section .text..break
67 .balign 4 67 .balign 4
68 .globl __entry_break 68 .globl __entry_break
69__entry_break: 69__entry_break:
diff --git a/arch/frv/kernel/entry.S b/arch/frv/kernel/entry.S
index 189397ec012a..63d579bf1c29 100644
--- a/arch/frv/kernel/entry.S
+++ b/arch/frv/kernel/entry.S
@@ -38,7 +38,7 @@
38 38
39#define nr_syscalls ((syscall_table_size)/4) 39#define nr_syscalls ((syscall_table_size)/4)
40 40
41 .section .text.entry 41 .section .text..entry
42 .balign 4 42 .balign 4
43 43
44.macro LEDS val 44.macro LEDS val
diff --git a/arch/frv/kernel/head.S b/arch/frv/kernel/head.S
index b825ef3f2d54..e9a8cc63ac94 100644
--- a/arch/frv/kernel/head.S
+++ b/arch/frv/kernel/head.S
@@ -542,7 +542,7 @@ __head_end:
542 .size _boot, .-_boot 542 .size _boot, .-_boot
543 543
544 # provide a point for GDB to place a break 544 # provide a point for GDB to place a break
545 .section .text.start,"ax" 545 .section .text..start,"ax"
546 .globl _start 546 .globl _start
547 .balign 4 547 .balign 4
548_start: 548_start:
diff --git a/arch/frv/kernel/vmlinux.lds.S b/arch/frv/kernel/vmlinux.lds.S
index cbe811fccfcc..8b973f3cc90e 100644
--- a/arch/frv/kernel/vmlinux.lds.S
+++ b/arch/frv/kernel/vmlinux.lds.S
@@ -57,10 +57,10 @@ SECTIONS
57 _text = .; 57 _text = .;
58 _stext = .; 58 _stext = .;
59 .text : { 59 .text : {
60 *(.text.start) 60 *(.text..start)
61 *(.text.entry) 61 *(.text..entry)
62 *(.text.break) 62 *(.text..break)
63 *(.text.tlbmiss) 63 *(.text..tlbmiss)
64 TEXT_TEXT 64 TEXT_TEXT
65 SCHED_TEXT 65 SCHED_TEXT
66 LOCK_TEXT 66 LOCK_TEXT
@@ -114,7 +114,7 @@ SECTIONS
114 114
115 .sbss : { *(.sbss .sbss.*) } 115 .sbss : { *(.sbss .sbss.*) }
116 .bss : { *(.bss .bss.*) } 116 .bss : { *(.bss .bss.*) }
117 .bss.stack : { *(.bss) } 117 .bss..stack : { *(.bss) }
118 118
119 __bss_stop = .; 119 __bss_stop = .;
120 _end = . ; 120 _end = . ;
diff --git a/arch/frv/mm/tlb-miss.S b/arch/frv/mm/tlb-miss.S
index 7f392bc651a3..f3ac019bb18b 100644
--- a/arch/frv/mm/tlb-miss.S
+++ b/arch/frv/mm/tlb-miss.S
@@ -15,7 +15,7 @@
15#include <asm/pgtable.h> 15#include <asm/pgtable.h>
16#include <asm/spr-regs.h> 16#include <asm/spr-regs.h>
17 17
18 .section .text.tlbmiss 18 .section .text..tlbmiss
19 .balign 4 19 .balign 4
20 20
21 .globl __entry_insn_mmu_miss 21 .globl __entry_insn_mmu_miss
diff --git a/arch/h8300/boot/compressed/head.S b/arch/h8300/boot/compressed/head.S
index 985a81a2435a..10e9a2d1cc6c 100644
--- a/arch/h8300/boot/compressed/head.S
+++ b/arch/h8300/boot/compressed/head.S
@@ -9,7 +9,7 @@
9 9
10#define SRAM_START 0xff4000 10#define SRAM_START 0xff4000
11 11
12 .section .text.startup 12 .section .text..startup
13 .global startup 13 .global startup
14startup: 14startup:
15 mov.l #SRAM_START+0x8000, sp 15 mov.l #SRAM_START+0x8000, sp
diff --git a/arch/h8300/boot/compressed/vmlinux.lds b/arch/h8300/boot/compressed/vmlinux.lds
index 65e2a0d1ae39..a0a3a0ed54ef 100644
--- a/arch/h8300/boot/compressed/vmlinux.lds
+++ b/arch/h8300/boot/compressed/vmlinux.lds
@@ -4,7 +4,7 @@ SECTIONS
4 { 4 {
5 __stext = . ; 5 __stext = . ;
6 __text = .; 6 __text = .;
7 *(.text.startup) 7 *(.text..startup)
8 *(.text) 8 *(.text)
9 __etext = . ; 9 __etext = . ;
10 } 10 }
diff --git a/arch/ia64/include/asm/asmmacro.h b/arch/ia64/include/asm/asmmacro.h
index c1642fd64029..3ab6d75aa3db 100644
--- a/arch/ia64/include/asm/asmmacro.h
+++ b/arch/ia64/include/asm/asmmacro.h
@@ -70,12 +70,12 @@ name:
70 * path (ivt.S - TLB miss processing) or in places where it might not be 70 * path (ivt.S - TLB miss processing) or in places where it might not be
71 * safe to use a "tpa" instruction (mca_asm.S - error recovery). 71 * safe to use a "tpa" instruction (mca_asm.S - error recovery).
72 */ 72 */
73 .section ".data.patch.vtop", "a" // declare section & section attributes 73 .section ".data..patch.vtop", "a" // declare section & section attributes
74 .previous 74 .previous
75 75
76#define LOAD_PHYSICAL(pr, reg, obj) \ 76#define LOAD_PHYSICAL(pr, reg, obj) \
77[1:](pr)movl reg = obj; \ 77[1:](pr)movl reg = obj; \
78 .xdata4 ".data.patch.vtop", 1b-. 78 .xdata4 ".data..patch.vtop", 1b-.
79 79
80/* 80/*
81 * For now, we always put in the McKinley E9 workaround. On CPUs that don't need it, 81 * For now, we always put in the McKinley E9 workaround. On CPUs that don't need it,
@@ -84,11 +84,11 @@ name:
84#define DO_MCKINLEY_E9_WORKAROUND 84#define DO_MCKINLEY_E9_WORKAROUND
85 85
86#ifdef DO_MCKINLEY_E9_WORKAROUND 86#ifdef DO_MCKINLEY_E9_WORKAROUND
87 .section ".data.patch.mckinley_e9", "a" 87 .section ".data..patch.mckinley_e9", "a"
88 .previous 88 .previous
89/* workaround for Itanium 2 Errata 9: */ 89/* workaround for Itanium 2 Errata 9: */
90# define FSYS_RETURN \ 90# define FSYS_RETURN \
91 .xdata4 ".data.patch.mckinley_e9", 1f-.; \ 91 .xdata4 ".data..patch.mckinley_e9", 1f-.; \
921:{ .mib; \ 921:{ .mib; \
93 nop.m 0; \ 93 nop.m 0; \
94 mov r16=ar.pfs; \ 94 mov r16=ar.pfs; \
@@ -107,11 +107,11 @@ name:
107 * If physical stack register size is different from DEF_NUM_STACK_REG, 107 * If physical stack register size is different from DEF_NUM_STACK_REG,
108 * dynamically patch the kernel for correct size. 108 * dynamically patch the kernel for correct size.
109 */ 109 */
110 .section ".data.patch.phys_stack_reg", "a" 110 .section ".data..patch.phys_stack_reg", "a"
111 .previous 111 .previous
112#define LOAD_PHYS_STACK_REG_SIZE(reg) \ 112#define LOAD_PHYS_STACK_REG_SIZE(reg) \
113[1:] adds reg=IA64_NUM_PHYS_STACK_REG*8+8,r0; \ 113[1:] adds reg=IA64_NUM_PHYS_STACK_REG*8+8,r0; \
114 .xdata4 ".data.patch.phys_stack_reg", 1b-. 114 .xdata4 ".data..patch.phys_stack_reg", 1b-.
115 115
116/* 116/*
117 * Up until early 2004, use of .align within a function caused bad unwind info. 117 * Up until early 2004, use of .align within a function caused bad unwind info.
diff --git a/arch/ia64/include/asm/cache.h b/arch/ia64/include/asm/cache.h
index e7482bd628ff..988254a7d349 100644
--- a/arch/ia64/include/asm/cache.h
+++ b/arch/ia64/include/asm/cache.h
@@ -24,6 +24,6 @@
24# define SMP_CACHE_BYTES (1 << 3) 24# define SMP_CACHE_BYTES (1 << 3)
25#endif 25#endif
26 26
27#define __read_mostly __attribute__((__section__(".data.read_mostly"))) 27#define __read_mostly __attribute__((__section__(".data..read_mostly")))
28 28
29#endif /* _ASM_IA64_CACHE_H */ 29#endif /* _ASM_IA64_CACHE_H */
diff --git a/arch/ia64/include/asm/percpu.h b/arch/ia64/include/asm/percpu.h
index 1bd408265694..14aa1c58912b 100644
--- a/arch/ia64/include/asm/percpu.h
+++ b/arch/ia64/include/asm/percpu.h
@@ -31,7 +31,7 @@ extern void *per_cpu_init(void);
31 31
32#endif /* SMP */ 32#endif /* SMP */
33 33
34#define PER_CPU_BASE_SECTION ".data.percpu" 34#define PER_CPU_BASE_SECTION ".data..percpu"
35 35
36/* 36/*
37 * Be extremely careful when taking the address of this variable! Due to virtual 37 * Be extremely careful when taking the address of this variable! Due to virtual
diff --git a/arch/ia64/kernel/Makefile.gate b/arch/ia64/kernel/Makefile.gate
index ab9b03a9adcc..ceeffc509764 100644
--- a/arch/ia64/kernel/Makefile.gate
+++ b/arch/ia64/kernel/Makefile.gate
@@ -21,7 +21,7 @@ GATECFLAGS_gate-syms.o = -r
21$(obj)/gate-syms.o: $(obj)/gate.lds $(obj)/gate.o FORCE 21$(obj)/gate-syms.o: $(obj)/gate.lds $(obj)/gate.o FORCE
22 $(call if_changed,gate) 22 $(call if_changed,gate)
23 23
24# gate-data.o contains the gate DSO image as data in section .data.gate. 24# gate-data.o contains the gate DSO image as data in section .data..gate.
25# We must build gate.so before we can assemble it. 25# We must build gate.so before we can assemble it.
26# Note: kbuild does not track this dependency due to usage of .incbin 26# Note: kbuild does not track this dependency due to usage of .incbin
27$(obj)/gate-data.o: $(obj)/gate.so 27$(obj)/gate-data.o: $(obj)/gate.so
diff --git a/arch/ia64/kernel/gate-data.S b/arch/ia64/kernel/gate-data.S
index 258c0a3238fb..b3ef1c72e132 100644
--- a/arch/ia64/kernel/gate-data.S
+++ b/arch/ia64/kernel/gate-data.S
@@ -1,3 +1,3 @@
1 .section .data.gate, "aw" 1 .section .data..gate, "aw"
2 2
3 .incbin "arch/ia64/kernel/gate.so" 3 .incbin "arch/ia64/kernel/gate.so"
diff --git a/arch/ia64/kernel/gate.S b/arch/ia64/kernel/gate.S
index cf5e0a105e16..245d3e1ec7e1 100644
--- a/arch/ia64/kernel/gate.S
+++ b/arch/ia64/kernel/gate.S
@@ -21,18 +21,18 @@
21 * to targets outside the shared object) and to avoid multi-phase kernel builds, we 21 * to targets outside the shared object) and to avoid multi-phase kernel builds, we
22 * simply create minimalistic "patch lists" in special ELF sections. 22 * simply create minimalistic "patch lists" in special ELF sections.
23 */ 23 */
24 .section ".data.patch.fsyscall_table", "a" 24 .section ".data..patch.fsyscall_table", "a"
25 .previous 25 .previous
26#define LOAD_FSYSCALL_TABLE(reg) \ 26#define LOAD_FSYSCALL_TABLE(reg) \
27[1:] movl reg=0; \ 27[1:] movl reg=0; \
28 .xdata4 ".data.patch.fsyscall_table", 1b-. 28 .xdata4 ".data..patch.fsyscall_table", 1b-.
29 29
30 .section ".data.patch.brl_fsys_bubble_down", "a" 30 .section ".data..patch.brl_fsys_bubble_down", "a"
31 .previous 31 .previous
32#define BRL_COND_FSYS_BUBBLE_DOWN(pr) \ 32#define BRL_COND_FSYS_BUBBLE_DOWN(pr) \
33[1:](pr)brl.cond.sptk 0; \ 33[1:](pr)brl.cond.sptk 0; \
34 ;; \ 34 ;; \
35 .xdata4 ".data.patch.brl_fsys_bubble_down", 1b-. 35 .xdata4 ".data..patch.brl_fsys_bubble_down", 1b-.
36 36
37GLOBAL_ENTRY(__kernel_syscall_via_break) 37GLOBAL_ENTRY(__kernel_syscall_via_break)
38 .prologue 38 .prologue
diff --git a/arch/ia64/kernel/gate.lds.S b/arch/ia64/kernel/gate.lds.S
index 88c64ed47c36..d32b0855110a 100644
--- a/arch/ia64/kernel/gate.lds.S
+++ b/arch/ia64/kernel/gate.lds.S
@@ -33,21 +33,21 @@ SECTIONS
33 */ 33 */
34 . = GATE_ADDR + 0x600; 34 . = GATE_ADDR + 0x600;
35 35
36 .data.patch : { 36 .data..patch : {
37 __paravirt_start_gate_mckinley_e9_patchlist = .; 37 __paravirt_start_gate_mckinley_e9_patchlist = .;
38 *(.data.patch.mckinley_e9) 38 *(.data..patch.mckinley_e9)
39 __paravirt_end_gate_mckinley_e9_patchlist = .; 39 __paravirt_end_gate_mckinley_e9_patchlist = .;
40 40
41 __paravirt_start_gate_vtop_patchlist = .; 41 __paravirt_start_gate_vtop_patchlist = .;
42 *(.data.patch.vtop) 42 *(.data..patch.vtop)
43 __paravirt_end_gate_vtop_patchlist = .; 43 __paravirt_end_gate_vtop_patchlist = .;
44 44
45 __paravirt_start_gate_fsyscall_patchlist = .; 45 __paravirt_start_gate_fsyscall_patchlist = .;
46 *(.data.patch.fsyscall_table) 46 *(.data..patch.fsyscall_table)
47 __paravirt_end_gate_fsyscall_patchlist = .; 47 __paravirt_end_gate_fsyscall_patchlist = .;
48 48
49 __paravirt_start_gate_brl_fsys_bubble_down_patchlist = .; 49 __paravirt_start_gate_brl_fsys_bubble_down_patchlist = .;
50 *(.data.patch.brl_fsys_bubble_down) 50 *(.data..patch.brl_fsys_bubble_down)
51 __paravirt_end_gate_brl_fsys_bubble_down_patchlist = .; 51 __paravirt_end_gate_brl_fsys_bubble_down_patchlist = .;
52 } :readable 52 } :readable
53 53
diff --git a/arch/ia64/kernel/init_task.c b/arch/ia64/kernel/init_task.c
index e253ab8fcbc8..f9efe9739d3f 100644
--- a/arch/ia64/kernel/init_task.c
+++ b/arch/ia64/kernel/init_task.c
@@ -23,7 +23,7 @@ static struct sighand_struct init_sighand = INIT_SIGHAND(init_sighand);
23 * Initial task structure. 23 * Initial task structure.
24 * 24 *
25 * We need to make sure that this is properly aligned due to the way process stacks are 25 * We need to make sure that this is properly aligned due to the way process stacks are
26 * handled. This is done by having a special ".data.init_task" section... 26 * handled. This is done by having a special ".data..init_task" section...
27 */ 27 */
28#define init_thread_info init_task_mem.s.thread_info 28#define init_thread_info init_task_mem.s.thread_info
29 29
diff --git a/arch/ia64/kernel/ivt.S b/arch/ia64/kernel/ivt.S
index 179fd122e837..d93e396bf599 100644
--- a/arch/ia64/kernel/ivt.S
+++ b/arch/ia64/kernel/ivt.S
@@ -82,7 +82,7 @@
82 mov r19=n;; /* prepare to save predicates */ \ 82 mov r19=n;; /* prepare to save predicates */ \
83 br.sptk.many dispatch_to_fault_handler 83 br.sptk.many dispatch_to_fault_handler
84 84
85 .section .text.ivt,"ax" 85 .section .text..ivt,"ax"
86 86
87 .align 32768 // align on 32KB boundary 87 .align 32768 // align on 32KB boundary
88 .global ia64_ivt 88 .global ia64_ivt
diff --git a/arch/ia64/kernel/minstate.h b/arch/ia64/kernel/minstate.h
index 292e214a3b84..d56753a11636 100644
--- a/arch/ia64/kernel/minstate.h
+++ b/arch/ia64/kernel/minstate.h
@@ -16,7 +16,7 @@
16#define ACCOUNT_SYS_ENTER 16#define ACCOUNT_SYS_ENTER
17#endif 17#endif
18 18
19.section ".data.patch.rse", "a" 19.section ".data..patch.rse", "a"
20.previous 20.previous
21 21
22/* 22/*
@@ -215,7 +215,7 @@
215(pUStk) extr.u r17=r18,3,6; \ 215(pUStk) extr.u r17=r18,3,6; \
216(pUStk) sub r16=r18,r22; \ 216(pUStk) sub r16=r18,r22; \
217[1:](pKStk) br.cond.sptk.many 1f; \ 217[1:](pKStk) br.cond.sptk.many 1f; \
218 .xdata4 ".data.patch.rse",1b-. \ 218 .xdata4 ".data..patch.rse",1b-. \
219 ;; \ 219 ;; \
220 cmp.ge p6,p7 = 33,r17; \ 220 cmp.ge p6,p7 = 33,r17; \
221 ;; \ 221 ;; \
diff --git a/arch/ia64/kernel/paravirtentry.S b/arch/ia64/kernel/paravirtentry.S
index 6158560d7f17..92d880c4d3d1 100644
--- a/arch/ia64/kernel/paravirtentry.S
+++ b/arch/ia64/kernel/paravirtentry.S
@@ -28,7 +28,7 @@
28#include "entry.h" 28#include "entry.h"
29 29
30#define DATA8(sym, init_value) \ 30#define DATA8(sym, init_value) \
31 .pushsection .data.read_mostly ; \ 31 .pushsection .data..read_mostly ; \
32 .align 8 ; \ 32 .align 8 ; \
33 .global sym ; \ 33 .global sym ; \
34 sym: ; \ 34 sym: ; \
diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S
index 1295ba327f6f..e07218a2577f 100644
--- a/arch/ia64/kernel/vmlinux.lds.S
+++ b/arch/ia64/kernel/vmlinux.lds.S
@@ -8,7 +8,7 @@
8 8
9#define IVT_TEXT \ 9#define IVT_TEXT \
10 VMLINUX_SYMBOL(__start_ivt_text) = .; \ 10 VMLINUX_SYMBOL(__start_ivt_text) = .; \
11 *(.text.ivt) \ 11 *(.text..ivt) \
12 VMLINUX_SYMBOL(__end_ivt_text) = .; 12 VMLINUX_SYMBOL(__end_ivt_text) = .;
13 13
14OUTPUT_FORMAT("elf64-ia64-little") 14OUTPUT_FORMAT("elf64-ia64-little")
@@ -54,8 +54,8 @@ SECTIONS
54 .text2 : AT(ADDR(.text2) - LOAD_OFFSET) 54 .text2 : AT(ADDR(.text2) - LOAD_OFFSET)
55 { *(.text2) } 55 { *(.text2) }
56#ifdef CONFIG_SMP 56#ifdef CONFIG_SMP
57 .text.lock : AT(ADDR(.text.lock) - LOAD_OFFSET) 57 .text..lock : AT(ADDR(.text..lock) - LOAD_OFFSET)
58 { *(.text.lock) } 58 { *(.text..lock) }
59#endif 59#endif
60 _etext = .; 60 _etext = .;
61 61
@@ -75,10 +75,10 @@ SECTIONS
75 __stop___mca_table = .; 75 __stop___mca_table = .;
76 } 76 }
77 77
78 .data.patch.phys_stack_reg : AT(ADDR(.data.patch.phys_stack_reg) - LOAD_OFFSET) 78 .data..patch.phys_stack_reg : AT(ADDR(.data..patch.phys_stack_reg) - LOAD_OFFSET)
79 { 79 {
80 __start___phys_stack_reg_patchlist = .; 80 __start___phys_stack_reg_patchlist = .;
81 *(.data.patch.phys_stack_reg) 81 *(.data..patch.phys_stack_reg)
82 __end___phys_stack_reg_patchlist = .; 82 __end___phys_stack_reg_patchlist = .;
83 } 83 }
84 84
@@ -110,24 +110,24 @@ SECTIONS
110 INIT_TEXT_SECTION(PAGE_SIZE) 110 INIT_TEXT_SECTION(PAGE_SIZE)
111 INIT_DATA_SECTION(16) 111 INIT_DATA_SECTION(16)
112 112
113 .data.patch.vtop : AT(ADDR(.data.patch.vtop) - LOAD_OFFSET) 113 .data..patch.vtop : AT(ADDR(.data..patch.vtop) - LOAD_OFFSET)
114 { 114 {
115 __start___vtop_patchlist = .; 115 __start___vtop_patchlist = .;
116 *(.data.patch.vtop) 116 *(.data..patch.vtop)
117 __end___vtop_patchlist = .; 117 __end___vtop_patchlist = .;
118 } 118 }
119 119
120 .data.patch.rse : AT(ADDR(.data.patch.rse) - LOAD_OFFSET) 120 .data..patch.rse : AT(ADDR(.data..patch.rse) - LOAD_OFFSET)
121 { 121 {
122 __start___rse_patchlist = .; 122 __start___rse_patchlist = .;
123 *(.data.patch.rse) 123 *(.data..patch.rse)
124 __end___rse_patchlist = .; 124 __end___rse_patchlist = .;
125 } 125 }
126 126
127 .data.patch.mckinley_e9 : AT(ADDR(.data.patch.mckinley_e9) - LOAD_OFFSET) 127 .data..patch.mckinley_e9 : AT(ADDR(.data..patch.mckinley_e9) - LOAD_OFFSET)
128 { 128 {
129 __start___mckinley_e9_bundles = .; 129 __start___mckinley_e9_bundles = .;
130 *(.data.patch.mckinley_e9) 130 *(.data..patch.mckinley_e9)
131 __end___mckinley_e9_bundles = .; 131 __end___mckinley_e9_bundles = .;
132 } 132 }
133 133
@@ -175,17 +175,17 @@ SECTIONS
175 . = ALIGN(PAGE_SIZE); 175 . = ALIGN(PAGE_SIZE);
176 __init_end = .; 176 __init_end = .;
177 177
178 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) 178 .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET)
179 { 179 {
180 PAGE_ALIGNED_DATA(PAGE_SIZE) 180 PAGE_ALIGNED_DATA(PAGE_SIZE)
181 . = ALIGN(PAGE_SIZE); 181 . = ALIGN(PAGE_SIZE);
182 __start_gate_section = .; 182 __start_gate_section = .;
183 *(.data.gate) 183 *(.data..gate)
184 __stop_gate_section = .; 184 __stop_gate_section = .;
185#ifdef CONFIG_XEN 185#ifdef CONFIG_XEN
186 . = ALIGN(PAGE_SIZE); 186 . = ALIGN(PAGE_SIZE);
187 __xen_start_gate_section = .; 187 __xen_start_gate_section = .;
188 *(.data.gate.xen) 188 *(.data..gate.xen)
189 __xen_stop_gate_section = .; 189 __xen_stop_gate_section = .;
190#endif 190#endif
191 } 191 }
diff --git a/arch/ia64/kvm/vmm_ivt.S b/arch/ia64/kvm/vmm_ivt.S
index 40920c630649..24018484c6e9 100644
--- a/arch/ia64/kvm/vmm_ivt.S
+++ b/arch/ia64/kvm/vmm_ivt.S
@@ -104,7 +104,7 @@ GLOBAL_ENTRY(kvm_vmm_panic)
104 br.call.sptk.many b6=vmm_panic_handler; 104 br.call.sptk.many b6=vmm_panic_handler;
105END(kvm_vmm_panic) 105END(kvm_vmm_panic)
106 106
107 .section .text.ivt,"ax" 107 .section .text..ivt,"ax"
108 108
109 .align 32768 // align on 32KB boundary 109 .align 32768 // align on 32KB boundary
110 .global kvm_ia64_ivt 110 .global kvm_ia64_ivt
diff --git a/arch/ia64/scripts/unwcheck.py b/arch/ia64/scripts/unwcheck.py
index c27849889e19..2bfd941ff7c7 100644
--- a/arch/ia64/scripts/unwcheck.py
+++ b/arch/ia64/scripts/unwcheck.py
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/python
2# 2#
3# Usage: unwcheck.py FILE 3# Usage: unwcheck.py FILE
4# 4#
diff --git a/arch/ia64/xen/gate-data.S b/arch/ia64/xen/gate-data.S
index 7d4830afc91d..6f95b6b32a4e 100644
--- a/arch/ia64/xen/gate-data.S
+++ b/arch/ia64/xen/gate-data.S
@@ -1,3 +1,3 @@
1 .section .data.gate.xen, "aw" 1 .section .data..gate.xen, "aw"
2 2
3 .incbin "arch/ia64/xen/gate.so" 3 .incbin "arch/ia64/xen/gate.so"
diff --git a/arch/ia64/xen/xensetup.S b/arch/ia64/xen/xensetup.S
index aff8346ea193..b820ed02ab9f 100644
--- a/arch/ia64/xen/xensetup.S
+++ b/arch/ia64/xen/xensetup.S
@@ -14,7 +14,7 @@
14#include <linux/init.h> 14#include <linux/init.h>
15#include <xen/interface/elfnote.h> 15#include <xen/interface/elfnote.h>
16 16
17 .section .data.read_mostly 17 .section .data..read_mostly
18 .align 8 18 .align 8
19 .global xen_domain_type 19 .global xen_domain_type
20xen_domain_type: 20xen_domain_type:
diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S
index 9f1784f586b9..a91b2713451d 100644
--- a/arch/m68knommu/kernel/vmlinux.lds.S
+++ b/arch/m68knommu/kernel/vmlinux.lds.S
@@ -57,7 +57,7 @@ SECTIONS {
57 .romvec : { 57 .romvec : {
58 __rom_start = . ; 58 __rom_start = . ;
59 _romvec = .; 59 _romvec = .;
60 *(.data.initvect) 60 *(.data..initvect)
61 } > romvec 61 } > romvec
62#endif 62#endif
63 63
@@ -68,7 +68,7 @@ SECTIONS {
68 TEXT_TEXT 68 TEXT_TEXT
69 SCHED_TEXT 69 SCHED_TEXT
70 LOCK_TEXT 70 LOCK_TEXT
71 *(.text.lock) 71 *(.text..lock)
72 72
73 . = ALIGN(16); /* Exception table */ 73 . = ALIGN(16); /* Exception table */
74 __start___ex_table = .; 74 __start___ex_table = .;
diff --git a/arch/m68knommu/platform/68360/head-ram.S b/arch/m68knommu/platform/68360/head-ram.S
index 2ef06242398b..8eb94fb6b971 100644
--- a/arch/m68knommu/platform/68360/head-ram.S
+++ b/arch/m68knommu/platform/68360/head-ram.S
@@ -280,7 +280,7 @@ _dprbase:
280 * and then overwritten as needed. 280 * and then overwritten as needed.
281 */ 281 */
282 282
283.section ".data.initvect","awx" 283.section ".data..initvect","awx"
284 .long RAMEND /* Reset: Initial Stack Pointer - 0. */ 284 .long RAMEND /* Reset: Initial Stack Pointer - 0. */
285 .long _start /* Reset: Initial Program Counter - 1. */ 285 .long _start /* Reset: Initial Program Counter - 1. */
286 .long buserr /* Bus Error - 2. */ 286 .long buserr /* Bus Error - 2. */
diff --git a/arch/m68knommu/platform/68360/head-rom.S b/arch/m68knommu/platform/68360/head-rom.S
index 62ecf4144b3b..97510e55b802 100644
--- a/arch/m68knommu/platform/68360/head-rom.S
+++ b/arch/m68knommu/platform/68360/head-rom.S
@@ -291,7 +291,7 @@ _dprbase:
291 * and then overwritten as needed. 291 * and then overwritten as needed.
292 */ 292 */
293 293
294.section ".data.initvect","awx" 294.section ".data..initvect","awx"
295 .long RAMEND /* Reset: Initial Stack Pointer - 0. */ 295 .long RAMEND /* Reset: Initial Stack Pointer - 0. */
296 .long _start /* Reset: Initial Program Counter - 1. */ 296 .long _start /* Reset: Initial Program Counter - 1. */
297 .long buserr /* Bus Error - 2. */ 297 .long buserr /* Bus Error - 2. */
diff --git a/arch/mips/lasat/image/head.S b/arch/mips/lasat/image/head.S
index efb95f2609c2..e0ecda92c40a 100644
--- a/arch/mips/lasat/image/head.S
+++ b/arch/mips/lasat/image/head.S
@@ -1,7 +1,7 @@
1#include <asm/lasat/head.h> 1#include <asm/lasat/head.h>
2 2
3 .text 3 .text
4 .section .text.start, "ax" 4 .section .text..start, "ax"
5 .set noreorder 5 .set noreorder
6 .set mips3 6 .set mips3
7 7
diff --git a/arch/mips/lasat/image/romscript.normal b/arch/mips/lasat/image/romscript.normal
index 988f8ad189cb..0864c963e188 100644
--- a/arch/mips/lasat/image/romscript.normal
+++ b/arch/mips/lasat/image/romscript.normal
@@ -4,7 +4,7 @@ SECTIONS
4{ 4{
5 .text : 5 .text :
6 { 6 {
7 *(.text.start) 7 *(.text..start)
8 } 8 }
9 9
10 /* Data in ROM */ 10 /* Data in ROM */
diff --git a/arch/parisc/include/asm/cache.h b/arch/parisc/include/asm/cache.h
index 32c2cca74345..45effe6978fa 100644
--- a/arch/parisc/include/asm/cache.h
+++ b/arch/parisc/include/asm/cache.h
@@ -28,7 +28,7 @@
28 28
29#define SMP_CACHE_BYTES L1_CACHE_BYTES 29#define SMP_CACHE_BYTES L1_CACHE_BYTES
30 30
31#define __read_mostly __attribute__((__section__(".data.read_mostly"))) 31#define __read_mostly __attribute__((__section__(".data..read_mostly")))
32 32
33void parisc_cache_init(void); /* initializes cache-flushing */ 33void parisc_cache_init(void); /* initializes cache-flushing */
34void disable_sr_hashing_asm(int); /* low level support for above */ 34void disable_sr_hashing_asm(int); /* low level support for above */
diff --git a/arch/parisc/include/asm/system.h b/arch/parisc/include/asm/system.h
index 4653c77bf9d1..2ab4af58ecb9 100644
--- a/arch/parisc/include/asm/system.h
+++ b/arch/parisc/include/asm/system.h
@@ -174,7 +174,7 @@ static inline void set_eiem(unsigned long val)
174}) 174})
175 175
176#ifdef CONFIG_SMP 176#ifdef CONFIG_SMP
177# define __lock_aligned __attribute__((__section__(".data.lock_aligned"))) 177# define __lock_aligned __attribute__((__section__(".data..lock_aligned")))
178#endif 178#endif
179 179
180#define arch_align_stack(x) (x) 180#define arch_align_stack(x) (x)
diff --git a/arch/parisc/kernel/head.S b/arch/parisc/kernel/head.S
index 0e3d9f9b9e33..4dbdf0ed6fa0 100644
--- a/arch/parisc/kernel/head.S
+++ b/arch/parisc/kernel/head.S
@@ -345,7 +345,7 @@ smp_slave_stext:
345ENDPROC(stext) 345ENDPROC(stext)
346 346
347#ifndef CONFIG_64BIT 347#ifndef CONFIG_64BIT
348 .section .data.read_mostly 348 .section .data..read_mostly
349 349
350 .align 4 350 .align 4
351 .export $global$,data 351 .export $global$,data
diff --git a/arch/parisc/kernel/init_task.c b/arch/parisc/kernel/init_task.c
index d020eae6525c..4a91e433416f 100644
--- a/arch/parisc/kernel/init_task.c
+++ b/arch/parisc/kernel/init_task.c
@@ -53,11 +53,11 @@ union thread_union init_thread_union __init_task_data
53 * guarantee that global objects will be laid out in memory in the same order 53 * guarantee that global objects will be laid out in memory in the same order
54 * as the order of declaration, so put these in different sections and use 54 * as the order of declaration, so put these in different sections and use
55 * the linker script to order them. */ 55 * the linker script to order them. */
56pmd_t pmd0[PTRS_PER_PMD] __attribute__ ((__section__ (".data.vm0.pmd"), aligned(PAGE_SIZE))); 56pmd_t pmd0[PTRS_PER_PMD] __attribute__ ((__section__ (".data..vm0.pmd"), aligned(PAGE_SIZE)));
57#endif 57#endif
58 58
59pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__ ((__section__ (".data.vm0.pgd"), aligned(PAGE_SIZE))); 59pgd_t swapper_pg_dir[PTRS_PER_PGD] __attribute__ ((__section__ (".data..vm0.pgd"), aligned(PAGE_SIZE)));
60pte_t pg0[PT_INITIAL * PTRS_PER_PTE] __attribute__ ((__section__ (".data.vm0.pte"), aligned(PAGE_SIZE))); 60pte_t pg0[PT_INITIAL * PTRS_PER_PTE] __attribute__ ((__section__ (".data..vm0.pte"), aligned(PAGE_SIZE)));
61 61
62/* 62/*
63 * Initial task structure. 63 * Initial task structure.
diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S
index 9dab4a4e09f7..d64a6bbec2aa 100644
--- a/arch/parisc/kernel/vmlinux.lds.S
+++ b/arch/parisc/kernel/vmlinux.lds.S
@@ -94,8 +94,8 @@ SECTIONS
94 94
95 /* PA-RISC locks requires 16-byte alignment */ 95 /* PA-RISC locks requires 16-byte alignment */
96 . = ALIGN(16); 96 . = ALIGN(16);
97 .data.lock_aligned : { 97 .data..lock_aligned : {
98 *(.data.lock_aligned) 98 *(.data..lock_aligned)
99 } 99 }
100 100
101 /* End of data section */ 101 /* End of data section */
@@ -105,10 +105,10 @@ SECTIONS
105 __bss_start = .; 105 __bss_start = .;
106 /* page table entries need to be PAGE_SIZE aligned */ 106 /* page table entries need to be PAGE_SIZE aligned */
107 . = ALIGN(PAGE_SIZE); 107 . = ALIGN(PAGE_SIZE);
108 .data.vmpages : { 108 .data..vmpages : {
109 *(.data.vm0.pmd) 109 *(.data..vm0.pmd)
110 *(.data.vm0.pgd) 110 *(.data..vm0.pgd)
111 *(.data.vm0.pte) 111 *(.data..vm0.pte)
112 } 112 }
113 .bss : { 113 .bss : {
114 *(.bss) 114 *(.bss)
diff --git a/arch/powerpc/Makefile b/arch/powerpc/Makefile
index 1a54a3b3a3fa..42dcd3f4ad7b 100644
--- a/arch/powerpc/Makefile
+++ b/arch/powerpc/Makefile
@@ -112,6 +112,11 @@ KBUILD_CFLAGS += $(call cc-option,-mspe=no)
112# kernel considerably. 112# kernel considerably.
113KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time) 113KBUILD_CFLAGS += $(call cc-option,-funit-at-a-time)
114 114
115# FIXME: the module load should be taught about the additional relocs
116# generated by this.
117# revert to pre-gcc-4.4 behaviour of .eh_frame
118KBUILD_CFLAGS += $(call cc-option,-fno-dwarf2-cfi-asm)
119
115# Never use string load/store instructions as they are 120# Never use string load/store instructions as they are
116# often slow when they are implemented at all 121# often slow when they are implemented at all
117KBUILD_CFLAGS += -mno-string 122KBUILD_CFLAGS += -mno-string
diff --git a/arch/powerpc/include/asm/cache.h b/arch/powerpc/include/asm/cache.h
index 725634fc18c6..4b509411ad8a 100644
--- a/arch/powerpc/include/asm/cache.h
+++ b/arch/powerpc/include/asm/cache.h
@@ -42,7 +42,7 @@ extern struct ppc64_caches ppc64_caches;
42#endif /* __powerpc64__ && ! __ASSEMBLY__ */ 42#endif /* __powerpc64__ && ! __ASSEMBLY__ */
43 43
44#if !defined(__ASSEMBLY__) 44#if !defined(__ASSEMBLY__)
45#define __read_mostly __attribute__((__section__(".data.read_mostly"))) 45#define __read_mostly __attribute__((__section__(".data..read_mostly")))
46#endif 46#endif
47 47
48#endif /* __KERNEL__ */ 48#endif /* __KERNEL__ */
diff --git a/arch/powerpc/include/asm/page_64.h b/arch/powerpc/include/asm/page_64.h
index bfc4e027e2ad..358ff14ea25e 100644
--- a/arch/powerpc/include/asm/page_64.h
+++ b/arch/powerpc/include/asm/page_64.h
@@ -162,14 +162,6 @@ do { \
162 162
163#endif /* !CONFIG_HUGETLB_PAGE */ 163#endif /* !CONFIG_HUGETLB_PAGE */
164 164
165#ifdef MODULE
166#define __page_aligned __attribute__((__aligned__(PAGE_SIZE)))
167#else
168#define __page_aligned \
169 __attribute__((__aligned__(PAGE_SIZE), \
170 __section__(".data.page_aligned")))
171#endif
172
173#define VM_DATA_DEFAULT_FLAGS \ 165#define VM_DATA_DEFAULT_FLAGS \
174 (test_thread_flag(TIF_32BIT) ? \ 166 (test_thread_flag(TIF_32BIT) ? \
175 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64) 167 VM_DATA_DEFAULT_FLAGS32 : VM_DATA_DEFAULT_FLAGS64)
diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S
index dcd01c82e701..8a0deefac08d 100644
--- a/arch/powerpc/kernel/vmlinux.lds.S
+++ b/arch/powerpc/kernel/vmlinux.lds.S
@@ -223,19 +223,17 @@ SECTIONS
223#endif 223#endif
224 224
225 /* The initial task and kernel stack */ 225 /* The initial task and kernel stack */
226 .data.init_task : AT(ADDR(.data.init_task) - LOAD_OFFSET) { 226 INIT_TASK_DATA_SECTION(THREAD_SIZE)
227 INIT_TASK_DATA(THREAD_SIZE)
228 }
229 227
230 .data.page_aligned : AT(ADDR(.data.page_aligned) - LOAD_OFFSET) { 228 .data..page_aligned : AT(ADDR(.data..page_aligned) - LOAD_OFFSET) {
231 PAGE_ALIGNED_DATA(PAGE_SIZE) 229 PAGE_ALIGNED_DATA(PAGE_SIZE)
232 } 230 }
233 231
234 .data.cacheline_aligned : AT(ADDR(.data.cacheline_aligned) - LOAD_OFFSET) { 232 .data..cacheline_aligned : AT(ADDR(.data..cacheline_aligned) - LOAD_OFFSET) {
235 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES) 233 CACHELINE_ALIGNED_DATA(L1_CACHE_BYTES)
236 } 234 }
237 235
238 .data.read_mostly : AT(ADDR(.data.read_mostly) - LOAD_OFFSET) { 236 .data..read_mostly : AT(ADDR(.data..read_mostly) - LOAD_OFFSET) {
239 READ_MOSTLY_DATA(L1_CACHE_BYTES) 237 READ_MOSTLY_DATA(L1_CACHE_BYTES)
240 } 238 }
241 239
diff --git a/arch/s390/include/asm/cache.h b/arch/s390/include/asm/cache.h
index 9b866816863c..24aafa68b643 100644
--- a/arch/s390/include/asm/cache.h
+++ b/arch/s390/include/asm/cache.h
@@ -14,6 +14,6 @@
14#define L1_CACHE_BYTES 256 14#define L1_CACHE_BYTES 256
15#define L1_CACHE_SHIFT 8 15#define L1_CACHE_SHIFT 8
16 16
17#define __read_mostly __attribute__((__section__(".data.read_mostly"))) 17#define __read_mostly __attribute__((__section__(".data..read_mostly")))
18 18
19#endif 19#endif
diff --git a/arch/s390/kernel/swsusp_asm64.S b/arch/s390/kernel/swsusp_asm64.S
index c56d3f56d020..1f066e46e83e 100644
--- a/arch/s390/kernel/swsusp_asm64.S
+++ b/arch/s390/kernel/swsusp_asm64.S
@@ -264,7 +264,7 @@ restore_registers:
264 lghi %r2,0 264 lghi %r2,0
265 br %r14 265 br %r14
266 266
267 .section .data.nosave,"aw",@progbits 267 .section .data..nosave,"aw",@progbits
268 .align 8 268 .align 8
269.Ldisabled_wait_31: 269.Ldisabled_wait_31:
270 .long 0x000a0000,0x00000000 270 .long 0x000a0000,0x00000000
diff --git a/arch/sh/boot/compressed/vmlinux.scr b/arch/sh/boot/compressed/vmlinux.scr
index f02382ae5c48..862d74808236 100644
--- a/arch/sh/boot/compressed/vmlinux.scr
+++ b/arch/sh/boot/compressed/vmlinux.scr
@@ -1,6 +1,6 @@
1SECTIONS 1SECTIONS
2{ 2{
3 .rodata.compressed : { 3 .rodata..compressed : {
4 input_len = .; 4 input_len = .;
5 LONG(input_data_end - input_data) input_data = .; 5 LONG(input_data_end - input_data) input_data = .;
6 *(.data) 6 *(.data)
diff --git a/arch/sh/include/asm/cache.h b/arch/sh/include/asm/cache.h
index e461d67f03c3..ef9e555aafba 100644
--- a/arch/sh/include/asm/cache.h
+++ b/arch/sh/include/asm/cache.h
@@ -14,7 +14,7 @@
14 14
15#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 15#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
16 16
17#define __read_mostly __attribute__((__section__(".data.read_mostly"))) 17#define __read_mostly __attribute__((__section__(".data..read_mostly")))
18 18
19#ifndef __ASSEMBLY__ 19#ifndef __ASSEMBLY__
20struct cache_info { 20struct cache_info {
diff --git a/arch/sparc/boot/btfixupprep.c b/arch/sparc/boot/btfixupprep.c
index bbf91b9c3d39..e7f2940bd270 100644
--- a/arch/sparc/boot/btfixupprep.c
+++ b/arch/sparc/boot/btfixupprep.c
@@ -325,7 +325,7 @@ main1:
325 (*rr)->next = NULL; 325 (*rr)->next = NULL;
326 } 326 }
327 printf("! Generated by btfixupprep. Do not edit.\n\n"); 327 printf("! Generated by btfixupprep. Do not edit.\n\n");
328 printf("\t.section\t\".data.init\",#alloc,#write\n\t.align\t4\n\n"); 328 printf("\t.section\t\".data..init\",#alloc,#write\n\t.align\t4\n\n");
329 printf("\t.global\t___btfixup_start\n___btfixup_start:\n\n"); 329 printf("\t.global\t___btfixup_start\n___btfixup_start:\n\n");
330 for (i = 0; i < last; i++) { 330 for (i = 0; i < last; i++) {
331 f = array + i; 331 f = array + i;
diff --git a/arch/sparc/include/asm/cache.h b/arch/sparc/include/asm/cache.h
index 78b07009f60a..0588b8c7faa2 100644
--- a/arch/sparc/include/asm/cache.h
+++ b/arch/sparc/include/asm/cache.h
@@ -21,7 +21,7 @@
21 21
22#define SMP_CACHE_BYTES (1 << SMP_CACHE_BYTES_SHIFT) 22#define SMP_CACHE_BYTES (1 << SMP_CACHE_BYTES_SHIFT)
23 23
24#define __read_mostly __attribute__((__section__(".data.read_mostly"))) 24#define __read_mostly __attribute__((__section__(".data..read_mostly")))
25 25
26#ifdef CONFIG_SPARC32 26#ifdef CONFIG_SPARC32
27#include <asm/asi.h> 27#include <asm/asi.h>
diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S
index 7fcad58e216d..69268014dd8e 100644
--- a/arch/um/kernel/dyn.lds.S
+++ b/arch/um/kernel/dyn.lds.S
@@ -94,7 +94,7 @@ SECTIONS
94 .data : { 94 .data : {
95 INIT_TASK_DATA(KERNEL_STACK_SIZE) 95 INIT_TASK_DATA(KERNEL_STACK_SIZE)
96 . = ALIGN(KERNEL_STACK_SIZE); 96 . = ALIGN(KERNEL_STACK_SIZE);
97 *(.data.init_irqstack) 97 *(.data..init_irqstack)
98 DATA_DATA 98 DATA_DATA
99 *(.data.* .gnu.linkonce.d.*) 99 *(.data.* .gnu.linkonce.d.*)
100 SORT(CONSTRUCTORS) 100 SORT(CONSTRUCTORS)
diff --git a/arch/um/kernel/init_task.c b/arch/um/kernel/init_task.c
index 8aa77b61a5ff..ddc9698b66ed 100644
--- a/arch/um/kernel/init_task.c
+++ b/arch/um/kernel/init_task.c
@@ -34,5 +34,5 @@ union thread_union init_thread_union __init_task_data =
34 { INIT_THREAD_INFO(init_task) }; 34 { INIT_THREAD_INFO(init_task) };
35 35
36union thread_union cpu0_irqstack 36union thread_union cpu0_irqstack
37 __attribute__((__section__(".data.init_irqstack"))) = 37 __attribute__((__section__(".data..init_irqstack"))) =
38 { INIT_THREAD_INFO(init_task) }; 38 { INIT_THREAD_INFO(init_task) };
diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S
index e7a6cca667aa..ec6378550671 100644
--- a/arch/um/kernel/uml.lds.S
+++ b/arch/um/kernel/uml.lds.S
@@ -50,7 +50,7 @@ SECTIONS
50 { 50 {
51 INIT_TASK_DATA(KERNEL_STACK_SIZE) 51 INIT_TASK_DATA(KERNEL_STACK_SIZE)
52 . = ALIGN(KERNEL_STACK_SIZE); 52 . = ALIGN(KERNEL_STACK_SIZE);
53 *(.data.init_irqstack) 53 *(.data..init_irqstack)
54 DATA_DATA 54 DATA_DATA
55 *(.gnu.linkonce.d*) 55 *(.gnu.linkonce.d*)
56 CONSTRUCTORS 56 CONSTRUCTORS
diff --git a/arch/x86/.gitignore b/arch/x86/.gitignore
new file mode 100644
index 000000000000..028079065af6
--- /dev/null
+++ b/arch/x86/.gitignore
@@ -0,0 +1,3 @@
1boot/compressed/vmlinux
2tools/test_get_len
3
diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c
index bcbd36c41432..5c228129d175 100644
--- a/arch/x86/boot/compressed/mkpiggy.c
+++ b/arch/x86/boot/compressed/mkpiggy.c
@@ -77,7 +77,7 @@ int main(int argc, char *argv[])
77 offs += 32*1024 + 18; /* Add 32K + 18 bytes slack */ 77 offs += 32*1024 + 18; /* Add 32K + 18 bytes slack */
78 offs = (offs+4095) & ~4095; /* Round to a 4K boundary */ 78 offs = (offs+4095) & ~4095; /* Round to a 4K boundary */
79 79
80 printf(".section \".rodata.compressed\",\"a\",@progbits\n"); 80 printf(".section \".rodata..compressed\",\"a\",@progbits\n");
81 printf(".globl z_input_len\n"); 81 printf(".globl z_input_len\n");
82 printf("z_input_len = %lu\n", ilen); 82 printf("z_input_len = %lu\n", ilen);
83 printf(".globl z_output_len\n"); 83 printf(".globl z_output_len\n");
diff --git a/arch/x86/boot/compressed/vmlinux.lds.S b/arch/x86/boot/compressed/vmlinux.lds.S
index a6f1a59a5b0c..5ddabceee124 100644
--- a/arch/x86/boot/compressed/vmlinux.lds.S
+++ b/arch/x86/boot/compressed/vmlinux.lds.S
@@ -26,8 +26,8 @@ SECTIONS
26 HEAD_TEXT 26 HEAD_TEXT
27 _ehead = . ; 27 _ehead = . ;
28 } 28 }
29 .rodata.compressed : { 29 .rodata..compressed : {
30 *(.rodata.compressed) 30 *(.rodata..compressed)
31 } 31 }
32 .text : { 32 .text : {
33 _text = .; /* Text */ 33 _text = .; /* Text */
diff --git a/arch/x86/include/asm/cache.h b/arch/x86/include/asm/cache.h
index 2f9047cfaaca..48f99f15452e 100644
--- a/arch/x86/include/asm/cache.h
+++ b/arch/x86/include/asm/cache.h
@@ -7,7 +7,7 @@
7#define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT) 7#define L1_CACHE_SHIFT (CONFIG_X86_L1_CACHE_SHIFT)
8#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT) 8#define L1_CACHE_BYTES (1 << L1_CACHE_SHIFT)
9 9
10#define __read_mostly __attribute__((__section__(".data.read_mostly"))) 10#define __read_mostly __attribute__((__section__(".data..read_mostly")))
11 11
12#define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT 12#define INTERNODE_CACHE_SHIFT CONFIG_X86_INTERNODE_CACHE_SHIFT
13#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT) 13#define INTERNODE_CACHE_BYTES (1 << INTERNODE_CACHE_SHIFT)
diff --git a/arch/x86/kernel/acpi/wakeup_32.S b/arch/x86/kernel/acpi/wakeup_32.S
index 8ded418b0593..13ab720573e3 100644
--- a/arch/x86/kernel/acpi/wakeup_32.S
+++ b/arch/x86/kernel/acpi/wakeup_32.S
@@ -1,4 +1,4 @@
1 .section .text.page_aligned 1 .section .text..page_aligned
2#include <linux/linkage.h> 2#include <linux/linkage.h>
3#include <asm/segment.h> 3#include <asm/segment.h>
4#include <asm/page_types.h> 4#include <asm/page_types.h>
diff --git a/arch/x86/kernel/init_task.c b/arch/x86/kernel/init_task.c
index 3a54dcb9cd0e..43e9ccf44947 100644
--- a/arch/x86/kernel/init_task.c
+++ b/arch/x86/kernel/init_task.c
@@ -34,7 +34,7 @@ EXPORT_SYMBOL(init_task);
34/* 34/*
35 * per-CPU TSS segments. Threads are completely 'soft' on Linux, 35 * per-CPU TSS segments. Threads are completely 'soft' on Linux,
36 * no more per-task TSS's. The TSS size is kept cacheline-aligned 36 * no more per-task TSS's. The TSS size is kept cacheline-aligned
37 * so they are allowed to end up in the .data.cacheline_aligned 37 * so they are allowed to end up in the .data..cacheline_aligned
38 * section. Since TSS's are completely CPU-local, we want them 38 * section. Since TSS's are completely CPU-local, we want them
39 * on exact cacheline boundaries, to eliminate cacheline ping-pong. 39 * on exact cacheline boundaries, to eliminate cacheline ping-pong.
40 */ 40 */
diff --git a/arch/x86/kernel/setup_percpu.c b/arch/x86/kernel/setup_percpu.c
index a867940a6dfc..cf592767812e 100644
--- a/arch/x86/kernel/setup_percpu.c
+++ b/arch/x86/kernel/setup_percpu.c
@@ -247,7 +247,7 @@ void __init setup_per_cpu_areas(void)
247#endif 247#endif
248#endif 248#endif
249 /* 249 /*
250 * Up to this point, the boot CPU has been using .data.init 250 * Up to this point, the boot CPU has been using .init.data
251 * area. Reload any changed state for the boot CPU. 251 * area. Reload any changed state for the boot CPU.
252 */ 252 */
253 if (cpu == boot_cpu_id) 253 if (cpu == boot_cpu_id)
diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S
index 2cc249718c46..d0bb52296fa3 100644
--- a/arch/x86/kernel/vmlinux.lds.S
+++ b/arch/x86/kernel/vmlinux.lds.S
@@ -97,7 +97,7 @@ SECTIONS
97 HEAD_TEXT 97 HEAD_TEXT
98#ifdef CONFIG_X86_32 98#ifdef CONFIG_X86_32
99 . = ALIGN(PAGE_SIZE); 99 . = ALIGN(PAGE_SIZE);
100 *(.text.page_aligned) 100 *(.text..page_aligned)
101#endif 101#endif
102 . = ALIGN(8); 102 . = ALIGN(8);
103 _stext = .; 103 _stext = .;
@@ -305,7 +305,7 @@ SECTIONS
305 . = ALIGN(PAGE_SIZE); 305 . = ALIGN(PAGE_SIZE);
306 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { 306 .bss : AT(ADDR(.bss) - LOAD_OFFSET) {
307 __bss_start = .; 307 __bss_start = .;
308 *(.bss.page_aligned) 308 *(.bss..page_aligned)
309 *(.bss) 309 *(.bss)
310 . = ALIGN(4); 310 . = ALIGN(4);
311 __bss_stop = .; 311 __bss_stop = .;
diff --git a/include/asm-generic/percpu.h b/include/asm-generic/percpu.h
index 04f91c2d3f7b..b5043a9890d8 100644
--- a/include/asm-generic/percpu.h
+++ b/include/asm-generic/percpu.h
@@ -80,7 +80,7 @@ extern void setup_per_cpu_areas(void);
80 80
81#ifndef PER_CPU_BASE_SECTION 81#ifndef PER_CPU_BASE_SECTION
82#ifdef CONFIG_SMP 82#ifdef CONFIG_SMP
83#define PER_CPU_BASE_SECTION ".data.percpu" 83#define PER_CPU_BASE_SECTION ".data..percpu"
84#else 84#else
85#define PER_CPU_BASE_SECTION ".data" 85#define PER_CPU_BASE_SECTION ".data"
86#endif 86#endif
@@ -92,15 +92,15 @@ extern void setup_per_cpu_areas(void);
92#define PER_CPU_SHARED_ALIGNED_SECTION "" 92#define PER_CPU_SHARED_ALIGNED_SECTION ""
93#define PER_CPU_ALIGNED_SECTION "" 93#define PER_CPU_ALIGNED_SECTION ""
94#else 94#else
95#define PER_CPU_SHARED_ALIGNED_SECTION ".shared_aligned" 95#define PER_CPU_SHARED_ALIGNED_SECTION "..shared_aligned"
96#define PER_CPU_ALIGNED_SECTION ".shared_aligned" 96#define PER_CPU_ALIGNED_SECTION "..shared_aligned"
97#endif 97#endif
98#define PER_CPU_FIRST_SECTION ".first" 98#define PER_CPU_FIRST_SECTION "..first"
99 99
100#else 100#else
101 101
102#define PER_CPU_SHARED_ALIGNED_SECTION "" 102#define PER_CPU_SHARED_ALIGNED_SECTION ""
103#define PER_CPU_ALIGNED_SECTION ".shared_aligned" 103#define PER_CPU_ALIGNED_SECTION "..shared_aligned"
104#define PER_CPU_FIRST_SECTION "" 104#define PER_CPU_FIRST_SECTION ""
105 105
106#endif 106#endif
diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index ef779c6fc3d7..48c5299cbf26 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -175,25 +175,25 @@
175#define NOSAVE_DATA \ 175#define NOSAVE_DATA \
176 . = ALIGN(PAGE_SIZE); \ 176 . = ALIGN(PAGE_SIZE); \
177 VMLINUX_SYMBOL(__nosave_begin) = .; \ 177 VMLINUX_SYMBOL(__nosave_begin) = .; \
178 *(.data.nosave) \ 178 *(.data..nosave) \
179 . = ALIGN(PAGE_SIZE); \ 179 . = ALIGN(PAGE_SIZE); \
180 VMLINUX_SYMBOL(__nosave_end) = .; 180 VMLINUX_SYMBOL(__nosave_end) = .;
181 181
182#define PAGE_ALIGNED_DATA(page_align) \ 182#define PAGE_ALIGNED_DATA(page_align) \
183 . = ALIGN(page_align); \ 183 . = ALIGN(page_align); \
184 *(.data.page_aligned) 184 *(.data..page_aligned)
185 185
186#define READ_MOSTLY_DATA(align) \ 186#define READ_MOSTLY_DATA(align) \
187 . = ALIGN(align); \ 187 . = ALIGN(align); \
188 *(.data.read_mostly) 188 *(.data..read_mostly)
189 189
190#define CACHELINE_ALIGNED_DATA(align) \ 190#define CACHELINE_ALIGNED_DATA(align) \
191 . = ALIGN(align); \ 191 . = ALIGN(align); \
192 *(.data.cacheline_aligned) 192 *(.data..cacheline_aligned)
193 193
194#define INIT_TASK_DATA(align) \ 194#define INIT_TASK_DATA(align) \
195 . = ALIGN(align); \ 195 . = ALIGN(align); \
196 *(.data.init_task) 196 *(.data..init_task)
197 197
198/* 198/*
199 * Read only Data 199 * Read only Data
@@ -435,7 +435,7 @@
435 */ 435 */
436#define INIT_TASK_DATA_SECTION(align) \ 436#define INIT_TASK_DATA_SECTION(align) \
437 . = ALIGN(align); \ 437 . = ALIGN(align); \
438 .data.init_task : { \ 438 .data..init_task : { \
439 INIT_TASK_DATA(align) \ 439 INIT_TASK_DATA(align) \
440 } 440 }
441 441
@@ -499,7 +499,7 @@
499#define BSS(bss_align) \ 499#define BSS(bss_align) \
500 . = ALIGN(bss_align); \ 500 . = ALIGN(bss_align); \
501 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \ 501 .bss : AT(ADDR(.bss) - LOAD_OFFSET) { \
502 *(.bss.page_aligned) \ 502 *(.bss..page_aligned) \
503 *(.dynbss) \ 503 *(.dynbss) \
504 *(.bss) \ 504 *(.bss) \
505 *(COMMON) \ 505 *(COMMON) \
@@ -666,16 +666,16 @@
666 */ 666 */
667#define PERCPU_VADDR(vaddr, phdr) \ 667#define PERCPU_VADDR(vaddr, phdr) \
668 VMLINUX_SYMBOL(__per_cpu_load) = .; \ 668 VMLINUX_SYMBOL(__per_cpu_load) = .; \
669 .data.percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \ 669 .data..percpu vaddr : AT(VMLINUX_SYMBOL(__per_cpu_load) \
670 - LOAD_OFFSET) { \ 670 - LOAD_OFFSET) { \
671 VMLINUX_SYMBOL(__per_cpu_start) = .; \ 671 VMLINUX_SYMBOL(__per_cpu_start) = .; \
672 *(.data.percpu.first) \ 672 *(.data..percpu..first) \
673 *(.data.percpu.page_aligned) \ 673 *(.data..percpu..page_aligned) \
674 *(.data.percpu) \ 674 *(.data..percpu) \
675 *(.data.percpu.shared_aligned) \ 675 *(.data..percpu..shared_aligned) \
676 VMLINUX_SYMBOL(__per_cpu_end) = .; \ 676 VMLINUX_SYMBOL(__per_cpu_end) = .; \
677 } phdr \ 677 } phdr \
678 . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data.percpu); 678 . = VMLINUX_SYMBOL(__per_cpu_load) + SIZEOF(.data..percpu);
679 679
680/** 680/**
681 * PERCPU - define output section for percpu area, simple version 681 * PERCPU - define output section for percpu area, simple version
@@ -687,18 +687,18 @@
687 * 687 *
688 * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except 688 * This macro is equivalent to ALIGN(align); PERCPU_VADDR( , ) except
689 * that __per_cpu_load is defined as a relative symbol against 689 * that __per_cpu_load is defined as a relative symbol against
690 * .data.percpu which is required for relocatable x86_32 690 * .data..percpu which is required for relocatable x86_32
691 * configuration. 691 * configuration.
692 */ 692 */
693#define PERCPU(align) \ 693#define PERCPU(align) \
694 . = ALIGN(align); \ 694 . = ALIGN(align); \
695 .data.percpu : AT(ADDR(.data.percpu) - LOAD_OFFSET) { \ 695 .data..percpu : AT(ADDR(.data..percpu) - LOAD_OFFSET) { \
696 VMLINUX_SYMBOL(__per_cpu_load) = .; \ 696 VMLINUX_SYMBOL(__per_cpu_load) = .; \
697 VMLINUX_SYMBOL(__per_cpu_start) = .; \ 697 VMLINUX_SYMBOL(__per_cpu_start) = .; \
698 *(.data.percpu.first) \ 698 *(.data..percpu..first) \
699 *(.data.percpu.page_aligned) \ 699 *(.data..percpu..page_aligned) \
700 *(.data.percpu) \ 700 *(.data..percpu) \
701 *(.data.percpu.shared_aligned) \ 701 *(.data..percpu..shared_aligned) \
702 VMLINUX_SYMBOL(__per_cpu_end) = .; \ 702 VMLINUX_SYMBOL(__per_cpu_end) = .; \
703 } 703 }
704 704
diff --git a/include/linux/cache.h b/include/linux/cache.h
index 97e24881c4c6..4c570653ab84 100644
--- a/include/linux/cache.h
+++ b/include/linux/cache.h
@@ -31,7 +31,7 @@
31#ifndef __cacheline_aligned 31#ifndef __cacheline_aligned
32#define __cacheline_aligned \ 32#define __cacheline_aligned \
33 __attribute__((__aligned__(SMP_CACHE_BYTES), \ 33 __attribute__((__aligned__(SMP_CACHE_BYTES), \
34 __section__(".data.cacheline_aligned"))) 34 __section__(".data..cacheline_aligned")))
35#endif /* __cacheline_aligned */ 35#endif /* __cacheline_aligned */
36 36
37#ifndef __cacheline_aligned_in_smp 37#ifndef __cacheline_aligned_in_smp
diff --git a/include/linux/init.h b/include/linux/init.h
index ab1d31f9352b..de994304e0bb 100644
--- a/include/linux/init.h
+++ b/include/linux/init.h
@@ -301,7 +301,7 @@ void __init parse_early_options(char *cmdline);
301#endif 301#endif
302 302
303/* Data marked not to be saved by software suspend */ 303/* Data marked not to be saved by software suspend */
304#define __nosavedata __section(.data.nosave) 304#define __nosavedata __section(.data..nosave)
305 305
306/* This means "can be init if no module support, otherwise module load 306/* This means "can be init if no module support, otherwise module load
307 may call it." */ 307 may call it." */
diff --git a/include/linux/init_task.h b/include/linux/init_task.h
index 2beaa13492be..1f43fa56f600 100644
--- a/include/linux/init_task.h
+++ b/include/linux/init_task.h
@@ -183,7 +183,7 @@ extern struct cred init_cred;
183} 183}
184 184
185/* Attach to the init_task data structure for proper alignment */ 185/* Attach to the init_task data structure for proper alignment */
186#define __init_task_data __attribute__((__section__(".data.init_task"))) 186#define __init_task_data __attribute__((__section__(".data..init_task")))
187 187
188 188
189#endif 189#endif
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index 5126cceb6ae9..7135ebc8428c 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -18,8 +18,8 @@
18# define asmregparm 18# define asmregparm
19#endif 19#endif
20 20
21#define __page_aligned_data __section(.data.page_aligned) __aligned(PAGE_SIZE) 21#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
22#define __page_aligned_bss __section(.bss.page_aligned) __aligned(PAGE_SIZE) 22#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
23 23
24/* 24/*
25 * For assembly routines. 25 * For assembly routines.
@@ -27,8 +27,8 @@
27 * Note when using these that you must specify the appropriate 27 * Note when using these that you must specify the appropriate
28 * alignment directives yourself 28 * alignment directives yourself
29 */ 29 */
30#define __PAGE_ALIGNED_DATA .section ".data.page_aligned", "aw" 30#define __PAGE_ALIGNED_DATA .section ".data..page_aligned", "aw"
31#define __PAGE_ALIGNED_BSS .section ".bss.page_aligned", "aw" 31#define __PAGE_ALIGNED_BSS .section ".bss..page_aligned", "aw"
32 32
33/* 33/*
34 * This is used by architectures to keep arguments on the stack 34 * This is used by architectures to keep arguments on the stack
diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h
index 68567c0b3a5d..ce2dc655cd1d 100644
--- a/include/linux/percpu-defs.h
+++ b/include/linux/percpu-defs.h
@@ -131,11 +131,11 @@
131 * Declaration/definition used for per-CPU variables that must be page aligned. 131 * Declaration/definition used for per-CPU variables that must be page aligned.
132 */ 132 */
133#define DECLARE_PER_CPU_PAGE_ALIGNED(type, name) \ 133#define DECLARE_PER_CPU_PAGE_ALIGNED(type, name) \
134 DECLARE_PER_CPU_SECTION(type, name, ".page_aligned") \ 134 DECLARE_PER_CPU_SECTION(type, name, "..page_aligned") \
135 __aligned(PAGE_SIZE) 135 __aligned(PAGE_SIZE)
136 136
137#define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \ 137#define DEFINE_PER_CPU_PAGE_ALIGNED(type, name) \
138 DEFINE_PER_CPU_SECTION(type, name, ".page_aligned") \ 138 DEFINE_PER_CPU_SECTION(type, name, "..page_aligned") \
139 __aligned(PAGE_SIZE) 139 __aligned(PAGE_SIZE)
140 140
141/* 141/*
diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
index 89fac6a3f78b..f8854655860e 100644
--- a/include/linux/spinlock.h
+++ b/include/linux/spinlock.h
@@ -60,7 +60,7 @@
60/* 60/*
61 * Must define these before including other files, inline functions need them 61 * Must define these before including other files, inline functions need them
62 */ 62 */
63#define LOCK_SECTION_NAME ".text.lock."KBUILD_BASENAME 63#define LOCK_SECTION_NAME ".text..lock."KBUILD_BASENAME
64 64
65#define LOCK_SECTION_START(extra) \ 65#define LOCK_SECTION_START(extra) \
66 ".subsection 1\n\t" \ 66 ".subsection 1\n\t" \
diff --git a/init/Kconfig b/init/Kconfig
index 2cce9f343ad0..5cff9a980c39 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -76,6 +76,14 @@ config INIT_ENV_ARG_LIMIT
76 variables passed to init from the kernel command line. 76 variables passed to init from the kernel command line.
77 77
78 78
79config CROSS_COMPILE
80 string "Cross-compiler tool prefix"
81 help
82 Same as running 'make CROSS_COMPILE=prefix-' but stored for
83 default make runs in this kernel build directory. You don't
84 need to set this unless you want the configured kernel build
85 directory to select the cross-compiler automatically.
86
79config LOCALVERSION 87config LOCALVERSION
80 string "Local version - append to kernel release" 88 string "Local version - append to kernel release"
81 help 89 help
diff --git a/kernel/module.c b/kernel/module.c
index d806e00e4450..0129769301e3 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -403,7 +403,7 @@ static unsigned int find_pcpusec(Elf_Ehdr *hdr,
403 Elf_Shdr *sechdrs, 403 Elf_Shdr *sechdrs,
404 const char *secstrings) 404 const char *secstrings)
405{ 405{
406 return find_sec(hdr, sechdrs, secstrings, ".data.percpu"); 406 return find_sec(hdr, sechdrs, secstrings, ".data..percpu");
407} 407}
408 408
409static void percpu_modcopy(struct module *mod, 409static void percpu_modcopy(struct module *mod,
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 0b94d2fa3a88..e4deb73e9a84 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -82,7 +82,7 @@ ifneq ($(strip $(lib-y) $(lib-m) $(lib-n) $(lib-)),)
82lib-target := $(obj)/lib.a 82lib-target := $(obj)/lib.a
83endif 83endif
84 84
85ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),) 85ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(subdir-m) $(lib-target)),)
86builtin-target := $(obj)/built-in.o 86builtin-target := $(obj)/built-in.o
87endif 87endif
88 88
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index cbcd654215e6..54fd1b700131 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -241,7 +241,7 @@ cmd_lzma = (cat $(filter-out FORCE,$^) | \
241 lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 241 lzma -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
242 (rm -f $@ ; false) 242 (rm -f $@ ; false)
243 243
244quiet_cmd_lzo = LZO $@ 244quiet_cmd_lzo = LZO $@
245cmd_lzo = (cat $(filter-out FORCE,$^) | \ 245cmd_lzo = (cat $(filter-out FORCE,$^) | \
246 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \ 246 lzop -9 && $(call size_append, $(filter-out FORCE,$^))) > $@ || \
247 (rm -f $@ ; false) 247 (rm -f $@ ; false)
diff --git a/scripts/checkincludes.pl b/scripts/checkincludes.pl
index 676ddc07d6fa..97b2c6143fe4 100755
--- a/scripts/checkincludes.pl
+++ b/scripts/checkincludes.pl
@@ -11,6 +11,8 @@
11# you do have real dups and do not have them under #ifdef's. You 11# you do have real dups and do not have them under #ifdef's. You
12# could also just review the results. 12# could also just review the results.
13 13
14use strict;
15
14sub usage { 16sub usage {
15 print "Usage: checkincludes.pl [-r]\n"; 17 print "Usage: checkincludes.pl [-r]\n";
16 print "By default we just warn of duplicates\n"; 18 print "By default we just warn of duplicates\n";
@@ -35,23 +37,24 @@ if ($#ARGV >= 1) {
35 } 37 }
36} 38}
37 39
38foreach $file (@ARGV) { 40foreach my $file (@ARGV) {
39 open(FILE, $file) or die "Cannot open $file: $!.\n"; 41 open(my $f, '<', $file)
42 or die "Cannot open $file: $!.\n";
40 43
41 my %includedfiles = (); 44 my %includedfiles = ();
42 my @file_lines = (); 45 my @file_lines = ();
43 46
44 while (<FILE>) { 47 while (<$f>) {
45 if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) { 48 if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) {
46 ++$includedfiles{$1}; 49 ++$includedfiles{$1};
47 } 50 }
48 push(@file_lines, $_); 51 push(@file_lines, $_);
49 } 52 }
50 53
51 close(FILE); 54 close($f);
52 55
53 if (!$remove) { 56 if (!$remove) {
54 foreach $filename (keys %includedfiles) { 57 foreach my $filename (keys %includedfiles) {
55 if ($includedfiles{$filename} > 1) { 58 if ($includedfiles{$filename} > 1) {
56 print "$file: $filename is included more than once.\n"; 59 print "$file: $filename is included more than once.\n";
57 } 60 }
@@ -59,27 +62,28 @@ foreach $file (@ARGV) {
59 next; 62 next;
60 } 63 }
61 64
62 open(FILE,">$file") || die("Cannot write to $file: $!"); 65 open($f, '>', $file)
66 or die("Cannot write to $file: $!");
63 67
64 my $dups = 0; 68 my $dups = 0;
65 foreach (@file_lines) { 69 foreach (@file_lines) {
66 if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) { 70 if (m/^\s*#\s*include\s*[<"](\S*)[>"]/o) {
67 foreach $filename (keys %includedfiles) { 71 foreach my $filename (keys %includedfiles) {
68 if ($1 eq $filename) { 72 if ($1 eq $filename) {
69 if ($includedfiles{$filename} > 1) { 73 if ($includedfiles{$filename} > 1) {
70 $includedfiles{$filename}--; 74 $includedfiles{$filename}--;
71 $dups++; 75 $dups++;
72 } else { 76 } else {
73 print FILE $_; 77 print {$f} $_;
74 } 78 }
75 } 79 }
76 } 80 }
77 } else { 81 } else {
78 print FILE $_; 82 print {$f} $_;
79 } 83 }
80 } 84 }
81 if ($dups > 0) { 85 if ($dups > 0) {
82 print "$file: removed $dups duplicate includes\n"; 86 print "$file: removed $dups duplicate includes\n";
83 } 87 }
84 close(FILE); 88 close($f);
85} 89}
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl
index 14ee68e991dd..1afff6658a7d 100755
--- a/scripts/checkstack.pl
+++ b/scripts/checkstack.pl
@@ -21,6 +21,8 @@
21# 21#
22# TODO : Port to all architectures (one regex per arch) 22# TODO : Port to all architectures (one regex per arch)
23 23
24use strict;
25
24# check for arch 26# check for arch
25# 27#
26# $re is used for two matches: 28# $re is used for two matches:
@@ -104,19 +106,11 @@ my (@stack, $re, $dre, $x, $xs);
104 } 106 }
105} 107}
106 108
107sub bysize($) {
108 my ($asize, $bsize);
109 ($asize = $a) =~ s/.*: *(.*)$/$1/;
110 ($bsize = $b) =~ s/.*: *(.*)$/$1/;
111 $bsize <=> $asize
112}
113
114# 109#
115# main() 110# main()
116# 111#
117my $funcre = qr/^$x* <(.*)>:$/; 112my $funcre = qr/^$x* <(.*)>:$/;
118my $func; 113my ($func, $file, $lastslash);
119my $file, $lastslash;
120 114
121while (my $line = <STDIN>) { 115while (my $line = <STDIN>) {
122 if ($line =~ m/$funcre/) { 116 if ($line =~ m/$funcre/) {
@@ -173,4 +167,6 @@ while (my $line = <STDIN>) {
173 } 167 }
174} 168}
175 169
176print sort bysize @stack; 170# Sort output by size (last field)
171print sort { ($b =~ /:\t*(\d+)$/)[0] <=> ($a =~ /:\t*(\d+)$/)[0] } @stack;
172
diff --git a/scripts/checkversion.pl b/scripts/checkversion.pl
index ec7d21161bdc..b444e89a0095 100755
--- a/scripts/checkversion.pl
+++ b/scripts/checkversion.pl
@@ -5,23 +5,22 @@
5# including <linux/version.h> that don't need it. 5# including <linux/version.h> that don't need it.
6# Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net> 6# Copyright (C) 2003, Randy Dunlap <rdunlap@xenotime.net>
7 7
8use strict;
9
8$| = 1; 10$| = 1;
9 11
10my $debugging = 0; 12my $debugging;
11 13
12foreach $file (@ARGV) 14foreach my $file (@ARGV) {
13{
14 # Open this file. 15 # Open this file.
15 open(FILE, $file) || die "Can't open $file: $!\n"; 16 open( my $f, '<', $file )
17 or die "Can't open $file: $!\n";
16 18
17 # Initialize variables. 19 # Initialize variables.
18 my $fInComment = 0; 20 my ($fInComment, $fInString, $fUseVersion);
19 my $fInString = 0;
20 my $fUseVersion = 0;
21 my $iLinuxVersion = 0; 21 my $iLinuxVersion = 0;
22 22
23 LINE: while ( <FILE> ) 23 while (<$f>) {
24 {
25 # Strip comments. 24 # Strip comments.
26 $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next); 25 $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next);
27 m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1))); 26 m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1)));
@@ -43,8 +42,8 @@ foreach $file (@ARGV)
43 # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE 42 # Look for uses: LINUX_VERSION_CODE, KERNEL_VERSION, UTS_RELEASE
44 if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) { 43 if (($_ =~ /LINUX_VERSION_CODE/) || ($_ =~ /\WKERNEL_VERSION/)) {
45 $fUseVersion = 1; 44 $fUseVersion = 1;
46 last LINE if $iLinuxVersion; 45 last if $iLinuxVersion;
47 } 46 }
48 } 47 }
49 48
50 # Report used version IDs without include? 49 # Report used version IDs without include?
@@ -67,5 +66,5 @@ foreach $file (@ARGV)
67 } 66 }
68 } 67 }
69 68
70 close(FILE); 69 close($f);
71} 70}
diff --git a/scripts/decodecode b/scripts/decodecode
index 4b00647814bc..8b30cc36744f 100755
--- a/scripts/decodecode
+++ b/scripts/decodecode
@@ -7,7 +7,7 @@
7# AFLAGS=--32 decodecode < 386.oops 7# AFLAGS=--32 decodecode < 386.oops
8 8
9cleanup() { 9cleanup() {
10 rm -f $T $T.s $T.o $T.oo $T.aa $T.aaa 10 rm -f $T $T.s $T.o $T.oo $T.aa $T.dis
11 exit 1 11 exit 1
12} 12}
13 13
@@ -39,6 +39,29 @@ fi
39echo $code 39echo $code
40code=`echo $code | sed -e 's/.*Code: //'` 40code=`echo $code | sed -e 's/.*Code: //'`
41 41
42width=`expr index "$code" ' '`
43width=$[($width-1)/2]
44case $width in
451) type=byte ;;
462) type=2byte ;;
474) type=4byte ;;
48esac
49
50disas() {
51 ${CROSS_COMPILE}as $AFLAGS -o $1.o $1.s &> /dev/null
52
53 if [ "$ARCH" == "arm" ]; then
54 if [ $width == 2 ]; then
55 OBJDUMPFLAGS="-M force-thumb"
56 fi
57
58 ${CROSS_COMPILE}strip $1.o
59 fi
60
61 ${CROSS_COMPILE}objdump $OBJDUMPFLAGS -S $1.o | \
62 grep -v "/tmp\|Disassembly\|\.text\|^$" &> $1.dis
63}
64
42marker=`expr index "$code" "\<"` 65marker=`expr index "$code" "\<"`
43if [ $marker -eq 0 ]; then 66if [ $marker -eq 0 ]; then
44 marker=`expr index "$code" "\("` 67 marker=`expr index "$code" "\("`
@@ -49,26 +72,25 @@ if [ $marker -ne 0 ]; then
49 echo All code >> $T.oo 72 echo All code >> $T.oo
50 echo ======== >> $T.oo 73 echo ======== >> $T.oo
51 beforemark=`echo "$code"` 74 beforemark=`echo "$code"`
52 echo -n " .byte 0x" > $T.s 75 echo -n " .$type 0x" > $T.s
53 echo $beforemark | sed -e 's/ /,0x/g' | sed -e 's/<//g' | sed -e 's/>//g' >> $T.s 76 echo $beforemark | sed -e 's/ /,0x/g; s/[<>()]//g' >> $T.s
54 as $AFLAGS -o $T.o $T.s &> /dev/null 77 disas $T
55 objdump -S $T.o | grep -v "/tmp" | grep -v "Disassembly" | grep -v "\.text" | grep -v "^$" &> $T.ooo 78 cat $T.dis >> $T.oo
56 cat $T.ooo >> $T.oo 79 rm -f $T.o $T.s $T.dis
57 rm -f $T.o $T.s $T.ooo
58 80
59# and fix code at-and-after marker 81# and fix code at-and-after marker
60 code=`echo "$code" | cut -c$((${marker} + 1))-` 82 code=`echo "$code" | cut -c$((${marker} + 1))-`
61fi 83fi
62echo Code starting with the faulting instruction > $T.aa 84echo Code starting with the faulting instruction > $T.aa
63echo =========================================== >> $T.aa 85echo =========================================== >> $T.aa
64code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'` 86code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g; s/[>)]$//'`
65echo -n " .byte 0x" > $T.s 87echo -n " .$type 0x" > $T.s
66echo $code >> $T.s 88echo $code >> $T.s
67as $AFLAGS -o $T.o $T.s &> /dev/null 89disas $T
68objdump -S $T.o | grep -v "Disassembly" | grep -v "/tmp" | grep -v "\.text" | grep -v "^$" &> $T.aaa 90cat $T.dis >> $T.aa
69cat $T.aaa >> $T.aa
70 91
71faultline=`cat $T.aaa | head -1 | cut -d":" -f2` 92faultline=`cat $T.dis | head -1 | cut -d":" -f2`
93faultline=`echo "$faultline" | sed -e 's/\[/\\\[/g; s/\]/\\\]/g'`
72 94
73cat $T.oo | sed -e "s/\($faultline\)/\*\1 <-- trapping instruction/g" 95cat $T.oo | sed -e "s/\($faultline\)/\*\1 <-- trapping instruction/g"
74echo 96echo
diff --git a/scripts/export_report.pl b/scripts/export_report.pl
index 705b5ba7c152..04dce7c15f83 100644
--- a/scripts/export_report.pl
+++ b/scripts/export_report.pl
@@ -49,10 +49,10 @@ sub usage {
49} 49}
50 50
51sub collectcfiles { 51sub collectcfiles {
52 my @file = `cat .tmp_versions/*.mod | grep '.*\.ko\$'`; 52 my @file
53 @file = grep {s/\.ko/.mod.c/} @file; 53 = `cat .tmp_versions/*.mod | grep '.*\.ko\$' | sed s/\.ko$/.mod.c/`;
54 chomp @file; 54 chomp @file;
55 return @file; 55 return @file;
56} 56}
57 57
58my (%SYMBOL, %MODULE, %opt, @allcfiles); 58my (%SYMBOL, %MODULE, %opt, @allcfiles);
@@ -71,37 +71,40 @@ if (not defined $opt{'k'}) {
71 $opt{'k'} = "Module.symvers"; 71 $opt{'k'} = "Module.symvers";
72} 72}
73 73
74unless (open(MODULE_SYMVERS, $opt{'k'})) { 74open (my $module_symvers, '<', $opt{'k'})
75 die "Sorry, cannot open $opt{'k'}: $!\n"; 75 or die "Sorry, cannot open $opt{'k'}: $!\n";
76}
77 76
78if (defined $opt{'o'}) { 77if (defined $opt{'o'}) {
79 unless (open(OUTPUT_HANDLE, ">$opt{'o'}")) { 78 open (my $out, '>', $opt{'o'})
80 die "Sorry, cannot open $opt{'o'} $!\n"; 79 or die "Sorry, cannot open $opt{'o'} $!\n";
81 } 80
82 select OUTPUT_HANDLE; 81 select $out;
83} 82}
83
84# 84#
85# collect all the symbols and their attributes from the 85# collect all the symbols and their attributes from the
86# Module.symvers file 86# Module.symvers file
87# 87#
88while ( <MODULE_SYMVERS> ) { 88while ( <$module_symvers> ) {
89 chomp; 89 chomp;
90 my (undef, $symbol, $module, $gpl) = split; 90 my (undef, $symbol, $module, $gpl) = split;
91 $SYMBOL { $symbol } = [ $module , "0" , $symbol, $gpl]; 91 $SYMBOL { $symbol } = [ $module , "0" , $symbol, $gpl];
92} 92}
93close(MODULE_SYMVERS); 93close($module_symvers);
94 94
95# 95#
96# collect the usage count of each symbol. 96# collect the usage count of each symbol.
97# 97#
98foreach my $thismod (@allcfiles) { 98foreach my $thismod (@allcfiles) {
99 unless (open(MODULE_MODULE, $thismod)) { 99 my $module;
100 print "Sorry, cannot open $thismod: $!\n"; 100
101 unless (open ($module, '<', $thismod)) {
102 warn "Sorry, cannot open $thismod: $!\n";
101 next; 103 next;
102 } 104 }
105
103 my $state=0; 106 my $state=0;
104 while ( <MODULE_MODULE> ) { 107 while ( <$module> ) {
105 chomp; 108 chomp;
106 if ($state == 0) { 109 if ($state == 0) {
107 $state = 1 if ($_ =~ /static const struct modversion_info/); 110 $state = 1 if ($_ =~ /static const struct modversion_info/);
@@ -124,7 +127,7 @@ foreach my $thismod (@allcfiles) {
124 if ($state != 2) { 127 if ($state != 2) {
125 print "WARNING:$thismod is not built with CONFIG_MODVERSION enabled\n"; 128 print "WARNING:$thismod is not built with CONFIG_MODVERSION enabled\n";
126 } 129 }
127 close(MODULE_MODULE); 130 close($module);
128} 131}
129 132
130print "\tThis file reports the exported symbols usage patterns by in-tree\n", 133print "\tThis file reports the exported symbols usage patterns by in-tree\n",
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index a932ae52f921..5958fffb2114 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -202,6 +202,7 @@ input_file() {
202 print_mtime "$1" >> ${output} 202 print_mtime "$1" >> ${output}
203 cat "$1" >> ${output} 203 cat "$1" >> ${output}
204 else 204 else
205 echo "$1 \\"
205 cat "$1" | while read type dir file perm ; do 206 cat "$1" | while read type dir file perm ; do
206 if [ "$type" == "file" ]; then 207 if [ "$type" == "file" ]; then
207 echo "$file \\"; 208 echo "$file \\";
@@ -231,7 +232,7 @@ arg="$1"
231case "$arg" in 232case "$arg" in
232 "-l") # files included in initramfs - used by kbuild 233 "-l") # files included in initramfs - used by kbuild
233 dep_list="list_" 234 dep_list="list_"
234 echo "deps_initramfs := \\" 235 echo "deps_initramfs := $0 \\"
235 shift 236 shift
236 ;; 237 ;;
237 "-o") # generate compressed cpio image named $1 238 "-o") # generate compressed cpio image named $1
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index af6b8363a2d5..f99115ebe925 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -758,8 +758,10 @@ int main(int argc, char **argv)
758 /* setlinebuf(debugfile); */ 758 /* setlinebuf(debugfile); */
759 } 759 }
760 760
761 if (flag_reference) 761 if (flag_reference) {
762 read_reference(ref_file); 762 read_reference(ref_file);
763 fclose(ref_file);
764 }
763 765
764 yyparse(); 766 yyparse();
765 767
diff --git a/scripts/headerdep.pl b/scripts/headerdep.pl
index b7f6c560e24d..8dd019bc5a73 100755
--- a/scripts/headerdep.pl
+++ b/scripts/headerdep.pl
@@ -80,8 +80,7 @@ sub search {
80 my $path = "$i/$filename"; 80 my $path = "$i/$filename";
81 return $path if -f $path; 81 return $path if -f $path;
82 } 82 }
83 83 return;
84 return undef;
85} 84}
86 85
87sub parse_all { 86sub parse_all {
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl
index db1dd7a549f2..50d6cfd1fa77 100644
--- a/scripts/headers_check.pl
+++ b/scripts/headers_check.pl
@@ -28,11 +28,12 @@ my $lineno = 0;
28my $filename; 28my $filename;
29 29
30foreach my $file (@files) { 30foreach my $file (@files) {
31 local *FH;
32 $filename = $file; 31 $filename = $file;
33 open(FH, "<$filename") or die "$filename: $!\n"; 32
33 open(my $fh, '<', $filename)
34 or die "$filename: $!\n";
34 $lineno = 0; 35 $lineno = 0;
35 while ($line = <FH>) { 36 while ($line = <$fh>) {
36 $lineno++; 37 $lineno++;
37 &check_include(); 38 &check_include();
38 &check_asm_types(); 39 &check_asm_types();
@@ -40,7 +41,7 @@ foreach my $file (@files) {
40 &check_declarations(); 41 &check_declarations();
41 # Dropped for now. Too much noise &check_config(); 42 # Dropped for now. Too much noise &check_config();
42 } 43 }
43 close FH; 44 close $fh;
44} 45}
45exit $ret; 46exit $ret;
46 47
@@ -78,7 +79,7 @@ sub check_config
78} 79}
79 80
80my $linux_asm_types; 81my $linux_asm_types;
81sub check_asm_types() 82sub check_asm_types
82{ 83{
83 if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { 84 if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) {
84 return; 85 return;
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl
index b89ca2c58fdb..4ca3be3b2e50 100644
--- a/scripts/headers_install.pl
+++ b/scripts/headers_install.pl
@@ -23,13 +23,13 @@ my ($readdir, $installdir, $arch, @files) = @ARGV;
23my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__"; 23my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__";
24 24
25foreach my $file (@files) { 25foreach my $file (@files) {
26 local *INFILE;
27 local *OUTFILE;
28 my $tmpfile = "$installdir/$file.tmp"; 26 my $tmpfile = "$installdir/$file.tmp";
29 open(INFILE, "<$readdir/$file") 27
30 or die "$readdir/$file: $!\n"; 28 open(my $in, '<', "$readdir/$file")
31 open(OUTFILE, ">$tmpfile") or die "$tmpfile: $!\n"; 29 or die "$readdir/$file: $!\n";
32 while (my $line = <INFILE>) { 30 open(my $out, '>', $tmpfile)
31 or die "$tmpfile: $!\n";
32 while (my $line = <$in>) {
33 $line =~ s/([\s(])__user\s/$1/g; 33 $line =~ s/([\s(])__user\s/$1/g;
34 $line =~ s/([\s(])__force\s/$1/g; 34 $line =~ s/([\s(])__force\s/$1/g;
35 $line =~ s/([\s(])__iomem\s/$1/g; 35 $line =~ s/([\s(])__iomem\s/$1/g;
@@ -39,10 +39,11 @@ foreach my $file (@files) {
39 $line =~ s/(^|\s)(inline)\b/$1__$2__/g; 39 $line =~ s/(^|\s)(inline)\b/$1__$2__/g;
40 $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; 40 $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g;
41 $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; 41 $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g;
42 printf OUTFILE "%s", $line; 42 printf {$out} "%s", $line;
43 } 43 }
44 close OUTFILE; 44 close $out;
45 close INFILE; 45 close $in;
46
46 system $unifdef . " $tmpfile > $installdir/$file"; 47 system $unifdef . " $tmpfile > $installdir/$file";
47 unlink $tmpfile; 48 unlink $tmpfile;
48} 49}
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c
index 86c3896a1e01..e3902fb39afd 100644
--- a/scripts/kallsyms.c
+++ b/scripts/kallsyms.c
@@ -108,8 +108,10 @@ static int read_symbol(FILE *in, struct sym_entry *s)
108 rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str); 108 rc = fscanf(in, "%llx %c %499s\n", &s->addr, &stype, str);
109 if (rc != 3) { 109 if (rc != 3) {
110 if (rc != EOF) { 110 if (rc != EOF) {
111 /* skip line */ 111 /* skip line. sym is used as dummy to
112 fgets(str, 500, in); 112 * shut of "warn_unused_result" warning.
113 */
114 sym = fgets(str, 500, in);
113 } 115 }
114 return -1; 116 return -1;
115 } 117 }
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 186c46604d06..7cdae39b8f09 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -23,6 +23,9 @@ menuconfig: $(obj)/mconf
23config: $(obj)/conf 23config: $(obj)/conf
24 $< $(Kconfig) 24 $< $(Kconfig)
25 25
26nconfig: $(obj)/nconf
27 $< $(Kconfig)
28
26oldconfig: $(obj)/conf 29oldconfig: $(obj)/conf
27 $< -o $(Kconfig) 30 $< -o $(Kconfig)
28 31
@@ -120,6 +123,7 @@ endif
120# Help text used by make help 123# Help text used by make help
121help: 124help:
122 @echo ' config - Update current config utilising a line-oriented program' 125 @echo ' config - Update current config utilising a line-oriented program'
126 @echo ' nconfig - Update current config utilising a ncurses menu based program'
123 @echo ' menuconfig - Update current config utilising a menu based program' 127 @echo ' menuconfig - Update current config utilising a menu based program'
124 @echo ' xconfig - Update current config utilising a QT based front-end' 128 @echo ' xconfig - Update current config utilising a QT based front-end'
125 @echo ' gconfig - Update current config utilising a GTK based front-end' 129 @echo ' gconfig - Update current config utilising a GTK based front-end'
@@ -147,6 +151,8 @@ HOST_EXTRACFLAGS += -DLOCALE
147# =========================================================================== 151# ===========================================================================
148# Shared Makefile for the various kconfig executables: 152# Shared Makefile for the various kconfig executables:
149# conf: Used for defconfig, oldconfig and related targets 153# conf: Used for defconfig, oldconfig and related targets
154# nconf: Used for the nconfig target.
155# Utilizes ncurses
150# mconf: Used for the menuconfig target 156# mconf: Used for the menuconfig target
151# Utilizes the lxdialog package 157# Utilizes the lxdialog package
152# qconf: Used for the xconfig target 158# qconf: Used for the xconfig target
@@ -159,11 +165,16 @@ lxdialog := lxdialog/checklist.o lxdialog/util.o lxdialog/inputbox.o
159lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o 165lxdialog += lxdialog/textbox.o lxdialog/yesno.o lxdialog/menubox.o
160 166
161conf-objs := conf.o zconf.tab.o 167conf-objs := conf.o zconf.tab.o
162mconf-objs := mconf.o zconf.tab.o $(lxdialog) 168mconf-objs := mconf.o zconf.tab.o $(lxdialog)
169nconf-objs := nconf.o zconf.tab.o nconf.gui.o
163kxgettext-objs := kxgettext.o zconf.tab.o 170kxgettext-objs := kxgettext.o zconf.tab.o
164 171
165hostprogs-y := conf qconf gconf kxgettext 172hostprogs-y := conf qconf gconf kxgettext
166 173
174ifeq ($(MAKECMDGOALS),nconfig)
175 hostprogs-y += nconf
176endif
177
167ifeq ($(MAKECMDGOALS),menuconfig) 178ifeq ($(MAKECMDGOALS),menuconfig)
168 hostprogs-y += mconf 179 hostprogs-y += mconf
169endif 180endif
@@ -187,7 +198,7 @@ endif
187 198
188clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ 199clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \
189 .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h 200 .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
190clean-files += mconf qconf gconf 201clean-files += mconf qconf gconf nconf
191clean-files += config.pot linux.pot 202clean-files += config.pot linux.pot
192 203
193# Check that we have the required ncurses stuff installed for lxdialog (menuconfig) 204# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
@@ -212,6 +223,7 @@ HOSTLOADLIBES_gconf = `pkg-config --libs gtk+-2.0 gmodule-2.0 libglade-2.0`
212HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \ 223HOSTCFLAGS_gconf.o = `pkg-config --cflags gtk+-2.0 gmodule-2.0 libglade-2.0` \
213 -D LKC_DIRECT_LINK 224 -D LKC_DIRECT_LINK
214 225
226HOSTLOADLIBES_nconf = -lmenu -lpanel -lncurses
215$(obj)/qconf.o: $(obj)/.tmp_qtcheck 227$(obj)/qconf.o: $(obj)/.tmp_qtcheck
216 228
217ifeq ($(qconf-target),1) 229ifeq ($(qconf-target),1)
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index edd3f39a080a..d83f2322893a 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -1097,9 +1097,32 @@ void expr_fprint(struct expr *e, FILE *out)
1097 1097
1098static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str) 1098static void expr_print_gstr_helper(void *data, struct symbol *sym, const char *str)
1099{ 1099{
1100 str_append((struct gstr*)data, str); 1100 struct gstr *gs = (struct gstr*)data;
1101 const char *sym_str = NULL;
1102
1103 if (sym)
1104 sym_str = sym_get_string_value(sym);
1105
1106 if (gs->max_width) {
1107 unsigned extra_length = strlen(str);
1108 const char *last_cr = strrchr(gs->s, '\n');
1109 unsigned last_line_length;
1110
1111 if (sym_str)
1112 extra_length += 4 + strlen(sym_str);
1113
1114 if (!last_cr)
1115 last_cr = gs->s;
1116
1117 last_line_length = strlen(gs->s) - (last_cr - gs->s);
1118
1119 if ((last_line_length + extra_length) > gs->max_width)
1120 str_append(gs, "\\\n");
1121 }
1122
1123 str_append(gs, str);
1101 if (sym) 1124 if (sym)
1102 str_printf((struct gstr*)data, " [=%s]", sym_get_string_value(sym)); 1125 str_printf(gs, " [=%s]", sym_str);
1103} 1126}
1104 1127
1105void expr_gstr_print(struct expr *e, struct gstr *gs) 1128void expr_gstr_print(struct expr *e, struct gstr *gs)
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index 6408fefae083..891cd9ce9ba2 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -86,7 +86,7 @@ struct symbol {
86 struct expr_value rev_dep; 86 struct expr_value rev_dep;
87}; 87};
88 88
89#define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) 89#define for_all_symbols(i, sym) for (i = 0; i < SYMBOL_HASHSIZE; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER)
90 90
91#define SYMBOL_CONST 0x0001 /* symbol is const */ 91#define SYMBOL_CONST 0x0001 /* symbol is const */
92#define SYMBOL_CHECK 0x0008 /* used during dependency checking */ 92#define SYMBOL_CHECK 0x0008 /* used during dependency checking */
@@ -108,8 +108,7 @@ struct symbol {
108#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ 108#define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */
109 109
110#define SYMBOL_MAXLENGTH 256 110#define SYMBOL_MAXLENGTH 256
111#define SYMBOL_HASHSIZE 257 111#define SYMBOL_HASHSIZE 9973
112#define SYMBOL_HASHMASK 0xff
113 112
114/* A property represent the config options that can be associated 113/* A property represent the config options that can be associated
115 * with a config "symbol". 114 * with a config "symbol".
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 65464366fe38..bef10411837f 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -30,13 +30,16 @@ enum {
30 SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW 30 SINGLE_VIEW, SPLIT_VIEW, FULL_VIEW
31}; 31};
32 32
33enum {
34 OPT_NORMAL, OPT_ALL, OPT_PROMPT
35};
36
33static gint view_mode = FULL_VIEW; 37static gint view_mode = FULL_VIEW;
34static gboolean show_name = TRUE; 38static gboolean show_name = TRUE;
35static gboolean show_range = TRUE; 39static gboolean show_range = TRUE;
36static gboolean show_value = TRUE; 40static gboolean show_value = TRUE;
37static gboolean show_all = FALSE;
38static gboolean show_debug = FALSE;
39static gboolean resizeable = FALSE; 41static gboolean resizeable = FALSE;
42static int opt_mode = OPT_NORMAL;
40 43
41GtkWidget *main_wnd = NULL; 44GtkWidget *main_wnd = NULL;
42GtkWidget *tree1_w = NULL; // left frame 45GtkWidget *tree1_w = NULL; // left frame
@@ -76,36 +79,7 @@ static void conf_changed(void);
76 79
77/* Helping/Debugging Functions */ 80/* Helping/Debugging Functions */
78 81
79 82const char *dbg_sym_flags(int val)
80const char *dbg_print_stype(int val)
81{
82 static char buf[256];
83
84 bzero(buf, 256);
85
86 if (val == S_UNKNOWN)
87 strcpy(buf, "unknown");
88 if (val == S_BOOLEAN)
89 strcpy(buf, "boolean");
90 if (val == S_TRISTATE)
91 strcpy(buf, "tristate");
92 if (val == S_INT)
93 strcpy(buf, "int");
94 if (val == S_HEX)
95 strcpy(buf, "hex");
96 if (val == S_STRING)
97 strcpy(buf, "string");
98 if (val == S_OTHER)
99 strcpy(buf, "other");
100
101#ifdef DEBUG
102 printf("%s", buf);
103#endif
104
105 return buf;
106}
107
108const char *dbg_print_flags(int val)
109{ 83{
110 static char buf[256]; 84 static char buf[256];
111 85
@@ -131,40 +105,10 @@ const char *dbg_print_flags(int val)
131 strcat(buf, "auto/"); 105 strcat(buf, "auto/");
132 106
133 buf[strlen(buf) - 1] = '\0'; 107 buf[strlen(buf) - 1] = '\0';
134#ifdef DEBUG
135 printf("%s", buf);
136#endif
137
138 return buf;
139}
140
141const char *dbg_print_ptype(int val)
142{
143 static char buf[256];
144
145 bzero(buf, 256);
146
147 if (val == P_UNKNOWN)
148 strcpy(buf, "unknown");
149 if (val == P_PROMPT)
150 strcpy(buf, "prompt");
151 if (val == P_COMMENT)
152 strcpy(buf, "comment");
153 if (val == P_MENU)
154 strcpy(buf, "menu");
155 if (val == P_DEFAULT)
156 strcpy(buf, "default");
157 if (val == P_CHOICE)
158 strcpy(buf, "choice");
159
160#ifdef DEBUG
161 printf("%s", buf);
162#endif
163 108
164 return buf; 109 return buf;
165} 110}
166 111
167
168void replace_button_icon(GladeXML * xml, GdkDrawable * window, 112void replace_button_icon(GladeXML * xml, GdkDrawable * window,
169 GtkStyle * style, gchar * btn_name, gchar ** xpm) 113 GtkStyle * style, gchar * btn_name, gchar ** xpm)
170{ 114{
@@ -697,20 +641,29 @@ void on_show_data1_activate(GtkMenuItem * menuitem, gpointer user_data)
697 641
698 642
699void 643void
700on_show_all_options1_activate(GtkMenuItem * menuitem, gpointer user_data) 644on_set_option_mode1_activate(GtkMenuItem *menuitem, gpointer user_data)
701{ 645{
702 show_all = GTK_CHECK_MENU_ITEM(menuitem)->active; 646 opt_mode = OPT_NORMAL;
647 gtk_tree_store_clear(tree2);
648 display_tree(&rootmenu); /* instead of update_tree to speed-up */
649}
650
703 651
652void
653on_set_option_mode2_activate(GtkMenuItem *menuitem, gpointer user_data)
654{
655 opt_mode = OPT_ALL;
704 gtk_tree_store_clear(tree2); 656 gtk_tree_store_clear(tree2);
705 display_tree(&rootmenu); // instead of update_tree to speed-up 657 display_tree(&rootmenu); /* instead of update_tree to speed-up */
706} 658}
707 659
708 660
709void 661void
710on_show_debug_info1_activate(GtkMenuItem * menuitem, gpointer user_data) 662on_set_option_mode3_activate(GtkMenuItem *menuitem, gpointer user_data)
711{ 663{
712 show_debug = GTK_CHECK_MENU_ITEM(menuitem)->active; 664 opt_mode = OPT_PROMPT;
713 update_tree(&rootmenu, NULL); 665 gtk_tree_store_clear(tree2);
666 display_tree(&rootmenu); /* instead of update_tree to speed-up */
714} 667}
715 668
716 669
@@ -1163,7 +1116,10 @@ static gchar **fill_row(struct menu *menu)
1163 g_strdup_printf("%s %s", _(menu_get_prompt(menu)), 1116 g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
1164 sym && sym_has_value(sym) ? "(NEW)" : ""); 1117 sym && sym_has_value(sym) ? "(NEW)" : "");
1165 1118
1166 if (show_all && !menu_is_visible(menu)) 1119 if (opt_mode == OPT_ALL && !menu_is_visible(menu))
1120 row[COL_COLOR] = g_strdup("DarkGray");
1121 else if (opt_mode == OPT_PROMPT &&
1122 menu_has_prompt(menu) && !menu_is_visible(menu))
1167 row[COL_COLOR] = g_strdup("DarkGray"); 1123 row[COL_COLOR] = g_strdup("DarkGray");
1168 else 1124 else
1169 row[COL_COLOR] = g_strdup("Black"); 1125 row[COL_COLOR] = g_strdup("Black");
@@ -1386,16 +1342,19 @@ static void update_tree(struct menu *src, GtkTreeIter * dst)
1386 menu2 ? menu_get_prompt(menu2) : "nil"); 1342 menu2 ? menu_get_prompt(menu2) : "nil");
1387#endif 1343#endif
1388 1344
1389 if (!menu_is_visible(child1) && !show_all) { // remove node 1345 if ((opt_mode == OPT_NORMAL && !menu_is_visible(child1)) ||
1346 (opt_mode == OPT_PROMPT && !menu_has_prompt(child1))) {
1347
1348 /* remove node */
1390 if (gtktree_iter_find_node(dst, menu1) != NULL) { 1349 if (gtktree_iter_find_node(dst, menu1) != NULL) {
1391 memcpy(&tmp, child2, sizeof(GtkTreeIter)); 1350 memcpy(&tmp, child2, sizeof(GtkTreeIter));
1392 valid = gtk_tree_model_iter_next(model2, 1351 valid = gtk_tree_model_iter_next(model2,
1393 child2); 1352 child2);
1394 gtk_tree_store_remove(tree2, &tmp); 1353 gtk_tree_store_remove(tree2, &tmp);
1395 if (!valid) 1354 if (!valid)
1396 return; // next parent 1355 return; /* next parent */
1397 else 1356 else
1398 goto reparse; // next child 1357 goto reparse; /* next child */
1399 } else 1358 } else
1400 continue; 1359 continue;
1401 } 1360 }
@@ -1464,17 +1423,19 @@ static void display_tree(struct menu *menu)
1464 && (tree == tree2)) 1423 && (tree == tree2))
1465 continue; 1424 continue;
1466 1425
1467 if (menu_is_visible(child) || show_all) 1426 if ((opt_mode == OPT_NORMAL && menu_is_visible(child)) ||
1427 (opt_mode == OPT_PROMPT && menu_has_prompt(child)) ||
1428 (opt_mode == OPT_ALL))
1468 place_node(child, fill_row(child)); 1429 place_node(child, fill_row(child));
1469#ifdef DEBUG 1430#ifdef DEBUG
1470 printf("%*c%s: ", indent, ' ', menu_get_prompt(child)); 1431 printf("%*c%s: ", indent, ' ', menu_get_prompt(child));
1471 printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : ""); 1432 printf("%s", child->flags & MENU_ROOT ? "rootmenu | " : "");
1472 dbg_print_ptype(ptype); 1433 printf("%s", prop_get_type_name(ptype));
1473 printf(" | "); 1434 printf(" | ");
1474 if (sym) { 1435 if (sym) {
1475 dbg_print_stype(sym->type); 1436 printf("%s", sym_type_name(sym->type));
1476 printf(" | "); 1437 printf(" | ");
1477 dbg_print_flags(sym->flags); 1438 printf("%s", dbg_sym_flags(sym->flags));
1478 printf("\n"); 1439 printf("\n");
1479 } else 1440 } else
1480 printf("\n"); 1441 printf("\n");
diff --git a/scripts/kconfig/gconf.glade b/scripts/kconfig/gconf.glade
index b1c86c19292c..d52b0a75d824 100644
--- a/scripts/kconfig/gconf.glade
+++ b/scripts/kconfig/gconf.glade
@@ -190,26 +190,40 @@
190 </child> 190 </child>
191 191
192 <child> 192 <child>
193 <widget class="GtkCheckMenuItem" id="show_all_options1"> 193 <widget class="GtkRadioMenuItem" id="set_option_mode1">
194 <property name="visible">True</property>
195 <property name="tooltip" translatable="yes">Show normal options</property>
196 <property name="label" translatable="yes">Show normal options</property>
197 <property name="use_underline">True</property>
198 <property name="active">True</property>
199 <signal name="activate" handler="on_set_option_mode1_activate"/>
200 </widget>
201 </child>
202
203 <child>
204 <widget class="GtkRadioMenuItem" id="set_option_mode2">
194 <property name="visible">True</property> 205 <property name="visible">True</property>
195 <property name="tooltip" translatable="yes">Show all options</property> 206 <property name="tooltip" translatable="yes">Show all options</property>
196 <property name="label" translatable="yes">Show all _options</property> 207 <property name="label" translatable="yes">Show all _options</property>
197 <property name="use_underline">True</property> 208 <property name="use_underline">True</property>
198 <property name="active">False</property> 209 <property name="active">False</property>
199 <signal name="activate" handler="on_show_all_options1_activate"/> 210 <property name="group">set_option_mode1</property>
211 <signal name="activate" handler="on_set_option_mode2_activate"/>
200 </widget> 212 </widget>
201 </child> 213 </child>
202 214
203 <child> 215 <child>
204 <widget class="GtkCheckMenuItem" id="show_debug_info1"> 216 <widget class="GtkRadioMenuItem" id="set_option_mode3">
205 <property name="visible">True</property> 217 <property name="visible">True</property>
206 <property name="tooltip" translatable="yes">Show masked options</property> 218 <property name="tooltip" translatable="yes">Show all options with prompts</property>
207 <property name="label" translatable="yes">Show _debug info</property> 219 <property name="label" translatable="yes">Show all prompt options</property>
208 <property name="use_underline">True</property> 220 <property name="use_underline">True</property>
209 <property name="active">False</property> 221 <property name="active">False</property>
210 <signal name="activate" handler="on_show_debug_info1_activate"/> 222 <property name="group">set_option_mode1</property>
223 <signal name="activate" handler="on_set_option_mode3_activate"/>
211 </widget> 224 </widget>
212 </child> 225 </child>
226
213 </widget> 227 </widget>
214 </child> 228 </child>
215 </widget> 229 </widget>
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index f379b0bf8c9e..ce6549cdaccf 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -84,7 +84,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode);
84void kconfig_load(void); 84void kconfig_load(void);
85 85
86/* menu.c */ 86/* menu.c */
87void menu_init(void); 87void _menu_init(void);
88void menu_warn(struct menu *menu, const char *fmt, ...); 88void menu_warn(struct menu *menu, const char *fmt, ...);
89struct menu *menu_add_menu(void); 89struct menu *menu_add_menu(void);
90void menu_end_menu(void); 90void menu_end_menu(void);
@@ -106,6 +106,11 @@ int file_write_dep(const char *name);
106struct gstr { 106struct gstr {
107 size_t len; 107 size_t len;
108 char *s; 108 char *s;
109 /*
110 * when max_width is not zero long lines in string s (if any) get
111 * wrapped not to exceed the max_width value
112 */
113 int max_width;
109}; 114};
110struct gstr str_new(void); 115struct gstr str_new(void);
111struct gstr str_assign(const char *s); 116struct gstr str_assign(const char *s);
diff --git a/scripts/kconfig/lkc_proto.h b/scripts/kconfig/lkc_proto.h
index ffeb532b2cff..7cadcad8233b 100644
--- a/scripts/kconfig/lkc_proto.h
+++ b/scripts/kconfig/lkc_proto.h
@@ -11,13 +11,15 @@ P(conf_set_changed_callback, void,(void (*fn)(void)));
11/* menu.c */ 11/* menu.c */
12P(rootmenu,struct menu,); 12P(rootmenu,struct menu,);
13 13
14P(menu_is_visible,bool,(struct menu *menu)); 14P(menu_is_visible, bool, (struct menu *menu));
15P(menu_has_prompt, bool, (struct menu *menu));
15P(menu_get_prompt,const char *,(struct menu *menu)); 16P(menu_get_prompt,const char *,(struct menu *menu));
16P(menu_get_root_menu,struct menu *,(struct menu *menu)); 17P(menu_get_root_menu,struct menu *,(struct menu *menu));
17P(menu_get_parent_menu,struct menu *,(struct menu *menu)); 18P(menu_get_parent_menu,struct menu *,(struct menu *menu));
18P(menu_has_help,bool,(struct menu *menu)); 19P(menu_has_help,bool,(struct menu *menu));
19P(menu_get_help,const char *,(struct menu *menu)); 20P(menu_get_help,const char *,(struct menu *menu));
20P(get_symbol_str,void,(struct gstr *r, struct symbol *sym)); 21P(get_symbol_str, void, (struct gstr *r, struct symbol *sym));
22P(get_relations_str, struct gstr, (struct symbol **sym_arr));
21P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help)); 23P(menu_get_ext_help,void,(struct menu *menu, struct gstr *help));
22 24
23/* symbol.c */ 25/* symbol.c */
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
index 616c60138183..dd8e587c50e2 100644
--- a/scripts/kconfig/lxdialog/inputbox.c
+++ b/scripts/kconfig/lxdialog/inputbox.c
@@ -180,7 +180,7 @@ do_resize:
180 case KEY_LEFT: 180 case KEY_LEFT:
181 switch (button) { 181 switch (button) {
182 case -1: 182 case -1:
183 button = 1; /* Indicates "Cancel" button is selected */ 183 button = 1; /* Indicates "Help" button is selected */
184 print_buttons(dialog, height, width, 1); 184 print_buttons(dialog, height, width, 1);
185 break; 185 break;
186 case 0: 186 case 0:
@@ -204,7 +204,7 @@ do_resize:
204 print_buttons(dialog, height, width, 0); 204 print_buttons(dialog, height, width, 0);
205 break; 205 break;
206 case 0: 206 case 0:
207 button = 1; /* Indicates "Cancel" button is selected */ 207 button = 1; /* Indicates "Help" button is selected */
208 print_buttons(dialog, height, width, 1); 208 print_buttons(dialog, height, width, 1);
209 break; 209 break;
210 case 1: 210 case 1:
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index fa9d633f293c..1d604738fa13 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -383,6 +383,10 @@ do_resize:
383 case 'n': 383 case 'n':
384 case 'm': 384 case 'm':
385 case '/': 385 case '/':
386 case 'h':
387 case '?':
388 case 'z':
389 case '\n':
386 /* save scroll info */ 390 /* save scroll info */
387 *s_scroll = scroll; 391 *s_scroll = scroll;
388 delwin(menu); 392 delwin(menu);
@@ -390,8 +394,10 @@ do_resize:
390 item_set(scroll + choice); 394 item_set(scroll + choice);
391 item_set_selected(1); 395 item_set_selected(1);
392 switch (key) { 396 switch (key) {
397 case 'h':
398 case '?':
399 return 2;
393 case 's': 400 case 's':
394 return 3;
395 case 'y': 401 case 'y':
396 return 3; 402 return 3;
397 case 'n': 403 case 'n':
@@ -402,18 +408,12 @@ do_resize:
402 return 6; 408 return 6;
403 case '/': 409 case '/':
404 return 7; 410 return 7;
411 case 'z':
412 return 8;
413 case '\n':
414 return button;
405 } 415 }
406 return 0; 416 return 0;
407 case 'h':
408 case '?':
409 button = 2;
410 case '\n':
411 *s_scroll = scroll;
412 delwin(menu);
413 delwin(dialog);
414 item_set(scroll + choice);
415 item_set_selected(1);
416 return button;
417 case 'e': 417 case 'e':
418 case 'x': 418 case 'x':
419 key = KEY_ESC; 419 key = KEY_ESC;
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 8413cf38ed27..2c83d3234d30 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -67,13 +67,15 @@ static const char mconf_readme[] = N_(
67" there is a delayed response which you may find annoying.\n" 67" there is a delayed response which you may find annoying.\n"
68"\n" 68"\n"
69" Also, the <TAB> and cursor keys will cycle between <Select>,\n" 69" Also, the <TAB> and cursor keys will cycle between <Select>,\n"
70" <Exit> and <Help>\n" 70" <Exit> and <Help>.\n"
71"\n" 71"\n"
72"o To get help with an item, use the cursor keys to highlight <Help>\n" 72"o To get help with an item, use the cursor keys to highlight <Help>\n"
73" and Press <ENTER>.\n" 73" and press <ENTER>.\n"
74"\n" 74"\n"
75" Shortcut: Press <H> or <?>.\n" 75" Shortcut: Press <H> or <?>.\n"
76"\n" 76"\n"
77"o To show hidden options, press <Z>.\n"
78"\n"
77"\n" 79"\n"
78"Radiolists (Choice lists)\n" 80"Radiolists (Choice lists)\n"
79"-----------\n" 81"-----------\n"
@@ -272,6 +274,7 @@ static int indent;
272static struct menu *current_menu; 274static struct menu *current_menu;
273static int child_count; 275static int child_count;
274static int single_menu_mode; 276static int single_menu_mode;
277static int show_all_options;
275 278
276static void conf(struct menu *menu); 279static void conf(struct menu *menu);
277static void conf_choice(struct menu *menu); 280static void conf_choice(struct menu *menu);
@@ -282,19 +285,6 @@ static void show_textbox(const char *title, const char *text, int r, int c);
282static void show_helptext(const char *title, const char *text); 285static void show_helptext(const char *title, const char *text);
283static void show_help(struct menu *menu); 286static void show_help(struct menu *menu);
284 287
285static struct gstr get_relations_str(struct symbol **sym_arr)
286{
287 struct symbol *sym;
288 struct gstr res = str_new();
289 int i;
290
291 for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
292 get_symbol_str(&res, sym);
293 if (!i)
294 str_append(&res, _("No matches found.\n"));
295 return res;
296}
297
298static char filename[PATH_MAX+1]; 288static char filename[PATH_MAX+1];
299static void set_config_filename(const char *config_filename) 289static void set_config_filename(const char *config_filename)
300{ 290{
@@ -359,8 +349,16 @@ static void build_conf(struct menu *menu)
359 int type, tmp, doint = 2; 349 int type, tmp, doint = 2;
360 tristate val; 350 tristate val;
361 char ch; 351 char ch;
362 352 bool visible;
363 if (!menu_is_visible(menu)) 353
354 /*
355 * note: menu_is_visible() has side effect that it will
356 * recalc the value of the symbol.
357 */
358 visible = menu_is_visible(menu);
359 if (show_all_options && !menu_has_prompt(menu))
360 return;
361 else if (!show_all_options && !visible)
364 return; 362 return;
365 363
366 sym = menu->sym; 364 sym = menu->sym;
@@ -619,6 +617,9 @@ static void conf(struct menu *menu)
619 case 7: 617 case 7:
620 search_conf(); 618 search_conf();
621 break; 619 break;
620 case 8:
621 show_all_options = !show_all_options;
622 break;
622 } 623 }
623 } 624 }
624} 625}
@@ -638,6 +639,7 @@ static void show_help(struct menu *menu)
638{ 639{
639 struct gstr help = str_new(); 640 struct gstr help = str_new();
640 641
642 help.max_width = getmaxx(stdscr) - 10;
641 menu_get_ext_help(menu, &help); 643 menu_get_ext_help(menu, &help);
642 644
643 show_helptext(_(menu_get_prompt(menu)), str_get(&help)); 645 show_helptext(_(menu_get_prompt(menu)), str_get(&help));
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index 059a2465c574..203632cc30bd 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -38,7 +38,7 @@ static void prop_warn(struct property *prop, const char *fmt, ...)
38 va_end(ap); 38 va_end(ap);
39} 39}
40 40
41void menu_init(void) 41void _menu_init(void)
42{ 42{
43 current_entry = current_menu = &rootmenu; 43 current_entry = current_menu = &rootmenu;
44 last_entry_ptr = &rootmenu.list; 44 last_entry_ptr = &rootmenu.list;
@@ -197,7 +197,7 @@ static void sym_check_prop(struct symbol *sym)
197 if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) && 197 if ((sym->type == S_STRING || sym->type == S_INT || sym->type == S_HEX) &&
198 prop->expr->type != E_SYMBOL) 198 prop->expr->type != E_SYMBOL)
199 prop_warn(prop, 199 prop_warn(prop,
200 "default for config symbol '%'" 200 "default for config symbol '%s'"
201 " must be a single symbol", sym->name); 201 " must be a single symbol", sym->name);
202 break; 202 break;
203 case P_SELECT: 203 case P_SELECT:
@@ -390,6 +390,13 @@ void menu_finalize(struct menu *parent)
390 } 390 }
391} 391}
392 392
393bool menu_has_prompt(struct menu *menu)
394{
395 if (!menu->prompt)
396 return false;
397 return true;
398}
399
393bool menu_is_visible(struct menu *menu) 400bool menu_is_visible(struct menu *menu)
394{ 401{
395 struct menu *child; 402 struct menu *child;
@@ -398,6 +405,7 @@ bool menu_is_visible(struct menu *menu)
398 405
399 if (!menu->prompt) 406 if (!menu->prompt)
400 return false; 407 return false;
408
401 sym = menu->sym; 409 sym = menu->sym;
402 if (sym) { 410 if (sym) {
403 sym_calc_value(sym); 411 sym_calc_value(sym);
@@ -407,12 +415,14 @@ bool menu_is_visible(struct menu *menu)
407 415
408 if (visible != no) 416 if (visible != no)
409 return true; 417 return true;
418
410 if (!sym || sym_get_tristate_value(menu->sym) == no) 419 if (!sym || sym_get_tristate_value(menu->sym) == no)
411 return false; 420 return false;
412 421
413 for (child = menu->list; child; child = child->next) 422 for (child = menu->list; child; child = child->next)
414 if (menu_is_visible(child)) 423 if (menu_is_visible(child))
415 return true; 424 return true;
425
416 return false; 426 return false;
417} 427}
418 428
@@ -515,6 +525,20 @@ void get_symbol_str(struct gstr *r, struct symbol *sym)
515 str_append(r, "\n\n"); 525 str_append(r, "\n\n");
516} 526}
517 527
528struct gstr get_relations_str(struct symbol **sym_arr)
529{
530 struct symbol *sym;
531 struct gstr res = str_new();
532 int i;
533
534 for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
535 get_symbol_str(&res, sym);
536 if (!i)
537 str_append(&res, _("No matches found.\n"));
538 return res;
539}
540
541
518void menu_get_ext_help(struct menu *menu, struct gstr *help) 542void menu_get_ext_help(struct menu *menu, struct gstr *help)
519{ 543{
520 struct symbol *sym = menu->sym; 544 struct symbol *sym = menu->sym;
diff --git a/scripts/kconfig/nconf.c b/scripts/kconfig/nconf.c
new file mode 100644
index 000000000000..762caf80ce37
--- /dev/null
+++ b/scripts/kconfig/nconf.c
@@ -0,0 +1,1568 @@
1/*
2 * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
3 * Released under the terms of the GNU GPL v2.0.
4 *
5 * Derived from menuconfig.
6 *
7 */
8#define LKC_DIRECT_LINK
9#include "lkc.h"
10#include "nconf.h"
11
12static const char nconf_readme[] = N_(
13"Overview\n"
14"--------\n"
15"Some kernel features may be built directly into the kernel.\n"
16"Some may be made into loadable runtime modules. Some features\n"
17"may be completely removed altogether. There are also certain\n"
18"kernel parameters which are not really features, but must be\n"
19"entered in as decimal or hexadecimal numbers or possibly text.\n"
20"\n"
21"Menu items beginning with following braces represent features that\n"
22" [ ] can be built in or removed\n"
23" < > can be built in, modularized or removed\n"
24" { } can be built in or modularized (selected by other feature)\n"
25" - - are selected by other feature,\n"
26" XXX cannot be selected. use Symbol Info to find out why,\n"
27"while *, M or whitespace inside braces means to build in, build as\n"
28"a module or to exclude the feature respectively.\n"
29"\n"
30"To change any of these features, highlight it with the cursor\n"
31"keys and press <Y> to build it in, <M> to make it a module or\n"
32"<N> to removed it. You may also press the <Space Bar> to cycle\n"
33"through the available options (ie. Y->N->M->Y).\n"
34"\n"
35"Some additional keyboard hints:\n"
36"\n"
37"Menus\n"
38"----------\n"
39"o Use the Up/Down arrow keys (cursor keys) to highlight the item\n"
40" you wish to change use <Enter> or <Space>. Goto submenu by \n"
41" pressing <Enter> of <right-arrow>. Use <Esc> or <left-arrow> to go back.\n"
42" Submenus are designated by \"--->\".\n"
43"\n"
44" Shortcut: Press the option's highlighted letter (hotkey).\n"
45" Pressing a hotkey more than once will sequence\n"
46" through all visible items which use that hotkey.\n"
47"\n"
48" You may also use the <PAGE UP> and <PAGE DOWN> keys to scroll\n"
49" unseen options into view.\n"
50"\n"
51"o To exit a menu use the just press <ESC> <F5> <F8> or <left-arrow>.\n"
52"\n"
53"o To get help with an item, press <F1>\n"
54" Shortcut: Press <h> or <?>.\n"
55"\n"
56"\n"
57"Radiolists (Choice lists)\n"
58"-----------\n"
59"o Use the cursor keys to select the option you wish to set and press\n"
60" <S> or the <SPACE BAR>.\n"
61"\n"
62" Shortcut: Press the first letter of the option you wish to set then\n"
63" press <S> or <SPACE BAR>.\n"
64"\n"
65"o To see available help for the item, press <F1>\n"
66" Shortcut: Press <H> or <?>.\n"
67"\n"
68"\n"
69"Data Entry\n"
70"-----------\n"
71"o Enter the requested information and press <ENTER>\n"
72" If you are entering hexadecimal values, it is not necessary to\n"
73" add the '0x' prefix to the entry.\n"
74"\n"
75"o For help, press <F1>.\n"
76"\n"
77"\n"
78"Text Box (Help Window)\n"
79"--------\n"
80"o Use the cursor keys to scroll up/down/left/right. The VI editor\n"
81" keys h,j,k,l function here as do <SPACE BAR> for those\n"
82" who are familiar with less and lynx.\n"
83"\n"
84"o Press <Enter>, <F1>, <F5>, <F7> or <Esc> to exit.\n"
85"\n"
86"\n"
87"Alternate Configuration Files\n"
88"-----------------------------\n"
89"nconfig supports the use of alternate configuration files for\n"
90"those who, for various reasons, find it necessary to switch\n"
91"between different kernel configurations.\n"
92"\n"
93"At the end of the main menu you will find two options. One is\n"
94"for saving the current configuration to a file of your choosing.\n"
95"The other option is for loading a previously saved alternate\n"
96"configuration.\n"
97"\n"
98"Even if you don't use alternate configuration files, but you\n"
99"find during a nconfig session that you have completely messed\n"
100"up your settings, you may use the \"Load Alternate...\" option to\n"
101"restore your previously saved settings from \".config\" without\n"
102"restarting nconfig.\n"
103"\n"
104"Other information\n"
105"-----------------\n"
106"If you use nconfig in an XTERM window make sure you have your\n"
107"$TERM variable set to point to a xterm definition which supports color.\n"
108"Otherwise, nconfig will look rather bad. nconfig will not\n"
109"display correctly in a RXVT window because rxvt displays only one\n"
110"intensity of color, bright.\n"
111"\n"
112"nconfig will display larger menus on screens or xterms which are\n"
113"set to display more than the standard 25 row by 80 column geometry.\n"
114"In order for this to work, the \"stty size\" command must be able to\n"
115"display the screen's current row and column geometry. I STRONGLY\n"
116"RECOMMEND that you make sure you do NOT have the shell variables\n"
117"LINES and COLUMNS exported into your environment. Some distributions\n"
118"export those variables via /etc/profile. Some ncurses programs can\n"
119"become confused when those variables (LINES & COLUMNS) don't reflect\n"
120"the true screen size.\n"
121"\n"
122"Optional personality available\n"
123"------------------------------\n"
124"If you prefer to have all of the kernel options listed in a single\n"
125"menu, rather than the default multimenu hierarchy, run the nconfig\n"
126"with NCONFIG_MODE environment variable set to single_menu. Example:\n"
127"\n"
128"make NCONFIG_MODE=single_menu nconfig\n"
129"\n"
130"<Enter> will then unroll the appropriate category, or enfold it if it\n"
131"is already unrolled.\n"
132"\n"
133"Note that this mode can eventually be a little more CPU expensive\n"
134"(especially with a larger number of unrolled categories) than the\n"
135"default mode.\n"
136"\n"),
137menu_no_f_instructions[] = N_(
138" You do not have function keys support. Please follow the\n"
139" following instructions:\n"
140" Arrow keys navigate the menu.\n"
141" <Enter> or <right-arrow> selects submenus --->.\n"
142" Capital Letters are hotkeys.\n"
143" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n"
144" Pressing SpaceBar toggles between the above options\n"
145" Press <Esc> or <left-arrow> to go back one menu, \n"
146" <?> or <h> for Help, </> for Search.\n"
147" <1> is interchangable with <F1>, <2> with <F2>, etc.\n"
148" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
149" <Esc> always leaves the current window\n"),
150menu_instructions[] = N_(
151" Arrow keys navigate the menu.\n"
152" <Enter> or <right-arrow> selects submenus --->.\n"
153" Capital Letters are hotkeys.\n"
154" Pressing <Y> includes, <N> excludes, <M> modularizes features.\n"
155" Pressing SpaceBar toggles between the above options\n"
156" Press <Esc>, <F3> or <left-arrow> to go back one menu, \n"
157" <?>, <F1> or <h> for Help, </> for Search.\n"
158" <1> is interchangable with <F1>, <2> with <F2>, etc.\n"
159" Legend: [*] built-in [ ] excluded <M> module < > module capable.\n"
160" <Esc> always leaves the current window\n"),
161radiolist_instructions[] = N_(
162" Use the arrow keys to navigate this window or\n"
163" press the hotkey of the item you wish to select\n"
164" followed by the <SPACE BAR>.\n"
165" Press <?>, <F1> or <h> for additional information about this option.\n"),
166inputbox_instructions_int[] = N_(
167"Please enter a decimal value.\n"
168"Fractions will not be accepted.\n"
169"Press <RETURN> to accept, <ESC> to cancel."),
170inputbox_instructions_hex[] = N_(
171"Please enter a hexadecimal value.\n"
172"Press <RETURN> to accept, <ESC> to cancel."),
173inputbox_instructions_string[] = N_(
174"Please enter a string value.\n"
175"Press <RETURN> to accept, <ESC> to cancel."),
176setmod_text[] = N_(
177"This feature depends on another which\n"
178"has been configured as a module.\n"
179"As a result, this feature will be built as a module."),
180nohelp_text[] = N_(
181"There is no help available for this kernel option.\n"),
182load_config_text[] = N_(
183"Enter the name of the configuration file you wish to load.\n"
184"Accept the name shown to restore the configuration you\n"
185"last retrieved. Leave blank to abort."),
186load_config_help[] = N_(
187"\n"
188"For various reasons, one may wish to keep several different kernel\n"
189"configurations available on a single machine.\n"
190"\n"
191"If you have saved a previous configuration in a file other than the\n"
192"kernel's default, entering the name of the file here will allow you\n"
193"to modify that configuration.\n"
194"\n"
195"If you are uncertain, then you have probably never used alternate\n"
196"configuration files. You should therefor leave this blank to abort.\n"),
197save_config_text[] = N_(
198"Enter a filename to which this configuration should be saved\n"
199"as an alternate. Leave blank to abort."),
200save_config_help[] = N_(
201"\n"
202"For various reasons, one may wish to keep different kernel\n"
203"configurations available on a single machine.\n"
204"\n"
205"Entering a file name here will allow you to later retrieve, modify\n"
206"and use the current configuration as an alternate to whatever\n"
207"configuration options you have selected at that time.\n"
208"\n"
209"If you are uncertain what all this means then you should probably\n"
210"leave this blank.\n"),
211search_help[] = N_(
212"\n"
213"Search for CONFIG_ symbols and display their relations.\n"
214"Regular expressions are allowed.\n"
215"Example: search for \"^FOO\"\n"
216"Result:\n"
217"-----------------------------------------------------------------\n"
218"Symbol: FOO [ = m]\n"
219"Prompt: Foo bus is used to drive the bar HW\n"
220"Defined at drivers/pci/Kconfig:47\n"
221"Depends on: X86_LOCAL_APIC && X86_IO_APIC || IA64\n"
222"Location:\n"
223" -> Bus options (PCI, PCMCIA, EISA, MCA, ISA)\n"
224" -> PCI support (PCI [ = y])\n"
225" -> PCI access mode (<choice> [ = y])\n"
226"Selects: LIBCRC32\n"
227"Selected by: BAR\n"
228"-----------------------------------------------------------------\n"
229"o The line 'Prompt:' shows the text used in the menu structure for\n"
230" this CONFIG_ symbol\n"
231"o The 'Defined at' line tell at what file / line number the symbol\n"
232" is defined\n"
233"o The 'Depends on:' line tell what symbols needs to be defined for\n"
234" this symbol to be visible in the menu (selectable)\n"
235"o The 'Location:' lines tell where in the menu structure this symbol\n"
236" is located\n"
237" A location followed by a [ = y] indicate that this is a selectable\n"
238" menu item - and current value is displayed inside brackets.\n"
239"o The 'Selects:' line tell what symbol will be automatically\n"
240" selected if this symbol is selected (y or m)\n"
241"o The 'Selected by' line tell what symbol has selected this symbol\n"
242"\n"
243"Only relevant lines are shown.\n"
244"\n\n"
245"Search examples:\n"
246"Examples: USB = > find all CONFIG_ symbols containing USB\n"
247" ^USB => find all CONFIG_ symbols starting with USB\n"
248" USB$ => find all CONFIG_ symbols ending with USB\n"
249"\n");
250
251struct mitem {
252 char str[256];
253 char tag;
254 void *usrptr;
255 int is_hot;
256 int is_visible;
257};
258
259#define MAX_MENU_ITEMS 4096
260static int show_all_items;
261static int indent;
262static struct menu *current_menu;
263static int child_count;
264static int single_menu_mode;
265/* the window in which all information appears */
266static WINDOW *main_window;
267/* the largest size of the menu window */
268static int mwin_max_lines;
269static int mwin_max_cols;
270/* the window in which we show option buttons */
271static MENU *curses_menu;
272static ITEM *curses_menu_items[MAX_MENU_ITEMS];
273static struct mitem k_menu_items[MAX_MENU_ITEMS];
274static int items_num;
275static int global_exit;
276/* the currently selected button */
277const char *current_instructions = menu_instructions;
278/* this array is used to implement hot keys. it is updated in item_make and
279 * resetted in clean_items. It would be better to use a hash, but lets keep it
280 * simple... */
281#define MAX_SAME_KEY MAX_MENU_ITEMS
282struct {
283 int count;
284 int ptrs[MAX_MENU_ITEMS];
285} hotkeys[1<<(sizeof(char)*8)];
286
287static void conf(struct menu *menu);
288static void conf_choice(struct menu *menu);
289static void conf_string(struct menu *menu);
290static void conf_load(void);
291static void conf_save(void);
292static void show_help(struct menu *menu);
293static int do_exit(void);
294static void setup_windows(void);
295
296typedef void (*function_key_handler_t)(int *key, struct menu *menu);
297static void handle_f1(int *key, struct menu *current_item);
298static void handle_f2(int *key, struct menu *current_item);
299static void handle_f3(int *key, struct menu *current_item);
300static void handle_f4(int *key, struct menu *current_item);
301static void handle_f5(int *key, struct menu *current_item);
302static void handle_f6(int *key, struct menu *current_item);
303static void handle_f7(int *key, struct menu *current_item);
304static void handle_f8(int *key, struct menu *current_item);
305
306struct function_keys {
307 const char *key_str;
308 const char *func;
309 function_key key;
310 function_key_handler_t handler;
311};
312
313static const int function_keys_num = 8;
314struct function_keys function_keys[] = {
315 {
316 .key_str = "F1",
317 .func = "Help",
318 .key = F_HELP,
319 .handler = handle_f1,
320 },
321 {
322 .key_str = "F2",
323 .func = "Symbol Info",
324 .key = F_SYMBOL,
325 .handler = handle_f2,
326 },
327 {
328 .key_str = "F3",
329 .func = "Instructions",
330 .key = F_INSTS,
331 .handler = handle_f3,
332 },
333 {
334 .key_str = "F4",
335 .func = "Config",
336 .key = F_CONF,
337 .handler = handle_f4,
338 },
339 {
340 .key_str = "F5",
341 .func = "Back",
342 .key = F_BACK,
343 .handler = handle_f5,
344 },
345 {
346 .key_str = "F6",
347 .func = "Save",
348 .key = F_SAVE,
349 .handler = handle_f6,
350 },
351 {
352 .key_str = "F7",
353 .func = "Load",
354 .key = F_LOAD,
355 .handler = handle_f7,
356 },
357 {
358 .key_str = "F8",
359 .func = "Exit",
360 .key = F_EXIT,
361 .handler = handle_f8,
362 },
363};
364
365static void print_function_line(void)
366{
367 int i;
368 int offset = 1;
369 const int skip = 1;
370
371 for (i = 0; i < function_keys_num; i++) {
372 wattrset(main_window, attributes[FUNCTION_HIGHLIGHT]);
373 mvwprintw(main_window, LINES-3, offset,
374 "%s",
375 function_keys[i].key_str);
376 wattrset(main_window, attributes[FUNCTION_TEXT]);
377 offset += strlen(function_keys[i].key_str);
378 mvwprintw(main_window, LINES-3,
379 offset, "%s",
380 function_keys[i].func);
381 offset += strlen(function_keys[i].func) + skip;
382 }
383 wattrset(main_window, attributes[NORMAL]);
384}
385
386/* help */
387static void handle_f1(int *key, struct menu *current_item)
388{
389 show_scroll_win(main_window,
390 _("README"), _(nconf_readme));
391 return;
392}
393
394/* symbole help */
395static void handle_f2(int *key, struct menu *current_item)
396{
397 show_help(current_item);
398 return;
399}
400
401/* instructions */
402static void handle_f3(int *key, struct menu *current_item)
403{
404 show_scroll_win(main_window,
405 _("Instructions"),
406 _(current_instructions));
407 return;
408}
409
410/* config */
411static void handle_f4(int *key, struct menu *current_item)
412{
413 int res = btn_dialog(main_window,
414 _("Show all symbols?"),
415 2,
416 " <Show All> ",
417 "<Don't show all>");
418 if (res == 0)
419 show_all_items = 1;
420 else if (res == 1)
421 show_all_items = 0;
422
423 return;
424}
425
426/* back */
427static void handle_f5(int *key, struct menu *current_item)
428{
429 *key = KEY_LEFT;
430 return;
431}
432
433/* save */
434static void handle_f6(int *key, struct menu *current_item)
435{
436 conf_save();
437 return;
438}
439
440/* load */
441static void handle_f7(int *key, struct menu *current_item)
442{
443 conf_load();
444 return;
445}
446
447/* exit */
448static void handle_f8(int *key, struct menu *current_item)
449{
450 do_exit();
451 return;
452}
453
454/* return != 0 to indicate the key was handles */
455static int process_special_keys(int *key, struct menu *menu)
456{
457 int i;
458
459 if (*key == KEY_RESIZE) {
460 setup_windows();
461 return 1;
462 }
463
464 for (i = 0; i < function_keys_num; i++) {
465 if (*key == KEY_F(function_keys[i].key) ||
466 *key == '0' + function_keys[i].key){
467 function_keys[i].handler(key, menu);
468 return 1;
469 }
470 }
471
472 return 0;
473}
474
475static void clean_items(void)
476{
477 int i;
478 for (i = 0; curses_menu_items[i]; i++)
479 free_item(curses_menu_items[i]);
480 bzero(curses_menu_items, sizeof(curses_menu_items));
481 bzero(k_menu_items, sizeof(k_menu_items));
482 bzero(hotkeys, sizeof(hotkeys));
483 items_num = 0;
484}
485
486/* return the index of the next hot item, or -1 if no such item exists */
487static int get_next_hot(int c)
488{
489 static int hot_index;
490 static int hot_char;
491
492 if (c < 0 || c > 255 || hotkeys[c].count <= 0)
493 return -1;
494
495 if (hot_char == c) {
496 hot_index = (hot_index+1)%hotkeys[c].count;
497 return hotkeys[c].ptrs[hot_index];
498 } else {
499 hot_char = c;
500 hot_index = 0;
501 return hotkeys[c].ptrs[0];
502 }
503}
504
505/* can the char c be a hot key? no, if c is a common shortcut used elsewhere */
506static int canbhot(char c)
507{
508 c = tolower(c);
509 return isalnum(c) && c != 'y' && c != 'm' && c != 'h' &&
510 c != 'n' && c != '?';
511}
512
513/* check if str already contains a hot key. */
514static int is_hot(int index)
515{
516 return k_menu_items[index].is_hot;
517}
518
519/* find the first possible hot key, and mark it.
520 * index is the index of the item in the menu
521 * return 0 on success*/
522static int make_hot(char *dest, int len, const char *org, int index)
523{
524 int position = -1;
525 int i;
526 int tmp;
527 int c;
528 int org_len = strlen(org);
529
530 if (org == NULL || is_hot(index))
531 return 1;
532
533 /* make sure not to make hot keys out of markers.
534 * find where to start looking for a hot key
535 */
536 i = 0;
537 /* skip white space */
538 while (i < org_len && org[i] == ' ')
539 i++;
540 if (i == org_len)
541 return -1;
542 /* if encountering '(' or '<' or '[', find the match and look from there
543 **/
544 if (org[i] == '[' || org[i] == '<' || org[i] == '(') {
545 i++;
546 for (; i < org_len; i++)
547 if (org[i] == ']' || org[i] == '>' || org[i] == ')')
548 break;
549 }
550 if (i == org_len)
551 return -1;
552 for (; i < org_len; i++) {
553 if (canbhot(org[i]) && org[i-1] != '<' && org[i-1] != '(') {
554 position = i;
555 break;
556 }
557 }
558 if (position == -1)
559 return 1;
560
561 /* ok, char at org[position] should be a hot key to this item */
562 c = tolower(org[position]);
563 tmp = hotkeys[c].count;
564 hotkeys[c].ptrs[tmp] = index;
565 hotkeys[c].count++;
566 /*
567 snprintf(dest, len, "%.*s(%c)%s", position, org, org[position],
568 &org[position+1]);
569 */
570 /* make org[position] uppercase, and all leading letter small case */
571 strncpy(dest, org, len);
572 for (i = 0; i < position; i++)
573 dest[i] = tolower(dest[i]);
574 dest[position] = toupper(dest[position]);
575 k_menu_items[index].is_hot = 1;
576 return 0;
577}
578
579/* Make a new item. Add a hotkey mark in the first possible letter.
580 * As ncurses does not allow any attributes inside menue item, we mark the
581 * hot key as the first capitalized letter in the string */
582static void item_make(struct menu *menu, char tag, const char *fmt, ...)
583{
584 va_list ap;
585 char tmp_str[256];
586
587 if (items_num > MAX_MENU_ITEMS-1)
588 return;
589
590 bzero(&k_menu_items[items_num], sizeof(k_menu_items[0]));
591 k_menu_items[items_num].tag = tag;
592 k_menu_items[items_num].usrptr = menu;
593 if (menu != NULL)
594 k_menu_items[items_num].is_visible =
595 menu_is_visible(menu);
596 else
597 k_menu_items[items_num].is_visible = 1;
598
599 va_start(ap, fmt);
600 vsnprintf(tmp_str, sizeof(tmp_str), fmt, ap);
601 if (!k_menu_items[items_num].is_visible)
602 memcpy(tmp_str, "XXX", 3);
603 va_end(ap);
604 if (make_hot(
605 k_menu_items[items_num].str,
606 sizeof(k_menu_items[items_num].str), tmp_str, items_num) != 0)
607 strncpy(k_menu_items[items_num].str,
608 tmp_str,
609 sizeof(k_menu_items[items_num].str));
610
611 curses_menu_items[items_num] = new_item(
612 k_menu_items[items_num].str,
613 k_menu_items[items_num].str);
614 set_item_userptr(curses_menu_items[items_num],
615 &k_menu_items[items_num]);
616 /*
617 if (!k_menu_items[items_num].is_visible)
618 item_opts_off(curses_menu_items[items_num], O_SELECTABLE);
619 */
620
621 items_num++;
622 curses_menu_items[items_num] = NULL;
623}
624
625/* very hackish. adds a string to the last item added */
626static void item_add_str(const char *fmt, ...)
627{
628 va_list ap;
629 int index = items_num-1;
630 char new_str[256];
631 char tmp_str[256];
632
633 if (index < 0)
634 return;
635
636 va_start(ap, fmt);
637 vsnprintf(new_str, sizeof(new_str), fmt, ap);
638 va_end(ap);
639 snprintf(tmp_str, sizeof(tmp_str), "%s%s",
640 k_menu_items[index].str, new_str);
641 if (make_hot(k_menu_items[index].str,
642 sizeof(k_menu_items[index].str), tmp_str, index) != 0)
643 strncpy(k_menu_items[index].str,
644 tmp_str,
645 sizeof(k_menu_items[index].str));
646
647 free_item(curses_menu_items[index]);
648 curses_menu_items[index] = new_item(
649 k_menu_items[index].str,
650 k_menu_items[index].str);
651 set_item_userptr(curses_menu_items[index],
652 &k_menu_items[index]);
653}
654
655/* get the tag of the currently selected item */
656static char item_tag(void)
657{
658 ITEM *cur;
659 struct mitem *mcur;
660
661 cur = current_item(curses_menu);
662 if (cur == NULL)
663 return 0;
664 mcur = (struct mitem *) item_userptr(cur);
665 return mcur->tag;
666}
667
668static int curses_item_index(void)
669{
670 return item_index(current_item(curses_menu));
671}
672
673static void *item_data(void)
674{
675 ITEM *cur;
676 struct mitem *mcur;
677
678 cur = current_item(curses_menu);
679 mcur = (struct mitem *) item_userptr(cur);
680 return mcur->usrptr;
681
682}
683
684static int item_is_tag(char tag)
685{
686 return item_tag() == tag;
687}
688
689static char filename[PATH_MAX+1];
690static char menu_backtitle[PATH_MAX+128];
691static const char *set_config_filename(const char *config_filename)
692{
693 int size;
694 struct symbol *sym;
695
696 sym = sym_lookup("KERNELVERSION", 0);
697 sym_calc_value(sym);
698 size = snprintf(menu_backtitle, sizeof(menu_backtitle),
699 _("%s - Linux Kernel v%s Configuration"),
700 config_filename, sym_get_string_value(sym));
701 if (size >= sizeof(menu_backtitle))
702 menu_backtitle[sizeof(menu_backtitle)-1] = '\0';
703
704 size = snprintf(filename, sizeof(filename), "%s", config_filename);
705 if (size >= sizeof(filename))
706 filename[sizeof(filename)-1] = '\0';
707 return menu_backtitle;
708}
709
710/* command = 0 is supress, 1 is restore */
711static void supress_stdout(int command)
712{
713 static FILE *org_stdout;
714 static FILE *org_stderr;
715
716 if (command == 0) {
717 org_stdout = stdout;
718 org_stderr = stderr;
719 stdout = fopen("/dev/null", "a");
720 stderr = fopen("/dev/null", "a");
721 } else {
722 fclose(stdout);
723 fclose(stderr);
724 stdout = org_stdout;
725 stderr = org_stderr;
726 }
727}
728
729/* return = 0 means we are successful.
730 * -1 means go on doing what you were doing
731 */
732static int do_exit(void)
733{
734 int res;
735 if (!conf_get_changed()) {
736 global_exit = 1;
737 return 0;
738 }
739 res = btn_dialog(main_window,
740 _("Do you wish to save your "
741 "new kernel configuration?\n"
742 "<ESC> to cancel and resume nconfig."),
743 2,
744 " <save> ",
745 "<don't save>");
746 if (res == KEY_EXIT) {
747 global_exit = 0;
748 return -1;
749 }
750
751 /* if we got here, the user really wants to exit */
752 switch (res) {
753 case 0:
754 supress_stdout(0);
755 res = conf_write(filename);
756 supress_stdout(1);
757 if (res)
758 btn_dialog(
759 main_window,
760 _("Error during writing of the kernel "
761 "configuration.\n"
762 "Your kernel configuration "
763 "changes were NOT saved."),
764 1,
765 "<OK>");
766 else {
767 char buf[1024];
768 snprintf(buf, 1024,
769 _("Configuration written to %s\n"
770 "End of Linux kernel configuration.\n"
771 "Execute 'make' to build the kernel or try"
772 " 'make help'."), filename);
773 btn_dialog(
774 main_window,
775 buf,
776 1,
777 "<OK>");
778 }
779 break;
780 default:
781 btn_dialog(
782 main_window,
783 _("Your kernel configuration changes were NOT saved."),
784 1,
785 "<OK>");
786 break;
787 }
788 global_exit = 1;
789 return 0;
790}
791
792
793static void search_conf(void)
794{
795 struct symbol **sym_arr;
796 struct gstr res;
797 char dialog_input_result[100];
798 char *dialog_input;
799 int dres;
800again:
801 dres = dialog_inputbox(main_window,
802 _("Search Configuration Parameter"),
803 _("Enter CONFIG_ (sub)string to search for "
804 "(with or without \"CONFIG\")"),
805 "", dialog_input_result, 99);
806 switch (dres) {
807 case 0:
808 break;
809 case 1:
810 show_scroll_win(main_window,
811 _("Search Configuration"), search_help);
812 goto again;
813 default:
814 return;
815 }
816
817 /* strip CONFIG_ if necessary */
818 dialog_input = dialog_input_result;
819 if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0)
820 dialog_input += 7;
821
822 sym_arr = sym_re_search(dialog_input);
823 res = get_relations_str(sym_arr);
824 free(sym_arr);
825 show_scroll_win(main_window,
826 _("Search Results"), str_get(&res));
827 str_free(&res);
828}
829
830
831static void build_conf(struct menu *menu)
832{
833 struct symbol *sym;
834 struct property *prop;
835 struct menu *child;
836 int type, tmp, doint = 2;
837 tristate val;
838 char ch;
839
840 if (!menu || (!show_all_items && !menu_is_visible(menu)))
841 return;
842
843 sym = menu->sym;
844 prop = menu->prompt;
845 if (!sym) {
846 if (prop && menu != current_menu) {
847 const char *prompt = menu_get_prompt(menu);
848 enum prop_type ptype;
849 ptype = menu->prompt ? menu->prompt->type : P_UNKNOWN;
850 switch (ptype) {
851 case P_MENU:
852 child_count++;
853 prompt = _(prompt);
854 if (single_menu_mode) {
855 item_make(menu, 'm',
856 "%s%*c%s",
857 menu->data ? "-->" : "++>",
858 indent + 1, ' ', prompt);
859 } else
860 item_make(menu, 'm',
861 " %*c%s --->",
862 indent + 1,
863 ' ', prompt);
864
865 if (single_menu_mode && menu->data)
866 goto conf_childs;
867 return;
868 case P_COMMENT:
869 if (prompt) {
870 child_count++;
871 item_make(menu, ':',
872 " %*c*** %s ***",
873 indent + 1, ' ',
874 _(prompt));
875 }
876 break;
877 default:
878 if (prompt) {
879 child_count++;
880 item_make(menu, ':', "---%*c%s",
881 indent + 1, ' ',
882 _(prompt));
883 }
884 }
885 } else
886 doint = 0;
887 goto conf_childs;
888 }
889
890 type = sym_get_type(sym);
891 if (sym_is_choice(sym)) {
892 struct symbol *def_sym = sym_get_choice_value(sym);
893 struct menu *def_menu = NULL;
894
895 child_count++;
896 for (child = menu->list; child; child = child->next) {
897 if (menu_is_visible(child) && child->sym == def_sym)
898 def_menu = child;
899 }
900
901 val = sym_get_tristate_value(sym);
902 if (sym_is_changable(sym)) {
903 switch (type) {
904 case S_BOOLEAN:
905 item_make(menu, 't', "[%c]",
906 val == no ? ' ' : '*');
907 break;
908 case S_TRISTATE:
909 switch (val) {
910 case yes:
911 ch = '*';
912 break;
913 case mod:
914 ch = 'M';
915 break;
916 default:
917 ch = ' ';
918 break;
919 }
920 item_make(menu, 't', "<%c>", ch);
921 break;
922 }
923 } else {
924 item_make(menu, def_menu ? 't' : ':', " ");
925 }
926
927 item_add_str("%*c%s", indent + 1,
928 ' ', _(menu_get_prompt(menu)));
929 if (val == yes) {
930 if (def_menu) {
931 item_add_str(" (%s)",
932 _(menu_get_prompt(def_menu)));
933 item_add_str(" --->");
934 if (def_menu->list) {
935 indent += 2;
936 build_conf(def_menu);
937 indent -= 2;
938 }
939 }
940 return;
941 }
942 } else {
943 if (menu == current_menu) {
944 item_make(menu, ':',
945 "---%*c%s", indent + 1,
946 ' ', _(menu_get_prompt(menu)));
947 goto conf_childs;
948 }
949 child_count++;
950 val = sym_get_tristate_value(sym);
951 if (sym_is_choice_value(sym) && val == yes) {
952 item_make(menu, ':', " ");
953 } else {
954 switch (type) {
955 case S_BOOLEAN:
956 if (sym_is_changable(sym))
957 item_make(menu, 't', "[%c]",
958 val == no ? ' ' : '*');
959 else
960 item_make(menu, 't', "-%c-",
961 val == no ? ' ' : '*');
962 break;
963 case S_TRISTATE:
964 switch (val) {
965 case yes:
966 ch = '*';
967 break;
968 case mod:
969 ch = 'M';
970 break;
971 default:
972 ch = ' ';
973 break;
974 }
975 if (sym_is_changable(sym)) {
976 if (sym->rev_dep.tri == mod)
977 item_make(menu,
978 't', "{%c}", ch);
979 else
980 item_make(menu,
981 't', "<%c>", ch);
982 } else
983 item_make(menu, 't', "-%c-", ch);
984 break;
985 default:
986 tmp = 2 + strlen(sym_get_string_value(sym));
987 item_make(menu, 's', " (%s)",
988 sym_get_string_value(sym));
989 tmp = indent - tmp + 4;
990 if (tmp < 0)
991 tmp = 0;
992 item_add_str("%*c%s%s", tmp, ' ',
993 _(menu_get_prompt(menu)),
994 (sym_has_value(sym) ||
995 !sym_is_changable(sym)) ? "" :
996 _(" (NEW)"));
997 goto conf_childs;
998 }
999 }
1000 item_add_str("%*c%s%s", indent + 1, ' ',
1001 _(menu_get_prompt(menu)),
1002 (sym_has_value(sym) || !sym_is_changable(sym)) ?
1003 "" : _(" (NEW)"));
1004 if (menu->prompt && menu->prompt->type == P_MENU) {
1005 item_add_str(" --->");
1006 return;
1007 }
1008 }
1009
1010conf_childs:
1011 indent += doint;
1012 for (child = menu->list; child; child = child->next)
1013 build_conf(child);
1014 indent -= doint;
1015}
1016
1017static void reset_menu(void)
1018{
1019 unpost_menu(curses_menu);
1020 clean_items();
1021}
1022
1023/* adjust the menu to show this item.
1024 * prefer not to scroll the menu if possible*/
1025static void center_item(int selected_index, int *last_top_row)
1026{
1027 int toprow;
1028 int maxy, maxx;
1029
1030 scale_menu(curses_menu, &maxy, &maxx);
1031 set_top_row(curses_menu, *last_top_row);
1032 toprow = top_row(curses_menu);
1033 if (selected_index >= toprow && selected_index < toprow+maxy) {
1034 /* we can only move the selected item. no need to scroll */
1035 set_current_item(curses_menu,
1036 curses_menu_items[selected_index]);
1037 } else {
1038 toprow = max(selected_index-maxy/2, 0);
1039 if (toprow >= item_count(curses_menu)-maxy)
1040 toprow = item_count(curses_menu)-mwin_max_lines;
1041 set_top_row(curses_menu, toprow);
1042 set_current_item(curses_menu,
1043 curses_menu_items[selected_index]);
1044 }
1045 *last_top_row = toprow;
1046 post_menu(curses_menu);
1047 refresh_all_windows(main_window);
1048}
1049
1050/* this function assumes reset_menu has been called before */
1051static void show_menu(const char *prompt, const char *instructions,
1052 int selected_index, int *last_top_row)
1053{
1054 int maxx, maxy;
1055 WINDOW *menu_window;
1056
1057 current_instructions = instructions;
1058
1059 clear();
1060 wattrset(main_window, attributes[NORMAL]);
1061 print_in_middle(stdscr, 1, 0, COLS,
1062 menu_backtitle,
1063 attributes[MAIN_HEADING]);
1064
1065 wattrset(main_window, attributes[MAIN_MENU_BOX]);
1066 box(main_window, 0, 0);
1067 wattrset(main_window, attributes[MAIN_MENU_HEADING]);
1068 mvwprintw(main_window, 0, 3, " %s ", prompt);
1069 wattrset(main_window, attributes[NORMAL]);
1070
1071 set_menu_items(curses_menu, curses_menu_items);
1072
1073 /* position the menu at the middle of the screen */
1074 scale_menu(curses_menu, &maxy, &maxx);
1075 maxx = min(maxx, mwin_max_cols-2);
1076 maxy = mwin_max_lines-2;
1077 menu_window = derwin(main_window,
1078 maxy,
1079 maxx,
1080 2,
1081 (mwin_max_cols-maxx)/2);
1082 keypad(menu_window, TRUE);
1083 set_menu_win(curses_menu, menu_window);
1084 set_menu_sub(curses_menu, menu_window);
1085
1086 /* must reassert this after changing items, otherwise returns to a
1087 * default of 16
1088 */
1089 set_menu_format(curses_menu, maxy, 1);
1090 center_item(selected_index, last_top_row);
1091 set_menu_format(curses_menu, maxy, 1);
1092
1093 print_function_line();
1094
1095 /* Post the menu */
1096 post_menu(curses_menu);
1097 refresh_all_windows(main_window);
1098}
1099
1100
1101static void conf(struct menu *menu)
1102{
1103 char pattern[256];
1104 struct menu *submenu = 0;
1105 const char *prompt = menu_get_prompt(menu);
1106 struct symbol *sym;
1107 struct menu *active_menu = NULL;
1108 int res;
1109 int current_index = 0;
1110 int last_top_row = 0;
1111
1112 bzero(pattern, sizeof(pattern));
1113
1114 while (!global_exit) {
1115 reset_menu();
1116 current_menu = menu;
1117 build_conf(menu);
1118 if (!child_count)
1119 break;
1120
1121 show_menu(prompt ? _(prompt) : _("Main Menu"),
1122 _(menu_instructions),
1123 current_index, &last_top_row);
1124 keypad((menu_win(curses_menu)), TRUE);
1125 while (!global_exit && (res = wgetch(menu_win(curses_menu)))) {
1126 if (process_special_keys(&res,
1127 (struct menu *) item_data()))
1128 break;
1129 switch (res) {
1130 case KEY_DOWN:
1131 menu_driver(curses_menu, REQ_DOWN_ITEM);
1132 break;
1133 case KEY_UP:
1134 menu_driver(curses_menu, REQ_UP_ITEM);
1135 break;
1136 case KEY_NPAGE:
1137 menu_driver(curses_menu, REQ_SCR_DPAGE);
1138 break;
1139 case KEY_PPAGE:
1140 menu_driver(curses_menu, REQ_SCR_UPAGE);
1141 break;
1142 case KEY_HOME:
1143 menu_driver(curses_menu, REQ_FIRST_ITEM);
1144 break;
1145 case KEY_END:
1146 menu_driver(curses_menu, REQ_LAST_ITEM);
1147 break;
1148 case 'h':
1149 case '?':
1150 show_help((struct menu *) item_data());
1151 break;
1152 }
1153 if (res == 10 || res == 27 ||
1154 res == 32 || res == 'n' || res == 'y' ||
1155 res == KEY_LEFT || res == KEY_RIGHT ||
1156 res == 'm' || res == '/')
1157 break;
1158 else if (canbhot(res)) {
1159 /* check for hot keys: */
1160 int tmp = get_next_hot(res);
1161 if (tmp != -1)
1162 center_item(tmp, &last_top_row);
1163 }
1164 refresh_all_windows(main_window);
1165 }
1166
1167 refresh_all_windows(main_window);
1168 /* if ESC or left*/
1169 if (res == 27 || (menu != &rootmenu && res == KEY_LEFT))
1170 break;
1171
1172 /* remember location in the menu */
1173 last_top_row = top_row(curses_menu);
1174 current_index = curses_item_index();
1175
1176 if (!item_tag())
1177 continue;
1178
1179 submenu = (struct menu *) item_data();
1180 active_menu = (struct menu *)item_data();
1181 if (!submenu || !menu_is_visible(submenu))
1182 continue;
1183 if (submenu)
1184 sym = submenu->sym;
1185 else
1186 sym = NULL;
1187
1188 switch (res) {
1189 case ' ':
1190 if (item_is_tag('t'))
1191 sym_toggle_tristate_value(sym);
1192 else if (item_is_tag('m'))
1193 conf(submenu);
1194 break;
1195 case KEY_RIGHT:
1196 case 10: /* ENTER WAS PRESSED */
1197 switch (item_tag()) {
1198 case 'm':
1199 if (single_menu_mode)
1200 submenu->data =
1201 (void *) (long) !submenu->data;
1202 else
1203 conf(submenu);
1204 break;
1205 case 't':
1206 if (sym_is_choice(sym) &&
1207 sym_get_tristate_value(sym) == yes)
1208 conf_choice(submenu);
1209 else if (submenu->prompt &&
1210 submenu->prompt->type == P_MENU)
1211 conf(submenu);
1212 else if (res == 10)
1213 sym_toggle_tristate_value(sym);
1214 break;
1215 case 's':
1216 conf_string(submenu);
1217 break;
1218 }
1219 break;
1220 case 'y':
1221 if (item_is_tag('t')) {
1222 if (sym_set_tristate_value(sym, yes))
1223 break;
1224 if (sym_set_tristate_value(sym, mod))
1225 btn_dialog(main_window, setmod_text, 0);
1226 }
1227 break;
1228 case 'n':
1229 if (item_is_tag('t'))
1230 sym_set_tristate_value(sym, no);
1231 break;
1232 case 'm':
1233 if (item_is_tag('t'))
1234 sym_set_tristate_value(sym, mod);
1235 break;
1236 case '/':
1237 search_conf();
1238 break;
1239 }
1240 }
1241}
1242
1243static void show_help(struct menu *menu)
1244{
1245 struct gstr help = str_new();
1246
1247 if (menu && menu->sym && menu_has_help(menu)) {
1248 if (menu->sym->name) {
1249 str_printf(&help, "CONFIG_%s:\n\n", menu->sym->name);
1250 str_append(&help, _(menu_get_help(menu)));
1251 str_append(&help, "\n");
1252 get_symbol_str(&help, menu->sym);
1253 }
1254 } else {
1255 str_append(&help, nohelp_text);
1256 }
1257 show_scroll_win(main_window, _(menu_get_prompt(menu)), str_get(&help));
1258 str_free(&help);
1259}
1260
1261static void conf_choice(struct menu *menu)
1262{
1263 const char *prompt = _(menu_get_prompt(menu));
1264 struct menu *child = 0;
1265 struct symbol *active;
1266 int selected_index = 0;
1267 int last_top_row = 0;
1268 int res, i = 0;
1269
1270 active = sym_get_choice_value(menu->sym);
1271 /* this is mostly duplicated from the conf() function. */
1272 while (!global_exit) {
1273 reset_menu();
1274
1275 for (i = 0, child = menu->list; child; child = child->next) {
1276 if (!show_all_items && !menu_is_visible(child))
1277 continue;
1278
1279 if (child->sym == sym_get_choice_value(menu->sym))
1280 item_make(child, ':', "<X> %s",
1281 _(menu_get_prompt(child)));
1282 else
1283 item_make(child, ':', " %s",
1284 _(menu_get_prompt(child)));
1285 if (child->sym == active){
1286 last_top_row = top_row(curses_menu);
1287 selected_index = i;
1288 }
1289 i++;
1290 }
1291 show_menu(prompt ? _(prompt) : _("Choice Menu"),
1292 _(radiolist_instructions),
1293 selected_index,
1294 &last_top_row);
1295 while (!global_exit && (res = wgetch(menu_win(curses_menu)))) {
1296 if (process_special_keys(
1297 &res,
1298 (struct menu *) item_data()))
1299 break;
1300 switch (res) {
1301 case KEY_DOWN:
1302 menu_driver(curses_menu, REQ_DOWN_ITEM);
1303 break;
1304 case KEY_UP:
1305 menu_driver(curses_menu, REQ_UP_ITEM);
1306 break;
1307 case KEY_NPAGE:
1308 menu_driver(curses_menu, REQ_SCR_DPAGE);
1309 break;
1310 case KEY_PPAGE:
1311 menu_driver(curses_menu, REQ_SCR_UPAGE);
1312 break;
1313 case KEY_HOME:
1314 menu_driver(curses_menu, REQ_FIRST_ITEM);
1315 break;
1316 case KEY_END:
1317 menu_driver(curses_menu, REQ_LAST_ITEM);
1318 break;
1319 case 'h':
1320 case '?':
1321 show_help((struct menu *) item_data());
1322 break;
1323 }
1324 if (res == 10 || res == 27 || res == ' ' ||
1325 res == KEY_LEFT)
1326 break;
1327 else if (canbhot(res)) {
1328 /* check for hot keys: */
1329 int tmp = get_next_hot(res);
1330 if (tmp != -1)
1331 center_item(tmp, &last_top_row);
1332 }
1333 refresh_all_windows(main_window);
1334 }
1335 /* if ESC or left */
1336 if (res == 27 || res == KEY_LEFT)
1337 break;
1338
1339 child = item_data();
1340 if (!child || !menu_is_visible(child))
1341 continue;
1342 switch (res) {
1343 case ' ':
1344 case 10:
1345 case KEY_RIGHT:
1346 sym_set_tristate_value(child->sym, yes);
1347 return;
1348 case 'h':
1349 case '?':
1350 show_help(child);
1351 active = child->sym;
1352 break;
1353 case KEY_EXIT:
1354 return;
1355 }
1356 }
1357}
1358
1359static void conf_string(struct menu *menu)
1360{
1361 const char *prompt = menu_get_prompt(menu);
1362 char dialog_input_result[256];
1363
1364 while (1) {
1365 int res;
1366 const char *heading;
1367
1368 switch (sym_get_type(menu->sym)) {
1369 case S_INT:
1370 heading = _(inputbox_instructions_int);
1371 break;
1372 case S_HEX:
1373 heading = _(inputbox_instructions_hex);
1374 break;
1375 case S_STRING:
1376 heading = _(inputbox_instructions_string);
1377 break;
1378 default:
1379 heading = _("Internal nconf error!");
1380 }
1381 res = dialog_inputbox(main_window,
1382 prompt ? _(prompt) : _("Main Menu"),
1383 heading,
1384 sym_get_string_value(menu->sym),
1385 dialog_input_result,
1386 sizeof(dialog_input_result));
1387 switch (res) {
1388 case 0:
1389 if (sym_set_string_value(menu->sym,
1390 dialog_input_result))
1391 return;
1392 btn_dialog(main_window,
1393 _("You have made an invalid entry."), 0);
1394 break;
1395 case 1:
1396 show_help(menu);
1397 break;
1398 case KEY_EXIT:
1399 return;
1400 }
1401 }
1402}
1403
1404static void conf_load(void)
1405{
1406 char dialog_input_result[256];
1407 while (1) {
1408 int res;
1409 res = dialog_inputbox(main_window,
1410 NULL, load_config_text,
1411 filename,
1412 dialog_input_result,
1413 sizeof(dialog_input_result));
1414 switch (res) {
1415 case 0:
1416 if (!dialog_input_result[0])
1417 return;
1418 if (!conf_read(dialog_input_result)) {
1419 set_config_filename(dialog_input_result);
1420 sym_set_change_count(1);
1421 return;
1422 }
1423 btn_dialog(main_window, _("File does not exist!"), 0);
1424 break;
1425 case 1:
1426 show_scroll_win(main_window,
1427 _("Load Alternate Configuration"),
1428 load_config_help);
1429 break;
1430 case KEY_EXIT:
1431 return;
1432 }
1433 }
1434}
1435
1436static void conf_save(void)
1437{
1438 char dialog_input_result[256];
1439 while (1) {
1440 int res;
1441 res = dialog_inputbox(main_window,
1442 NULL, save_config_text,
1443 filename,
1444 dialog_input_result,
1445 sizeof(dialog_input_result));
1446 switch (res) {
1447 case 0:
1448 if (!dialog_input_result[0])
1449 return;
1450 supress_stdout(0);
1451 res = conf_write(dialog_input_result);
1452 supress_stdout(1);
1453 if (!res) {
1454 char buf[1024];
1455 sprintf(buf, "%s %s",
1456 _("configuration file saved to: "),
1457 dialog_input_result);
1458 btn_dialog(main_window,
1459 buf, 1, "<OK>");
1460 set_config_filename(dialog_input_result);
1461 return;
1462 }
1463 btn_dialog(main_window, _("Can't create file! "
1464 "Probably a nonexistent directory."),
1465 1, "<OK>");
1466 break;
1467 case 1:
1468 show_scroll_win(main_window,
1469 _("Save Alternate Configuration"),
1470 save_config_help);
1471 break;
1472 case KEY_EXIT:
1473 return;
1474 }
1475 }
1476}
1477
1478void setup_windows(void)
1479{
1480 if (main_window != NULL)
1481 delwin(main_window);
1482
1483 /* set up the menu and menu window */
1484 main_window = newwin(LINES-2, COLS-2, 2, 1);
1485 keypad(main_window, TRUE);
1486 mwin_max_lines = LINES-6;
1487 mwin_max_cols = COLS-6;
1488
1489 /* panels order is from bottom to top */
1490 new_panel(main_window);
1491}
1492
1493int main(int ac, char **av)
1494{
1495 char *mode;
1496
1497 setlocale(LC_ALL, "");
1498 bindtextdomain(PACKAGE, LOCALEDIR);
1499 textdomain(PACKAGE);
1500
1501 conf_parse(av[1]);
1502 conf_read(NULL);
1503
1504 mode = getenv("NCONFIG_MODE");
1505 if (mode) {
1506 if (!strcasecmp(mode, "single_menu"))
1507 single_menu_mode = 1;
1508 }
1509
1510 /* Initialize curses */
1511 initscr();
1512 /* set color theme */
1513 set_colors();
1514
1515 cbreak();
1516 noecho();
1517 keypad(stdscr, TRUE);
1518 curs_set(0);
1519
1520 if (COLS < 75 || LINES < 20) {
1521 endwin();
1522 printf("Your terminal should have at "
1523 "least 20 lines and 75 columns\n");
1524 return 1;
1525 }
1526
1527 notimeout(stdscr, FALSE);
1528 ESCDELAY = 1;
1529
1530 /* set btns menu */
1531 curses_menu = new_menu(curses_menu_items);
1532 menu_opts_off(curses_menu, O_SHOWDESC);
1533 menu_opts_off(curses_menu, O_SHOWMATCH);
1534 menu_opts_on(curses_menu, O_ONEVALUE);
1535 menu_opts_on(curses_menu, O_NONCYCLIC);
1536 set_menu_mark(curses_menu, " ");
1537 set_menu_fore(curses_menu, attributes[MAIN_MENU_FORE]);
1538 set_menu_back(curses_menu, attributes[MAIN_MENU_BACK]);
1539 set_menu_grey(curses_menu, attributes[MAIN_MENU_GREY]);
1540
1541 set_config_filename(conf_get_configname());
1542 setup_windows();
1543
1544 /* check for KEY_FUNC(1) */
1545 if (has_key(KEY_F(1)) == FALSE) {
1546 show_scroll_win(main_window,
1547 _("Instructions"),
1548 _(menu_no_f_instructions));
1549 }
1550
1551
1552
1553 /* do the work */
1554 while (!global_exit) {
1555 conf(&rootmenu);
1556 if (!global_exit && do_exit() == 0)
1557 break;
1558 }
1559 /* ok, we are done */
1560 unpost_menu(curses_menu);
1561 free_menu(curses_menu);
1562 delwin(main_window);
1563 clear();
1564 refresh();
1565 endwin();
1566 return 0;
1567}
1568
diff --git a/scripts/kconfig/nconf.gui.c b/scripts/kconfig/nconf.gui.c
new file mode 100644
index 000000000000..115edb437fb1
--- /dev/null
+++ b/scripts/kconfig/nconf.gui.c
@@ -0,0 +1,617 @@
1/*
2 * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
3 * Released under the terms of the GNU GPL v2.0.
4 *
5 * Derived from menuconfig.
6 *
7 */
8#include "nconf.h"
9
10/* a list of all the different widgets we use */
11attributes_t attributes[ATTR_MAX+1] = {0};
12
13/* available colors:
14 COLOR_BLACK 0
15 COLOR_RED 1
16 COLOR_GREEN 2
17 COLOR_YELLOW 3
18 COLOR_BLUE 4
19 COLOR_MAGENTA 5
20 COLOR_CYAN 6
21 COLOR_WHITE 7
22 */
23static void set_normal_colors(void)
24{
25 init_pair(NORMAL, -1, -1);
26 init_pair(MAIN_HEADING, COLOR_MAGENTA, -1);
27
28 /* FORE is for the selected item */
29 init_pair(MAIN_MENU_FORE, -1, -1);
30 /* BACK for all the rest */
31 init_pair(MAIN_MENU_BACK, -1, -1);
32 init_pair(MAIN_MENU_GREY, -1, -1);
33 init_pair(MAIN_MENU_HEADING, COLOR_GREEN, -1);
34 init_pair(MAIN_MENU_BOX, COLOR_YELLOW, -1);
35
36 init_pair(SCROLLWIN_TEXT, -1, -1);
37 init_pair(SCROLLWIN_HEADING, COLOR_GREEN, -1);
38 init_pair(SCROLLWIN_BOX, COLOR_YELLOW, -1);
39
40 init_pair(DIALOG_TEXT, -1, -1);
41 init_pair(DIALOG_BOX, COLOR_YELLOW, -1);
42 init_pair(DIALOG_MENU_BACK, COLOR_YELLOW, -1);
43 init_pair(DIALOG_MENU_FORE, COLOR_RED, -1);
44
45 init_pair(INPUT_BOX, COLOR_YELLOW, -1);
46 init_pair(INPUT_HEADING, COLOR_GREEN, -1);
47 init_pair(INPUT_TEXT, -1, -1);
48 init_pair(INPUT_FIELD, -1, -1);
49
50 init_pair(FUNCTION_HIGHLIGHT, -1, -1);
51 init_pair(FUNCTION_TEXT, COLOR_BLUE, -1);
52}
53
54/* available attributes:
55 A_NORMAL Normal display (no highlight)
56 A_STANDOUT Best highlighting mode of the terminal.
57 A_UNDERLINE Underlining
58 A_REVERSE Reverse video
59 A_BLINK Blinking
60 A_DIM Half bright
61 A_BOLD Extra bright or bold
62 A_PROTECT Protected mode
63 A_INVIS Invisible or blank mode
64 A_ALTCHARSET Alternate character set
65 A_CHARTEXT Bit-mask to extract a character
66 COLOR_PAIR(n) Color-pair number n
67 */
68static void normal_color_theme(void)
69{
70 /* automatically add color... */
71#define mkattr(name, attr) do { \
72attributes[name] = attr | COLOR_PAIR(name); } while (0)
73 mkattr(NORMAL, NORMAL);
74 mkattr(MAIN_HEADING, A_BOLD | A_UNDERLINE);
75
76 mkattr(MAIN_MENU_FORE, A_REVERSE);
77 mkattr(MAIN_MENU_BACK, A_NORMAL);
78 mkattr(MAIN_MENU_GREY, A_NORMAL);
79 mkattr(MAIN_MENU_HEADING, A_BOLD);
80 mkattr(MAIN_MENU_BOX, A_NORMAL);
81
82 mkattr(SCROLLWIN_TEXT, A_NORMAL);
83 mkattr(SCROLLWIN_HEADING, A_BOLD);
84 mkattr(SCROLLWIN_BOX, A_BOLD);
85
86 mkattr(DIALOG_TEXT, A_BOLD);
87 mkattr(DIALOG_BOX, A_BOLD);
88 mkattr(DIALOG_MENU_FORE, A_STANDOUT);
89 mkattr(DIALOG_MENU_BACK, A_NORMAL);
90
91 mkattr(INPUT_BOX, A_NORMAL);
92 mkattr(INPUT_HEADING, A_BOLD);
93 mkattr(INPUT_TEXT, A_NORMAL);
94 mkattr(INPUT_FIELD, A_UNDERLINE);
95
96 mkattr(FUNCTION_HIGHLIGHT, A_BOLD);
97 mkattr(FUNCTION_TEXT, A_REVERSE);
98}
99
100static void no_colors_theme(void)
101{
102 /* automatically add highlight, no color */
103#define mkattrn(name, attr) { attributes[name] = attr; }
104
105 mkattrn(NORMAL, NORMAL);
106 mkattrn(MAIN_HEADING, A_BOLD | A_UNDERLINE);
107
108 mkattrn(MAIN_MENU_FORE, A_STANDOUT);
109 mkattrn(MAIN_MENU_BACK, A_NORMAL);
110 mkattrn(MAIN_MENU_GREY, A_NORMAL);
111 mkattrn(MAIN_MENU_HEADING, A_BOLD);
112 mkattrn(MAIN_MENU_BOX, A_NORMAL);
113
114 mkattrn(SCROLLWIN_TEXT, A_NORMAL);
115 mkattrn(SCROLLWIN_HEADING, A_BOLD);
116 mkattrn(SCROLLWIN_BOX, A_BOLD);
117
118 mkattrn(DIALOG_TEXT, A_NORMAL);
119 mkattrn(DIALOG_BOX, A_BOLD);
120 mkattrn(DIALOG_MENU_FORE, A_STANDOUT);
121 mkattrn(DIALOG_MENU_BACK, A_NORMAL);
122
123 mkattrn(INPUT_BOX, A_BOLD);
124 mkattrn(INPUT_HEADING, A_BOLD);
125 mkattrn(INPUT_TEXT, A_NORMAL);
126 mkattrn(INPUT_FIELD, A_UNDERLINE);
127
128 mkattrn(FUNCTION_HIGHLIGHT, A_BOLD);
129 mkattrn(FUNCTION_TEXT, A_REVERSE);
130}
131
132void set_colors()
133{
134 start_color();
135 use_default_colors();
136 set_normal_colors();
137 if (has_colors()) {
138 normal_color_theme();
139 } else {
140 /* give deafults */
141 no_colors_theme();
142 }
143}
144
145
146/* this changes the windows attributes !!! */
147void print_in_middle(WINDOW *win,
148 int starty,
149 int startx,
150 int width,
151 const char *string,
152 chtype color)
153{ int length, x, y;
154 float temp;
155
156
157 if (win == NULL)
158 win = stdscr;
159 getyx(win, y, x);
160 if (startx != 0)
161 x = startx;
162 if (starty != 0)
163 y = starty;
164 if (width == 0)
165 width = 80;
166
167 length = strlen(string);
168 temp = (width - length) / 2;
169 x = startx + (int)temp;
170 wattrset(win, color);
171 mvwprintw(win, y, x, "%s", string);
172 refresh();
173}
174
175int get_line_no(const char *text)
176{
177 int i;
178 int total = 1;
179
180 if (!text)
181 return 0;
182
183 for (i = 0; text[i] != '\0'; i++)
184 if (text[i] == '\n')
185 total++;
186 return total;
187}
188
189const char *get_line(const char *text, int line_no)
190{
191 int i;
192 int lines = 0;
193
194 if (!text)
195 return 0;
196
197 for (i = 0; text[i] != '\0' && lines < line_no; i++)
198 if (text[i] == '\n')
199 lines++;
200 return text+i;
201}
202
203int get_line_length(const char *line)
204{
205 int res = 0;
206 while (*line != '\0' && *line != '\n') {
207 line++;
208 res++;
209 }
210 return res;
211}
212
213/* print all lines to the window. */
214void fill_window(WINDOW *win, const char *text)
215{
216 int x, y;
217 int total_lines = get_line_no(text);
218 int i;
219
220 getmaxyx(win, y, x);
221 /* do not go over end of line */
222 total_lines = min(total_lines, y);
223 for (i = 0; i < total_lines; i++) {
224 char tmp[x+10];
225 const char *line = get_line(text, i);
226 int len = get_line_length(line);
227 strncpy(tmp, line, min(len, x));
228 tmp[len] = '\0';
229 mvwprintw(win, i, 0, tmp);
230 }
231}
232
233/* get the message, and buttons.
234 * each button must be a char*
235 * return the selected button
236 *
237 * this dialog is used for 2 different things:
238 * 1) show a text box, no buttons.
239 * 2) show a dialog, with horizontal buttons
240 */
241int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...)
242{
243 va_list ap;
244 char *btn;
245 int btns_width = 0;
246 int msg_lines = 0;
247 int msg_width = 0;
248 int total_width;
249 int win_rows = 0;
250 WINDOW *win;
251 WINDOW *msg_win;
252 WINDOW *menu_win;
253 MENU *menu;
254 ITEM *btns[btn_num+1];
255 int i, x, y;
256 int res = -1;
257
258
259 va_start(ap, btn_num);
260 for (i = 0; i < btn_num; i++) {
261 btn = va_arg(ap, char *);
262 btns[i] = new_item(btn, "");
263 btns_width += strlen(btn)+1;
264 }
265 va_end(ap);
266 btns[btn_num] = NULL;
267
268 /* find the widest line of msg: */
269 msg_lines = get_line_no(msg);
270 for (i = 0; i < msg_lines; i++) {
271 const char *line = get_line(msg, i);
272 int len = get_line_length(line);
273 if (msg_width < len)
274 msg_width = len;
275 }
276
277 total_width = max(msg_width, btns_width);
278 /* place dialog in middle of screen */
279 y = (LINES-(msg_lines+4))/2;
280 x = (COLS-(total_width+4))/2;
281
282
283 /* create the windows */
284 if (btn_num > 0)
285 win_rows = msg_lines+4;
286 else
287 win_rows = msg_lines+2;
288
289 win = newwin(win_rows, total_width+4, y, x);
290 keypad(win, TRUE);
291 menu_win = derwin(win, 1, btns_width, win_rows-2,
292 1+(total_width+2-btns_width)/2);
293 menu = new_menu(btns);
294 msg_win = derwin(win, win_rows-2, msg_width, 1,
295 1+(total_width+2-msg_width)/2);
296
297 set_menu_fore(menu, attributes[DIALOG_MENU_FORE]);
298 set_menu_back(menu, attributes[DIALOG_MENU_BACK]);
299
300 wattrset(win, attributes[DIALOG_BOX]);
301 box(win, 0, 0);
302
303 /* print message */
304 wattrset(msg_win, attributes[DIALOG_TEXT]);
305 fill_window(msg_win, msg);
306
307 set_menu_win(menu, win);
308 set_menu_sub(menu, menu_win);
309 set_menu_format(menu, 1, btn_num);
310 menu_opts_off(menu, O_SHOWDESC);
311 menu_opts_off(menu, O_SHOWMATCH);
312 menu_opts_on(menu, O_ONEVALUE);
313 menu_opts_on(menu, O_NONCYCLIC);
314 set_menu_mark(menu, "");
315 post_menu(menu);
316
317
318 touchwin(win);
319 refresh_all_windows(main_window);
320 while ((res = wgetch(win))) {
321 switch (res) {
322 case KEY_LEFT:
323 menu_driver(menu, REQ_LEFT_ITEM);
324 break;
325 case KEY_RIGHT:
326 menu_driver(menu, REQ_RIGHT_ITEM);
327 break;
328 case 10: /* ENTER */
329 case 27: /* ESCAPE */
330 case ' ':
331 case KEY_F(F_BACK):
332 case KEY_F(F_EXIT):
333 break;
334 }
335 touchwin(win);
336 refresh_all_windows(main_window);
337
338 if (res == 10 || res == ' ') {
339 res = item_index(current_item(menu));
340 break;
341 } else if (res == 27 || res == KEY_F(F_BACK) ||
342 res == KEY_F(F_EXIT)) {
343 res = KEY_EXIT;
344 break;
345 }
346 }
347
348 unpost_menu(menu);
349 free_menu(menu);
350 for (i = 0; i < btn_num; i++)
351 free_item(btns[i]);
352
353 delwin(win);
354 return res;
355}
356
357int dialog_inputbox(WINDOW *main_window,
358 const char *title, const char *prompt,
359 const char *init, char *result, int result_len)
360{
361 int prompt_lines = 0;
362 int prompt_width = 0;
363 WINDOW *win;
364 WINDOW *prompt_win;
365 WINDOW *form_win;
366 PANEL *panel;
367 int i, x, y;
368 int res = -1;
369 int cursor_position = strlen(init);
370
371
372 /* find the widest line of msg: */
373 prompt_lines = get_line_no(prompt);
374 for (i = 0; i < prompt_lines; i++) {
375 const char *line = get_line(prompt, i);
376 int len = get_line_length(line);
377 prompt_width = max(prompt_width, len);
378 }
379
380 if (title)
381 prompt_width = max(prompt_width, strlen(title));
382
383 /* place dialog in middle of screen */
384 y = (LINES-(prompt_lines+4))/2;
385 x = (COLS-(prompt_width+4))/2;
386
387 strncpy(result, init, result_len);
388
389 /* create the windows */
390 win = newwin(prompt_lines+6, prompt_width+7, y, x);
391 prompt_win = derwin(win, prompt_lines+1, prompt_width, 2, 2);
392 form_win = derwin(win, 1, prompt_width, prompt_lines+3, 2);
393 keypad(form_win, TRUE);
394
395 wattrset(form_win, attributes[INPUT_FIELD]);
396
397 wattrset(win, attributes[INPUT_BOX]);
398 box(win, 0, 0);
399 wattrset(win, attributes[INPUT_HEADING]);
400 if (title)
401 mvwprintw(win, 0, 3, "%s", title);
402
403 /* print message */
404 wattrset(prompt_win, attributes[INPUT_TEXT]);
405 fill_window(prompt_win, prompt);
406
407 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
408 mvwprintw(form_win, 0, 0, "%s", result);
409
410 /* create panels */
411 panel = new_panel(win);
412
413 /* show the cursor */
414 curs_set(1);
415
416 touchwin(win);
417 refresh_all_windows(main_window);
418 while ((res = wgetch(form_win))) {
419 int len = strlen(result);
420 switch (res) {
421 case 10: /* ENTER */
422 case 27: /* ESCAPE */
423 case KEY_F(F_HELP):
424 case KEY_F(F_EXIT):
425 case KEY_F(F_BACK):
426 break;
427 case 127:
428 case KEY_BACKSPACE:
429 if (cursor_position > 0) {
430 memmove(&result[cursor_position-1],
431 &result[cursor_position],
432 len-cursor_position+1);
433 cursor_position--;
434 }
435 break;
436 case KEY_DC:
437 if (cursor_position >= 0 && cursor_position < len) {
438 memmove(&result[cursor_position],
439 &result[cursor_position+1],
440 len-cursor_position+1);
441 }
442 break;
443 case KEY_UP:
444 case KEY_RIGHT:
445 if (cursor_position < len &&
446 cursor_position < min(result_len, prompt_width))
447 cursor_position++;
448 break;
449 case KEY_DOWN:
450 case KEY_LEFT:
451 if (cursor_position > 0)
452 cursor_position--;
453 break;
454 default:
455 if ((isgraph(res) || isspace(res)) &&
456 len-2 < result_len) {
457 /* insert the char at the proper position */
458 memmove(&result[cursor_position+1],
459 &result[cursor_position],
460 len+1);
461 result[cursor_position] = res;
462 cursor_position++;
463 } else {
464 mvprintw(0, 0, "unknow key: %d\n", res);
465 }
466 break;
467 }
468 wmove(form_win, 0, 0);
469 wclrtoeol(form_win);
470 mvwprintw(form_win, 0, 0, "%*s", prompt_width, " ");
471 mvwprintw(form_win, 0, 0, "%s", result);
472 wmove(form_win, 0, cursor_position);
473 touchwin(win);
474 refresh_all_windows(main_window);
475
476 if (res == 10) {
477 res = 0;
478 break;
479 } else if (res == 27 || res == KEY_F(F_BACK) ||
480 res == KEY_F(F_EXIT)) {
481 res = KEY_EXIT;
482 break;
483 } else if (res == KEY_F(F_HELP)) {
484 res = 1;
485 break;
486 }
487 }
488
489 /* hide the cursor */
490 curs_set(0);
491 del_panel(panel);
492 delwin(prompt_win);
493 delwin(form_win);
494 delwin(win);
495 return res;
496}
497
498/* refresh all windows in the correct order */
499void refresh_all_windows(WINDOW *main_window)
500{
501 update_panels();
502 touchwin(main_window);
503 refresh();
504}
505
506/* layman's scrollable window... */
507void show_scroll_win(WINDOW *main_window,
508 const char *title,
509 const char *text)
510{
511 int res;
512 int total_lines = get_line_no(text);
513 int x, y;
514 int start_x = 0, start_y = 0;
515 int text_lines = 0, text_cols = 0;
516 int total_cols = 0;
517 int win_cols = 0;
518 int win_lines = 0;
519 int i = 0;
520 WINDOW *win;
521 WINDOW *pad;
522 PANEL *panel;
523
524 /* find the widest line of msg: */
525 total_lines = get_line_no(text);
526 for (i = 0; i < total_lines; i++) {
527 const char *line = get_line(text, i);
528 int len = get_line_length(line);
529 total_cols = max(total_cols, len+2);
530 }
531
532 /* create the pad */
533 pad = newpad(total_lines+10, total_cols+10);
534 wattrset(pad, attributes[SCROLLWIN_TEXT]);
535 fill_window(pad, text);
536
537 win_lines = min(total_lines+4, LINES-2);
538 win_cols = min(total_cols+2, COLS-2);
539 text_lines = max(win_lines-4, 0);
540 text_cols = max(win_cols-2, 0);
541
542 /* place window in middle of screen */
543 y = (LINES-win_lines)/2;
544 x = (COLS-win_cols)/2;
545
546 win = newwin(win_lines, win_cols, y, x);
547 keypad(win, TRUE);
548 /* show the help in the help window, and show the help panel */
549 wattrset(win, attributes[SCROLLWIN_BOX]);
550 box(win, 0, 0);
551 wattrset(win, attributes[SCROLLWIN_HEADING]);
552 mvwprintw(win, 0, 3, " %s ", title);
553 panel = new_panel(win);
554
555 /* handle scrolling */
556 do {
557
558 copywin(pad, win, start_y, start_x, 2, 2, text_lines,
559 text_cols, 0);
560 print_in_middle(win,
561 text_lines+2,
562 0,
563 text_cols,
564 "<OK>",
565 attributes[DIALOG_MENU_FORE]);
566 wrefresh(win);
567
568 res = wgetch(win);
569 switch (res) {
570 case KEY_NPAGE:
571 case ' ':
572 start_y += text_lines-2;
573 break;
574 case KEY_PPAGE:
575 start_y -= text_lines+2;
576 break;
577 case KEY_HOME:
578 start_y = 0;
579 break;
580 case KEY_END:
581 start_y = total_lines-text_lines;
582 break;
583 case KEY_DOWN:
584 case 'j':
585 start_y++;
586 break;
587 case KEY_UP:
588 case 'k':
589 start_y--;
590 break;
591 case KEY_LEFT:
592 case 'h':
593 start_x--;
594 break;
595 case KEY_RIGHT:
596 case 'l':
597 start_x++;
598 break;
599 }
600 if (res == 10 || res == 27 || res == 'q'
601 || res == KEY_F(F_BACK) || res == KEY_F(F_EXIT)) {
602 break;
603 }
604 if (start_y < 0)
605 start_y = 0;
606 if (start_y >= total_lines-text_lines)
607 start_y = total_lines-text_lines;
608 if (start_x < 0)
609 start_x = 0;
610 if (start_x >= total_cols-text_cols)
611 start_x = total_cols-text_cols;
612 } while (res);
613
614 del_panel(panel);
615 delwin(win);
616 refresh_all_windows(main_window);
617}
diff --git a/scripts/kconfig/nconf.h b/scripts/kconfig/nconf.h
new file mode 100644
index 000000000000..fb4296666004
--- /dev/null
+++ b/scripts/kconfig/nconf.h
@@ -0,0 +1,95 @@
1/*
2 * Copyright (C) 2008 Nir Tzachar <nir.tzachar@gmail.com?
3 * Released under the terms of the GNU GPL v2.0.
4 *
5 * Derived from menuconfig.
6 *
7 */
8
9#include <ctype.h>
10#include <errno.h>
11#include <fcntl.h>
12#include <limits.h>
13#include <stdarg.h>
14#include <stdlib.h>
15#include <string.h>
16#include <unistd.h>
17#include <locale.h>
18#include <curses.h>
19#include <menu.h>
20#include <panel.h>
21#include <form.h>
22
23#include <stdio.h>
24#include <time.h>
25#include <sys/time.h>
26
27#include "ncurses.h"
28
29#define max(a, b) ({\
30 typeof(a) _a = a;\
31 typeof(b) _b = b;\
32 _a > _b ? _a : _b; })
33
34#define min(a, b) ({\
35 typeof(a) _a = a;\
36 typeof(b) _b = b;\
37 _a < _b ? _a : _b; })
38
39typedef enum {
40 NORMAL = 1,
41 MAIN_HEADING,
42 MAIN_MENU_BOX,
43 MAIN_MENU_FORE,
44 MAIN_MENU_BACK,
45 MAIN_MENU_GREY,
46 MAIN_MENU_HEADING,
47 SCROLLWIN_TEXT,
48 SCROLLWIN_HEADING,
49 SCROLLWIN_BOX,
50 DIALOG_TEXT,
51 DIALOG_MENU_FORE,
52 DIALOG_MENU_BACK,
53 DIALOG_BOX,
54 INPUT_BOX,
55 INPUT_HEADING,
56 INPUT_TEXT,
57 INPUT_FIELD,
58 FUNCTION_TEXT,
59 FUNCTION_HIGHLIGHT,
60 ATTR_MAX
61} attributes_t;
62extern attributes_t attributes[];
63
64typedef enum {
65 F_HELP = 1,
66 F_SYMBOL = 2,
67 F_INSTS = 3,
68 F_CONF = 4,
69 F_BACK = 5,
70 F_SAVE = 6,
71 F_LOAD = 7,
72 F_EXIT = 8
73} function_key;
74
75void set_colors(void);
76
77/* this changes the windows attributes !!! */
78void print_in_middle(WINDOW *win,
79 int starty,
80 int startx,
81 int width,
82 const char *string,
83 chtype color);
84int get_line_length(const char *line);
85int get_line_no(const char *text);
86const char *get_line(const char *text, int line_no);
87void fill_window(WINDOW *win, const char *text);
88int btn_dialog(WINDOW *main_window, const char *msg, int btn_num, ...);
89int dialog_inputbox(WINDOW *main_window,
90 const char *title, const char *prompt,
91 const char *init, char *result, int result_len);
92void refresh_all_windows(WINDOW *main_window);
93void show_scroll_win(WINDOW *main_window,
94 const char *title,
95 const char *text);
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index 6c8fbbb66ebc..2e7a048e0cfc 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -651,12 +651,20 @@ bool sym_is_changable(struct symbol *sym)
651 return sym->visible > sym->rev_dep.tri; 651 return sym->visible > sym->rev_dep.tri;
652} 652}
653 653
654static unsigned strhash(const char *s)
655{
656 /* fnv32 hash */
657 unsigned hash = 2166136261U;
658 for (; *s; s++)
659 hash = (hash ^ *s) * 0x01000193;
660 return hash;
661}
662
654struct symbol *sym_lookup(const char *name, int flags) 663struct symbol *sym_lookup(const char *name, int flags)
655{ 664{
656 struct symbol *symbol; 665 struct symbol *symbol;
657 const char *ptr;
658 char *new_name; 666 char *new_name;
659 int hash = 0; 667 int hash;
660 668
661 if (name) { 669 if (name) {
662 if (name[0] && !name[1]) { 670 if (name[0] && !name[1]) {
@@ -666,12 +674,11 @@ struct symbol *sym_lookup(const char *name, int flags)
666 case 'n': return &symbol_no; 674 case 'n': return &symbol_no;
667 } 675 }
668 } 676 }
669 for (ptr = name; *ptr; ptr++) 677 hash = strhash(name) % SYMBOL_HASHSIZE;
670 hash += *ptr;
671 hash &= 0xff;
672 678
673 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { 679 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
674 if (!strcmp(symbol->name, name) && 680 if (symbol->name &&
681 !strcmp(symbol->name, name) &&
675 (flags ? symbol->flags & flags 682 (flags ? symbol->flags & flags
676 : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE)))) 683 : !(symbol->flags & (SYMBOL_CONST|SYMBOL_CHOICE))))
677 return symbol; 684 return symbol;
@@ -679,7 +686,7 @@ struct symbol *sym_lookup(const char *name, int flags)
679 new_name = strdup(name); 686 new_name = strdup(name);
680 } else { 687 } else {
681 new_name = NULL; 688 new_name = NULL;
682 hash = 256; 689 hash = 0;
683 } 690 }
684 691
685 symbol = malloc(sizeof(*symbol)); 692 symbol = malloc(sizeof(*symbol));
@@ -697,7 +704,6 @@ struct symbol *sym_lookup(const char *name, int flags)
697struct symbol *sym_find(const char *name) 704struct symbol *sym_find(const char *name)
698{ 705{
699 struct symbol *symbol = NULL; 706 struct symbol *symbol = NULL;
700 const char *ptr;
701 int hash = 0; 707 int hash = 0;
702 708
703 if (!name) 709 if (!name)
@@ -710,12 +716,11 @@ struct symbol *sym_find(const char *name)
710 case 'n': return &symbol_no; 716 case 'n': return &symbol_no;
711 } 717 }
712 } 718 }
713 for (ptr = name; *ptr; ptr++) 719 hash = strhash(name) % SYMBOL_HASHSIZE;
714 hash += *ptr;
715 hash &= 0xff;
716 720
717 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) { 721 for (symbol = symbol_hash[hash]; symbol; symbol = symbol->next) {
718 if (!strcmp(symbol->name, name) && 722 if (symbol->name &&
723 !strcmp(symbol->name, name) &&
719 !(symbol->flags & SYMBOL_CONST)) 724 !(symbol->flags & SYMBOL_CONST))
720 break; 725 break;
721 } 726 }
@@ -750,6 +755,7 @@ struct symbol **sym_re_search(const char *pattern)
750 return NULL; 755 return NULL;
751 } 756 }
752 } 757 }
758 sym_calc_value(sym);
753 sym_arr[cnt++] = sym; 759 sym_arr[cnt++] = sym;
754 } 760 }
755 if (sym_arr) 761 if (sym_arr)
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index 25d1ec4ca28a..78b5c04e736b 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -78,6 +78,7 @@ struct gstr str_new(void)
78 struct gstr gs; 78 struct gstr gs;
79 gs.s = malloc(sizeof(char) * 64); 79 gs.s = malloc(sizeof(char) * 64);
80 gs.len = 64; 80 gs.len = 64;
81 gs.max_width = 0;
81 strcpy(gs.s, "\0"); 82 strcpy(gs.s, "\0");
82 return gs; 83 return gs;
83} 84}
@@ -88,6 +89,7 @@ struct gstr str_assign(const char *s)
88 struct gstr gs; 89 struct gstr gs;
89 gs.s = strdup(s); 90 gs.s = strdup(s);
90 gs.len = strlen(s) + 1; 91 gs.len = strlen(s) + 1;
92 gs.max_width = 0;
91 return gs; 93 return gs;
92} 94}
93 95
diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped
index 6e9dcd59aa87..32a9eefd842c 100644
--- a/scripts/kconfig/zconf.tab.c_shipped
+++ b/scripts/kconfig/zconf.tab.c_shipped
@@ -104,7 +104,7 @@ static void zconf_error(const char *err, ...);
104static void zconferror(const char *err); 104static void zconferror(const char *err);
105static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); 105static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
106 106
107struct symbol *symbol_hash[257]; 107struct symbol *symbol_hash[SYMBOL_HASHSIZE];
108 108
109static struct menu *current_menu, *current_entry; 109static struct menu *current_menu, *current_entry;
110 110
@@ -2220,7 +2220,7 @@ void conf_parse(const char *name)
2220 zconf_initscan(name); 2220 zconf_initscan(name);
2221 2221
2222 sym_init(); 2222 sym_init();
2223 menu_init(); 2223 _menu_init();
2224 modules_sym = sym_lookup(NULL, 0); 2224 modules_sym = sym_lookup(NULL, 0);
2225 modules_sym->type = S_BOOLEAN; 2225 modules_sym->type = S_BOOLEAN;
2226 modules_sym->flags |= SYMBOL_AUTO; 2226 modules_sym->flags |= SYMBOL_AUTO;
@@ -2336,9 +2336,9 @@ static void print_symbol(FILE *out, struct menu *menu)
2336 struct property *prop; 2336 struct property *prop;
2337 2337
2338 if (sym_is_choice(sym)) 2338 if (sym_is_choice(sym))
2339 fprintf(out, "choice\n"); 2339 fprintf(out, "\nchoice\n");
2340 else 2340 else
2341 fprintf(out, "config %s\n", sym->name); 2341 fprintf(out, "\nconfig %s\n", sym->name);
2342 switch (sym->type) { 2342 switch (sym->type) {
2343 case S_BOOLEAN: 2343 case S_BOOLEAN:
2344 fputs(" boolean\n", out); 2344 fputs(" boolean\n", out);
@@ -2384,6 +2384,21 @@ static void print_symbol(FILE *out, struct menu *menu)
2384 case P_CHOICE: 2384 case P_CHOICE:
2385 fputs(" #choice value\n", out); 2385 fputs(" #choice value\n", out);
2386 break; 2386 break;
2387 case P_SELECT:
2388 fputs( " select ", out);
2389 expr_fprint(prop->expr, out);
2390 fputc('\n', out);
2391 break;
2392 case P_RANGE:
2393 fputs( " range ", out);
2394 expr_fprint(prop->expr, out);
2395 fputc('\n', out);
2396 break;
2397 case P_MENU:
2398 fputs( " menu ", out);
2399 print_quoted_string(out, prop->text);
2400 fputc('\n', out);
2401 break;
2387 default: 2402 default:
2388 fprintf(out, " unknown prop %d!\n", prop->type); 2403 fprintf(out, " unknown prop %d!\n", prop->type);
2389 break; 2404 break;
@@ -2395,7 +2410,6 @@ static void print_symbol(FILE *out, struct menu *menu)
2395 menu->help[len] = 0; 2410 menu->help[len] = 0;
2396 fprintf(out, " help\n%s\n", menu->help); 2411 fprintf(out, " help\n%s\n", menu->help);
2397 } 2412 }
2398 fputc('\n', out);
2399} 2413}
2400 2414
2401void zconfdump(FILE *out) 2415void zconfdump(FILE *out)
@@ -2428,7 +2442,6 @@ void zconfdump(FILE *out)
2428 expr_fprint(prop->visible.expr, out); 2442 expr_fprint(prop->visible.expr, out);
2429 fputc('\n', out); 2443 fputc('\n', out);
2430 } 2444 }
2431 fputs("\n", out);
2432 } 2445 }
2433 2446
2434 if (menu->list) 2447 if (menu->list)
diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y
index 8c43491f8cc9..23dfd3baa7a1 100644
--- a/scripts/kconfig/zconf.y
+++ b/scripts/kconfig/zconf.y
@@ -27,7 +27,7 @@ static void zconf_error(const char *err, ...);
27static void zconferror(const char *err); 27static void zconferror(const char *err);
28static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken); 28static bool zconf_endtoken(struct kconf_id *id, int starttoken, int endtoken);
29 29
30struct symbol *symbol_hash[257]; 30struct symbol *symbol_hash[SYMBOL_HASHSIZE];
31 31
32static struct menu *current_menu, *current_entry; 32static struct menu *current_menu, *current_entry;
33 33
@@ -475,7 +475,7 @@ void conf_parse(const char *name)
475 zconf_initscan(name); 475 zconf_initscan(name);
476 476
477 sym_init(); 477 sym_init();
478 menu_init(); 478 _menu_init();
479 modules_sym = sym_lookup(NULL, 0); 479 modules_sym = sym_lookup(NULL, 0);
480 modules_sym->type = S_BOOLEAN; 480 modules_sym->type = S_BOOLEAN;
481 modules_sym->flags |= SYMBOL_AUTO; 481 modules_sym->flags |= SYMBOL_AUTO;
@@ -591,9 +591,9 @@ static void print_symbol(FILE *out, struct menu *menu)
591 struct property *prop; 591 struct property *prop;
592 592
593 if (sym_is_choice(sym)) 593 if (sym_is_choice(sym))
594 fprintf(out, "choice\n"); 594 fprintf(out, "\nchoice\n");
595 else 595 else
596 fprintf(out, "config %s\n", sym->name); 596 fprintf(out, "\nconfig %s\n", sym->name);
597 switch (sym->type) { 597 switch (sym->type) {
598 case S_BOOLEAN: 598 case S_BOOLEAN:
599 fputs(" boolean\n", out); 599 fputs(" boolean\n", out);
@@ -639,6 +639,21 @@ static void print_symbol(FILE *out, struct menu *menu)
639 case P_CHOICE: 639 case P_CHOICE:
640 fputs(" #choice value\n", out); 640 fputs(" #choice value\n", out);
641 break; 641 break;
642 case P_SELECT:
643 fputs( " select ", out);
644 expr_fprint(prop->expr, out);
645 fputc('\n', out);
646 break;
647 case P_RANGE:
648 fputs( " range ", out);
649 expr_fprint(prop->expr, out);
650 fputc('\n', out);
651 break;
652 case P_MENU:
653 fputs( " menu ", out);
654 print_quoted_string(out, prop->text);
655 fputc('\n', out);
656 break;
642 default: 657 default:
643 fprintf(out, " unknown prop %d!\n", prop->type); 658 fprintf(out, " unknown prop %d!\n", prop->type);
644 break; 659 break;
@@ -650,7 +665,6 @@ static void print_symbol(FILE *out, struct menu *menu)
650 menu->help[len] = 0; 665 menu->help[len] = 0;
651 fprintf(out, " help\n%s\n", menu->help); 666 fprintf(out, " help\n%s\n", menu->help);
652 } 667 }
653 fputc('\n', out);
654} 668}
655 669
656void zconfdump(FILE *out) 670void zconfdump(FILE *out)
@@ -683,7 +697,6 @@ void zconfdump(FILE *out)
683 expr_fprint(prop->visible.expr, out); 697 expr_fprint(prop->visible.expr, out);
684 fputc('\n', out); 698 fputc('\n', out);
685 } 699 }
686 fputs("\n", out);
687 } 700 }
688 701
689 if (menu->list) 702 if (menu->list)
diff --git a/scripts/markup_oops.pl b/scripts/markup_oops.pl
index e950f9cde019..827896f56501 100644
--- a/scripts/markup_oops.pl
+++ b/scripts/markup_oops.pl
@@ -2,6 +2,7 @@
2 2
3use File::Basename; 3use File::Basename;
4use Math::BigInt; 4use Math::BigInt;
5use Getopt::Long;
5 6
6# Copyright 2008, Intel Corporation 7# Copyright 2008, Intel Corporation
7# 8#
@@ -15,6 +16,16 @@ use Math::BigInt;
15# Arjan van de Ven <arjan@linux.intel.com> 16# Arjan van de Ven <arjan@linux.intel.com>
16 17
17 18
19my $cross_compile = "";
20my $vmlinux_name = "";
21my $modulefile = "";
22
23# Get options
24Getopt::Long::GetOptions(
25 'cross-compile|c=s' => \$cross_compile,
26 'module|m=s' => \$modulefile,
27 'help|h' => \&usage,
28) || usage ();
18my $vmlinux_name = $ARGV[0]; 29my $vmlinux_name = $ARGV[0];
19if (!defined($vmlinux_name)) { 30if (!defined($vmlinux_name)) {
20 my $kerver = `uname -r`; 31 my $kerver = `uname -r`;
@@ -23,9 +34,8 @@ if (!defined($vmlinux_name)) {
23 print "No vmlinux specified, assuming $vmlinux_name\n"; 34 print "No vmlinux specified, assuming $vmlinux_name\n";
24} 35}
25my $filename = $vmlinux_name; 36my $filename = $vmlinux_name;
26# 37
27# Step 1: Parse the oops to find the EIP value 38# Parse the oops to find the EIP value
28#
29 39
30my $target = "0"; 40my $target = "0";
31my $function; 41my $function;
@@ -177,26 +187,26 @@ my $decodestart = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("
177my $decodestop = Math::BigInt->from_hex("0x$target") + 8192; 187my $decodestop = Math::BigInt->from_hex("0x$target") + 8192;
178if ($target eq "0") { 188if ($target eq "0") {
179 print "No oops found!\n"; 189 print "No oops found!\n";
180 print "Usage: \n"; 190 usage();
181 print " dmesg | perl scripts/markup_oops.pl vmlinux\n";
182 exit;
183} 191}
184 192
185# if it's a module, we need to find the .ko file and calculate a load offset 193# if it's a module, we need to find the .ko file and calculate a load offset
186if ($module ne "") { 194if ($module ne "") {
187 my $modulefile = `modinfo $module | grep '^filename:' | awk '{ print \$2 }'`; 195 if ($modulefile eq "") {
188 chomp($modulefile); 196 $modulefile = `modinfo -F filename $module`;
197 chomp($modulefile);
198 }
189 $filename = $modulefile; 199 $filename = $modulefile;
190 if ($filename eq "") { 200 if ($filename eq "") {
191 print "Module .ko file for $module not found. Aborting\n"; 201 print "Module .ko file for $module not found. Aborting\n";
192 exit; 202 exit;
193 } 203 }
194 # ok so we found the module, now we need to calculate the vma offset 204 # ok so we found the module, now we need to calculate the vma offset
195 open(FILE, "objdump -dS $filename |") || die "Cannot start objdump"; 205 open(FILE, $cross_compile."objdump -dS $filename |") || die "Cannot start objdump";
196 while (<FILE>) { 206 while (<FILE>) {
197 if ($_ =~ /^([0-9a-f]+) \<$function\>\:/) { 207 if ($_ =~ /^([0-9a-f]+) \<$function\>\:/) {
198 my $fu = $1; 208 my $fu = $1;
199 $vmaoffset = hex($target) - hex($fu) - hex($func_offset); 209 $vmaoffset = Math::BigInt->from_hex("0x$target") - Math::BigInt->from_hex("0x$fu") - Math::BigInt->from_hex("0x$func_offset");
200 } 210 }
201 } 211 }
202 close(FILE); 212 close(FILE);
@@ -204,7 +214,7 @@ if ($module ne "") {
204 214
205my $counter = 0; 215my $counter = 0;
206my $state = 0; 216my $state = 0;
207my $center = 0; 217my $center = -1;
208my @lines; 218my @lines;
209my @reglines; 219my @reglines;
210 220
@@ -212,7 +222,7 @@ sub InRange {
212 my ($address, $target) = @_; 222 my ($address, $target) = @_;
213 my $ad = "0x".$address; 223 my $ad = "0x".$address;
214 my $ta = "0x".$target; 224 my $ta = "0x".$target;
215 my $delta = hex($ad) - hex($ta); 225 my $delta = Math::BigInt->from_hex($ad) - Math::BigInt->from_hex($ta);
216 226
217 if (($delta > -4096) && ($delta < 4096)) { 227 if (($delta > -4096) && ($delta < 4096)) {
218 return 1; 228 return 1;
@@ -225,7 +235,7 @@ sub InRange {
225# first, parse the input into the lines array, but to keep size down, 235# first, parse the input into the lines array, but to keep size down,
226# we only do this for 4Kb around the sweet spot 236# we only do this for 4Kb around the sweet spot
227 237
228open(FILE, "objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename |") || die "Cannot start objdump"; 238open(FILE, $cross_compile."objdump -dS --adjust-vma=$vmaoffset --start-address=$decodestart --stop-address=$decodestop $filename |") || die "Cannot start objdump";
229 239
230while (<FILE>) { 240while (<FILE>) {
231 my $line = $_; 241 my $line = $_;
@@ -236,7 +246,8 @@ while (<FILE>) {
236 $state = 1; 246 $state = 1;
237 } 247 }
238 } 248 }
239 } else { 249 }
250 if ($state == 1) {
240 if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) { 251 if ($line =~ /^([a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9][a-f0-9]+)\:/) {
241 my $val = $1; 252 my $val = $1;
242 if (!InRange($val, $target)) { 253 if (!InRange($val, $target)) {
@@ -259,7 +270,7 @@ if ($counter == 0) {
259 exit; 270 exit;
260} 271}
261 272
262if ($center == 0) { 273if ($center == -1) {
263 print "No matching code found \n"; 274 print "No matching code found \n";
264 exit; 275 exit;
265} 276}
@@ -344,3 +355,16 @@ while ($i < $finish) {
344 $i = $i +1; 355 $i = $i +1;
345} 356}
346 357
358sub usage {
359 print <<EOT;
360Usage:
361 dmesg | perl $0 [OPTION] [VMLINUX]
362
363OPTION:
364 -c, --cross-compile CROSS_COMPILE Specify the prefix used for toolchain.
365 -m, --module MODULE_DIRNAME Specify the module filename.
366 -h, --help Help.
367EOT
368 exit;
369}
370
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h
index 23dbad80cce9..50ad317a4bf9 100755
--- a/scripts/mkcompile_h
+++ b/scripts/mkcompile_h
@@ -67,9 +67,8 @@ UTS_TRUNCATE="cut -b -$UTS_LEN"
67 echo \#define LINUX_COMPILE_BY \"`whoami`\" 67 echo \#define LINUX_COMPILE_BY \"`whoami`\"
68 echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\" 68 echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\"
69 69
70 if [ -x /bin/dnsdomainname ]; then 70 domain=`dnsdomainname 2> /dev/null`
71 domain=`dnsdomainname 2> /dev/null` 71 if [ -z "$domain" ]; then
72 elif [ -x /bin/domainname ]; then
73 domain=`domainname 2> /dev/null` 72 domain=`domainname 2> /dev/null`
74 fi 73 fi
75 74
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 20923613467c..3318692e4e76 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -781,10 +781,13 @@ static void check_section(const char *modname, struct elf_info *elf,
781#define ALL_EXIT_TEXT_SECTIONS \ 781#define ALL_EXIT_TEXT_SECTIONS \
782 ".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$" 782 ".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$"
783 783
784#define ALL_INIT_SECTIONS INIT_SECTIONS, DEV_INIT_SECTIONS, \ 784#define ALL_XXXINIT_SECTIONS DEV_INIT_SECTIONS, CPU_INIT_SECTIONS, \
785 CPU_INIT_SECTIONS, MEM_INIT_SECTIONS 785 MEM_INIT_SECTIONS
786#define ALL_EXIT_SECTIONS EXIT_SECTIONS, DEV_EXIT_SECTIONS, \ 786#define ALL_XXXEXIT_SECTIONS DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, \
787 CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS 787 MEM_EXIT_SECTIONS
788
789#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
790#define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS
788 791
789#define DATA_SECTIONS ".data$", ".data.rel$" 792#define DATA_SECTIONS ".data$", ".data.rel$"
790#define TEXT_SECTIONS ".text$" 793#define TEXT_SECTIONS ".text$"
@@ -814,33 +817,29 @@ static const char *data_sections[] = { DATA_SECTIONS, NULL };
814 817
815 818
816/* symbols in .data that may refer to init/exit sections */ 819/* symbols in .data that may refer to init/exit sections */
817static const char *symbol_white_list[] = 820#define DEFAULT_SYMBOL_WHITE_LIST \
818{ 821 "*driver", \
819 "*driver", 822 "*_template", /* scsi uses *_template a lot */ \
820 "*_template", /* scsi uses *_template a lot */ 823 "*_timer", /* arm uses ops structures named _timer a lot */ \
821 "*_timer", /* arm uses ops structures named _timer a lot */ 824 "*_sht", /* scsi also used *_sht to some extent */ \
822 "*_sht", /* scsi also used *_sht to some extent */ 825 "*_ops", \
823 "*_ops", 826 "*_probe", \
824 "*_probe", 827 "*_probe_one", \
825 "*_probe_one", 828 "*_console"
826 "*_console",
827 NULL
828};
829 829
830static const char *head_sections[] = { ".head.text*", NULL }; 830static const char *head_sections[] = { ".head.text*", NULL };
831static const char *linker_symbols[] = 831static const char *linker_symbols[] =
832 { "__init_begin", "_sinittext", "_einittext", NULL }; 832 { "__init_begin", "_sinittext", "_einittext", NULL };
833 833
834enum mismatch { 834enum mismatch {
835 NO_MISMATCH, 835 TEXT_TO_ANY_INIT,
836 TEXT_TO_INIT, 836 DATA_TO_ANY_INIT,
837 DATA_TO_INIT, 837 TEXT_TO_ANY_EXIT,
838 TEXT_TO_EXIT, 838 DATA_TO_ANY_EXIT,
839 DATA_TO_EXIT, 839 XXXINIT_TO_SOME_INIT,
840 XXXINIT_TO_INIT, 840 XXXEXIT_TO_SOME_EXIT,
841 XXXEXIT_TO_EXIT, 841 ANY_INIT_TO_ANY_EXIT,
842 INIT_TO_EXIT, 842 ANY_EXIT_TO_ANY_INIT,
843 EXIT_TO_INIT,
844 EXPORT_TO_INIT_EXIT, 843 EXPORT_TO_INIT_EXIT,
845}; 844};
846 845
@@ -848,6 +847,7 @@ struct sectioncheck {
848 const char *fromsec[20]; 847 const char *fromsec[20];
849 const char *tosec[20]; 848 const char *tosec[20];
850 enum mismatch mismatch; 849 enum mismatch mismatch;
850 const char *symbol_white_list[20];
851}; 851};
852 852
853const struct sectioncheck sectioncheck[] = { 853const struct sectioncheck sectioncheck[] = {
@@ -857,80 +857,103 @@ const struct sectioncheck sectioncheck[] = {
857{ 857{
858 .fromsec = { TEXT_SECTIONS, NULL }, 858 .fromsec = { TEXT_SECTIONS, NULL },
859 .tosec = { ALL_INIT_SECTIONS, NULL }, 859 .tosec = { ALL_INIT_SECTIONS, NULL },
860 .mismatch = TEXT_TO_INIT, 860 .mismatch = TEXT_TO_ANY_INIT,
861 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
861}, 862},
862{ 863{
863 .fromsec = { DATA_SECTIONS, NULL }, 864 .fromsec = { DATA_SECTIONS, NULL },
864 .tosec = { ALL_INIT_SECTIONS, NULL }, 865 .tosec = { ALL_XXXINIT_SECTIONS, NULL },
865 .mismatch = DATA_TO_INIT, 866 .mismatch = DATA_TO_ANY_INIT,
867 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
868},
869{
870 .fromsec = { DATA_SECTIONS, NULL },
871 .tosec = { INIT_SECTIONS, NULL },
872 .mismatch = DATA_TO_ANY_INIT,
873 .symbol_white_list = {
874 "*_template", "*_timer", "*_sht", "*_ops",
875 "*_probe", "*_probe_one", "*_console", NULL
876 },
866}, 877},
867{ 878{
868 .fromsec = { TEXT_SECTIONS, NULL }, 879 .fromsec = { TEXT_SECTIONS, NULL },
869 .tosec = { ALL_EXIT_SECTIONS, NULL }, 880 .tosec = { ALL_EXIT_SECTIONS, NULL },
870 .mismatch = TEXT_TO_EXIT, 881 .mismatch = TEXT_TO_ANY_EXIT,
882 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
871}, 883},
872{ 884{
873 .fromsec = { DATA_SECTIONS, NULL }, 885 .fromsec = { DATA_SECTIONS, NULL },
874 .tosec = { ALL_EXIT_SECTIONS, NULL }, 886 .tosec = { ALL_EXIT_SECTIONS, NULL },
875 .mismatch = DATA_TO_EXIT, 887 .mismatch = DATA_TO_ANY_EXIT,
888 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
876}, 889},
877/* Do not reference init code/data from devinit/cpuinit/meminit code/data */ 890/* Do not reference init code/data from devinit/cpuinit/meminit code/data */
878{ 891{
879 .fromsec = { DEV_INIT_SECTIONS, CPU_INIT_SECTIONS, MEM_INIT_SECTIONS, NULL }, 892 .fromsec = { ALL_XXXINIT_SECTIONS, NULL },
880 .tosec = { INIT_SECTIONS, NULL }, 893 .tosec = { INIT_SECTIONS, NULL },
881 .mismatch = XXXINIT_TO_INIT, 894 .mismatch = XXXINIT_TO_SOME_INIT,
895 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
882}, 896},
883/* Do not reference cpuinit code/data from meminit code/data */ 897/* Do not reference cpuinit code/data from meminit code/data */
884{ 898{
885 .fromsec = { MEM_INIT_SECTIONS, NULL }, 899 .fromsec = { MEM_INIT_SECTIONS, NULL },
886 .tosec = { CPU_INIT_SECTIONS, NULL }, 900 .tosec = { CPU_INIT_SECTIONS, NULL },
887 .mismatch = XXXINIT_TO_INIT, 901 .mismatch = XXXINIT_TO_SOME_INIT,
902 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
888}, 903},
889/* Do not reference meminit code/data from cpuinit code/data */ 904/* Do not reference meminit code/data from cpuinit code/data */
890{ 905{
891 .fromsec = { CPU_INIT_SECTIONS, NULL }, 906 .fromsec = { CPU_INIT_SECTIONS, NULL },
892 .tosec = { MEM_INIT_SECTIONS, NULL }, 907 .tosec = { MEM_INIT_SECTIONS, NULL },
893 .mismatch = XXXINIT_TO_INIT, 908 .mismatch = XXXINIT_TO_SOME_INIT,
909 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
894}, 910},
895/* Do not reference exit code/data from devexit/cpuexit/memexit code/data */ 911/* Do not reference exit code/data from devexit/cpuexit/memexit code/data */
896{ 912{
897 .fromsec = { DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS, NULL }, 913 .fromsec = { ALL_XXXEXIT_SECTIONS, NULL },
898 .tosec = { EXIT_SECTIONS, NULL }, 914 .tosec = { EXIT_SECTIONS, NULL },
899 .mismatch = XXXEXIT_TO_EXIT, 915 .mismatch = XXXEXIT_TO_SOME_EXIT,
916 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
900}, 917},
901/* Do not reference cpuexit code/data from memexit code/data */ 918/* Do not reference cpuexit code/data from memexit code/data */
902{ 919{
903 .fromsec = { MEM_EXIT_SECTIONS, NULL }, 920 .fromsec = { MEM_EXIT_SECTIONS, NULL },
904 .tosec = { CPU_EXIT_SECTIONS, NULL }, 921 .tosec = { CPU_EXIT_SECTIONS, NULL },
905 .mismatch = XXXEXIT_TO_EXIT, 922 .mismatch = XXXEXIT_TO_SOME_EXIT,
923 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
906}, 924},
907/* Do not reference memexit code/data from cpuexit code/data */ 925/* Do not reference memexit code/data from cpuexit code/data */
908{ 926{
909 .fromsec = { CPU_EXIT_SECTIONS, NULL }, 927 .fromsec = { CPU_EXIT_SECTIONS, NULL },
910 .tosec = { MEM_EXIT_SECTIONS, NULL }, 928 .tosec = { MEM_EXIT_SECTIONS, NULL },
911 .mismatch = XXXEXIT_TO_EXIT, 929 .mismatch = XXXEXIT_TO_SOME_EXIT,
930 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
912}, 931},
913/* Do not use exit code/data from init code */ 932/* Do not use exit code/data from init code */
914{ 933{
915 .fromsec = { ALL_INIT_SECTIONS, NULL }, 934 .fromsec = { ALL_INIT_SECTIONS, NULL },
916 .tosec = { ALL_EXIT_SECTIONS, NULL }, 935 .tosec = { ALL_EXIT_SECTIONS, NULL },
917 .mismatch = INIT_TO_EXIT, 936 .mismatch = ANY_INIT_TO_ANY_EXIT,
937 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
918}, 938},
919/* Do not use init code/data from exit code */ 939/* Do not use init code/data from exit code */
920{ 940{
921 .fromsec = { ALL_EXIT_SECTIONS, NULL }, 941 .fromsec = { ALL_EXIT_SECTIONS, NULL },
922 .tosec = { ALL_INIT_SECTIONS, NULL }, 942 .tosec = { ALL_INIT_SECTIONS, NULL },
923 .mismatch = EXIT_TO_INIT, 943 .mismatch = ANY_EXIT_TO_ANY_INIT,
944 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
924}, 945},
925/* Do not export init/exit functions or data */ 946/* Do not export init/exit functions or data */
926{ 947{
927 .fromsec = { "__ksymtab*", NULL }, 948 .fromsec = { "__ksymtab*", NULL },
928 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL }, 949 .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL },
929 .mismatch = EXPORT_TO_INIT_EXIT 950 .mismatch = EXPORT_TO_INIT_EXIT,
951 .symbol_white_list = { DEFAULT_SYMBOL_WHITE_LIST, NULL },
930} 952}
931}; 953};
932 954
933static int section_mismatch(const char *fromsec, const char *tosec) 955static const struct sectioncheck *section_mismatch(
956 const char *fromsec, const char *tosec)
934{ 957{
935 int i; 958 int i;
936 int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck); 959 int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck);
@@ -939,10 +962,10 @@ static int section_mismatch(const char *fromsec, const char *tosec)
939 for (i = 0; i < elems; i++) { 962 for (i = 0; i < elems; i++) {
940 if (match(fromsec, check->fromsec) && 963 if (match(fromsec, check->fromsec) &&
941 match(tosec, check->tosec)) 964 match(tosec, check->tosec))
942 return check->mismatch; 965 return check;
943 check++; 966 check++;
944 } 967 }
945 return NO_MISMATCH; 968 return NULL;
946} 969}
947 970
948/** 971/**
@@ -961,7 +984,7 @@ static int section_mismatch(const char *fromsec, const char *tosec)
961 * Pattern 2: 984 * Pattern 2:
962 * Many drivers utilise a *driver container with references to 985 * Many drivers utilise a *driver container with references to
963 * add, remove, probe functions etc. 986 * add, remove, probe functions etc.
964 * These functions may often be marked __init and we do not want to 987 * These functions may often be marked __devinit and we do not want to
965 * warn here. 988 * warn here.
966 * the pattern is identified by: 989 * the pattern is identified by:
967 * tosec = init or exit section 990 * tosec = init or exit section
@@ -982,7 +1005,8 @@ static int section_mismatch(const char *fromsec, const char *tosec)
982 * refsymname = __init_begin, _sinittext, _einittext 1005 * refsymname = __init_begin, _sinittext, _einittext
983 * 1006 *
984 **/ 1007 **/
985static int secref_whitelist(const char *fromsec, const char *fromsym, 1008static int secref_whitelist(const struct sectioncheck *mismatch,
1009 const char *fromsec, const char *fromsym,
986 const char *tosec, const char *tosym) 1010 const char *tosec, const char *tosym)
987{ 1011{
988 /* Check for pattern 1 */ 1012 /* Check for pattern 1 */
@@ -994,7 +1018,7 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
994 /* Check for pattern 2 */ 1018 /* Check for pattern 2 */
995 if (match(tosec, init_exit_sections) && 1019 if (match(tosec, init_exit_sections) &&
996 match(fromsec, data_sections) && 1020 match(fromsec, data_sections) &&
997 match(fromsym, symbol_white_list)) 1021 match(fromsym, mismatch->symbol_white_list))
998 return 0; 1022 return 0;
999 1023
1000 /* Check for pattern 3 */ 1024 /* Check for pattern 3 */
@@ -1155,7 +1179,8 @@ static int is_function(Elf_Sym *sym)
1155 * Try to find symbols near it so user can find it. 1179 * Try to find symbols near it so user can find it.
1156 * Check whitelist before warning - it may be a false positive. 1180 * Check whitelist before warning - it may be a false positive.
1157 */ 1181 */
1158static void report_sec_mismatch(const char *modname, enum mismatch mismatch, 1182static void report_sec_mismatch(const char *modname,
1183 const struct sectioncheck *mismatch,
1159 const char *fromsec, 1184 const char *fromsec,
1160 unsigned long long fromaddr, 1185 unsigned long long fromaddr,
1161 const char *fromsym, 1186 const char *fromsym,
@@ -1186,8 +1211,8 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
1186 modname, fromsec, fromaddr, from, fromsym, from_p, to, tosec, 1211 modname, fromsec, fromaddr, from, fromsym, from_p, to, tosec,
1187 tosym, to_p); 1212 tosym, to_p);
1188 1213
1189 switch (mismatch) { 1214 switch (mismatch->mismatch) {
1190 case TEXT_TO_INIT: 1215 case TEXT_TO_ANY_INIT:
1191 fprintf(stderr, 1216 fprintf(stderr,
1192 "The function %s%s() references\n" 1217 "The function %s%s() references\n"
1193 "the %s %s%s%s.\n" 1218 "the %s %s%s%s.\n"
@@ -1197,8 +1222,8 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
1197 to, sec2annotation(tosec), tosym, to_p, 1222 to, sec2annotation(tosec), tosym, to_p,
1198 fromsym, sec2annotation(tosec), tosym); 1223 fromsym, sec2annotation(tosec), tosym);
1199 break; 1224 break;
1200 case DATA_TO_INIT: { 1225 case DATA_TO_ANY_INIT: {
1201 const char **s = symbol_white_list; 1226 const char *const *s = mismatch->symbol_white_list;
1202 fprintf(stderr, 1227 fprintf(stderr,
1203 "The variable %s references\n" 1228 "The variable %s references\n"
1204 "the %s %s%s%s\n" 1229 "the %s %s%s%s\n"
@@ -1211,15 +1236,15 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
1211 fprintf(stderr, "\n"); 1236 fprintf(stderr, "\n");
1212 break; 1237 break;
1213 } 1238 }
1214 case TEXT_TO_EXIT: 1239 case TEXT_TO_ANY_EXIT:
1215 fprintf(stderr, 1240 fprintf(stderr,
1216 "The function %s() references a %s in an exit section.\n" 1241 "The function %s() references a %s in an exit section.\n"
1217 "Often the %s %s%s has valid usage outside the exit section\n" 1242 "Often the %s %s%s has valid usage outside the exit section\n"
1218 "and the fix is to remove the %sannotation of %s.\n", 1243 "and the fix is to remove the %sannotation of %s.\n",
1219 fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym); 1244 fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym);
1220 break; 1245 break;
1221 case DATA_TO_EXIT: { 1246 case DATA_TO_ANY_EXIT: {
1222 const char **s = symbol_white_list; 1247 const char *const *s = mismatch->symbol_white_list;
1223 fprintf(stderr, 1248 fprintf(stderr,
1224 "The variable %s references\n" 1249 "The variable %s references\n"
1225 "the %s %s%s%s\n" 1250 "the %s %s%s%s\n"
@@ -1232,8 +1257,8 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
1232 fprintf(stderr, "\n"); 1257 fprintf(stderr, "\n");
1233 break; 1258 break;
1234 } 1259 }
1235 case XXXINIT_TO_INIT: 1260 case XXXINIT_TO_SOME_INIT:
1236 case XXXEXIT_TO_EXIT: 1261 case XXXEXIT_TO_SOME_EXIT:
1237 fprintf(stderr, 1262 fprintf(stderr,
1238 "The %s %s%s%s references\n" 1263 "The %s %s%s%s references\n"
1239 "a %s %s%s%s.\n" 1264 "a %s %s%s%s.\n"
@@ -1243,7 +1268,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
1243 to, sec2annotation(tosec), tosym, to_p, 1268 to, sec2annotation(tosec), tosym, to_p,
1244 tosym, fromsym, tosym); 1269 tosym, fromsym, tosym);
1245 break; 1270 break;
1246 case INIT_TO_EXIT: 1271 case ANY_INIT_TO_ANY_EXIT:
1247 fprintf(stderr, 1272 fprintf(stderr,
1248 "The %s %s%s%s references\n" 1273 "The %s %s%s%s references\n"
1249 "a %s %s%s%s.\n" 1274 "a %s %s%s%s.\n"
@@ -1256,7 +1281,7 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
1256 to, sec2annotation(tosec), tosym, to_p, 1281 to, sec2annotation(tosec), tosym, to_p,
1257 sec2annotation(tosec), tosym, to_p); 1282 sec2annotation(tosec), tosym, to_p);
1258 break; 1283 break;
1259 case EXIT_TO_INIT: 1284 case ANY_EXIT_TO_ANY_INIT:
1260 fprintf(stderr, 1285 fprintf(stderr,
1261 "The %s %s%s%s references\n" 1286 "The %s %s%s%s references\n"
1262 "a %s %s%s%s.\n" 1287 "a %s %s%s%s.\n"
@@ -1275,8 +1300,6 @@ static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
1275 "Fix this by removing the %sannotation of %s " 1300 "Fix this by removing the %sannotation of %s "
1276 "or drop the export.\n", 1301 "or drop the export.\n",
1277 tosym, sec2annotation(tosec), sec2annotation(tosec), tosym); 1302 tosym, sec2annotation(tosec), sec2annotation(tosec), tosym);
1278 case NO_MISMATCH:
1279 /* To get warnings on missing members */
1280 break; 1303 break;
1281 } 1304 }
1282 fprintf(stderr, "\n"); 1305 fprintf(stderr, "\n");
@@ -1286,11 +1309,11 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
1286 Elf_Rela *r, Elf_Sym *sym, const char *fromsec) 1309 Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
1287{ 1310{
1288 const char *tosec; 1311 const char *tosec;
1289 enum mismatch mismatch; 1312 const struct sectioncheck *mismatch;
1290 1313
1291 tosec = sec_name(elf, sym->st_shndx); 1314 tosec = sec_name(elf, sym->st_shndx);
1292 mismatch = section_mismatch(fromsec, tosec); 1315 mismatch = section_mismatch(fromsec, tosec);
1293 if (mismatch != NO_MISMATCH) { 1316 if (mismatch) {
1294 Elf_Sym *to; 1317 Elf_Sym *to;
1295 Elf_Sym *from; 1318 Elf_Sym *from;
1296 const char *tosym; 1319 const char *tosym;
@@ -1302,7 +1325,8 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
1302 tosym = sym_name(elf, to); 1325 tosym = sym_name(elf, to);
1303 1326
1304 /* check whitelist - we may ignore it */ 1327 /* check whitelist - we may ignore it */
1305 if (secref_whitelist(fromsec, fromsym, tosec, tosym)) { 1328 if (secref_whitelist(mismatch,
1329 fromsec, fromsym, tosec, tosym)) {
1306 report_sec_mismatch(modname, mismatch, 1330 report_sec_mismatch(modname, mismatch,
1307 fromsec, r->r_offset, fromsym, 1331 fromsec, r->r_offset, fromsym,
1308 is_function(from), tosec, tosym, 1332 is_function(from), tosec, tosym,
diff --git a/scripts/namespace.pl b/scripts/namespace.pl
index c6e88c652c2f..361d0f71184b 100755
--- a/scripts/namespace.pl
+++ b/scripts/namespace.pl
@@ -175,12 +175,11 @@ sub do_nm
175 } 175 }
176 if (! -e "$source.c" && ! -e "$source.S") { 176 if (! -e "$source.c" && ! -e "$source.S") {
177 # No obvious source, exclude the object if it is conglomerate 177 # No obvious source, exclude the object if it is conglomerate
178 if (! open(OBJDUMPDATA, "$objdump $basename|")) { 178 open(my $objdumpdata, "$objdump $basename|")
179 printf STDERR "$objdump $fullname failed $!\n"; 179 or die "$objdump $fullname failed $!\n";
180 return; 180
181 }
182 my $comment; 181 my $comment;
183 while (<OBJDUMPDATA>) { 182 while (<$objdumpdata>) {
184 chomp(); 183 chomp();
185 if (/^In archive/) { 184 if (/^In archive/) {
186 # Archives are always conglomerate 185 # Archives are always conglomerate
@@ -190,18 +189,18 @@ sub do_nm
190 next if (! /^[ 0-9a-f]{5,} /); 189 next if (! /^[ 0-9a-f]{5,} /);
191 $comment .= substr($_, 43); 190 $comment .= substr($_, 43);
192 } 191 }
193 close(OBJDUMPDATA); 192 close($objdumpdata);
193
194 if (!defined($comment) || $comment !~ /GCC\:.*GCC\:/m) { 194 if (!defined($comment) || $comment !~ /GCC\:.*GCC\:/m) {
195 printf STDERR "No source file found for $fullname\n"; 195 printf STDERR "No source file found for $fullname\n";
196 } 196 }
197 return; 197 return;
198 } 198 }
199 if (! open(NMDATA, "$nm $basename|")) { 199 open (my $nmdata, "$nm $basename|")
200 printf STDERR "$nm $fullname failed $!\n"; 200 or die "$nm $fullname failed $!\n";
201 return; 201
202 }
203 my @nmdata; 202 my @nmdata;
204 while (<NMDATA>) { 203 while (<$nmdata>) {
205 chop; 204 chop;
206 ($type, $name) = (split(/ +/, $_, 3))[1..2]; 205 ($type, $name) = (split(/ +/, $_, 3))[1..2];
207 # Expected types 206 # Expected types
@@ -268,7 +267,8 @@ sub do_nm
268 } 267 }
269 } 268 }
270 } 269 }
271 close(NMDATA); 270 close($nmdata);
271
272 if ($#nmdata < 0) { 272 if ($#nmdata < 0) {
273 if ( 273 if (
274 $fullname ne "lib/brlock.o" 274 $fullname ne "lib/brlock.o"
@@ -316,8 +316,7 @@ sub drop_def
316 316
317sub list_multiply_defined 317sub list_multiply_defined
318{ 318{
319 my ($name, $module); 319 foreach my $name (keys(%def)) {
320 foreach $name (keys(%def)) {
321 if ($#{$def{$name}} > 0) { 320 if ($#{$def{$name}} > 0) {
322 # Special case for cond_syscall 321 # Special case for cond_syscall
323 if ($#{$def{$name}} == 1 && $name =~ /^sys_/ && 322 if ($#{$def{$name}} == 1 && $name =~ /^sys_/ &&
@@ -333,8 +332,9 @@ sub list_multiply_defined
333 &drop_def("arch/x86/kernel/vsyscall-sysenter_32.o", $name); 332 &drop_def("arch/x86/kernel/vsyscall-sysenter_32.o", $name);
334 next; 333 next;
335 } 334 }
335
336 printf "$name is multiply defined in :-\n"; 336 printf "$name is multiply defined in :-\n";
337 foreach $module (@{$def{$name}}) { 337 foreach my $module (@{$def{$name}}) {
338 printf "\t$module\n"; 338 printf "\t$module\n";
339 } 339 }
340 } 340 }
@@ -343,12 +343,13 @@ sub list_multiply_defined
343 343
344sub resolve_external_references 344sub resolve_external_references
345{ 345{
346 my ($object, $type, $name, $i, $j, $kstrtab, $ksymtab, $export); 346 my ($kstrtab, $ksymtab, $export);
347
347 printf "\n"; 348 printf "\n";
348 foreach $object (keys(%nmdata)) { 349 foreach my $object (keys(%nmdata)) {
349 my $nmdata = $nmdata{$object}; 350 my $nmdata = $nmdata{$object};
350 for ($i = 0; $i <= $#{$nmdata}; ++$i) { 351 for (my $i = 0; $i <= $#{$nmdata}; ++$i) {
351 ($type, $name) = split(' ', $nmdata->[$i], 2); 352 my ($type, $name) = split(' ', $nmdata->[$i], 2);
352 if ($type eq "U" || $type eq "w") { 353 if ($type eq "U" || $type eq "w") {
353 if (exists($def{$name}) || exists($ksymtab{$name})) { 354 if (exists($def{$name}) || exists($ksymtab{$name})) {
354 # add the owning object to the nmdata 355 # add the owning object to the nmdata
@@ -357,7 +358,7 @@ sub resolve_external_references
357 $kstrtab = "R __kstrtab_$name"; 358 $kstrtab = "R __kstrtab_$name";
358 $ksymtab = "R __ksymtab_$name"; 359 $ksymtab = "R __ksymtab_$name";
359 $export = 0; 360 $export = 0;
360 for ($j = 0; $j <= $#{$nmdata}; ++$j) { 361 for (my $j = 0; $j <= $#{$nmdata}; ++$j) {
361 if ($nmdata->[$j] eq $kstrtab || 362 if ($nmdata->[$j] eq $kstrtab ||
362 $nmdata->[$j] eq $ksymtab) { 363 $nmdata->[$j] eq $ksymtab) {
363 $export = 1; 364 $export = 1;
@@ -424,11 +425,11 @@ sub resolve_external_references
424sub list_extra_externals 425sub list_extra_externals
425{ 426{
426 my %noref = (); 427 my %noref = ();
427 my ($name, @module, $module, $export); 428
428 foreach $name (keys(%def)) { 429 foreach my $name (keys(%def)) {
429 if (! exists($ref{$name})) { 430 if (! exists($ref{$name})) {
430 @module = @{$def{$name}}; 431 my @module = @{$def{$name}};
431 foreach $module (@module) { 432 foreach my $module (@module) {
432 if (! exists($noref{$module})) { 433 if (! exists($noref{$module})) {
433 $noref{$module} = []; 434 $noref{$module} = [];
434 } 435 }
@@ -438,16 +439,16 @@ sub list_extra_externals
438 } 439 }
439 if (%noref) { 440 if (%noref) {
440 printf "\nExternally defined symbols with no external references\n"; 441 printf "\nExternally defined symbols with no external references\n";
441 foreach $module (sort(keys(%noref))) { 442 foreach my $module (sort(keys(%noref))) {
442 printf " $module\n"; 443 printf " $module\n";
443 foreach (sort(@{$noref{$module}})) { 444 foreach (sort(@{$noref{$module}})) {
444 if (exists($export{$_})) { 445 my $export;
445 $export = " (export only)"; 446 if (exists($export{$_})) {
446 } 447 $export = " (export only)";
447 else { 448 } else {
448 $export = ""; 449 $export = "";
449 } 450 }
450 printf " $_$export\n"; 451 printf " $_$export\n";
451 } 452 }
452 } 453 }
453 } 454 }
diff --git a/scripts/package/builddeb b/scripts/package/builddeb
index 8b357b0bd250..07f2fbde2abf 100644
--- a/scripts/package/builddeb
+++ b/scripts/package/builddeb
@@ -18,6 +18,8 @@ create_package() {
18 cp debian/copyright "$pdir/usr/share/doc/$pname/" 18 cp debian/copyright "$pdir/usr/share/doc/$pname/"
19 cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian" 19 cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian"
20 gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian" 20 gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian"
21 sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \
22 | xargs -r0 md5sum > DEBIAN/md5sums"
21 23
22 # Fix ownership and permissions 24 # Fix ownership and permissions
23 chown -R root:root "$pdir" 25 chown -R root:root "$pdir"
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index fa27f3dac769..15440f55aef6 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -39,7 +39,7 @@ if ! $PREBUILT; then
39echo "Source: kernel-$__KERNELRELEASE.tar.gz" 39echo "Source: kernel-$__KERNELRELEASE.tar.gz"
40fi 40fi
41 41
42echo "BuildRoot: /var/tmp/%{name}-%{PACKAGE_VERSION}-root" 42echo "BuildRoot: %{_tmppath}/%{name}-%{PACKAGE_VERSION}-root"
43echo "Provides: $PROVIDES" 43echo "Provides: $PROVIDES"
44echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :" 44echo "%define __spec_install_post /usr/lib/rpm/brp-compress || :"
45echo "%define debug_package %{nil}" 45echo "%define debug_package %{nil}"
diff --git a/scripts/profile2linkerlist.pl b/scripts/profile2linkerlist.pl
index cb4260ebdb91..6943fa7cc95b 100644
--- a/scripts/profile2linkerlist.pl
+++ b/scripts/profile2linkerlist.pl
@@ -7,15 +7,13 @@
7# usage: 7# usage:
8# readprofile | sort -rn | perl profile2linkerlist.pl > functionlist 8# readprofile | sort -rn | perl profile2linkerlist.pl > functionlist
9# 9#
10use strict;
10 11
11while (<>) { 12while (<>) {
12 my $line = $_; 13 my $line = $_;
13 14
14 $_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/; 15 $_ =~ /\W*[0-9]+\W*([a-zA-Z\_0-9]+)\W*[0-9]+/;
15 16
16 if ( ($line =~ /unknown/) || ($line =~ /total/)) { 17 print "*(.text.$1)\n"
17 18 unless ($line =~ /unknown/) || ($line =~ /total/);
18 } else {
19 print "*(.text.$1)\n";
20 }
21} 19}
diff --git a/scripts/rt-tester/rt-tester.py b/scripts/rt-tester/rt-tester.py
index 4c79660793cf..44423b4dcb82 100644
--- a/scripts/rt-tester/rt-tester.py
+++ b/scripts/rt-tester/rt-tester.py
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/python
2# 2#
3# rt-mutex tester 3# rt-mutex tester
4# 4#
diff --git a/scripts/show_delta b/scripts/show_delta
index 48a706ab3d0c..17df3051747a 100755
--- a/scripts/show_delta
+++ b/scripts/show_delta
@@ -1,4 +1,4 @@
1#!/usr/bin/env python 1#!/usr/bin/python
2# 2#
3# show_deltas: Read list of printk messages instrumented with 3# show_deltas: Read list of printk messages instrumented with
4# time data, and format with time deltas. 4# time data, and format with time deltas.
diff --git a/scripts/tags.sh b/scripts/tags.sh
index 1a0c44d7c4a7..8509bb512935 100755
--- a/scripts/tags.sh
+++ b/scripts/tags.sh
@@ -5,7 +5,7 @@
5# mode may be any of: tags, TAGS, cscope 5# mode may be any of: tags, TAGS, cscope
6# 6#
7# Uses the following environment variables: 7# Uses the following environment variables:
8# ARCH, SUBARCH, srctree, src, obj 8# ARCH, SUBARCH, SRCARCH, srctree, src, obj
9 9
10if [ "$KBUILD_VERBOSE" = "1" ]; then 10if [ "$KBUILD_VERBOSE" = "1" ]; then
11 set -x 11 set -x
@@ -17,28 +17,48 @@ ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \
17 -name .git ) \ 17 -name .git ) \
18 -prune -o" 18 -prune -o"
19 19
20# Do not use full path is we do not use O=.. builds 20# Do not use full path if we do not use O=.. builds
21# Use make O=. {tags|cscope}
22# to force full paths for a non-O= build
21if [ "${KBUILD_SRC}" = "" ]; then 23if [ "${KBUILD_SRC}" = "" ]; then
22 tree= 24 tree=
23else 25else
24 tree=${srctree}/ 26 tree=${srctree}/
25fi 27fi
26 28
29# Find all available archs
30find_all_archs()
31{
32 ALLSOURCE_ARCHS=""
33 for arch in `ls ${tree}arch`; do
34 ALLSOURCE_ARCHS="${ALLSOURCE_ARCHS} "${arch##\/}
35 done
36}
37
27# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH 38# Detect if ALLSOURCE_ARCHS is set. If not, we assume SRCARCH
28if [ "${ALLSOURCE_ARCHS}" = "" ]; then 39if [ "${ALLSOURCE_ARCHS}" = "" ]; then
29 ALLSOURCE_ARCHS=${SRCARCH} 40 ALLSOURCE_ARCHS=${SRCARCH}
41elif [ "${ALLSOURCE_ARCHS}" = "all" ]; then
42 find_all_archs
30fi 43fi
31 44
32# find sources in arch/$ARCH 45# find sources in arch/$ARCH
33find_arch_sources() 46find_arch_sources()
34{ 47{
35 find ${tree}arch/$1 $ignore -name "$2" -print; 48 for i in $archincludedir; do
49 prune="$prune -wholename $i -prune -o"
50 done
51 find ${tree}arch/$1 $ignore $prune -name "$2" -print;
36} 52}
37 53
38# find sources in arch/$1/include 54# find sources in arch/$1/include
39find_arch_include_sources() 55find_arch_include_sources()
40{ 56{
41 find ${tree}arch/$1/include $ignore -name "$2" -print; 57 include=$(find ${tree}arch/$1/ -name include -type d);
58 if [ -n "$include" ]; then
59 archincludedir="$archincludedir $include"
60 find $include $ignore -name "$2" -print;
61 fi
42} 62}
43 63
44# find sources in include/ 64# find sources in include/
@@ -63,14 +83,15 @@ find_sources()
63 83
64all_sources() 84all_sources()
65{ 85{
66 for arch in $ALLSOURCE_ARCHS 86 find_arch_include_sources ${SRCARCH} '*.[chS]'
67 do
68 find_sources $arch '*.[chS]'
69 done
70 if [ ! -z "$archinclude" ]; then 87 if [ ! -z "$archinclude" ]; then
71 find_arch_include_sources $archinclude '*.[chS]' 88 find_arch_include_sources $archinclude '*.[chS]'
72 fi 89 fi
73 find_include_sources '*.[chS]' 90 find_include_sources '*.[chS]'
91 for arch in $ALLSOURCE_ARCHS
92 do
93 find_sources $arch '*.[chS]'
94 done
74 find_other_sources '*.[chS]' 95 find_other_sources '*.[chS]'
75} 96}
76 97
@@ -89,13 +110,7 @@ all_defconfigs()
89 110
90docscope() 111docscope()
91{ 112{
92 # always use absolute paths for cscope, as recommended by cscope 113 (echo \-k; echo \-q; all_sources) > cscope.files
93 # upstream
94 case "$tree" in
95 /*) ;;
96 *) tree=$PWD/$tree ;;
97 esac
98 (cd /; echo \-k; echo \-q; all_sources) > cscope.files
99 cscope -b -f cscope.out 114 cscope -b -f cscope.out
100} 115}
101 116