summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build26
-rw-r--r--scripts/Makefile.lib6
-rw-r--r--scripts/Makefile.modinst2
-rw-r--r--scripts/Makefile.modpost1
-rw-r--r--scripts/basic/docproc.c44
-rw-r--r--scripts/decodecode17
-rw-r--r--scripts/gcc-version.sh5
-rw-r--r--scripts/genksyms/genksyms.c10
-rw-r--r--scripts/kconfig/Makefile39
-rw-r--r--scripts/kconfig/POTFILES.in7
-rw-r--r--scripts/kconfig/conf.c69
-rw-r--r--scripts/kconfig/confdata.c24
-rw-r--r--scripts/kconfig/expr.c32
-rw-r--r--scripts/kconfig/expr.h16
-rw-r--r--scripts/kconfig/gconf.c16
-rw-r--r--scripts/kconfig/lex.zconf.c_shipped5
-rw-r--r--scripts/kconfig/lkc.h5
-rw-r--r--scripts/kconfig/lxdialog/check-lxdialog.sh16
-rw-r--r--scripts/kconfig/lxdialog/checklist.c4
-rw-r--r--scripts/kconfig/lxdialog/dialog.h11
-rw-r--r--scripts/kconfig/lxdialog/inputbox.c4
-rw-r--r--scripts/kconfig/lxdialog/menubox.c6
-rw-r--r--scripts/kconfig/lxdialog/textbox.c2
-rw-r--r--scripts/kconfig/lxdialog/util.c32
-rw-r--r--scripts/kconfig/lxdialog/yesno.c4
-rw-r--r--scripts/kconfig/mconf.c112
-rw-r--r--scripts/kconfig/menu.c49
-rw-r--r--scripts/kconfig/qconf.cc109
-rw-r--r--scripts/kconfig/symbol.c79
-rw-r--r--scripts/kconfig/util.c23
-rw-r--r--scripts/kconfig/zconf.gperf2
-rw-r--r--scripts/kconfig/zconf.hash.c_shipped19
-rw-r--r--scripts/kconfig/zconf.l5
-rwxr-xr-xscripts/kernel-doc85
-rw-r--r--scripts/mkmakefile10
-rw-r--r--scripts/mod/modpost.c1210
-rw-r--r--scripts/mod/modpost.h2
-rw-r--r--scripts/package/Makefile5
-rw-r--r--scripts/package/buildtar4
-rwxr-xr-xscripts/patch-kernel22
-rw-r--r--scripts/setlocalversion29
41 files changed, 1319 insertions, 849 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index de9836eee8b..67fb4530a6f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -83,10 +83,12 @@ ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-) $(lib-target)),)
builtin-target := $(obj)/built-in.o
endif
+modorder-target := $(obj)/modules.order
+
# We keep a list of all modules in $(MODVERDIR)
__build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
- $(if $(KBUILD_MODULES),$(obj-m)) \
+ $(if $(KBUILD_MODULES),$(obj-m) $(modorder-target)) \
$(subdir-ym) $(always)
@:
@@ -101,6 +103,10 @@ ifneq ($(KBUILD_CHECKSRC),0)
endif
endif
+# Do section mismatch analysis for each module/built-in.o
+ifdef CONFIG_DEBUG_SECTION_MISMATCH
+ cmd_secanalysis = ; scripts/mod/modpost $@
+endif
# Compile C sources (.c)
# ---------------------------------------------------------------------------
@@ -266,7 +272,8 @@ ifdef builtin-target
quiet_cmd_link_o_target = LD $@
# If the list of objects to link is empty, just create an empty built-in.o
cmd_link_o_target = $(if $(strip $(obj-y)),\
- $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^),\
+ $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \
+ $(cmd_secanalysis),\
rm -f $@; $(AR) rcs $@)
$(builtin-target): $(obj-y) FORCE
@@ -276,6 +283,19 @@ targets += $(builtin-target)
endif # builtin-target
#
+# Rule to create modules.order file
+#
+# Create commands to either record .ko file or cat modules.order from
+# a subdirectory
+modorder-cmds = \
+ $(foreach m, $(modorder), \
+ $(if $(filter %/modules.order, $m), \
+ cat $m;, echo kernel/$m;))
+
+$(modorder-target): $(subdir-ym) FORCE
+ $(Q)(cat /dev/null; $(modorder-cmds)) > $@
+
+#
# Rule to compile a set of .o files into one .a file
#
ifdef lib-target
@@ -301,7 +321,7 @@ $($(subst $(obj)/,,$(@:.o=-objs))) \
$($(subst $(obj)/,,$(@:.o=-y)))), $^)
quiet_cmd_link_multi-y = LD $@
-cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps)
+cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
quiet_cmd_link_multi-m = LD [M] $@
cmd_link_multi-m = $(cmd_link_multi-y)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3c5e88bfecf..8e440233c27 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -25,6 +25,11 @@ lib-y := $(filter-out $(obj-y), $(sort $(lib-y) $(lib-m)))
# o if we encounter foo/ in $(obj-m), remove it from $(obj-m)
# and add the directory to the list of dirs to descend into: $(subdir-m)
+# Determine modorder.
+# Unfortunately, we don't have information about ordering between -y
+# and -m subdirs. Just put -y's first.
+modorder := $(patsubst %/,%/modules.order, $(filter %/, $(obj-y)) $(obj-m:.o=.ko))
+
__subdir-y := $(patsubst %/,%,$(filter %/, $(obj-y)))
subdir-y += $(__subdir-y)
__subdir-m := $(patsubst %/,%,$(filter %/, $(obj-m)))
@@ -64,6 +69,7 @@ real-objs-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)
extra-y := $(addprefix $(obj)/,$(extra-y))
always := $(addprefix $(obj)/,$(always))
targets := $(addprefix $(obj)/,$(targets))
+modorder := $(addprefix $(obj)/,$(modorder))
obj-y := $(addprefix $(obj)/,$(obj-y))
obj-m := $(addprefix $(obj)/,$(obj-m))
lib-y := $(addprefix $(obj)/,$(lib-y))
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst
index f0ff248f5e6..efa5d940e63 100644
--- a/scripts/Makefile.modinst
+++ b/scripts/Makefile.modinst
@@ -21,7 +21,7 @@ quiet_cmd_modules_install = INSTALL $@
# Modules built outside the kernel source tree go into extra by default
INSTALL_MOD_DIR ?= extra
-ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(KBUILD_EXTMOD),,$(@D))
+ext-mod-dir = $(INSTALL_MOD_DIR)$(subst $(patsubst %/,%,$(KBUILD_EXTMOD)),,$(@D))
modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D))
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index d988f5d21e3..65e707e1ffc 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -62,6 +62,7 @@ modpost = scripts/mod/modpost \
$(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \
$(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \
$(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \
+ $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
$(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index 0e4bd5459df..35bdc68b6e6 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -30,6 +30,7 @@
* !Ifilename
* !Dfilename
* !Ffilename
+ * !Pfilename
*
*/
@@ -57,6 +58,7 @@ FILEONLY *symbolsonly;
typedef void FILELINE(char * file, char * line);
FILELINE * singlefunctions;
FILELINE * entity_system;
+FILELINE * docsection;
#define MAXLINESZ 2048
#define MAXFILES 250
@@ -65,6 +67,7 @@ FILELINE * entity_system;
#define DOCBOOK "-docbook"
#define FUNCTION "-function"
#define NOFUNCTION "-nofunction"
+#define NODOCSECTIONS "-no-doc-sections"
char *srctree;
@@ -231,13 +234,14 @@ void docfunctions(char * filename, char * type)
for (i=0; i <= symfilecnt; i++)
symcnt += symfilelist[i].symbolcnt;
- vec = malloc((2 + 2 * symcnt + 2) * sizeof(char*));
+ vec = malloc((2 + 2 * symcnt + 3) * sizeof(char *));
if (vec == NULL) {
perror("docproc: ");
exit(1);
}
vec[idx++] = KERNELDOC;
vec[idx++] = DOCBOOK;
+ vec[idx++] = NODOCSECTIONS;
for (i=0; i < symfilecnt; i++) {
struct symfile * sym = &symfilelist[i];
for (j=0; j < sym->symbolcnt; j++) {
@@ -287,12 +291,36 @@ void singfunc(char * filename, char * line)
}
/*
+ * Insert specific documentation section from a file.
+ * Call kernel-doc with the following parameters:
+ * kernel-doc -docbook -function "doc section" filename
+ */
+void docsect(char *filename, char *line)
+{
+ char *vec[6]; /* kerneldoc -docbook -function "section" file NULL */
+ char *s;
+
+ for (s = line; *s; s++)
+ if (*s == '\n')
+ *s = '\0';
+
+ vec[0] = KERNELDOC;
+ vec[1] = DOCBOOK;
+ vec[2] = FUNCTION;
+ vec[3] = line;
+ vec[4] = filename;
+ vec[5] = NULL;
+ exec_kernel_doc(vec);
+}
+
+/*
* Parse file, calling action specific functions for:
* 1) Lines containing !E
* 2) Lines containing !I
* 3) Lines containing !D
* 4) Lines containing !F
- * 5) Default lines - lines not matching the above
+ * 5) Lines containing !P
+ * 6) Default lines - lines not matching the above
*/
void parse_file(FILE *infile)
{
@@ -326,6 +354,15 @@ void parse_file(FILE *infile)
s++;
singlefunctions(line +2, s);
break;
+ case 'P':
+ /* filename */
+ while (*s && !isspace(*s)) s++;
+ *s++ = '\0';
+ /* DOC: section name */
+ while (isspace(*s))
+ s++;
+ docsection(line + 2, s);
+ break;
default:
defaultline(line);
}
@@ -372,6 +409,7 @@ int main(int argc, char *argv[])
externalfunctions = find_export_symbols;
symbolsonly = find_export_symbols;
singlefunctions = noaction2;
+ docsection = noaction2;
parse_file(infile);
/* Rewind to start from beginning of file again */
@@ -381,6 +419,7 @@ int main(int argc, char *argv[])
externalfunctions = extfunc;
symbolsonly = printline;
singlefunctions = singfunc;
+ docsection = docsect;
parse_file(infile);
}
@@ -394,6 +433,7 @@ int main(int argc, char *argv[])
externalfunctions = adddep;
symbolsonly = adddep;
singlefunctions = adddep2;
+ docsection = adddep2;
parse_file(infile);
printf("\n");
}
diff --git a/scripts/decodecode b/scripts/decodecode
index 1e1a8f620c4..235d3938529 100644
--- a/scripts/decodecode
+++ b/scripts/decodecode
@@ -6,7 +6,19 @@
# e.g., to decode an i386 oops on an x86_64 system, use:
# AFLAGS=--32 decodecode < 386.oops
-T=`mktemp`
+cleanup() {
+ rm -f $T $T.s $T.o
+ exit 1
+}
+
+die() {
+ echo "$@"
+ exit 1
+}
+
+trap cleanup EXIT
+
+T=`mktemp` || die "cannot create temp file"
code=
while read i ; do
@@ -20,6 +32,7 @@ esac
done
if [ -z "$code" ]; then
+ rm $T
exit
fi
@@ -48,4 +61,4 @@ echo -n " .byte 0x" > $T.s
echo $code >> $T.s
as $AFLAGS -o $T.o $T.s
objdump -S $T.o
-rm $T.o $T.s
+rm $T $T.s $T.o
diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh
index a5121a6d894..cc767b388ba 100644
--- a/scripts/gcc-version.sh
+++ b/scripts/gcc-version.sh
@@ -9,7 +9,10 @@
# gcc-2.95.3, `030301' for gcc-3.3.1, etc.
#
-if [[ $1 = "-p" ]] ; then with_patchlevel=1; shift; fi
+if [ "$1" = "-p" ] ; then
+ with_patchlevel=1;
+ shift;
+fi
compiler="$*"
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index 511023b430a..dca5e0dd09b 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -440,17 +440,21 @@ void error_with_pos(const char *fmt, ...)
static void genksyms_usage(void)
{
- fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n"
+ fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n"
#ifdef __GNU_LIBRARY__
+ " -a, --arch Select architecture\n"
" -d, --debug Increment the debug level (repeatable)\n"
" -D, --dump Dump expanded symbol defs (for debugging only)\n"
+ " -T, --dump-types file Dump expanded types into file (for debugging only)\n"
" -w, --warnings Enable warnings\n"
" -q, --quiet Disable warnings (default)\n"
" -h, --help Print this message\n"
" -V, --version Print the release version\n"
#else /* __GNU_LIBRARY__ */
+ " -a Select architecture\n"
" -d Increment the debug level (repeatable)\n"
" -D Dump expanded symbol defs (for debugging only)\n"
+ " -T file Dump expanded types into file (for debugging only)\n"
" -w Enable warnings\n"
" -q Disable warnings (default)\n"
" -h Print this message\n"
@@ -477,10 +481,10 @@ int main(int argc, char **argv)
{0, 0, 0, 0}
};
- while ((o = getopt_long(argc, argv, "a:dwqVDT:k:p:",
+ while ((o = getopt_long(argc, argv, "a:dwqVDT:h",
&long_opts[0], NULL)) != EOF)
#else /* __GNU_LIBRARY__ */
- while ((o = getopt(argc, argv, "a:dwqVDT:k:p:")) != EOF)
+ while ((o = getopt(argc, argv, "a:dwqVDT:h")) != EOF)
#endif /* __GNU_LIBRARY__ */
switch (o) {
case 'a':
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile
index 1ad6f7fc490..32e8c5a227c 100644
--- a/scripts/kconfig/Makefile
+++ b/scripts/kconfig/Makefile
@@ -24,22 +24,25 @@ oldconfig: $(obj)/conf
silentoldconfig: $(obj)/conf
$< -s $(Kconfig)
-# Create new linux.po file
+# Create new linux.pot file
# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files
# The symlink is used to repair a deficiency in arch/um
-update-po-config: $(obj)/kxgettext
- xgettext --default-domain=linux \
+update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h
+ $(Q)echo " GEN config"
+ $(Q)xgettext --default-domain=linux \
--add-comments --keyword=_ --keyword=N_ \
--from-code=UTF-8 \
--files-from=scripts/kconfig/POTFILES.in \
--output $(obj)/config.pot
$(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot
$(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch
- (for i in `ls arch/`; \
- do \
- $(obj)/kxgettext arch/$$i/Kconfig; \
- done ) >> $(obj)/config.pot
- msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
+ $(Q)(for i in `ls arch/`; \
+ do \
+ echo " GEN $$i"; \
+ $(obj)/kxgettext arch/$$i/Kconfig \
+ >> $(obj)/config.pot; \
+ done )
+ $(Q)msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \
--output $(obj)/linux.pot
$(Q)rm -f arch/um/Kconfig.arch
$(Q)rm -f $(obj)/config.pot
@@ -93,12 +96,6 @@ HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC))
HOST_EXTRACFLAGS += -DLOCALE
-PHONY += $(obj)/dochecklxdialog
-$(obj)/dochecklxdialog:
- $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES)
-
-always := dochecklxdialog
-
# ===========================================================================
# Shared Makefile for the various kconfig executables:
@@ -142,8 +139,17 @@ gconf-objs := gconf.o kconfig_load.o zconf.tab.o
endif
clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \
- .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c
+ .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c gconf.glade.h
clean-files += mconf qconf gconf
+clean-files += config.pot linux.pot
+
+# Check that we have the required ncurses stuff installed for lxdialog (menuconfig)
+PHONY += $(obj)/dochecklxdialog
+$(addprefix $(obj)/,$(lxdialog)): $(obj)/dochecklxdialog
+$(obj)/dochecklxdialog:
+ $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_EXTRACFLAGS) $(HOST_LOADLIBES)
+
+always := dochecklxdialog
# Add environment specific flags
HOST_EXTRACFLAGS += $(shell $(CONFIG_SHELL) $(srctree)/$(src)/check.sh $(HOSTCC) $(HOSTCFLAGS))
@@ -248,6 +254,9 @@ $(obj)/%.moc: $(src)/%.h
$(obj)/lkc_defs.h: $(src)/lkc_proto.h
sed < $< > $@ 's/P(\([^,]*\),.*/#define \1 (\*\1_p)/'
+# Extract gconf menu items for I18N support
+$(obj)/gconf.glade.h: $(obj)/gconf.glade
+ intltool-extract --type=gettext/glade $(obj)/gconf.glade
###
# The following requires flex/bison/gperf
diff --git a/scripts/kconfig/POTFILES.in b/scripts/kconfig/POTFILES.in
index cc94e46a79e..96745739699 100644
--- a/scripts/kconfig/POTFILES.in
+++ b/scripts/kconfig/POTFILES.in
@@ -1,5 +1,12 @@
+scripts/kconfig/lxdialog/checklist.c
+scripts/kconfig/lxdialog/inputbox.c
+scripts/kconfig/lxdialog/menubox.c
+scripts/kconfig/lxdialog/textbox.c
+scripts/kconfig/lxdialog/util.c
+scripts/kconfig/lxdialog/yesno.c
scripts/kconfig/mconf.c
scripts/kconfig/conf.c
scripts/kconfig/confdata.c
scripts/kconfig/gconf.c
+scripts/kconfig/gconf.glade.h
scripts/kconfig/qconf.cc
diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c
index 8d6f17490c5..fda63136ae6 100644
--- a/scripts/kconfig/conf.c
+++ b/scripts/kconfig/conf.c
@@ -3,12 +3,13 @@
* Released under the terms of the GNU GPL v2.0.
*/
+#include <locale.h>
#include <ctype.h>
-#include <stdlib.h>
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
-#include <unistd.h>
#include <time.h>
+#include <unistd.h>
#include <sys/stat.h>
#define LKC_DIRECT_LINK
@@ -40,7 +41,7 @@ static char nohelp_text[] = N_("Sorry, no help available for this option yet.\n"
static const char *get_help(struct menu *menu)
{
if (menu_has_help(menu))
- return menu_get_help(menu);
+ return _(menu_get_help(menu));
else
return nohelp_text;
}
@@ -78,7 +79,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
tristate val;
if (!sym_has_value(sym))
- printf("(NEW) ");
+ printf(_("(NEW) "));
line[0] = '\n';
line[1] = 0;
@@ -160,7 +161,7 @@ static int conf_askvalue(struct symbol *sym, const char *def)
}
case set_random:
do {
- val = (tristate)(random() % 3);
+ val = (tristate)(rand() % 3);
} while (!sym_tristate_within_range(sym, val));
switch (val) {
case no: line[0] = 'n'; break;
@@ -183,7 +184,7 @@ int conf_string(struct menu *menu)
const char *def;
while (1) {
- printf("%*s%s ", indent - 1, "", menu->prompt->text);
+ printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
printf("(%s) ", sym->name);
def = sym_get_string_value(sym);
if (sym_get_string_value(sym))
@@ -216,7 +217,7 @@ static int conf_sym(struct menu *menu)
tristate oldval, newval;
while (1) {
- printf("%*s%s ", indent - 1, "", menu->prompt->text);
+ printf("%*s%s ", indent - 1, "", _(menu->prompt->text));
if (sym->name)
printf("(%s) ", sym->name);
type = sym_get_type(sym);
@@ -306,7 +307,7 @@ static int conf_choice(struct menu *menu)
case no:
return 1;
case mod:
- printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
+ printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
return 0;
case yes:
break;
@@ -316,7 +317,7 @@ static int conf_choice(struct menu *menu)
while (1) {
int cnt, def;
- printf("%*s%s\n", indent - 1, "", menu_get_prompt(menu));
+ printf("%*s%s\n", indent - 1, "", _(menu_get_prompt(menu)));
def_sym = sym_get_choice_value(sym);
cnt = def = 0;
line[0] = 0;
@@ -324,7 +325,7 @@ static int conf_choice(struct menu *menu)
if (!menu_is_visible(child))
continue;
if (!child->sym) {
- printf("%*c %s\n", indent, '*', menu_get_prompt(child));
+ printf("%*c %s\n", indent, '*', _(menu_get_prompt(child)));
continue;
}
cnt++;
@@ -333,14 +334,14 @@ static int conf_choice(struct menu *menu)
printf("%*c", indent, '>');
} else
printf("%*c", indent, ' ');
- printf(" %d. %s", cnt, menu_get_prompt(child));
+ printf(" %d. %s", cnt, _(menu_get_prompt(child)));
if (child->sym->name)
printf(" (%s)", child->sym->name);
if (!sym_has_value(child->sym))
- printf(" (NEW)");
+ printf(_(" (NEW)"));
printf("\n");
}
- printf("%*schoice", indent - 1, "");
+ printf(_("%*schoice"), indent - 1, "");
if (cnt == 1) {
printf("[1]: 1\n");
goto conf_childs;
@@ -375,7 +376,7 @@ static int conf_choice(struct menu *menu)
break;
case set_random:
if (is_new)
- def = (random() % cnt) + 1;
+ def = (rand() % cnt) + 1;
case set_default:
case set_yes:
case set_mod:
@@ -399,9 +400,9 @@ static int conf_choice(struct menu *menu)
continue;
}
sym_set_choice_value(sym, child->sym);
- if (child->list) {
+ for (child = child->list; child; child = child->next) {
indent += 2;
- conf(child->list);
+ conf(child);
indent -= 2;
}
return 1;
@@ -433,7 +434,7 @@ static void conf(struct menu *menu)
if (prompt)
printf("%*c\n%*c %s\n%*c\n",
indent, '*',
- indent, '*', prompt,
+ indent, '*', _(prompt),
indent, '*');
default:
;
@@ -495,12 +496,16 @@ static void check_conf(struct menu *menu)
int main(int ac, char **av)
{
- int i = 1;
+ int opt;
const char *name;
struct stat tmpstat;
- if (ac > i && av[i][0] == '-') {
- switch (av[i++][1]) {
+ setlocale(LC_ALL, "");
+ bindtextdomain(PACKAGE, LOCALEDIR);
+ textdomain(PACKAGE);
+
+ while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) {
+ switch (opt) {
case 'o':
input_mode = ask_new;
break;
@@ -513,12 +518,7 @@ int main(int ac, char **av)
break;
case 'D':
input_mode = set_default;
- defconfig_file = av[i++];
- if (!defconfig_file) {
- printf(_("%s: No default config file specified\n"),
- av[0]);
- exit(1);
- }
+ defconfig_file = optarg;
break;
case 'n':
input_mode = set_no;
@@ -531,19 +531,22 @@ int main(int ac, char **av)
break;
case 'r':
input_mode = set_random;
- srandom(time(NULL));
+ srand(time(NULL));
break;
case 'h':
- case '?':
- fprintf(stderr, "See README for usage info\n");
+ printf(_("See README for usage info\n"));
exit(0);
+ break;
+ default:
+ fprintf(stderr, _("See README for usage info\n"));
+ exit(1);
}
}
- name = av[i];
- if (!name) {
+ if (ac == optind) {
printf(_("%s: Kconfig file missing\n"), av[0]);
exit(1);
}
+ name = av[optind];
conf_parse(name);
//zconfdump(stdout);
switch (input_mode) {
@@ -551,9 +554,9 @@ int main(int ac, char **av)
if (!defconfig_file)
defconfig_file = conf_get_default_confname();
if (conf_read(defconfig_file)) {
- printf("***\n"
+ printf(_("***\n"
"*** Can't find default configuration \"%s\"!\n"
- "***\n", defconfig_file);
+ "***\n"), defconfig_file);
exit(1);
}
break;
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c
index e0f402f3b75..ee5fe943d58 100644
--- a/scripts/kconfig/confdata.c
+++ b/scripts/kconfig/confdata.c
@@ -232,8 +232,7 @@ load:
sym->type = S_BOOLEAN;
}
if (sym->flags & def_flags) {
- conf_warning("trying to reassign symbol %s", sym->name);
- break;
+ conf_warning("override: reassigning to symbol %s", sym->name);
}
switch (sym->type) {
case S_BOOLEAN:
@@ -272,8 +271,7 @@ load:
sym->type = S_OTHER;
}
if (sym->flags & def_flags) {
- conf_warning("trying to reassign symbol %s", sym->name);
- break;
+ conf_warning("override: reassigning to symbol %s", sym->name);
}
if (conf_set_sym_val(sym, def, def_flags, p))
continue;
@@ -297,14 +295,12 @@ load:
}
break;
case yes:
- if (cs->def[def].tri != no) {
- conf_warning("%s creates inconsistent choice state", sym->name);
- cs->flags &= ~def_flags;
- } else
- cs->def[def].val = sym;
+ if (cs->def[def].tri != no)
+ conf_warning("override: %s changes choice state", sym->name);
+ cs->def[def].val = sym;
break;
}
- cs->def[def].tri = E_OR(cs->def[def].tri, sym->def[def].tri);
+ cs->def[def].tri = EXPR_OR(cs->def[def].tri, sym->def[def].tri);
}
}
fclose(in);
@@ -316,7 +312,7 @@ load:
int conf_read(const char *name)
{
- struct symbol *sym;
+ struct symbol *sym, *choice_sym;
struct property *prop;
struct expr *e;
int i, flags;
@@ -357,9 +353,9 @@ int conf_read(const char *name)
*/
prop = sym_get_choice_prop(sym);
flags = sym->flags;
- for (e = prop->expr; e; e = e->left.expr)
- if (e->right.sym->visible != no)
- flags &= e->right.sym->flags;
+ expr_list_for_each_sym(prop->expr, e, choice_sym)
+ if (choice_sym->visible != no)
+ flags &= choice_sym->flags;
sym->flags &= flags | ~SYMBOL_DEF_USER;
}
diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c
index 6f98dbfe70c..579ece4fa58 100644
--- a/scripts/kconfig/expr.c
+++ b/scripts/kconfig/expr.c
@@ -87,7 +87,7 @@ struct expr *expr_copy(struct expr *org)
break;
case E_AND:
case E_OR:
- case E_CHOICE:
+ case E_LIST:
e->left.expr = expr_copy(org->left.expr);
e->right.expr = expr_copy(org->right.expr);
break;
@@ -217,7 +217,7 @@ int expr_eq(struct expr *e1, struct expr *e2)
expr_free(e2);
trans_count = old_count;
return res;
- case E_CHOICE:
+ case E_LIST:
case E_RANGE:
case E_NONE:
/* panic */;
@@ -648,7 +648,7 @@ struct expr *expr_transform(struct expr *e)
case E_EQUAL:
case E_UNEQUAL:
case E_SYMBOL:
- case E_CHOICE:
+ case E_LIST:
break;
default:
e->left.expr = expr_transform(e->left.expr);
@@ -932,7 +932,7 @@ struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symb
break;
case E_SYMBOL:
return expr_alloc_comp(type, e->left.sym, sym);
- case E_CHOICE:
+ case E_LIST:
case E_RANGE:
case E_NONE:
/* panic */;
@@ -955,14 +955,14 @@ tristate expr_calc_value(struct expr *e)
case E_AND:
val1 = expr_calc_value(e->left.expr);
val2 = expr_calc_value(e->right.expr);
- return E_AND(val1, val2);
+ return EXPR_AND(val1, val2);
case E_OR:
val1 = expr_calc_value(e->left.expr);
val2 = expr_calc_value(e->right.expr);
- return E_OR(val1, val2);
+ return EXPR_OR(val1, val2);
case E_NOT:
val1 = expr_calc_value(e->left.expr);
- return E_NOT(val1);
+ return EXPR_NOT(val1);
case E_EQUAL:
sym_calc_value(e->left.sym);
sym_calc_value(e->right.sym);
@@ -1000,9 +1000,9 @@ int expr_compare_type(enum expr_type t1, enum expr_type t2)
if (t2 == E_OR)
return 1;
case E_OR:
- if (t2 == E_CHOICE)
+ if (t2 == E_LIST)
return 1;
- case E_CHOICE:
+ case E_LIST:
if (t2 == 0)
return 1;
default:
@@ -1034,12 +1034,18 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
expr_print(e->left.expr, fn, data, E_NOT);
break;
case E_EQUAL:
- fn(data, e->left.sym, e->left.sym->name);
+ if (e->left.sym->name)
+ fn(data, e->left.sym, e->left.sym->name);
+ else
+ fn(data, NULL, "<choice>");
fn(data, NULL, "=");
fn(data, e->right.sym, e->right.sym->name);
break;
case E_UNEQUAL:
- fn(data, e->left.sym, e->left.sym->name);
+ if (e->left.sym->name)
+ fn(data, e->left.sym, e->left.sym->name);
+ else
+ fn(data, NULL, "<choice>");
fn(data, NULL, "!=");
fn(data, e->right.sym, e->right.sym->name);
break;
@@ -1053,11 +1059,11 @@ void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *
fn(data, NULL, " && ");
expr_print(e->right.expr, fn, data, E_AND);
break;
- case E_CHOICE:
+ case E_LIST:
fn(data, e->right.sym, e->right.sym->name);
if (e->left.expr) {
fn(data, NULL, " ^ ");
- expr_print(e->left.expr, fn, data, E_CHOICE);
+ expr_print(e->left.expr, fn, data, E_LIST);
}
break;
case E_RANGE:
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h
index a195986eec6..9d4cba1c001 100644
--- a/scripts/kconfig/expr.h
+++ b/scripts/kconfig/expr.h
@@ -25,14 +25,13 @@ struct file {
#define FILE_BUSY 0x0001
#define FILE_SCANNED 0x0002
-#define FILE_PRINTED 0x0004
typedef enum tristate {
no, mod, yes
} tristate;
enum expr_type {
- E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_CHOICE, E_SYMBOL, E_RANGE
+ E_NONE, E_OR, E_AND, E_NOT, E_EQUAL, E_UNEQUAL, E_LIST, E_SYMBOL, E_RANGE
};
union expr_data {
@@ -45,9 +44,12 @@ struct expr {
union expr_data left, right;
};
-#define E_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2))
-#define E_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2))
-#define E_NOT(dep) (2-(dep))
+#define EXPR_OR(dep1, dep2) (((dep1)>(dep2))?(dep1):(dep2))
+#define EXPR_AND(dep1, dep2) (((dep1)<(dep2))?(dep1):(dep2))
+#define EXPR_NOT(dep) (2-(dep))
+
+#define expr_list_for_each_sym(l, e, s) \
+ for (e = (l); e && (s = e->right.sym); e = e->left.expr)
struct expr_value {
struct expr *expr;
@@ -86,7 +88,6 @@ struct symbol {
#define SYMBOL_CHECK 0x0008
#define SYMBOL_CHOICE 0x0010
#define SYMBOL_CHOICEVAL 0x0020
-#define SYMBOL_PRINTED 0x0040
#define SYMBOL_VALID 0x0080
#define SYMBOL_OPTIONAL 0x0100
#define SYMBOL_WRITE 0x0200
@@ -105,7 +106,8 @@ struct symbol {
#define SYMBOL_HASHMASK 0xff
enum prop_type {
- P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, P_SELECT, P_RANGE
+ P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE,
+ P_SELECT, P_RANGE, P_ENV
};
struct property {
diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c
index 262908cfc2a..199b22bb49e 100644
--- a/scripts/kconfig/gconf.c
+++ b/scripts/kconfig/gconf.c
@@ -119,8 +119,6 @@ const char *dbg_print_flags(int val)
strcat(buf, "choice/");
if (val & SYMBOL_CHOICEVAL)
strcat(buf, "choiceval/");
- if (val & SYMBOL_PRINTED)
- strcat(buf, "printed/");
if (val & SYMBOL_VALID)
strcat(buf, "valid/");
if (val & SYMBOL_OPTIONAL)
@@ -457,14 +455,18 @@ static void text_insert_help(struct menu *menu)
{
GtkTextBuffer *buffer;
GtkTextIter start, end;
- const char *prompt = menu_get_prompt(menu);
+ const char *prompt = _(menu_get_prompt(menu));
gchar *name;
const char *help;
- help = _(menu_get_help(menu));
+ help = menu_get_help(menu);
+
+ /* Gettextize if the help text not empty */
+ if ((help != 0) && (help[0] != 0))
+ help = _(help);
if (menu->sym && menu->sym->name)
- name = g_strdup_printf(_(menu->sym->name));
+ name = g_strdup_printf(menu->sym->name);
else
name = g_strdup("");
@@ -1171,7 +1173,7 @@ static gchar **fill_row(struct menu *menu)
bzero(row, sizeof(row));
row[COL_OPTION] =
- g_strdup_printf("%s %s", menu_get_prompt(menu),
+ g_strdup_printf("%s %s", _(menu_get_prompt(menu)),
sym && sym_has_value(sym) ? "(NEW)" : "");
if (show_all && !menu_is_visible(menu))
@@ -1221,7 +1223,7 @@ static gchar **fill_row(struct menu *menu)
if (def_menu)
row[COL_VALUE] =
- g_strdup(menu_get_prompt(def_menu));
+ g_strdup(_(menu_get_prompt(def_menu)));
}
if (sym->flags & SYMBOL_CHOICEVAL)
row[COL_BTNRAD] = GINT_TO_POINTER(TRUE);
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped
index a065d5a57c0..bed0f4e2d2f 100644
--- a/scripts/kconfig/lex.zconf.c_shipped
+++ b/scripts/kconfig/lex.zconf.c_shipped
@@ -1275,6 +1275,11 @@ YY_RULE_SETUP
case 32:
YY_RULE_SETUP
{
+ while (zconfleng) {
+ if ((zconftext[zconfleng-1] != ' ') && (zconftext[zconfleng-1] != '\t'))
+ break;
+ zconfleng--;
+ }
append_string(zconftext, zconfleng);
if (!first_ts)
first_ts = last_ts;
diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h
index 8a07ee4f6bd..4bc68f20a73 100644
--- a/scripts/kconfig/lkc.h
+++ b/scripts/kconfig/lkc.h
@@ -44,6 +44,7 @@ extern "C" {
#define T_OPT_MODULES 1
#define T_OPT_DEFCONFIG_LIST 2
+#define T_OPT_ENV 3
struct kconf_id {
int name;
@@ -74,6 +75,7 @@ void kconfig_load(void);
/* menu.c */
void menu_init(void);
+void menu_warn(struct menu *menu, const char *fmt, ...);
struct menu *menu_add_menu(void);
void menu_end_menu(void);
void menu_add_entry(struct symbol *sym);
@@ -103,6 +105,8 @@ void str_printf(struct gstr *gs, const char *fmt, ...);
const char *str_get(struct gstr *gs);
/* symbol.c */
+extern struct expr *sym_env_list;
+
void sym_init(void);
void sym_clear_all_valid(void);
void sym_set_all_changed(void);
@@ -110,6 +114,7 @@ void sym_set_changed(struct symbol *sym);
struct symbol *sym_check_deps(struct symbol *sym);
struct property *prop_alloc(enum prop_type type, struct symbol *sym);
struct symbol *prop_get_symbol(struct property *prop);
+struct property *sym_get_env_prop(struct symbol *sym);
static inline tristate sym_get_tristate_value(struct symbol *sym)
{
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh
index 9681476b96e..62e1e02126e 100644
--- a/scripts/kconfig/lxdialog/check-lxdialog.sh
+++ b/scripts/kconfig/lxdialog/check-lxdialog.sh
@@ -36,14 +36,16 @@ trap "rm -f $tmp" 0 1 2 3 15
# Check if we can link to ncurses
check() {
- echo "main() {}" | $cc -xc - -o $tmp 2> /dev/null
+ echo -e " #include CURSES_LOC \n main() {}" |
+ $cc -xc - -o $tmp 2> /dev/null
if [ $? != 0 ]; then
- echo " *** Unable to find the ncurses libraries." 1>&2
- echo " *** make menuconfig require the ncurses libraries" 1>&2
- echo " *** " 1>&2
- echo " *** Install ncurses (ncurses-devel) and try again" 1>&2
- echo " *** " 1>&2
- exit 1
+ echo " *** Unable to find the ncurses libraries or the" 1>&2
+ echo " *** required header files." 1>&2
+ echo " *** 'make menuconfig' requires the ncurses libraries." 1>&2
+ echo " *** " 1>&2
+ echo " *** Install ncurses (ncurses-devel) and try again." 1>&2
+ echo " *** " 1>&2
+ exit 1
fi
}
diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c
index cf697080ddd..b2a878c936d 100644
--- a/scripts/kconfig/lxdialog/checklist.c
+++ b/scripts/kconfig/lxdialog/checklist.c
@@ -97,8 +97,8 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
int x = width / 2 - 11;
int y = height - 2;
- print_button(dialog, "Select", y, x, selected == 0);
- print_button(dialog, " Help ", y, x + 14, selected == 1);
+ print_button(dialog, gettext("Select"), y, x, selected == 0);
+ print_button(dialog, gettext(" Help "), y, x + 14, selected == 1);
wmove(dialog, y, x + 1 + 14 * selected);
wrefresh(dialog);
diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h
index 7e17eba75ae..b5211fce0d9 100644
--- a/scripts/kconfig/lxdialog/dialog.h
+++ b/scripts/kconfig/lxdialog/dialog.h
@@ -26,6 +26,12 @@
#include <string.h>
#include <stdbool.h>
+#ifndef KBUILD_NO_NLS
+# include <libintl.h>
+#else
+# define gettext(Msgid) ((const char *) (Msgid))
+#endif
+
#ifdef __sun__
#define CURS_MACROS
#endif
@@ -187,10 +193,9 @@ int item_is_tag(char tag);
int on_key_esc(WINDOW *win);
int on_key_resize(void);
-void init_dialog(const char *backtitle);
+int init_dialog(const char *backtitle);
void set_dialog_backtitle(const char *backtitle);
-void reset_dialog(void);
-void end_dialog(void);
+void end_dialog(int x, int y);
void attr_clear(WINDOW * win, int height, int width, chtype attr);
void dialog_clear(void);
void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x);
diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c
index 05e72066b35..4946bd02b46 100644
--- a/scripts/kconfig/lxdialog/inputbox.c
+++ b/scripts/kconfig/lxdialog/inputbox.c
@@ -31,8 +31,8 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
int x = width / 2 - 11;
int y = height - 2;
- print_button(dialog, " Ok ", y, x, selected == 0);
- print_button(dialog, " Help ", y, x + 14, selected == 1);
+ print_button(dialog, gettext(" Ok "), y, x, selected == 0);
+ print_button(dialog, gettext(" Help "), y, x + 14, selected == 1);
wmove(dialog, y, x + 1 + 14 * selected);
wrefresh(dialog);
diff --git a/scripts/kconfig/lxdialog/menubox.c b/scripts/kconfig/lxdialog/menubox.c
index 0d83159d901..fa9d633f293 100644
--- a/scripts/kconfig/lxdialog/menubox.c
+++ b/scripts/kconfig/lxdialog/menubox.c
@@ -157,9 +157,9 @@ static void print_buttons(WINDOW * win, int height, int width, int selected)
int x = width / 2 - 16;
int y = height - 2;
- print_button(win, "Select", y, x, selected == 0);
- print_button(win, " Exit ", y, x + 12, selected == 1);
- print_button(win, " Help ", y, x + 24, selected == 2);
+ print_button(win, gettext("Select"), y, x, selected == 0);
+ print_button(win, gettext(" Exit "), y, x + 12, selected == 1);
+ print_button(win, gettext(" Help "), y, x + 24, selected == 2);
wmove(win, y, x + 1 + 12 * selected);
wrefresh(win);
diff --git a/scripts/kconfig/lxdialog/textbox.c b/scripts/kconfig/lxdialog/textbox.c
index fabfc1ad789..c704712d022 100644
--- a/scripts/kconfig/lxdialog/textbox.c
+++ b/scripts/kconfig/lxdialog/textbox.c
@@ -114,7 +114,7 @@ do_resize:
print_title(dialog, title, width);
- print_button(dialog, " Exit ", height - 2, width / 2 - 4, TRUE);
+ print_button(dialog, gettext(" Exit "), height - 2, width / 2 - 4, TRUE);
wnoutrefresh(dialog);
getyx(dialog, cur_y, cur_x); /* Save cursor position */
diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c
index a1bddefe73d..86d95cca46a 100644
--- a/scripts/kconfig/lxdialog/util.c
+++ b/scripts/kconfig/lxdialog/util.c
@@ -266,31 +266,41 @@ void dialog_clear(void)
/*
* Do some initialization for dialog
*/
-void init_dialog(const char *backtitle)
+int init_dialog(const char *backtitle)
{
- dlg.backtitle = backtitle;
- color_setup(getenv("MENUCONFIG_COLOR"));
-}
+ int height, width;
+
+ initscr(); /* Init curses */
+ getmaxyx(stdscr, height, width);
+ if (height < 19 || width < 80) {
+ endwin();
+ return -ERRDISPLAYTOOSMALL;
+ }
-void set_dialog_backtitle(const char *backtitle)
-{
dlg.backtitle = backtitle;
-}
+ color_setup(getenv("MENUCONFIG_COLOR"));
-void reset_dialog(void)
-{
- initscr(); /* Init curses */
keypad(stdscr, TRUE);
cbreak();
noecho();
dialog_clear();
+
+ return 0;
+}
+
+void set_dialog_backtitle(const char *backtitle)
+{
+ dlg.backtitle = backtitle;
}
/*
* End using dialog functions.
*/
-void end_dialog(void)
+void end_dialog(int x, int y)
{
+ /* move cursor back to original position */
+ move(y, x);
+ refresh();
endwin();
}
diff --git a/scripts/kconfig/lxdialog/yesno.c b/scripts/kconfig/lxdialog/yesno.c
index ee0a04e3e01..4e6e8090c20 100644
--- a/scripts/kconfig/lxdialog/yesno.c
+++ b/scripts/kconfig/lxdialog/yesno.c
@@ -29,8 +29,8 @@ static void print_buttons(WINDOW * dialog, int height, int width, int selected)
int x = width / 2 - 10;
int y = height - 2;
- print_button(dialog, " Yes ", y, x, selected == 0);
- print_button(dialog, " No ", y, x + 13, selected == 1);
+ print_button(dialog, gettext(" Yes "), y, x, selected == 0);
+ print_button(dialog, gettext(" No "), y, x + 13, selected == 1);
wmove(dialog, y, x + 1 + 13 * selected);
wrefresh(dialog);
diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c
index 47e226fdedd..50e61c411bc 100644
--- a/scripts/kconfig/mconf.c
+++ b/scripts/kconfig/mconf.c
@@ -8,17 +8,13 @@
* i18n, 2005, Arnaldo Carvalho de Melo <acme@conectiva.com.br>
*/
-#include <sys/ioctl.h>
-#include <sys/wait.h>
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
-#include <signal.h>
#include <stdarg.h>
#include <stdlib.h>
#include <string.h>
-#include <termios.h>
#include <unistd.h>
#include <locale.h>
@@ -275,8 +271,6 @@ search_help[] = N_(
"\n");
static int indent;
-static struct termios ios_org;
-static int rows = 0, cols = 0;
static struct menu *current_menu;
static int child_count;
static int single_menu_mode;
@@ -290,51 +284,16 @@ static void show_textbox(const char *title, const char *text, int r, int c);
static void show_helptext(const char *title, const char *text);
static void show_help(struct menu *menu);
-static void init_wsize(void)
-{
- struct winsize ws;
- char *env;
-
- if (!ioctl(STDIN_FILENO, TIOCGWINSZ, &ws)) {
- rows = ws.ws_row;
- cols = ws.ws_col;
- }
-
- if (!rows) {
- env = getenv("LINES");
- if (env)
- rows = atoi(env);
- if (!rows)
- rows = 24;
- }
- if (!cols) {
- env = getenv("COLUMNS");
- if (env)
- cols = atoi(env);
- if (!cols)
- cols = 80;
- }
-
- if (rows < 19 || cols < 80) {
- fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
- fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
- exit(1);
- }
-
- rows -= 4;
- cols -= 5;
-}
-
static void get_prompt_str(struct gstr *r, struct property *prop)
{
int i, j;
struct menu *submenu[8], *menu;
- str_printf(r, "Prompt: %s\n", prop->text);
- str_printf(r, " Defined at %s:%d\n", prop->menu->file->name,
+ str_printf(r, _("Prompt: %s\n"), _(prop->text));
+ str_printf(r, _(" Defined at %s:%d\n"), prop->menu->file->name,
prop->menu->lineno);
if (!expr_is_yes(prop->visible.expr)) {
- str_append(r, " Depends on: ");
+ str_append(r, _(" Depends on: "));
expr_gstr_print(prop->visible.expr, r);
str_append(r, "\n");
}
@@ -342,13 +301,13 @@ static void get_prompt_str(struct gstr *r, struct property *prop)
for (i = 0; menu != &rootmenu && i < 8; menu = menu->parent)
submenu[i++] = menu;
if (i > 0) {
- str_printf(r, " Location:\n");
+ str_printf(r, _(" Location:\n"));
for (j = 4; --i >= 0; j += 2) {
menu = submenu[i];
- str_printf(r, "%*c-> %s", j, ' ', menu_get_prompt(menu));
+ str_printf(r, "%*c-> %s", j, ' ', _(menu_get_prompt(menu)));
if (menu->sym) {
str_printf(r, " (%s [=%s])", menu->sym->name ?
- menu->sym->name : "<choice>",
+ menu->sym->name : _("<choice>"),
sym_get_string_value(menu->sym));
}
str_append(r, "\n");
@@ -378,7 +337,7 @@ static void get_symbol_str(struct gstr *r, struct symbol *sym)
if (hit)
str_append(r, "\n");
if (sym->rev_dep.expr) {
- str_append(r, " Selected by: ");
+ str_append(r, _(" Selected by: "));
expr_gstr_print(sym->rev_dep.expr, r);
str_append(r, "\n");
}
@@ -394,7 +353,7 @@ static struct gstr get_relations_str(struct symbol **sym_arr)
for (i = 0; sym_arr && (sym = sym_arr[i]); i++)
get_symbol_str(&res, sym);
if (!i)
- str_append(&res, "No matches found.\n");
+ str_append(&res, _("No matches found.\n"));
return res;
}
@@ -474,6 +433,7 @@ static void build_conf(struct menu *menu)
switch (prop->type) {
case P_MENU:
child_count++;
+ prompt = _(prompt);
if (single_menu_mode) {
item_make("%s%*c%s",
menu->data ? "-->" : "++>",
@@ -489,7 +449,7 @@ static void build_conf(struct menu *menu)
case P_COMMENT:
if (prompt) {
child_count++;
- item_make(" %*c*** %s ***", indent + 1, ' ', prompt);
+ item_make(" %*c*** %s ***", indent + 1, ' ', _(prompt));
item_set_tag(':');
item_set_data(menu);
}
@@ -497,7 +457,7 @@ static void build_conf(struct menu *menu)
default:
if (prompt) {
child_count++;
- item_make("---%*c%s", indent + 1, ' ', prompt);
+ item_make("---%*c%s", indent + 1, ' ', _(prompt));
item_set_tag(':');
item_set_data(menu);
}
@@ -541,10 +501,10 @@ static void build_conf(struct menu *menu)
item_set_data(menu);
}
- item_add_str("%*c%s", indent + 1, ' ', menu_get_prompt(menu));
+ item_add_str("%*c%s", indent + 1, ' ', _(menu_get_prompt(menu)));
if (val == yes) {
if (def_menu) {
- item_add_str(" (%s)", menu_get_prompt(def_menu));
+ item_add_str(" (%s)", _(menu_get_prompt(def_menu)));
item_add_str(" --->");
if (def_menu->list) {
indent += 2;
@@ -556,7 +516,7 @@ static void build_conf(struct menu *menu)
}
} else {
if (menu == current_menu) {
- item_make("---%*c%s", indent + 1, ' ', menu_get_prompt(menu));
+ item_make("---%*c%s", indent + 1, ' ', _(menu_get_prompt(menu)));
item_set_tag(':');
item_set_data(menu);
goto conf_childs;
@@ -599,17 +559,17 @@ static void build_conf(struct menu *menu)
tmp = indent - tmp + 4;
if (tmp < 0)
tmp = 0;
- item_add_str("%*c%s%s", tmp, ' ', menu_get_prompt(menu),
+ item_add_str("%*c%s%s", tmp, ' ', _(menu_get_prompt(menu)),
(sym_has_value(sym) || !sym_is_changable(sym)) ?
- "" : " (NEW)");
+ "" : _(" (NEW)"));
item_set_tag('s');
item_set_data(menu);
goto conf_childs;
}
}
- item_add_str("%*c%s%s", indent + 1, ' ', menu_get_prompt(menu),
+ item_add_str("%*c%s%s", indent + 1, ' ', _(menu_get_prompt(menu)),
(sym_has_value(sym) || !sym_is_changable(sym)) ?
- "" : " (NEW)");
+ "" : _(" (NEW)"));
if (menu->prompt->type == P_MENU) {
item_add_str(" --->");
return;
@@ -647,7 +607,7 @@ static void conf(struct menu *menu)
item_set_tag('S');
}
dialog_clear();
- res = dialog_menu(prompt ? prompt : _("Main Menu"),
+ res = dialog_menu(prompt ? _(prompt) : _("Main Menu"),
_(menu_instructions),
active_menu, &s_scroll);
if (res == 1 || res == KEY_ESC || res == -ERRDISPLAYTOOSMALL)
@@ -694,7 +654,7 @@ static void conf(struct menu *menu)
if (sym)
show_help(submenu);
else
- show_helptext("README", _(mconf_readme));
+ show_helptext(_("README"), _(mconf_readme));
break;
case 3:
if (item_is_tag('t')) {
@@ -752,13 +712,13 @@ static void show_help(struct menu *menu)
str_append(&help, nohelp_text);
}
get_symbol_str(&help, sym);
- show_helptext(menu_get_prompt(menu), str_get(&help));
+ show_helptext(_(menu_get_prompt(menu)), str_get(&help));
str_free(&help);
}
static void conf_choice(struct menu *menu)
{
- const char *prompt = menu_get_prompt(menu);
+ const char *prompt = _(menu_get_prompt(menu));
struct menu *child;
struct symbol *active;
@@ -772,7 +732,7 @@ static void conf_choice(struct menu *menu)
for (child = menu->list; child; child = child->next) {
if (!menu_is_visible(child))
continue;
- item_make("%s", menu_get_prompt(child));
+ item_make("%s", _(menu_get_prompt(child)));
item_set_data(child);
if (child->sym == active)
item_set_selected(1);
@@ -780,7 +740,7 @@ static void conf_choice(struct menu *menu)
item_set_tag('X');
}
dialog_clear();
- res = dialog_checklist(prompt ? prompt : _("Main Menu"),
+ res = dialog_checklist(prompt ? _(prompt) : _("Main Menu"),
_(radiolist_instructions),
15, 70, 6);
selected = item_activate_selected();
@@ -826,10 +786,10 @@ static void conf_string(struct menu *menu)
heading = _(inputbox_instructions_string);
break;
default:
- heading = "Internal mconf error!";
+ heading = _("Internal mconf error!");
}
dialog_clear();
- res = dialog_inputbox(prompt ? prompt : _("Main Menu"),
+ res = dialog_inputbox(prompt ? _(prompt) : _("Main Menu"),
heading, 10, 75,
sym_get_string_value(menu->sym));
switch (res) {
@@ -900,13 +860,9 @@ static void conf_save(void)
}
}
-static void conf_cleanup(void)
-{
- tcsetattr(1, TCSAFLUSH, &ios_org);
-}
-
int main(int ac, char **av)
{
+ int saved_x, saved_y;
char *mode;
int res;
@@ -923,11 +879,13 @@ int main(int ac, char **av)
single_menu_mode = 1;
}
- tcgetattr(1, &ios_org);
- atexit(conf_cleanup);
- init_wsize();
- reset_dialog();
- init_dialog(NULL);
+ getyx(stdscr, saved_y, saved_x);
+ if (init_dialog(NULL)) {
+ fprintf(stderr, N_("Your display is too small to run Menuconfig!\n"));
+ fprintf(stderr, N_("It must be at least 19 lines by 80 columns.\n"));
+ return 1;
+ }
+
set_config_filename(conf_get_configname());
do {
conf(&rootmenu);
@@ -941,7 +899,7 @@ int main(int ac, char **av)
else
res = -1;
} while (res == KEY_ESC);
- end_dialog();
+ end_dialog(saved_x, saved_y);
switch (res) {
case 0:
diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c
index f9d0d91a3fe..fdad17367f6 100644
--- a/scripts/kconfig/menu.c
+++ b/scripts/kconfig/menu.c
@@ -15,7 +15,7 @@ static struct menu **last_entry_ptr;
struct file *file_list;
struct file *current_file;
-static void menu_warn(struct menu *menu, const char *fmt, ...)
+void menu_warn(struct menu *menu, const char *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -172,6 +172,9 @@ void menu_add_option(int token, char *arg)
else if (sym_defconfig_list != current_entry->sym)
zconf_error("trying to redefine defconfig symbol");
break;
+ case T_OPT_ENV:
+ prop_add_env(arg);
+ break;
}
}
@@ -239,9 +242,11 @@ void menu_finalize(struct menu *parent)
for (menu = parent->list; menu; menu = menu->next) {
if (menu->sym) {
current_entry = parent;
- menu_set_type(menu->sym->type);
+ if (sym->type == S_UNKNOWN)
+ menu_set_type(menu->sym->type);
current_entry = menu;
- menu_set_type(sym->type);
+ if (menu->sym->type == S_UNKNOWN)
+ menu_set_type(sym->type);
break;
}
}
@@ -326,12 +331,42 @@ void menu_finalize(struct menu *parent)
"values not supported");
}
current_entry = menu;
- menu_set_type(sym->type);
+ if (menu->sym->type == S_UNKNOWN)
+ menu_set_type(sym->type);
+ /* Non-tristate choice values of tristate choices must
+ * depend on the choice being set to Y. The choice
+ * values' dependencies were propagated to their
+ * properties above, so the change here must be re-
+ * propagated. */
+ if (sym->type == S_TRISTATE && menu->sym->type != S_TRISTATE) {
+ basedep = expr_alloc_comp(E_EQUAL, sym, &symbol_yes);
+ basedep = expr_alloc_and(basedep, menu->dep);
+ basedep = expr_eliminate_dups(basedep);
+ menu->dep = basedep;
+ for (prop = menu->sym->prop; prop; prop = prop->next) {
+ if (prop->menu != menu)
+ continue;
+ dep = expr_alloc_and(expr_copy(basedep),
+ prop->visible.expr);
+ dep = expr_eliminate_dups(dep);
+ dep = expr_trans_bool(dep);
+ prop->visible.expr = dep;
+ if (prop->type == P_SELECT) {
+ struct symbol *es = prop_get_symbol(prop);
+ dep2 = expr_alloc_symbol(menu->sym);
+ dep = expr_alloc_and(dep2,
+ expr_copy(dep));
+ dep = expr_alloc_or(es->rev_dep.expr, dep);
+ dep = expr_eliminate_dups(dep);
+ es->rev_dep.expr = dep;
+ }
+ }
+ }
menu_add_symbol(P_CHOICE, sym, NULL);
prop = sym_get_choice_prop(sym);
for (ep = &prop->expr; *ep; ep = &(*ep)->left.expr)
;
- *ep = expr_alloc_one(E_CHOICE, NULL);
+ *ep = expr_alloc_one(E_LIST, NULL);
(*ep)->right.sym = menu->sym;
}
if (menu->list && (!menu->prompt || !menu->prompt->text)) {
@@ -394,9 +429,9 @@ bool menu_is_visible(struct menu *menu)
const char *menu_get_prompt(struct menu *menu)
{
if (menu->prompt)
- return _(menu->prompt->text);
+ return menu->prompt->text;
else if (menu->sym)
- return _(menu->sym->name);
+ return menu->sym->name;
return NULL;
}
diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc
index b9bb32dfd62..5d0fd38b089 100644
--- a/scripts/kconfig/qconf.cc
+++ b/scripts/kconfig/qconf.cc
@@ -114,7 +114,7 @@ void ConfigItem::updateMenu(void)
sym = menu->sym;
prop = menu->prompt;
- prompt = QString::fromLocal8Bit(menu_get_prompt(menu));
+ prompt = _(menu_get_prompt(menu));
if (prop) switch (prop->type) {
case P_MENU:
@@ -208,7 +208,7 @@ void ConfigItem::updateMenu(void)
break;
}
if (!sym_has_value(sym) && visible)
- prompt += " (NEW)";
+ prompt += _(" (NEW)");
set_prompt:
setText(promptColIdx, prompt);
}
@@ -346,7 +346,7 @@ ConfigList::ConfigList(ConfigView* p, const char *name)
for (i = 0; i < colNr; i++)
colMap[i] = colRevMap[i] = -1;
- addColumn(promptColIdx, "Option");
+ addColumn(promptColIdx, _("Option"));
reinit();
}
@@ -360,14 +360,14 @@ void ConfigList::reinit(void)
removeColumn(nameColIdx);
if (showName)
- addColumn(nameColIdx, "Name");
+ addColumn(nameColIdx, _("Name"));
if (showRange) {
addColumn(noColIdx, "N");
addColumn(modColIdx, "M");
addColumn(yesColIdx, "Y");
}
if (showData)
- addColumn(dataColIdx, "Value");
+ addColumn(dataColIdx, _("Value"));
updateListAll();
}
@@ -803,7 +803,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
QAction *action;
headerPopup = new QPopupMenu(this);
- action = new QAction(NULL, "Show Name", 0, this);
+ action = new QAction(NULL, _("Show Name"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowName(bool)));
@@ -811,7 +811,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
action, SLOT(setOn(bool)));
action->setOn(showName);
action->addTo(headerPopup);
- action = new QAction(NULL, "Show Range", 0, this);
+ action = new QAction(NULL, _("Show Range"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowRange(bool)));
@@ -819,7 +819,7 @@ void ConfigList::contextMenuEvent(QContextMenuEvent *e)
action, SLOT(setOn(bool)));
action->setOn(showRange);
action->addTo(headerPopup);
- action = new QAction(NULL, "Show Data", 0, this);
+ action = new QAction(NULL, _("Show Data"), 0, this);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)),
parent(), SLOT(setShowData(bool)));
@@ -1041,7 +1041,12 @@ void ConfigInfoView::menuInfo(void)
if (showDebug())
debug = debug_info(sym);
- help = print_filter(_(menu_get_help(menu)));
+ help = menu_get_help(menu);
+ /* Gettextize if the help text not empty */
+ if (help.isEmpty())
+ help = print_filter(menu_get_help(menu));
+ else
+ help = print_filter(_(menu_get_help(menu)));
} else if (menu->prompt) {
head += "<big><b>";
head += print_filter(_(menu->prompt->text));
@@ -1083,7 +1088,11 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
debug += "</a><br>";
break;
case P_DEFAULT:
- debug += "default: ";
+ case P_SELECT:
+ case P_RANGE:
+ case P_ENV:
+ debug += prop_get_type_name(prop->type);
+ debug += ": ";
expr_print(prop->expr, expr_print_help, &debug, E_NONE);
debug += "<br>";
break;
@@ -1094,16 +1103,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym)
debug += "<br>";
}
break;
- case P_SELECT:
- debug += "select: ";
- expr_print(prop->expr, expr_print_help, &debug, E_NONE);
- debug += "<br>";
- break;
- case P_RANGE:
- debug += "range: ";
- expr_print(prop->expr, expr_print_help, &debug, E_NONE);
- debug += "<br>";
- break;
default:
debug += "unknown property: ";
debug += prop_get_type_name(prop->type);
@@ -1167,7 +1166,7 @@ void ConfigInfoView::expr_print_help(void *data, struct symbol *sym, const char
QPopupMenu* ConfigInfoView::createPopupMenu(const QPoint& pos)
{
QPopupMenu* popup = Parent::createPopupMenu(pos);
- QAction* action = new QAction(NULL,"Show Debug Info", 0, popup);
+ QAction* action = new QAction(NULL, _("Show Debug Info"), 0, popup);
action->setToggleAction(TRUE);
connect(action, SIGNAL(toggled(bool)), SLOT(setShowDebug(bool)));
connect(this, SIGNAL(showDebugChanged(bool)), action, SLOT(setOn(bool)));
@@ -1189,11 +1188,11 @@ ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *nam
QVBoxLayout* layout1 = new QVBoxLayout(this, 11, 6);
QHBoxLayout* layout2 = new QHBoxLayout(0, 0, 6);
- layout2->addWidget(new QLabel("Find:", this));
+ layout2->addWidget(new QLabel(_("Find:"), this));
editField = new QLineEdit(this);
connect(editField, SIGNAL(returnPressed()), SLOT(search()));
layout2->addWidget(editField);
- searchButton = new QPushButton("Search", this);
+ searchButton = new QPushButton(_("Search"), this);
searchButton->setAutoDefault(FALSE);
connect(searchButton, SIGNAL(clicked()), SLOT(search()));
layout2->addWidget(searchButton);
@@ -1313,58 +1312,58 @@ ConfigMainWindow::ConfigMainWindow(void)
menu = menuBar();
toolBar = new QToolBar("Tools", this);
- backAction = new QAction("Back", QPixmap(xpm_back), "Back", 0, this);
+ backAction = new QAction("Back", QPixmap(xpm_back), _("Back"), 0, this);
connect(backAction, SIGNAL(activated()), SLOT(goBack()));
backAction->setEnabled(FALSE);
- QAction *quitAction = new QAction("Quit", "&Quit", CTRL+Key_Q, this);
+ QAction *quitAction = new QAction("Quit", _("&Quit"), CTRL+Key_Q, this);
connect(quitAction, SIGNAL(activated()), SLOT(close()));
- QAction *loadAction = new QAction("Load", QPixmap(xpm_load), "&Load", CTRL+Key_L, this);
+ QAction *loadAction = new QAction("Load", QPixmap(xpm_load), _("&Load"), CTRL+Key_L, this);
connect(loadAction, SIGNAL(activated()), SLOT(loadConfig()));
- saveAction = new QAction("Save", QPixmap(xpm_save), "&Save", CTRL+Key_S, this);
+ saveAction = new QAction("Save", QPixmap(xpm_save), _("&Save"), CTRL+Key_S, this);
connect(saveAction, SIGNAL(activated()), SLOT(saveConfig()));
conf_set_changed_callback(conf_changed);
// Set saveAction's initial state
conf_changed();
- QAction *saveAsAction = new QAction("Save As...", "Save &As...", 0, this);
+ QAction *saveAsAction = new QAction("Save As...", _("Save &As..."), 0, this);
connect(saveAsAction, SIGNAL(activated()), SLOT(saveConfigAs()));
- QAction *searchAction = new QAction("Find", "&Find", CTRL+Key_F, this);
+ QAction *searchAction = new QAction("Find", _("&Find"), CTRL+Key_F, this);
connect(searchAction, SIGNAL(activated()), SLOT(searchConfig()));
- QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), "Split View", 0, this);
+ QAction *singleViewAction = new QAction("Single View", QPixmap(xpm_single_view), _("Single View"), 0, this);
connect(singleViewAction, SIGNAL(activated()), SLOT(showSingleView()));
- QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), "Split View", 0, this);
+ QAction *splitViewAction = new QAction("Split View", QPixmap(xpm_split_view), _("Split View"), 0, this);
connect(splitViewAction, SIGNAL(activated()), SLOT(showSplitView()));
- QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), "Full View", 0, this);
+ QAction *fullViewAction = new QAction("Full View", QPixmap(xpm_tree_view), _("Full View"), 0, this);
connect(fullViewAction, SIGNAL(activated()), SLOT(showFullView()));
- QAction *showNameAction = new QAction(NULL, "Show Name", 0, this);
+ QAction *showNameAction = new QAction(NULL, _("Show Name"), 0, this);
showNameAction->setToggleAction(TRUE);
connect(showNameAction, SIGNAL(toggled(bool)), configView, SLOT(setShowName(bool)));
connect(configView, SIGNAL(showNameChanged(bool)), showNameAction, SLOT(setOn(bool)));
showNameAction->setOn(configView->showName());
- QAction *showRangeAction = new QAction(NULL, "Show Range", 0, this);
+ QAction *showRangeAction = new QAction(NULL, _("Show Range"), 0, this);
showRangeAction->setToggleAction(TRUE);
connect(showRangeAction, SIGNAL(toggled(bool)), configView, SLOT(setShowRange(bool)));
connect(configView, SIGNAL(showRangeChanged(bool)), showRangeAction, SLOT(setOn(bool)));
showRangeAction->setOn(configList->showRange);
- QAction *showDataAction = new QAction(NULL, "Show Data", 0, this);
+ QAction *showDataAction = new QAction(NULL, _("Show Data"), 0, this);
showDataAction->setToggleAction(TRUE);
connect(showDataAction, SIGNAL(toggled(bool)), configView, SLOT(setShowData(bool)));
connect(configView, SIGNAL(showDataChanged(bool)), showDataAction, SLOT(setOn(bool)));
showDataAction->setOn(configList->showData);
- QAction *showAllAction = new QAction(NULL, "Show All Options", 0, this);
+ QAction *showAllAction = new QAction(NULL, _("Show All Options"), 0, this);
showAllAction->setToggleAction(TRUE);
connect(showAllAction, SIGNAL(toggled(bool)), configView, SLOT(setShowAll(bool)));
connect(showAllAction, SIGNAL(toggled(bool)), menuView, SLOT(setShowAll(bool)));
showAllAction->setOn(configList->showAll);
- QAction *showDebugAction = new QAction(NULL, "Show Debug Info", 0, this);
+ QAction *showDebugAction = new QAction(NULL, _("Show Debug Info"), 0, this);
showDebugAction->setToggleAction(TRUE);
connect(showDebugAction, SIGNAL(toggled(bool)), helpText, SLOT(setShowDebug(bool)));
connect(helpText, SIGNAL(showDebugChanged(bool)), showDebugAction, SLOT(setOn(bool)));
showDebugAction->setOn(helpText->showDebug());
- QAction *showIntroAction = new QAction(NULL, "Introduction", 0, this);
+ QAction *showIntroAction = new QAction(NULL, _("Introduction"), 0, this);
connect(showIntroAction, SIGNAL(activated()), SLOT(showIntro()));
- QAction *showAboutAction = new QAction(NULL, "About", 0, this);
+ QAction *showAboutAction = new QAction(NULL, _("About"), 0, this);
connect(showAboutAction, SIGNAL(activated()), SLOT(showAbout()));
// init tool bar
@@ -1379,7 +1378,7 @@ ConfigMainWindow::ConfigMainWindow(void)
// create config menu
QPopupMenu* config = new QPopupMenu(this);
- menu->insertItem("&File", config);
+ menu->insertItem(_("&File"), config);
loadAction->addTo(config);
saveAction->addTo(config);
saveAsAction->addTo(config);
@@ -1388,12 +1387,12 @@ ConfigMainWindow::ConfigMainWindow(void)
// create edit menu
QPopupMenu* editMenu = new QPopupMenu(this);
- menu->insertItem("&Edit", editMenu);
+ menu->insertItem(_("&Edit"), editMenu);
searchAction->addTo(editMenu);
// create options menu
QPopupMenu* optionMenu = new QPopupMenu(this);
- menu->insertItem("&Option", optionMenu);
+ menu->insertItem(_("&Option"), optionMenu);
showNameAction->addTo(optionMenu);
showRangeAction->addTo(optionMenu);
showDataAction->addTo(optionMenu);
@@ -1404,7 +1403,7 @@ ConfigMainWindow::ConfigMainWindow(void)
// create help menu
QPopupMenu* helpMenu = new QPopupMenu(this);
menu->insertSeparator();
- menu->insertItem("&Help", helpMenu);
+ menu->insertItem(_("&Help"), helpMenu);
showIntroAction->addTo(helpMenu);
showAboutAction->addTo(helpMenu);
@@ -1452,14 +1451,14 @@ void ConfigMainWindow::loadConfig(void)
if (s.isNull())
return;
if (conf_read(QFile::encodeName(s)))
- QMessageBox::information(this, "qconf", "Unable to load configuration!");
+ QMessageBox::information(this, "qconf", _("Unable to load configuration!"));
ConfigView::updateListAll();
}
void ConfigMainWindow::saveConfig(void)
{
if (conf_write(NULL))
- QMessageBox::information(this, "qconf", "Unable to save configuration!");
+ QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
}
void ConfigMainWindow::saveConfigAs(void)
@@ -1468,7 +1467,7 @@ void ConfigMainWindow::saveConfigAs(void)
if (s.isNull())
return;
if (conf_write(QFile::encodeName(s)))
- QMessageBox::information(this, "qconf", "Unable to save configuration!");
+ QMessageBox::information(this, "qconf", _("Unable to save configuration!"));
}
void ConfigMainWindow::searchConfig(void)
@@ -1612,11 +1611,11 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
e->accept();
return;
}
- QMessageBox mb("qconf", "Save configuration?", QMessageBox::Warning,
+ QMessageBox mb("qconf", _("Save configuration?"), QMessageBox::Warning,
QMessageBox::Yes | QMessageBox::Default, QMessageBox::No, QMessageBox::Cancel | QMessageBox::Escape);
- mb.setButtonText(QMessageBox::Yes, "&Save Changes");
- mb.setButtonText(QMessageBox::No, "&Discard Changes");
- mb.setButtonText(QMessageBox::Cancel, "Cancel Exit");
+ mb.setButtonText(QMessageBox::Yes, _("&Save Changes"));
+ mb.setButtonText(QMessageBox::No, _("&Discard Changes"));
+ mb.setButtonText(QMessageBox::Cancel, _("Cancel Exit"));
switch (mb.exec()) {
case QMessageBox::Yes:
conf_write(NULL);
@@ -1631,7 +1630,7 @@ void ConfigMainWindow::closeEvent(QCloseEvent* e)
void ConfigMainWindow::showIntro(void)
{
- static char str[] = "Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
+ static const QString str = _("Welcome to the qconf graphical kernel configuration tool for Linux.\n\n"
"For each option, a blank box indicates the feature is disabled, a check\n"
"indicates it is enabled, and a dot indicates that it is to be compiled\n"
"as a module. Clicking on the box will cycle through the three states.\n\n"
@@ -1641,15 +1640,15 @@ void ConfigMainWindow::showIntro(void)
"options must be enabled to support the option you are interested in, you can\n"
"still view the help of a grayed-out option.\n\n"
"Toggling Show Debug Info under the Options menu will show the dependencies,\n"
- "which you can then match by examining other options.\n\n";
+ "which you can then match by examining other options.\n\n");
QMessageBox::information(this, "qconf", str);
}
void ConfigMainWindow::showAbout(void)
{
- static char str[] = "qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
- "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n";
+ static const QString str = _("qconf is Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>.\n\n"
+ "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n");
QMessageBox::information(this, "qconf", str);
}
@@ -1707,7 +1706,7 @@ static const char *progname;
static void usage(void)
{
- printf("%s <config>\n", progname);
+ printf(_("%s <config>\n"), progname);
exit(0);
}
diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index c35dcc5d618..3929e5b35e7 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -34,6 +34,8 @@ struct symbol *sym_defconfig_list;
struct symbol *modules_sym;
tristate modules_val;
+struct expr *sym_env_list;
+
void sym_add_default(struct symbol *sym, const char *def)
{
struct property *prop = prop_alloc(P_DEFAULT, sym);
@@ -45,7 +47,6 @@ void sym_init(void)
{
struct symbol *sym;
struct utsname uts;
- char *p;
static bool inited = false;
if (inited)
@@ -54,20 +55,6 @@ void sym_init(void)
uname(&uts);
- sym = sym_lookup("ARCH", 0);
- sym->type = S_STRING;
- sym->flags |= SYMBOL_AUTO;
- p = getenv("ARCH");
- if (p)
- sym_add_default(sym, p);
-
- sym = sym_lookup("KERNELVERSION", 0);
- sym->type = S_STRING;
- sym->flags |= SYMBOL_AUTO;
- p = getenv("KERNELVERSION");
- if (p)
- sym_add_default(sym, p);
-
sym = sym_lookup("UNAME_RELEASE", 0);
sym->type = S_STRING;
sym->flags |= SYMBOL_AUTO;
@@ -117,6 +104,15 @@ struct property *sym_get_choice_prop(struct symbol *sym)
return NULL;
}
+struct property *sym_get_env_prop(struct symbol *sym)
+{
+ struct property *prop;
+
+ for_all_properties(sym, prop, P_ENV)
+ return prop;
+ return NULL;
+}
+
struct property *sym_get_default_prop(struct symbol *sym)
{
struct property *prop;
@@ -199,7 +195,7 @@ static void sym_calc_visibility(struct symbol *sym)
tri = no;
for_all_prompts(sym, prop) {
prop->visible.tri = expr_calc_value(prop->visible.expr);
- tri = E_OR(tri, prop->visible.tri);
+ tri = EXPR_OR(tri, prop->visible.tri);
}
if (tri == mod && (sym->type != S_TRISTATE || modules_val == no))
tri = yes;
@@ -247,8 +243,7 @@ static struct symbol *sym_calc_choice(struct symbol *sym)
/* just get the first visible value */
prop = sym_get_choice_prop(sym);
- for (e = prop->expr; e; e = e->left.expr) {
- def_sym = e->right.sym;
+ expr_list_for_each_sym(prop->expr, e, def_sym) {
sym_calc_visibility(def_sym);
if (def_sym->visible != no)
return def_sym;
@@ -303,7 +298,7 @@ void sym_calc_value(struct symbol *sym)
if (sym_is_choice_value(sym) && sym->visible == yes) {
prop = sym_get_choice_prop(sym);
newval.tri = (prop_get_symbol(prop)->curr.val == sym) ? yes : no;
- } else if (E_OR(sym->visible, sym->rev_dep.tri) != no) {
+ } else if (EXPR_OR(sym->visible, sym->rev_dep.tri) != no) {
sym->flags |= SYMBOL_WRITE;
if (sym_has_value(sym))
newval.tri = sym->def[S_DEF_USER].tri;
@@ -312,7 +307,7 @@ void sym_calc_value(struct symbol *sym)
if (prop)
newval.tri = expr_calc_value(prop->expr);
}
- newval.tri = E_OR(E_AND(newval.tri, sym->visible), sym->rev_dep.tri);
+ newval.tri = EXPR_OR(EXPR_AND(newval.tri, sym->visible), sym->rev_dep.tri);
} else if (!sym_is_choice(sym)) {
prop = sym_get_default_prop(sym);
if (prop) {
@@ -347,6 +342,9 @@ void sym_calc_value(struct symbol *sym)
;
}
+ if (sym->flags & SYMBOL_AUTO)
+ sym->flags &= ~SYMBOL_WRITE;
+
sym->curr = newval;
if (sym_is_choice(sym) && newval.tri == yes)
sym->curr.val = sym_calc_choice(sym);
@@ -361,12 +359,14 @@ void sym_calc_value(struct symbol *sym)
}
if (sym_is_choice(sym)) {
+ struct symbol *choice_sym;
int flags = sym->flags & (SYMBOL_CHANGED | SYMBOL_WRITE);
+
prop = sym_get_choice_prop(sym);
- for (e = prop->expr; e; e = e->left.expr) {
- e->right.sym->flags |= flags;
+ expr_list_for_each_sym(prop->expr, e, choice_sym) {
+ choice_sym->flags |= flags;
if (flags & SYMBOL_CHANGED)
- sym_set_changed(e->right.sym);
+ sym_set_changed(choice_sym);
}
}
}
@@ -849,7 +849,7 @@ struct property *prop_alloc(enum prop_type type, struct symbol *sym)
struct symbol *prop_get_symbol(struct property *prop)
{
if (prop->expr && (prop->expr->type == E_SYMBOL ||
- prop->expr->type == E_CHOICE))
+ prop->expr->type == E_LIST))
return prop->expr->left.sym;
return NULL;
}
@@ -859,6 +859,8 @@ const char *prop_get_type_name(enum prop_type type)
switch (type) {
case P_PROMPT:
return "prompt";
+ case P_ENV:
+ return "env";
case P_COMMENT:
return "comment";
case P_MENU:
@@ -876,3 +878,32 @@ const char *prop_get_type_name(enum prop_type type)
}
return "unknown";
}
+
+void prop_add_env(const char *env)
+{
+ struct symbol *sym, *sym2;
+ struct property *prop;
+ char *p;
+
+ sym = current_entry->sym;
+ sym->flags |= SYMBOL_AUTO;
+ for_all_properties(sym, prop, P_ENV) {
+ sym2 = prop_get_symbol(prop);
+ if (strcmp(sym2->name, env))
+ menu_warn(current_entry, "redefining environment symbol from %s",
+ sym2->name);
+ return;
+ }
+
+ prop = prop_alloc(P_ENV, sym);
+ prop->expr = expr_alloc_symbol(sym_lookup(env, 1));
+
+ sym_env_list = expr_alloc_one(E_LIST, sym_env_list);
+ sym_env_list->right.sym = sym;
+
+ p = getenv(env);
+ if (p)
+ sym_add_default(sym, p);
+ else
+ menu_warn(current_entry, "environment variable %s undefined", env);
+}
diff --git a/scripts/kconfig/util.c b/scripts/kconfig/util.c
index e1cad924c0a..f8e73c039dc 100644
--- a/scripts/kconfig/util.c
+++ b/scripts/kconfig/util.c
@@ -29,6 +29,8 @@ struct file *file_lookup(const char *name)
/* write a dependency file as used by kbuild to track dependencies */
int file_write_dep(const char *name)
{
+ struct symbol *sym, *env_sym;
+ struct expr *e;
struct file *file;
FILE *out;
@@ -45,8 +47,25 @@ int file_write_dep(const char *name)
fprintf(out, "\t%s\n", file->name);
}
fprintf(out, "\ninclude/config/auto.conf: \\\n"
- "\t$(deps_config)\n\n"
- "$(deps_config): ;\n");
+ "\t$(deps_config)\n\n");
+
+ expr_list_for_each_sym(sym_env_list, e, sym) {
+ struct property *prop;
+ const char *value;
+
+ prop = sym_get_env_prop(sym);
+ env_sym = prop_get_symbol(prop);
+ if (!env_sym)
+ continue;
+ value = getenv(env_sym->name);
+ if (!value)
+ value = "";
+ fprintf(out, "ifneq \"$(%s)\" \"%s\"\n", env_sym->name, value);
+ fprintf(out, "include/config/auto.conf: FORCE\n");
+ fprintf(out, "endif\n");
+ }
+
+ fprintf(out, "\n$(deps_config): ;\n");
fclose(out);
rename("..config.tmp", name);
return 0;
diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf
index 93538e567bd..25ef5d01c0a 100644
--- a/scripts/kconfig/zconf.gperf
+++ b/scripts/kconfig/zconf.gperf
@@ -35,10 +35,10 @@ int, T_TYPE, TF_COMMAND, S_INT
hex, T_TYPE, TF_COMMAND, S_HEX
string, T_TYPE, TF_COMMAND, S_STRING
select, T_SELECT, TF_COMMAND
-enable, T_SELECT, TF_COMMAND
range, T_RANGE, TF_COMMAND
option, T_OPTION, TF_COMMAND
on, T_ON, TF_PARAM
modules, T_OPT_MODULES, TF_OPTION
defconfig_list, T_OPT_DEFCONFIG_LIST,TF_OPTION
+env, T_OPT_ENV, TF_OPTION
%%
diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped
index ab28b18153a..5c73d51339d 100644
--- a/scripts/kconfig/zconf.hash.c_shipped
+++ b/scripts/kconfig/zconf.hash.c_shipped
@@ -1,4 +1,4 @@
-/* ANSI-C code produced by gperf version 3.0.2 */
+/* ANSI-C code produced by gperf version 3.0.3 */
/* Command-line: gperf */
/* Computed positions: -k'1,3' */
@@ -53,9 +53,9 @@ kconf_id_hash (register const char *str, register unsigned int len)
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
- 49, 49, 49, 49, 49, 49, 49, 18, 11, 5,
+ 49, 49, 49, 49, 49, 49, 49, 49, 11, 5,
0, 0, 5, 49, 5, 20, 49, 49, 5, 20,
- 5, 0, 30, 49, 0, 15, 0, 10, 49, 49,
+ 5, 0, 30, 49, 0, 15, 0, 10, 0, 49,
25, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
49, 49, 49, 49, 49, 49, 49, 49, 49, 49,
@@ -89,6 +89,7 @@ kconf_id_hash (register const char *str, register unsigned int len)
struct kconf_id_strings_t
{
char kconf_id_strings_str2[sizeof("on")];
+ char kconf_id_strings_str3[sizeof("env")];
char kconf_id_strings_str5[sizeof("endif")];
char kconf_id_strings_str6[sizeof("option")];
char kconf_id_strings_str7[sizeof("endmenu")];
@@ -107,7 +108,6 @@ struct kconf_id_strings_t
char kconf_id_strings_str21[sizeof("string")];
char kconf_id_strings_str22[sizeof("if")];
char kconf_id_strings_str23[sizeof("int")];
- char kconf_id_strings_str24[sizeof("enable")];
char kconf_id_strings_str26[sizeof("select")];
char kconf_id_strings_str27[sizeof("modules")];
char kconf_id_strings_str28[sizeof("tristate")];
@@ -123,6 +123,7 @@ struct kconf_id_strings_t
static struct kconf_id_strings_t kconf_id_strings_contents =
{
"on",
+ "env",
"endif",
"option",
"endmenu",
@@ -141,7 +142,6 @@ static struct kconf_id_strings_t kconf_id_strings_contents =
"string",
"if",
"int",
- "enable",
"select",
"modules",
"tristate",
@@ -157,6 +157,9 @@ static struct kconf_id_strings_t kconf_id_strings_contents =
#define kconf_id_strings ((const char *) &kconf_id_strings_contents)
#ifdef __GNUC__
__inline
+#ifdef __GNUC_STDC_INLINE__
+__attribute__ ((__gnu_inline__))
+#endif
#endif
struct kconf_id *
kconf_id_lookup (register const char *str, register unsigned int len)
@@ -174,7 +177,8 @@ kconf_id_lookup (register const char *str, register unsigned int len)
{
{-1}, {-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str2, T_ON, TF_PARAM},
- {-1}, {-1},
+ {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str3, T_OPT_ENV, TF_OPTION},
+ {-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str5, T_ENDIF, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str6, T_OPTION, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str7, T_ENDMENU, TF_COMMAND},
@@ -194,8 +198,7 @@ kconf_id_lookup (register const char *str, register unsigned int len)
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str22, T_IF, TF_COMMAND|TF_PARAM},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str23, T_TYPE, TF_COMMAND, S_INT},
- {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str24, T_SELECT, TF_COMMAND},
- {-1},
+ {-1}, {-1},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str26, T_SELECT, TF_COMMAND},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str27, T_OPT_MODULES, TF_OPTION},
{(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str28, T_TYPE, TF_COMMAND, S_TRISTATE},
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l
index 187d38ccadd..4cea5c85cd0 100644
--- a/scripts/kconfig/zconf.l
+++ b/scripts/kconfig/zconf.l
@@ -217,6 +217,11 @@ n [A-Za-z0-9_]
append_string("\n", 1);
}
[^ \t\n].* {
+ while (yyleng) {
+ if ((yytext[yyleng-1] != ' ') && (yytext[yyleng-1] != '\t'))
+ break;
+ yyleng--;
+ }
append_string(yytext, yyleng);
if (!first_ts)
first_ts = last_ts;
diff --git a/scripts/kernel-doc b/scripts/kernel-doc
index 1d1401807e9..ec54f12f57b 100755
--- a/scripts/kernel-doc
+++ b/scripts/kernel-doc
@@ -46,21 +46,24 @@ use strict;
# Note: This only supports 'c'.
# usage:
-# kernel-doc [ -docbook | -html | -text | -man ]
+# kernel-doc [ -docbook | -html | -text | -man ] [ -no-doc-sections ]
# [ -function funcname [ -function funcname ...] ] c file(s)s > outputfile
# or
# [ -nofunction funcname [ -function funcname ...] ] c file(s)s > outputfile
#
# Set output format using one of -docbook -html -text or -man. Default is man.
#
+# -no-doc-sections
+# Do not output DOC: sections
+#
# -function funcname
-# If set, then only generate documentation for the given function(s). All
-# other functions are ignored.
+# If set, then only generate documentation for the given function(s) or
+# DOC: section titles. All other functions and DOC: sections are ignored.
#
# -nofunction funcname
-# If set, then only generate documentation for the other function(s).
-# Cannot be used together with -function
-# (yes, that's a bug -- perl hackers can fix it 8))
+# If set, then only generate documentation for the other function(s)/DOC:
+# sections. Cannot be used together with -function (yes, that's a bug --
+# perl hackers can fix it 8))
#
# c files - list of 'c' files to process
#
@@ -182,10 +185,10 @@ my $blankline_html = $local_lt . "p" . $local_gt; # was "<p>"
my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1<quote>\$2</quote>",
$type_constant, "<constant>\$1</constant>",
$type_func, "<function>\$1</function>",
- $type_struct, "<structname>\$1</structname>",
+ $type_struct_xml, "<structname>\$1</structname>",
$type_env, "<envar>\$1</envar>",
$type_param, "<parameter>\$1</parameter>" );
-my $blankline_xml = "</para><para>\n";
+my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n";
# gnome, docbook format
my %highlights_gnome = ( $type_constant, "<replaceable class=\"option\">\$1</replaceable>",
@@ -211,7 +214,7 @@ my $blankline_text = "";
sub usage {
- print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ]\n";
+ print "Usage: $0 [ -v ] [ -docbook | -html | -text | -man ] [ -no-doc-sections ]\n";
print " [ -function funcname [ -function funcname ...] ]\n";
print " [ -nofunction funcname [ -nofunction funcname ...] ]\n";
print " c source file(s) > outputfile\n";
@@ -225,6 +228,7 @@ if ($#ARGV==-1) {
my $verbose = 0;
my $output_mode = "man";
+my $no_doc_sections = 0;
my %highlights = %highlights_man;
my $blankline = $blankline_man;
my $modulename = "Kernel API";
@@ -329,12 +333,14 @@ while ($ARGV[0] =~ m/^-(.*)/) {
usage();
} elsif ($cmd eq '-filelist') {
$filelist = shift @ARGV;
+ } elsif ($cmd eq '-no-doc-sections') {
+ $no_doc_sections = 1;
}
}
# get kernel version from env
sub get_kernel_version() {
- my $version;
+ my $version = 'unknown kernel version';
if (defined($ENV{'KERNELVERSION'})) {
$version = $ENV{'KERNELVERSION'};
@@ -374,6 +380,29 @@ sub dump_section {
}
##
+# dump DOC: section after checking that it should go out
+#
+sub dump_doc_section {
+ my $name = shift;
+ my $contents = join "\n", @_;
+
+ if ($no_doc_sections) {
+ return;
+ }
+
+ if (($function_only == 0) ||
+ ( $function_only == 1 && defined($function_table{$name})) ||
+ ( $function_only == 2 && !defined($function_table{$name})))
+ {
+ dump_section $name, $contents;
+ output_blockhead({'sectionlist' => \@sectionlist,
+ 'sections' => \%sections,
+ 'module' => $modulename,
+ 'content-only' => ($function_only != 0), });
+ }
+}
+
+##
# output function
#
# parameterdescs, a hash.
@@ -394,7 +423,7 @@ sub output_highlight {
# confess "output_highlight got called with no args?\n";
# }
- if ($output_mode eq "html") {
+ if ($output_mode eq "html" || $output_mode eq "xml") {
$contents = local_unescape($contents);
# convert data read & converted thru xml_escape() into &xyz; format:
$contents =~ s/\\\\\\/&/g;
@@ -564,8 +593,8 @@ sub output_function_html(%) {
print "<hr>\n";
}
-# output intro in html
-sub output_intro_html(%) {
+# output DOC: block header in html
+sub output_blockhead_html(%) {
my %args = %{$_[0]};
my ($parameter, $section);
my $count;
@@ -871,7 +900,7 @@ sub output_typedef_xml(%) {
}
# output in XML DocBook
-sub output_intro_xml(%) {
+sub output_blockhead_xml(%) {
my %args = %{$_[0]};
my ($parameter, $section);
my $count;
@@ -882,15 +911,23 @@ sub output_intro_xml(%) {
# print out each section
$lineprefix=" ";
foreach $section (@{$args{'sectionlist'}}) {
- print "<refsect1>\n <title>$section</title>\n <para>\n";
+ if (!$args{'content-only'}) {
+ print "<refsect1>\n <title>$section</title>\n";
+ }
if ($section =~ m/EXAMPLE/i) {
print "<example><para>\n";
+ } else {
+ print "<para>\n";
}
output_highlight($args{'sections'}{$section});
if ($section =~ m/EXAMPLE/i) {
print "</para></example>\n";
+ } else {
+ print "</para>";
+ }
+ if (!$args{'content-only'}) {
+ print "\n</refsect1>\n";
}
- print " </para>\n</refsect1>\n";
}
print "\n\n";
@@ -1137,7 +1174,7 @@ sub output_typedef_man(%) {
}
}
-sub output_intro_man(%) {
+sub output_blockhead_man(%) {
my %args = %{$_[0]};
my ($parameter, $section);
my $count;
@@ -1294,7 +1331,7 @@ sub output_struct_text(%) {
output_section_text(@_);
}
-sub output_intro_text(%) {
+sub output_blockhead_text(%) {
my %args = %{$_[0]};
my ($parameter, $section);
@@ -1325,9 +1362,9 @@ sub output_declaration {
##
# generic output function - calls the right one based on current output mode.
-sub output_intro {
+sub output_blockhead {
no strict 'refs';
- my $func = "output_intro_".$output_mode;
+ my $func = "output_blockhead_".$output_mode;
&$func(@_);
$section_counter++;
}
@@ -1926,9 +1963,7 @@ sub process_file($) {
} elsif ($state == 4) {
# Documentation block
if (/$doc_block/) {
- dump_section($section, xml_escape($contents));
- output_intro({'sectionlist' => \@sectionlist,
- 'sections' => \%sections });
+ dump_doc_section($section, xml_escape($contents));
$contents = "";
$function = "";
%constants = ();
@@ -1946,9 +1981,7 @@ sub process_file($) {
}
elsif (/$doc_end/)
{
- dump_section($section, xml_escape($contents));
- output_intro({'sectionlist' => \@sectionlist,
- 'sections' => \%sections });
+ dump_doc_section($section, xml_escape($contents));
$contents = "";
$function = "";
%constants = ();
diff --git a/scripts/mkmakefile b/scripts/mkmakefile
index e0f54b9d8fe..e65d8b33faa 100644
--- a/scripts/mkmakefile
+++ b/scripts/mkmakefile
@@ -25,8 +25,11 @@ cat << EOF > $2/Makefile
VERSION = $3
PATCHLEVEL = $4
-KERNELSRC := $1
-KERNELOUTPUT := $2
+lastword = \$(word \$(words \$(1)),\$(1))
+makedir := \$(dir \$(call lastword,\$(MAKEFILE_LIST)))
+
+MAKEARGS := -C $1
+MAKEARGS += O=\$(if \$(patsubst /%,,\$(makedir)),\$(CURDIR)/)\$(patsubst %/,%,\$(makedir))
MAKEFLAGS += --no-print-directory
@@ -35,10 +38,11 @@ MAKEFLAGS += --no-print-directory
all := \$(filter-out all Makefile,\$(MAKECMDGOALS))
all:
- \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$(all)
+ \$(MAKE) \$(MAKEARGS) \$(all)
Makefile:;
\$(all) %/: all
@:
+
EOF
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 93ac52adb49..f8efc93eb70 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2,7 +2,7 @@
*
* Copyright 2003 Kai Germaschewski
* Copyright 2002-2004 Rusty Russell, IBM Corporation
- * Copyright 2006 Sam Ravnborg
+ * Copyright 2006-2008 Sam Ravnborg
* Based in part on module-init-tools/depmod.c,file2alias
*
* This software may be used and distributed according to the terms
@@ -28,12 +28,17 @@ static int vmlinux_section_warnings = 1;
/* Only warn about unresolved symbols */
static int warn_unresolved = 0;
/* How a symbol is exported */
+static int sec_mismatch_count = 0;
+static int sec_mismatch_verbose = 1;
+
enum export {
export_plain, export_unused, export_gpl,
export_unused_gpl, export_gpl_future, export_unknown
};
-void fatal(const char *fmt, ...)
+#define PRINTF __attribute__ ((format (printf, 1, 2)))
+
+PRINTF void fatal(const char *fmt, ...)
{
va_list arglist;
@@ -46,7 +51,7 @@ void fatal(const char *fmt, ...)
exit(1);
}
-void warn(const char *fmt, ...)
+PRINTF void warn(const char *fmt, ...)
{
va_list arglist;
@@ -57,7 +62,7 @@ void warn(const char *fmt, ...)
va_end(arglist);
}
-void merror(const char *fmt, ...)
+PRINTF void merror(const char *fmt, ...)
{
va_list arglist;
@@ -72,7 +77,8 @@ static int is_vmlinux(const char *modname)
{
const char *myname;
- if ((myname = strrchr(modname, '/')))
+ myname = strrchr(modname, '/');
+ if (myname)
myname++;
else
myname = modname;
@@ -83,14 +89,13 @@ static int is_vmlinux(const char *modname)
void *do_nofail(void *ptr, const char *expr)
{
- if (!ptr) {
+ if (!ptr)
fatal("modpost: Memory allocation failure: %s.\n", expr);
- }
+
return ptr;
}
/* A list of all modules we processed */
-
static struct module *modules;
static struct module *find_module(char *modname)
@@ -113,7 +118,8 @@ static struct module *new_module(char *modname)
p = NOFAIL(strdup(modname));
/* strip trailing .o */
- if ((s = strrchr(p, '.')) != NULL)
+ s = strrchr(p, '.');
+ if (s != NULL)
if (strcmp(s, ".o") == 0)
*s = '\0';
@@ -154,7 +160,7 @@ static inline unsigned int tdb_hash(const char *name)
unsigned i; /* Used to cycle through random values. */
/* Set the initial value from the key size. */
- for (value = 0x238F13AF * strlen(name), i=0; name[i]; i++)
+ for (value = 0x238F13AF * strlen(name), i = 0; name[i]; i++)
value = (value + (((unsigned char *)name)[i] << (i*5 % 24)));
return (1103515243 * value + 12345);
@@ -198,7 +204,7 @@ static struct symbol *find_symbol(const char *name)
if (name[0] == '.')
name++;
- for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s=s->next) {
+ for (s = symbolhash[tdb_hash(name) % SYMBOL_HASH_SIZE]; s; s = s->next) {
if (strcmp(s->name, name) == 0)
return s;
}
@@ -223,9 +229,10 @@ static const char *export_str(enum export ex)
return export_list[ex].str;
}
-static enum export export_no(const char * s)
+static enum export export_no(const char *s)
{
int i;
+
if (!s)
return export_unknown;
for (i = 0; export_list[i].export != export_unknown; i++) {
@@ -315,7 +322,7 @@ void *grab_file(const char *filename, unsigned long *size)
* spaces in the beginning of the line is trimmed away.
* Return a pointer to a static buffer.
**/
-char* get_next_line(unsigned long *pos, void *file, unsigned long size)
+char *get_next_line(unsigned long *pos, void *file, unsigned long size)
{
static char line[4096];
int skip = 1;
@@ -323,8 +330,7 @@ char* get_next_line(unsigned long *pos, void *file, unsigned long size)
signed char *p = (signed char *)file + *pos;
char *s = line;
- for (; *pos < size ; (*pos)++)
- {
+ for (; *pos < size ; (*pos)++) {
if (skip && isspace(*p)) {
p++;
continue;
@@ -386,7 +392,9 @@ static int parse_elf(struct elf_info *info, const char *filename)
/* Check if file offset is correct */
if (hdr->e_shoff > info->size) {
- fatal("section header offset=%u in file '%s' is bigger then filesize=%lu\n", hdr->e_shoff, filename, info->size);
+ fatal("section header offset=%lu in file '%s' is bigger than "
+ "filesize=%lu\n", (unsigned long)hdr->e_shoff,
+ filename, info->size);
return 0;
}
@@ -407,7 +415,10 @@ static int parse_elf(struct elf_info *info, const char *filename)
const char *secname;
if (sechdrs[i].sh_offset > info->size) {
- fatal("%s is truncated. sechdrs[i].sh_offset=%u > sizeof(*hrd)=%ul\n", filename, (unsigned int)sechdrs[i].sh_offset, sizeof(*hdr));
+ fatal("%s is truncated. sechdrs[i].sh_offset=%lu > "
+ "sizeof(*hrd)=%zu\n", filename,
+ (unsigned long)sechdrs[i].sh_offset,
+ sizeof(*hdr));
return 0;
}
secname = secstrings + sechdrs[i].sh_name;
@@ -434,9 +445,9 @@ static int parse_elf(struct elf_info *info, const char *filename)
info->strtab = (void *)hdr +
sechdrs[sechdrs[i].sh_link].sh_offset;
}
- if (!info->symtab_start) {
+ if (!info->symtab_start)
fatal("%s has no symtab?\n", filename);
- }
+
/* Fix endianness in symbols */
for (sym = info->symtab_start; sym < info->symtab_stop; sym++) {
sym->st_shndx = TO_NATIVE(sym->st_shndx);
@@ -505,11 +516,13 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
#endif
if (memcmp(symname, MODULE_SYMBOL_PREFIX,
- strlen(MODULE_SYMBOL_PREFIX)) == 0)
- mod->unres = alloc_symbol(symname +
- strlen(MODULE_SYMBOL_PREFIX),
- ELF_ST_BIND(sym->st_info) == STB_WEAK,
- mod->unres);
+ strlen(MODULE_SYMBOL_PREFIX)) == 0) {
+ mod->unres =
+ alloc_symbol(symname +
+ strlen(MODULE_SYMBOL_PREFIX),
+ ELF_ST_BIND(sym->st_info) == STB_WEAK,
+ mod->unres);
+ }
break;
default:
/* All exported symbols */
@@ -578,69 +591,303 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len,
**/
static int strrcmp(const char *s, const char *sub)
{
- int slen, sublen;
+ int slen, sublen;
if (!s || !sub)
return 1;
slen = strlen(s);
- sublen = strlen(sub);
+ sublen = strlen(sub);
if ((slen == 0) || (sublen == 0))
return 1;
- if (sublen > slen)
- return 1;
+ if (sublen > slen)
+ return 1;
- return memcmp(s + slen - sublen, sub, sublen);
+ return memcmp(s + slen - sublen, sub, sublen);
}
-/*
- * Functions used only during module init is marked __init and is stored in
- * a .init.text section. Likewise data is marked __initdata and stored in
- * a .init.data section.
- * If this section is one of these sections return 1
- * See include/linux/init.h for the details
+static const char *sym_name(struct elf_info *elf, Elf_Sym *sym)
+{
+ if (sym)
+ return elf->strtab + sym->st_name;
+ else
+ return "";
+}
+
+static const char *sec_name(struct elf_info *elf, int shndx)
+{
+ Elf_Shdr *sechdrs = elf->sechdrs;
+ return (void *)elf->hdr +
+ elf->sechdrs[elf->hdr->e_shstrndx].sh_offset +
+ sechdrs[shndx].sh_name;
+}
+
+static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr)
+{
+ return (void *)elf->hdr +
+ elf->sechdrs[elf->hdr->e_shstrndx].sh_offset +
+ sechdr->sh_name;
+}
+
+/* if sym is empty or point to a string
+ * like ".[0-9]+" then return 1.
+ * This is the optional prefix added by ld to some sections
*/
-static int init_section(const char *name)
+static int number_prefix(const char *sym)
{
- if (strcmp(name, ".init") == 0)
- return 1;
- if (strncmp(name, ".init.", strlen(".init.")) == 0)
+ if (*sym++ == '\0')
return 1;
+ if (*sym != '.')
+ return 0;
+ do {
+ char c = *sym++;
+ if (c < '0' || c > '9')
+ return 0;
+ } while (*sym);
+ return 1;
+}
+
+/* The pattern is an array of simple patterns.
+ * "foo" will match an exact string equal to "foo"
+ * "*foo" will match a string that ends with "foo"
+ * "foo*" will match a string that begins with "foo"
+ * "foo$" will match a string equal to "foo" or "foo.1"
+ * where the '1' can be any number including several digits.
+ * The $ syntax is for sections where ld append a dot number
+ * to make section name unique.
+ */
+int match(const char *sym, const char * const pat[])
+{
+ const char *p;
+ while (*pat) {
+ p = *pat++;
+ const char *endp = p + strlen(p) - 1;
+
+ /* "*foo" */
+ if (*p == '*') {
+ if (strrcmp(sym, p + 1) == 0)
+ return 1;
+ }
+ /* "foo*" */
+ else if (*endp == '*') {
+ if (strncmp(sym, p, strlen(p) - 1) == 0)
+ return 1;
+ }
+ /* "foo$" */
+ else if (*endp == '$') {
+ if (strncmp(sym, p, strlen(p) - 1) == 0) {
+ if (number_prefix(sym + strlen(p) - 1))
+ return 1;
+ }
+ }
+ /* no wildcards */
+ else {
+ if (strcmp(p, sym) == 0)
+ return 1;
+ }
+ }
+ /* no match */
return 0;
}
+/* sections that we do not want to do full section mismatch check on */
+static const char *section_white_list[] =
+ { ".debug*", ".stab*", ".note*", ".got*", ".toc*", NULL };
+
/*
- * Functions used only during module exit is marked __exit and is stored in
- * a .exit.text section. Likewise data is marked __exitdata and stored in
- * a .exit.data section.
- * If this section is one of these sections return 1
- * See include/linux/init.h for the details
- **/
-static int exit_section(const char *name)
+ * Is this section one we do not want to check?
+ * This is often debug sections.
+ * If we are going to check this section then
+ * test if section name ends with a dot and a number.
+ * This is used to find sections where the linker have
+ * appended a dot-number to make the name unique.
+ * The cause of this is often a section specified in assembler
+ * without "ax" / "aw" and the same section used in .c
+ * code where gcc add these.
+ */
+static int check_section(const char *modname, const char *sec)
{
- if (strcmp(name, ".exit.text") == 0)
- return 1;
- if (strcmp(name, ".exit.data") == 0)
+ const char *e = sec + strlen(sec) - 1;
+ if (match(sec, section_white_list))
return 1;
- return 0;
+ if (*e && isdigit(*e)) {
+ /* consume all digits */
+ while (*e && e != sec && isdigit(*e))
+ e--;
+ if (*e == '.') {
+ warn("%s (%s): unexpected section name.\n"
+ "The (.[number]+) following section name are "
+ "ld generated and not expected.\n"
+ "Did you forget to use \"ax\"/\"aw\" "
+ "in a .S file?\n"
+ "Note that for example <linux/init.h> contains\n"
+ "section definitions for use in .S files.\n\n",
+ modname, sec);
+ }
+ }
+ return 0;
}
-/*
- * Data sections are named like this:
- * .data | .data.rel | .data.rel.*
- * Return 1 if the specified section is a data section
+
+
+#define ALL_INIT_DATA_SECTIONS \
+ ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$"
+#define ALL_EXIT_DATA_SECTIONS \
+ ".exit.data$", ".devexit.data$", ".cpuexit.data$", ".memexit.data$"
+
+#define ALL_INIT_TEXT_SECTIONS \
+ ".init.text$", ".devinit.text$", ".cpuinit.text$", ".meminit.text$"
+#define ALL_EXIT_TEXT_SECTIONS \
+ ".exit.text$", ".devexit.text$", ".cpuexit.text$", ".memexit.text$"
+
+#define ALL_INIT_SECTIONS ALL_INIT_DATA_SECTIONS, ALL_INIT_TEXT_SECTIONS
+#define ALL_EXIT_SECTIONS ALL_EXIT_DATA_SECTIONS, ALL_EXIT_TEXT_SECTIONS
+
+#define DATA_SECTIONS ".data$", ".data.rel$"
+#define TEXT_SECTIONS ".text$"
+
+#define INIT_SECTIONS ".init.data$", ".init.text$"
+#define DEV_INIT_SECTIONS ".devinit.data$", ".devinit.text$"
+#define CPU_INIT_SECTIONS ".cpuinit.data$", ".cpuinit.text$"
+#define MEM_INIT_SECTIONS ".meminit.data$", ".meminit.text$"
+
+#define EXIT_SECTIONS ".exit.data$", ".exit.text$"
+#define DEV_EXIT_SECTIONS ".devexit.data$", ".devexit.text$"
+#define CPU_EXIT_SECTIONS ".cpuexit.data$", ".cpuexit.text$"
+#define MEM_EXIT_SECTIONS ".memexit.data$", ".memexit.text$"
+
+/* init data sections */
+static const char *init_data_sections[] = { ALL_INIT_DATA_SECTIONS, NULL };
+
+/* all init sections */
+static const char *init_sections[] = { ALL_INIT_SECTIONS, NULL };
+
+/* All init and exit sections (code + data) */
+static const char *init_exit_sections[] =
+ {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
+
+/* data section */
+static const char *data_sections[] = { DATA_SECTIONS, NULL };
+
+/* sections that may refer to an init/exit section with no warning */
+static const char *initref_sections[] =
+{
+ ".text.init.refok*",
+ ".exit.text.refok*",
+ ".data.init.refok*",
+ NULL
+};
+
+
+/* symbols in .data that may refer to init/exit sections */
+static const char *symbol_white_list[] =
+{
+ "*driver",
+ "*_template", /* scsi uses *_template a lot */
+ "*_timer", /* arm uses ops structures named _timer a lot */
+ "*_sht", /* scsi also used *_sht to some extent */
+ "*_ops",
+ "*_probe",
+ "*_probe_one",
+ "*_console",
+ NULL
+};
+
+static const char *head_sections[] = { ".head.text*", NULL };
+static const char *linker_symbols[] =
+ { "__init_begin", "_sinittext", "_einittext", NULL };
+
+enum mismatch {
+ NO_MISMATCH,
+ TEXT_TO_INIT,
+ DATA_TO_INIT,
+ TEXT_TO_EXIT,
+ DATA_TO_EXIT,
+ XXXINIT_TO_INIT,
+ XXXEXIT_TO_EXIT,
+ INIT_TO_EXIT,
+ EXIT_TO_INIT,
+ EXPORT_TO_INIT_EXIT,
+};
+
+struct sectioncheck {
+ const char *fromsec[20];
+ const char *tosec[20];
+ enum mismatch mismatch;
+};
+
+const struct sectioncheck sectioncheck[] = {
+/* Do not reference init/exit code/data from
+ * normal code and data
*/
-static int data_section(const char *name)
{
- if ((strcmp(name, ".data") == 0) ||
- (strcmp(name, ".data.rel") == 0) ||
- (strncmp(name, ".data.rel.", strlen(".data.rel.")) == 0))
- return 1;
- else
- return 0;
+ .fromsec = { TEXT_SECTIONS, NULL },
+ .tosec = { ALL_INIT_SECTIONS, NULL },
+ .mismatch = TEXT_TO_INIT,
+},
+{
+ .fromsec = { DATA_SECTIONS, NULL },
+ .tosec = { ALL_INIT_SECTIONS, NULL },
+ .mismatch = DATA_TO_INIT,
+},
+{
+ .fromsec = { TEXT_SECTIONS, NULL },
+ .tosec = { ALL_EXIT_SECTIONS, NULL },
+ .mismatch = TEXT_TO_EXIT,
+},
+{
+ .fromsec = { DATA_SECTIONS, NULL },
+ .tosec = { ALL_EXIT_SECTIONS, NULL },
+ .mismatch = DATA_TO_EXIT,
+},
+/* Do not reference init code/data from devinit/cpuinit/meminit code/data */
+{
+ .fromsec = { DEV_INIT_SECTIONS, CPU_INIT_SECTIONS, MEM_INIT_SECTIONS, NULL },
+ .tosec = { INIT_SECTIONS, NULL },
+ .mismatch = XXXINIT_TO_INIT,
+},
+/* Do not reference exit code/data from devexit/cpuexit/memexit code/data */
+{
+ .fromsec = { DEV_EXIT_SECTIONS, CPU_EXIT_SECTIONS, MEM_EXIT_SECTIONS, NULL },
+ .tosec = { EXIT_SECTIONS, NULL },
+ .mismatch = XXXEXIT_TO_EXIT,
+},
+/* Do not use exit code/data from init code */
+{
+ .fromsec = { ALL_INIT_SECTIONS, NULL },
+ .tosec = { ALL_EXIT_SECTIONS, NULL },
+ .mismatch = INIT_TO_EXIT,
+},
+/* Do not use init code/data from exit code */
+{
+ .fromsec = { ALL_EXIT_SECTIONS, NULL },
+ .tosec = { ALL_INIT_SECTIONS, NULL },
+ .mismatch = EXIT_TO_INIT,
+},
+/* Do not export init/exit functions or data */
+{
+ .fromsec = { "__ksymtab*", NULL },
+ .tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL },
+ .mismatch = EXPORT_TO_INIT_EXIT
+}
+};
+
+static int section_mismatch(const char *fromsec, const char *tosec)
+{
+ int i;
+ int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck);
+ const struct sectioncheck *check = &sectioncheck[0];
+
+ for (i = 0; i < elems; i++) {
+ if (match(fromsec, check->fromsec) &&
+ match(tosec, check->tosec))
+ return check->mismatch;
+ check++;
+ }
+ return NO_MISMATCH;
}
/**
@@ -669,7 +916,8 @@ static int data_section(const char *name)
* the pattern is identified by:
* tosec = init or exit section
* fromsec = data section
- * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer
+ * atsym = *driver, *_template, *_sht, *_ops, *_probe,
+ * *probe_one, *_console, *_timer
*
* Pattern 3:
* Whitelist all refereces from .text.head to .init.data
@@ -684,77 +932,36 @@ static int data_section(const char *name)
* This pattern is identified by
* refsymname = __init_begin, _sinittext, _einittext
*
- * Pattern 5:
- * Xtensa uses literal sections for constants that are accessed PC-relative.
- * Literal sections may safely reference their text sections.
- * (Note that the name for the literal section omits any trailing '.text')
- * tosec = <section>[.text]
- * fromsec = <section>.literal
**/
-static int secref_whitelist(const char *modname, const char *tosec,
- const char *fromsec, const char *atsym,
- const char *refsymname)
+static int secref_whitelist(const char *fromsec, const char *fromsym,
+ const char *tosec, const char *tosym)
{
- int len;
- const char **s;
- const char *pat2sym[] = {
- "driver",
- "_template", /* scsi uses *_template a lot */
- "_timer", /* arm uses ops structures named _timer a lot */
- "_sht", /* scsi also used *_sht to some extent */
- "_ops",
- "_probe",
- "_probe_one",
- "_console",
- NULL
- };
-
- const char *pat3refsym[] = {
- "__init_begin",
- "_sinittext",
- "_einittext",
- NULL
- };
-
/* Check for pattern 0 */
- if ((strncmp(fromsec, ".text.init.refok", strlen(".text.init.refok")) == 0) ||
- (strncmp(fromsec, ".exit.text.refok", strlen(".exit.text.refok")) == 0) ||
- (strncmp(fromsec, ".data.init.refok", strlen(".data.init.refok")) == 0))
- return 1;
+ if (match(fromsec, initref_sections))
+ return 0;
/* Check for pattern 1 */
- if ((strcmp(tosec, ".init.data") == 0) &&
- (strncmp(fromsec, ".data", strlen(".data")) == 0) &&
- (strncmp(atsym, "__param", strlen("__param")) == 0))
- return 1;
+ if (match(tosec, init_data_sections) &&
+ match(fromsec, data_sections) &&
+ (strncmp(fromsym, "__param", strlen("__param")) == 0))
+ return 0;
/* Check for pattern 2 */
- if ((init_section(tosec) || exit_section(tosec)) && data_section(fromsec))
- for (s = pat2sym; *s; s++)
- if (strrcmp(atsym, *s) == 0)
- return 1;
+ if (match(tosec, init_exit_sections) &&
+ match(fromsec, data_sections) &&
+ match(fromsym, symbol_white_list))
+ return 0;
/* Check for pattern 3 */
- if ((strcmp(fromsec, ".text.head") == 0) &&
- ((strcmp(tosec, ".init.data") == 0) ||
- (strcmp(tosec, ".init.text") == 0)))
- return 1;
+ if (match(fromsec, head_sections) &&
+ match(tosec, init_sections))
+ return 0;
/* Check for pattern 4 */
- for (s = pat3refsym; *s; s++)
- if (strcmp(refsymname, *s) == 0)
- return 1;
-
- /* Check for pattern 5 */
- if (strrcmp(tosec, ".text") == 0)
- len = strlen(tosec) - strlen(".text");
- else
- len = strlen(tosec);
- if ((strncmp(tosec, fromsec, len) == 0) && (strlen(fromsec) > len) &&
- (strcmp(fromsec + len, ".literal") == 0))
- return 1;
+ if (match(tosym, linker_symbols))
+ return 0;
- return 0;
+ return 1;
}
/**
@@ -764,10 +971,13 @@ static int secref_whitelist(const char *modname, const char *tosec,
* In other cases the symbol needs to be looked up in the symbol table
* based on section and address.
* **/
-static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
+static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf64_Sword addr,
Elf_Sym *relsym)
{
Elf_Sym *sym;
+ Elf_Sym *near = NULL;
+ Elf64_Sword distance = 20;
+ Elf64_Sword d;
if (relsym->st_name != 0)
return relsym;
@@ -778,8 +988,20 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr,
continue;
if (sym->st_value == addr)
return sym;
+ /* Find a symbol nearby - addr are maybe negative */
+ d = sym->st_value - addr;
+ if (d < 0)
+ d = addr - sym->st_value;
+ if (d < distance) {
+ distance = d;
+ near = sym;
+ }
}
- return NULL;
+ /* We need a close match */
+ if (distance < 20)
+ return near;
+ else
+ return NULL;
}
static inline int is_arm_mapping_symbol(const char *str)
@@ -812,121 +1034,245 @@ static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym)
* The ELF format may have a better way to detect what type of symbol
* it is, but this works for now.
**/
-static void find_symbols_between(struct elf_info *elf, Elf_Addr addr,
- const char *sec,
- Elf_Sym **before, Elf_Sym **after)
+static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
+ const char *sec)
{
Elf_Sym *sym;
- Elf_Ehdr *hdr = elf->hdr;
- Elf_Addr beforediff = ~0;
- Elf_Addr afterdiff = ~0;
- const char *secstrings = (void *)hdr +
- elf->sechdrs[hdr->e_shstrndx].sh_offset;
-
- *before = NULL;
- *after = NULL;
+ Elf_Sym *near = NULL;
+ Elf_Addr distance = ~0;
for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) {
const char *symsec;
if (sym->st_shndx >= SHN_LORESERVE)
continue;
- symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name;
+ symsec = sec_name(elf, sym->st_shndx);
if (strcmp(symsec, sec) != 0)
continue;
if (!is_valid_name(elf, sym))
continue;
if (sym->st_value <= addr) {
- if ((addr - sym->st_value) < beforediff) {
- beforediff = addr - sym->st_value;
- *before = sym;
- }
- else if ((addr - sym->st_value) == beforediff) {
- *before = sym;
+ if ((addr - sym->st_value) < distance) {
+ distance = addr - sym->st_value;
+ near = sym;
+ } else if ((addr - sym->st_value) == distance) {
+ near = sym;
}
}
+ }
+ return near;
+}
+
+/*
+ * Convert a section name to the function/data attribute
+ * .init.text => __init
+ * .cpuinit.data => __cpudata
+ * .memexitconst => __memconst
+ * etc.
+*/
+static char *sec2annotation(const char *s)
+{
+ if (match(s, init_exit_sections)) {
+ char *p = malloc(20);
+ char *r = p;
+
+ *p++ = '_';
+ *p++ = '_';
+ if (*s == '.')
+ s++;
+ while (*s && *s != '.')
+ *p++ = *s++;
+ *p = '\0';
+ if (*s == '.')
+ s++;
+ if (strstr(s, "rodata") != NULL)
+ strcat(p, "const ");
+ else if (strstr(s, "data") != NULL)
+ strcat(p, "data ");
else
- {
- if ((sym->st_value - addr) < afterdiff) {
- afterdiff = sym->st_value - addr;
- *after = sym;
- }
- else if ((sym->st_value - addr) == afterdiff) {
- *after = sym;
- }
- }
+ strcat(p, " ");
+ return r; /* we leak her but we do not care */
+ } else {
+ return "";
}
}
-/**
+static int is_function(Elf_Sym *sym)
+{
+ if (sym)
+ return ELF_ST_TYPE(sym->st_info) == STT_FUNC;
+ else
+ return 0;
+}
+
+/*
* Print a warning about a section mismatch.
* Try to find symbols near it so user can find it.
* Check whitelist before warning - it may be a false positive.
- **/
-static void warn_sec_mismatch(const char *modname, const char *fromsec,
- struct elf_info *elf, Elf_Sym *sym, Elf_Rela r)
+ */
+static void report_sec_mismatch(const char *modname, enum mismatch mismatch,
+ const char *fromsec,
+ unsigned long long fromaddr,
+ const char *fromsym,
+ int from_is_func,
+ const char *tosec, const char *tosym,
+ int to_is_func)
{
- const char *refsymname = "";
- Elf_Sym *before, *after;
- Elf_Sym *refsym;
- Elf_Ehdr *hdr = elf->hdr;
- Elf_Shdr *sechdrs = elf->sechdrs;
- const char *secstrings = (void *)hdr +
- sechdrs[hdr->e_shstrndx].sh_offset;
- const char *secname = secstrings + sechdrs[sym->st_shndx].sh_name;
-
- find_symbols_between(elf, r.r_offset, fromsec, &before, &after);
-
- refsym = find_elf_symbol(elf, r.r_addend, sym);
- if (refsym && strlen(elf->strtab + refsym->st_name))
- refsymname = elf->strtab + refsym->st_name;
-
- /* check whitelist - we may ignore it */
- if (secref_whitelist(modname, secname, fromsec,
- before ? elf->strtab + before->st_name : "",
- refsymname))
+ const char *from, *from_p;
+ const char *to, *to_p;
+ from = from_is_func ? "function" : "variable";
+ from_p = from_is_func ? "()" : "";
+ to = to_is_func ? "function" : "variable";
+ to_p = to_is_func ? "()" : "";
+
+ fprintf(stderr, "WARNING: %s(%s+0x%llx): Section mismatch in"
+ " reference from the %s %s%s to the %s %s:%s%s\n",
+ modname, fromsec, fromaddr, from, fromsym, from_p,
+ to, tosec, tosym, to_p);
+
+ sec_mismatch_count++;
+ if (!sec_mismatch_verbose)
return;
- if (before && after) {
- warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s "
- "(between '%s' and '%s')\n",
- modname, fromsec, (unsigned long long)r.r_offset,
- secname, refsymname,
- elf->strtab + before->st_name,
- elf->strtab + after->st_name);
- } else if (before) {
- warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s "
- "(after '%s')\n",
- modname, fromsec, (unsigned long long)r.r_offset,
- secname, refsymname,
- elf->strtab + before->st_name);
- } else if (after) {
- warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s "
- "before '%s' (at offset -0x%llx)\n",
- modname, fromsec, (unsigned long long)r.r_offset,
- secname, refsymname,
- elf->strtab + after->st_name);
- } else {
- warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s\n",
- modname, fromsec, (unsigned long long)r.r_offset,
- secname, refsymname);
+ switch (mismatch) {
+ case TEXT_TO_INIT:
+ fprintf(stderr,
+ "The function %s %s() references\n"
+ "the %s %s%s%s.\n"
+ "This is often because %s lacks a %s\n"
+ "annotation or the annotation of %s is wrong.\n",
+ sec2annotation(fromsec), fromsym,
+ to, sec2annotation(tosec), tosym, to_p,
+ fromsym, sec2annotation(tosec), tosym);
+ break;
+ case DATA_TO_INIT: {
+ const char **s = symbol_white_list;
+ fprintf(stderr,
+ "The variable %s references\n"
+ "the %s %s%s%s\n"
+ "If the reference is valid then annotate the\n"
+ "variable with __init* (see linux/init.h) "
+ "or name the variable:\n",
+ fromsym, to, sec2annotation(tosec), tosym, to_p);
+ while (*s)
+ fprintf(stderr, "%s, ", *s++);
+ fprintf(stderr, "\n");
+ break;
+ }
+ case TEXT_TO_EXIT:
+ fprintf(stderr,
+ "The function %s() references a %s in an exit section.\n"
+ "Often the %s %s%s has valid usage outside the exit section\n"
+ "and the fix is to remove the %sannotation of %s.\n",
+ fromsym, to, to, tosym, to_p, sec2annotation(tosec), tosym);
+ break;
+ case DATA_TO_EXIT: {
+ const char **s = symbol_white_list;
+ fprintf(stderr,
+ "The variable %s references\n"
+ "the %s %s%s%s\n"
+ "If the reference is valid then annotate the\n"
+ "variable with __exit* (see linux/init.h) or "
+ "name the variable:\n",
+ fromsym, to, sec2annotation(tosec), tosym, to_p);
+ while (*s)
+ fprintf(stderr, "%s, ", *s++);
+ fprintf(stderr, "\n");
+ break;
+ }
+ case XXXINIT_TO_INIT:
+ case XXXEXIT_TO_EXIT:
+ fprintf(stderr,
+ "The %s %s%s%s references\n"
+ "a %s %s%s%s.\n"
+ "If %s is only used by %s then\n"
+ "annotate %s with a matching annotation.\n",
+ from, sec2annotation(fromsec), fromsym, from_p,
+ to, sec2annotation(tosec), tosym, to_p,
+ fromsym, tosym, fromsym);
+ break;
+ case INIT_TO_EXIT:
+ fprintf(stderr,
+ "The %s %s%s%s references\n"
+ "a %s %s%s%s.\n"
+ "This is often seen when error handling "
+ "in the init function\n"
+ "uses functionality in the exit path.\n"
+ "The fix is often to remove the %sannotation of\n"
+ "%s%s so it may be used outside an exit section.\n",
+ from, sec2annotation(fromsec), fromsym, from_p,
+ to, sec2annotation(tosec), tosym, to_p,
+ sec2annotation(tosec), tosym, to_p);
+ break;
+ case EXIT_TO_INIT:
+ fprintf(stderr,
+ "The %s %s%s%s references\n"
+ "a %s %s%s%s.\n"
+ "This is often seen when error handling "
+ "in the exit function\n"
+ "uses functionality in the init path.\n"
+ "The fix is often to remove the %sannotation of\n"
+ "%s%s so it may be used outside an init section.\n",
+ from, sec2annotation(fromsec), fromsym, from_p,
+ to, sec2annotation(tosec), tosym, to_p,
+ sec2annotation(tosec), tosym, to_p);
+ break;
+ case EXPORT_TO_INIT_EXIT:
+ fprintf(stderr,
+ "The symbol %s is exported and annotated %s\n"
+ "Fix this by removing the %sannotation of %s "
+ "or drop the export.\n",
+ tosym, sec2annotation(tosec), sec2annotation(tosec), tosym);
+ case NO_MISMATCH:
+ /* To get warnings on missing members */
+ break;
+ }
+ fprintf(stderr, "\n");
+}
+
+static void check_section_mismatch(const char *modname, struct elf_info *elf,
+ Elf_Rela *r, Elf_Sym *sym, const char *fromsec)
+{
+ const char *tosec;
+ enum mismatch mismatch;
+
+ tosec = sec_name(elf, sym->st_shndx);
+ mismatch = section_mismatch(fromsec, tosec);
+ if (mismatch != NO_MISMATCH) {
+ Elf_Sym *to;
+ Elf_Sym *from;
+ const char *tosym;
+ const char *fromsym;
+
+ from = find_elf_symbol2(elf, r->r_offset, fromsec);
+ fromsym = sym_name(elf, from);
+ to = find_elf_symbol(elf, r->r_addend, sym);
+ tosym = sym_name(elf, to);
+
+ /* check whitelist - we may ignore it */
+ if (secref_whitelist(fromsec, fromsym, tosec, tosym)) {
+ report_sec_mismatch(modname, mismatch,
+ fromsec, r->r_offset, fromsym,
+ is_function(from), tosec, tosym,
+ is_function(to));
+ }
}
}
static unsigned int *reloc_location(struct elf_info *elf,
- int rsection, Elf_Rela *r)
+ Elf_Shdr *sechdr, Elf_Rela *r)
{
Elf_Shdr *sechdrs = elf->sechdrs;
- int section = sechdrs[rsection].sh_info;
+ int section = sechdr->sh_info;
return (void *)elf->hdr + sechdrs[section].sh_offset +
(r->r_offset - sechdrs[section].sh_addr);
}
-static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
+static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
{
unsigned int r_typ = ELF_R_TYPE(r->r_info);
- unsigned int *location = reloc_location(elf, rsection, r);
+ unsigned int *location = reloc_location(elf, sechdr, r);
switch (r_typ) {
case R_386_32:
@@ -942,19 +1288,21 @@ static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
return 0;
}
-static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
+static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
{
unsigned int r_typ = ELF_R_TYPE(r->r_info);
switch (r_typ) {
case R_ARM_ABS32:
/* From ARM ABI: (S + A) | T */
- r->r_addend = (int)(long)(elf->symtab_start + ELF_R_SYM(r->r_info));
+ r->r_addend = (int)(long)
+ (elf->symtab_start + ELF_R_SYM(r->r_info));
break;
case R_ARM_PC24:
/* From ARM ABI: ((S + A) | T) - P */
- r->r_addend = (int)(long)(elf->hdr + elf->sechdrs[rsection].sh_offset +
- (r->r_offset - elf->sechdrs[rsection].sh_addr));
+ r->r_addend = (int)(long)(elf->hdr +
+ sechdr->sh_offset +
+ (r->r_offset - sechdr->sh_addr));
break;
default:
return 1;
@@ -962,10 +1310,10 @@ static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
return 0;
}
-static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
+static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
{
unsigned int r_typ = ELF_R_TYPE(r->r_info);
- unsigned int *location = reloc_location(elf, rsection, r);
+ unsigned int *location = reloc_location(elf, sechdr, r);
unsigned int inst;
if (r_typ == R_MIPS_HI16)
@@ -985,6 +1333,108 @@ static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
return 0;
}
+static void section_rela(const char *modname, struct elf_info *elf,
+ Elf_Shdr *sechdr)
+{
+ Elf_Sym *sym;
+ Elf_Rela *rela;
+ Elf_Rela r;
+ unsigned int r_sym;
+ const char *fromsec;
+
+ Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset;
+ Elf_Rela *stop = (void *)start + sechdr->sh_size;
+
+ fromsec = sech_name(elf, sechdr);
+ fromsec += strlen(".rela");
+ /* if from section (name) is know good then skip it */
+ if (check_section(modname, fromsec))
+ return;
+
+ for (rela = start; rela < stop; rela++) {
+ r.r_offset = TO_NATIVE(rela->r_offset);
+#if KERNEL_ELFCLASS == ELFCLASS64
+ if (elf->hdr->e_machine == EM_MIPS) {
+ unsigned int r_typ;
+ r_sym = ELF64_MIPS_R_SYM(rela->r_info);
+ r_sym = TO_NATIVE(r_sym);
+ r_typ = ELF64_MIPS_R_TYPE(rela->r_info);
+ r.r_info = ELF64_R_INFO(r_sym, r_typ);
+ } else {
+ r.r_info = TO_NATIVE(rela->r_info);
+ r_sym = ELF_R_SYM(r.r_info);
+ }
+#else
+ r.r_info = TO_NATIVE(rela->r_info);
+ r_sym = ELF_R_SYM(r.r_info);
+#endif
+ r.r_addend = TO_NATIVE(rela->r_addend);
+ sym = elf->symtab_start + r_sym;
+ /* Skip special sections */
+ if (sym->st_shndx >= SHN_LORESERVE)
+ continue;
+ check_section_mismatch(modname, elf, &r, sym, fromsec);
+ }
+}
+
+static void section_rel(const char *modname, struct elf_info *elf,
+ Elf_Shdr *sechdr)
+{
+ Elf_Sym *sym;
+ Elf_Rel *rel;
+ Elf_Rela r;
+ unsigned int r_sym;
+ const char *fromsec;
+
+ Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset;
+ Elf_Rel *stop = (void *)start + sechdr->sh_size;
+
+ fromsec = sech_name(elf, sechdr);
+ fromsec += strlen(".rel");
+ /* if from section (name) is know good then skip it */
+ if (check_section(modname, fromsec))
+ return;
+
+ for (rel = start; rel < stop; rel++) {
+ r.r_offset = TO_NATIVE(rel->r_offset);
+#if KERNEL_ELFCLASS == ELFCLASS64
+ if (elf->hdr->e_machine == EM_MIPS) {
+ unsigned int r_typ;
+ r_sym = ELF64_MIPS_R_SYM(rel->r_info);
+ r_sym = TO_NATIVE(r_sym);
+ r_typ = ELF64_MIPS_R_TYPE(rel->r_info);
+ r.r_info = ELF64_R_INFO(r_sym, r_typ);
+ } else {
+ r.r_info = TO_NATIVE(rel->r_info);
+ r_sym = ELF_R_SYM(r.r_info);
+ }
+#else
+ r.r_info = TO_NATIVE(rel->r_info);
+ r_sym = ELF_R_SYM(r.r_info);
+#endif
+ r.r_addend = 0;
+ switch (elf->hdr->e_machine) {
+ case EM_386:
+ if (addend_386_rel(elf, sechdr, &r))
+ continue;
+ break;
+ case EM_ARM:
+ if (addend_arm_rel(elf, sechdr, &r))
+ continue;
+ break;
+ case EM_MIPS:
+ if (addend_mips_rel(elf, sechdr, &r))
+ continue;
+ break;
+ }
+ sym = elf->symtab_start + r_sym;
+ /* Skip special sections */
+ if (sym->st_shndx >= SHN_LORESERVE)
+ continue;
+ check_section_mismatch(modname, elf, &r, sym, fromsec);
+ }
+}
+
/**
* A module includes a number of sections that are discarded
* either when loaded or when used as built-in.
@@ -998,257 +1448,21 @@ static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r)
* be discarded and warns about it.
**/
static void check_sec_ref(struct module *mod, const char *modname,
- struct elf_info *elf,
- int section(const char*),
- int section_ref_ok(const char *))
+ struct elf_info *elf)
{
int i;
- Elf_Sym *sym;
- Elf_Ehdr *hdr = elf->hdr;
Elf_Shdr *sechdrs = elf->sechdrs;
- const char *secstrings = (void *)hdr +
- sechdrs[hdr->e_shstrndx].sh_offset;
/* Walk through all sections */
- for (i = 0; i < hdr->e_shnum; i++) {
- const char *name = secstrings + sechdrs[i].sh_name;
- const char *secname;
- Elf_Rela r;
- unsigned int r_sym;
+ for (i = 0; i < elf->hdr->e_shnum; i++) {
/* We want to process only relocation sections and not .init */
- if (sechdrs[i].sh_type == SHT_RELA) {
- Elf_Rela *rela;
- Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset;
- Elf_Rela *stop = (void*)start + sechdrs[i].sh_size;
- name += strlen(".rela");
- if (section_ref_ok(name))
- continue;
-
- for (rela = start; rela < stop; rela++) {
- r.r_offset = TO_NATIVE(rela->r_offset);
-#if KERNEL_ELFCLASS == ELFCLASS64
- if (hdr->e_machine == EM_MIPS) {
- unsigned int r_typ;
- r_sym = ELF64_MIPS_R_SYM(rela->r_info);
- r_sym = TO_NATIVE(r_sym);
- r_typ = ELF64_MIPS_R_TYPE(rela->r_info);
- r.r_info = ELF64_R_INFO(r_sym, r_typ);
- } else {
- r.r_info = TO_NATIVE(rela->r_info);
- r_sym = ELF_R_SYM(r.r_info);
- }
-#else
- r.r_info = TO_NATIVE(rela->r_info);
- r_sym = ELF_R_SYM(r.r_info);
-#endif
- r.r_addend = TO_NATIVE(rela->r_addend);
- sym = elf->symtab_start + r_sym;
- /* Skip special sections */
- if (sym->st_shndx >= SHN_LORESERVE)
- continue;
-
- secname = secstrings +
- sechdrs[sym->st_shndx].sh_name;
- if (section(secname))
- warn_sec_mismatch(modname, name,
- elf, sym, r);
- }
- } else if (sechdrs[i].sh_type == SHT_REL) {
- Elf_Rel *rel;
- Elf_Rel *start = (void *)hdr + sechdrs[i].sh_offset;
- Elf_Rel *stop = (void*)start + sechdrs[i].sh_size;
- name += strlen(".rel");
- if (section_ref_ok(name))
- continue;
-
- for (rel = start; rel < stop; rel++) {
- r.r_offset = TO_NATIVE(rel->r_offset);
-#if KERNEL_ELFCLASS == ELFCLASS64
- if (hdr->e_machine == EM_MIPS) {
- unsigned int r_typ;
- r_sym = ELF64_MIPS_R_SYM(rel->r_info);
- r_sym = TO_NATIVE(r_sym);
- r_typ = ELF64_MIPS_R_TYPE(rel->r_info);
- r.r_info = ELF64_R_INFO(r_sym, r_typ);
- } else {
- r.r_info = TO_NATIVE(rel->r_info);
- r_sym = ELF_R_SYM(r.r_info);
- }
-#else
- r.r_info = TO_NATIVE(rel->r_info);
- r_sym = ELF_R_SYM(r.r_info);
-#endif
- r.r_addend = 0;
- switch (hdr->e_machine) {
- case EM_386:
- if (addend_386_rel(elf, i, &r))
- continue;
- break;
- case EM_ARM:
- if(addend_arm_rel(elf, i, &r))
- continue;
- break;
- case EM_MIPS:
- if (addend_mips_rel(elf, i, &r))
- continue;
- break;
- }
- sym = elf->symtab_start + r_sym;
- /* Skip special sections */
- if (sym->st_shndx >= SHN_LORESERVE)
- continue;
-
- secname = secstrings +
- sechdrs[sym->st_shndx].sh_name;
- if (section(secname))
- warn_sec_mismatch(modname, name,
- elf, sym, r);
- }
- }
+ if (sechdrs[i].sh_type == SHT_RELA)
+ section_rela(modname, elf, &elf->sechdrs[i]);
+ else if (sechdrs[i].sh_type == SHT_REL)
+ section_rel(modname, elf, &elf->sechdrs[i]);
}
}
-/*
- * Identify sections from which references to either a
- * .init or a .exit section is OK.
- *
- * [OPD] Keith Ownes <kaos@sgi.com> commented:
- * For our future {in}sanity, add a comment that this is the ppc .opd
- * section, not the ia64 .opd section.
- * ia64 .opd should not point to discarded sections.
- * [.rodata] like for .init.text we ignore .rodata references -same reason
- */
-static int initexit_section_ref_ok(const char *name)
-{
- const char **s;
- /* Absolute section names */
- const char *namelist1[] = {
- "__bug_table", /* used by powerpc for BUG() */
- "__ex_table",
- ".altinstructions",
- ".cranges", /* used by sh64 */
- ".fixup",
- ".machvec", /* ia64 + powerpc uses these */
- ".machine.desc",
- ".opd", /* See comment [OPD] */
- "__dbe_table",
- ".parainstructions",
- ".pdr",
- ".plt", /* seen on ARCH=um build on x86_64. Harmless */
- ".smp_locks",
- ".stab",
- ".m68k_fixup",
- ".xt.prop", /* xtensa informational section */
- ".xt.lit", /* xtensa informational section */
- NULL
- };
- /* Start of section names */
- const char *namelist2[] = {
- ".debug",
- ".eh_frame",
- ".note", /* ignore ELF notes - may contain anything */
- ".got", /* powerpc - global offset table */
- ".toc", /* powerpc - table of contents */
- NULL
- };
- /* part of section name */
- const char *namelist3 [] = {
- ".unwind", /* Sample: IA_64.unwind.exit.text */
- NULL
- };
-
- for (s = namelist1; *s; s++)
- if (strcmp(*s, name) == 0)
- return 1;
- for (s = namelist2; *s; s++)
- if (strncmp(*s, name, strlen(*s)) == 0)
- return 1;
- for (s = namelist3; *s; s++)
- if (strstr(name, *s) != NULL)
- return 1;
- return 0;
-}
-
-
-/*
- * Identify sections from which references to a .init section is OK.
- *
- * Unfortunately references to read only data that referenced .init
- * sections had to be excluded. Almost all of these are false
- * positives, they are created by gcc. The downside of excluding rodata
- * is that there really are some user references from rodata to
- * init code, e.g. drivers/video/vgacon.c:
- *
- * const struct consw vga_con = {
- * con_startup: vgacon_startup,
- *
- * where vgacon_startup is __init. If you want to wade through the false
- * positives, take out the check for rodata.
- */
-static int init_section_ref_ok(const char *name)
-{
- const char **s;
- /* Absolute section names */
- const char *namelist1[] = {
- "__dbe_table", /* MIPS generate these */
- "__ftr_fixup", /* powerpc cpu feature fixup */
- "__fw_ftr_fixup", /* powerpc firmware feature fixup */
- "__param",
- ".data.rel.ro", /* used by parisc64 */
- ".init",
- ".text.lock",
- NULL
- };
- /* Start of section names */
- const char *namelist2[] = {
- ".init.",
- ".pci_fixup",
- ".rodata",
- NULL
- };
-
- if (initexit_section_ref_ok(name))
- return 1;
-
- for (s = namelist1; *s; s++)
- if (strcmp(*s, name) == 0)
- return 1;
- for (s = namelist2; *s; s++)
- if (strncmp(*s, name, strlen(*s)) == 0)
- return 1;
-
- /* If section name ends with ".init" we allow references
- * as is the case with .initcallN.init, .early_param.init, .taglist.init etc
- */
- if (strrcmp(name, ".init") == 0)
- return 1;
- return 0;
-}
-
-/*
- * Identify sections from which references to a .exit section is OK.
- */
-static int exit_section_ref_ok(const char *name)
-{
- const char **s;
- /* Absolute section names */
- const char *namelist1[] = {
- ".exit.data",
- ".exit.text",
- ".exitcall.exit",
- ".rodata",
- NULL
- };
-
- if (initexit_section_ref_ok(name))
- return 1;
-
- for (s = namelist1; *s; s++)
- if (strcmp(*s, name) == 0)
- return 1;
- return 0;
-}
-
static void read_symbols(char *modname)
{
const char *symname;
@@ -1288,10 +1502,9 @@ static void read_symbols(char *modname)
handle_modversions(mod, &info, sym, symname);
handle_moddevtable(mod, &info, sym, symname);
}
- if (is_vmlinux(modname) && vmlinux_section_warnings) {
- check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok);
- check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok);
- }
+ if (!is_vmlinux(modname) ||
+ (is_vmlinux(modname) && vmlinux_section_warnings))
+ check_sec_ref(mod, modname, &info);
version = get_modinfo(info.modinfo, info.modinfo_len, "version");
if (version)
@@ -1365,7 +1578,7 @@ static void check_for_gpl_usage(enum export exp, const char *m, const char *s)
}
}
-static void check_for_unused(enum export exp, const char* m, const char* s)
+static void check_for_unused(enum export exp, const char *m, const char *s)
{
const char *e = is_vmlinux(m) ?"":".ko";
@@ -1398,7 +1611,7 @@ static void check_exports(struct module *mod)
if (!mod->gpl_compatible)
check_for_gpl_usage(exp->export, basename, exp->name);
check_for_unused(exp->export, basename, exp->name);
- }
+ }
}
/**
@@ -1458,13 +1671,12 @@ static int add_versions(struct buffer *b, struct module *mod)
buf_printf(b, "\n");
buf_printf(b, "static const struct modversion_info ____versions[]\n");
- buf_printf(b, "__attribute_used__\n");
+ buf_printf(b, "__used\n");
buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n");
for (s = mod->unres; s; s = s->next) {
- if (!s->module) {
+ if (!s->module)
continue;
- }
if (!s->crc_valid) {
warn("\"%s\" [%s.ko] has no CRC!\n",
s->name, mod->name);
@@ -1485,13 +1697,12 @@ static void add_depends(struct buffer *b, struct module *mod,
struct module *m;
int first = 1;
- for (m = modules; m; m = m->next) {
+ for (m = modules; m; m = m->next)
m->seen = is_vmlinux(m->name);
- }
buf_printf(b, "\n");
buf_printf(b, "static const char __module_depends[]\n");
- buf_printf(b, "__attribute_used__\n");
+ buf_printf(b, "__used\n");
buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n");
buf_printf(b, "\"depends=");
for (s = mod->unres; s; s = s->next) {
@@ -1503,7 +1714,8 @@ static void add_depends(struct buffer *b, struct module *mod,
continue;
s->module->seen = 1;
- if ((p = strrchr(s->module->name, '/')) != NULL)
+ p = strrchr(s->module->name, '/');
+ if (p)
p++;
else
p = s->module->name;
@@ -1575,7 +1787,7 @@ static void read_dump(const char *fname, unsigned int kernel)
void *file = grab_file(fname, &size);
char *line;
- if (!file)
+ if (!file)
/* No symbol versions, silently ignore */
return;
@@ -1598,11 +1810,10 @@ static void read_dump(const char *fname, unsigned int kernel)
crc = strtoul(line, &d, 16);
if (*symname == '\0' || *modname == '\0' || *d != '\0')
goto fail;
-
- if (!(mod = find_module(modname))) {
- if (is_vmlinux(modname)) {
+ mod = find_module(modname);
+ if (!mod) {
+ if (is_vmlinux(modname))
have_vmlinux = 1;
- }
mod = new_module(NOFAIL(strdup(modname)));
mod->skip = 1;
}
@@ -1653,38 +1864,40 @@ int main(int argc, char **argv)
{
struct module *mod;
struct buffer buf = { };
- char fname[SZ];
char *kernel_read = NULL, *module_read = NULL;
char *dump_write = NULL;
int opt;
int err;
- while ((opt = getopt(argc, argv, "i:I:mso:aw")) != -1) {
- switch(opt) {
- case 'i':
- kernel_read = optarg;
- break;
- case 'I':
- module_read = optarg;
- external_module = 1;
- break;
- case 'm':
- modversions = 1;
- break;
- case 'o':
- dump_write = optarg;
- break;
- case 'a':
- all_versions = 1;
- break;
- case 's':
- vmlinux_section_warnings = 0;
- break;
- case 'w':
- warn_unresolved = 1;
- break;
- default:
- exit(1);
+ while ((opt = getopt(argc, argv, "i:I:msSo:aw")) != -1) {
+ switch (opt) {
+ case 'i':
+ kernel_read = optarg;
+ break;
+ case 'I':
+ module_read = optarg;
+ external_module = 1;
+ break;
+ case 'm':
+ modversions = 1;
+ break;
+ case 'o':
+ dump_write = optarg;
+ break;
+ case 'a':
+ all_versions = 1;
+ break;
+ case 's':
+ vmlinux_section_warnings = 0;
+ break;
+ case 'S':
+ sec_mismatch_verbose = 0;
+ break;
+ case 'w':
+ warn_unresolved = 1;
+ break;
+ default:
+ exit(1);
}
}
@@ -1693,9 +1906,8 @@ int main(int argc, char **argv)
if (module_read)
read_dump(module_read, 0);
- while (optind < argc) {
+ while (optind < argc)
read_symbols(argv[optind++]);
- }
for (mod = modules; mod; mod = mod->next) {
if (mod->skip)
@@ -1706,6 +1918,8 @@ int main(int argc, char **argv)
err = 0;
for (mod = modules; mod; mod = mod->next) {
+ char fname[strlen(mod->name) + 10];
+
if (mod->skip)
continue;
@@ -1723,6 +1937,12 @@ int main(int argc, char **argv)
if (dump_write)
write_dump(dump_write);
+ if (sec_mismatch_count && !sec_mismatch_verbose)
+ fprintf(stderr, "modpost: Found %d section mismatch(es).\n"
+ "To see additional details select \"Enable full "
+ "Section mismatch analysis\"\n"
+ "in the Kernel Hacking menu "
+ "(CONFIG_SECTION_MISMATCH).\n", sec_mismatch_count);
return err;
}
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 0ffed17ec20..999f15e0e00 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -17,6 +17,7 @@
#define Elf_Shdr Elf32_Shdr
#define Elf_Sym Elf32_Sym
#define Elf_Addr Elf32_Addr
+#define Elf_Sword Elf64_Sword
#define Elf_Section Elf32_Half
#define ELF_ST_BIND ELF32_ST_BIND
#define ELF_ST_TYPE ELF32_ST_TYPE
@@ -31,6 +32,7 @@
#define Elf_Shdr Elf64_Shdr
#define Elf_Sym Elf64_Sym
#define Elf_Addr Elf64_Addr
+#define Elf_Sword Elf64_Sxword
#define Elf_Section Elf64_Half
#define ELF_ST_BIND ELF64_ST_BIND
#define ELF_ST_TYPE ELF64_ST_TYPE
diff --git a/scripts/package/Makefile b/scripts/package/Makefile
index 7c434e037e7..5e326078a4a 100644
--- a/scripts/package/Makefile
+++ b/scripts/package/Makefile
@@ -89,9 +89,8 @@ clean-dirs += $(objtree)/tar-install/
# Help text displayed when executing 'make help'
# ---------------------------------------------------------------------------
help: FORCE
- @echo ' rpm-pkg - Build the kernel as an RPM package'
- @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel'
- @echo ' and modules'
+ @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
+ @echo ' binrpm-pkg - Build only the binary kernel package'
@echo ' deb-pkg - Build the kernel as an deb package'
@echo ' tar-pkg - Build the kernel as an uncompressed tarball'
@echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
diff --git a/scripts/package/buildtar b/scripts/package/buildtar
index aa0ccdbd1f4..28574ae5517 100644
--- a/scripts/package/buildtar
+++ b/scripts/package/buildtar
@@ -69,8 +69,8 @@ cp -v -- "${objtree}/vmlinux" "${tmpdir}/boot/vmlinux-${KERNELRELEASE}"
# Install arch-specific kernel image(s)
#
case "${ARCH}" in
- i386|x86_64)
- [ -f "${objtree}/arch/$ARCH/boot/bzImage" ] && cp -v -- "${objtree}/arch/$ARCH/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
+ x86|i386|x86_64)
+ [ -f "${objtree}/arch/x86/boot/bzImage" ] && cp -v -- "${objtree}/arch/x86/boot/bzImage" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
;;
alpha)
[ -f "${objtree}/arch/alpha/boot/vmlinux.gz" ] && cp -v -- "${objtree}/arch/alpha/boot/vmlinux.gz" "${tmpdir}/boot/vmlinuz-${KERNELRELEASE}"
diff --git a/scripts/patch-kernel b/scripts/patch-kernel
index 67e4b1868e5..ece46ef0ba5 100755
--- a/scripts/patch-kernel
+++ b/scripts/patch-kernel
@@ -65,7 +65,7 @@ sourcedir=${1-/usr/src/linux}
patchdir=${2-.}
stopvers=${3-default}
-if [ "$1" == -h -o "$1" == --help -o ! -r "$sourcedir/Makefile" ]; then
+if [ "$1" = -h -o "$1" = --help -o ! -r "$sourcedir/Makefile" ]; then
cat << USAGE
usage: $PNAME [-h] [ sourcedir [ patchdir [ stopversion ] [ -acxx ] ] ]
source directory defaults to /usr/src/linux,
@@ -182,10 +182,12 @@ reversePatch () {
}
# set current VERSION, PATCHLEVEL, SUBLEVEL, EXTRAVERSION
-TMPFILE=`mktemp .tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; }
+# force $TMPFILEs below to be in local directory: a slash character prevents
+# the dot command from using the search path.
+TMPFILE=`mktemp ./.tmpver.XXXXXX` || { echo "cannot make temp file" ; exit 1; }
grep -E "^(VERSION|PATCHLEVEL|SUBLEVEL|EXTRAVERSION)" $sourcedir/Makefile > $TMPFILE
tr -d [:blank:] < $TMPFILE > $TMPFILE.1
-source $TMPFILE.1
+. $TMPFILE.1
rm -f $TMPFILE*
if [ -z "$VERSION" -o -z "$PATCHLEVEL" -o -z "$SUBLEVEL" ]
then
@@ -202,11 +204,7 @@ echo "Current kernel version is $VERSION.$PATCHLEVEL.$SUBLEVEL${EXTRAVERSION} ($
EXTRAVER=
if [ x$EXTRAVERSION != "x" ]
then
- if [ ${EXTRAVERSION:0:1} == "." ]; then
- EXTRAVER=${EXTRAVERSION:1}
- else
- EXTRAVER=$EXTRAVERSION
- fi
+ EXTRAVER=${EXTRAVERSION#.}
EXTRAVER=${EXTRAVER%%[[:punct:]]*}
#echo "$PNAME: changing EXTRAVERSION from $EXTRAVERSION to $EXTRAVER"
fi
@@ -251,16 +249,16 @@ while : # incrementing SUBLEVEL (s in v.p.s)
do
CURRENTFULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
EXTRAVER=
- if [ $stopvers == $CURRENTFULLVERSION ]; then
+ if [ $stopvers = $CURRENTFULLVERSION ]; then
echo "Stopping at $CURRENTFULLVERSION base as requested."
break
fi
- SUBLEVEL=$((SUBLEVEL + 1))
+ SUBLEVEL=$(($SUBLEVEL + 1))
FULLVERSION="$VERSION.$PATCHLEVEL.$SUBLEVEL"
#echo "#___ trying $FULLVERSION ___"
- if [ $((SUBLEVEL)) -gt $((STOPSUBLEVEL)) ]; then
+ if [ $(($SUBLEVEL)) -gt $(($STOPSUBLEVEL)) ]; then
echo "Stopping since sublevel ($SUBLEVEL) is beyond stop-sublevel ($STOPSUBLEVEL)"
exit 1
fi
@@ -297,7 +295,7 @@ fi
if [ x$gotac != x ]; then
# Out great user wants the -ac patches
# They could have done -ac (get latest) or -acxx where xx=version they want
- if [ $gotac == "-ac" ]; then
+ if [ $gotac = "-ac" ]; then
# They want the latest version
HIGHESTPATCH=0
for PATCHNAMES in $patchdir/patch-${CURRENTFULLVERSION}-ac*\.*
diff --git a/scripts/setlocalversion b/scripts/setlocalversion
index 82e4993f0a7..52f032e409a 100644
--- a/scripts/setlocalversion
+++ b/scripts/setlocalversion
@@ -12,11 +12,36 @@ cd "${1:-.}" || usage
if head=`git rev-parse --verify HEAD 2>/dev/null`; then
# Do we have an untagged version?
if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then
- printf '%s%s' -g `echo "$head" | cut -c1-8`
+ git describe | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}'
fi
# Are there uncommitted changes?
- if git diff-index HEAD | read dummy; then
+ git update-index --refresh --unmerged > /dev/null
+ if git diff-index --name-only HEAD | grep -v "^scripts/package" \
+ | read dummy; then
printf '%s' -dirty
fi
+
+ # All done with git
+ exit
+fi
+
+# Check for mercurial and a mercurial repo.
+if hgid=`hg id 2>/dev/null`; then
+ tag=`printf '%s' "$hgid" | cut -d' ' -f2`
+
+ # Do we have an untagged version?
+ if [ -z "$tag" -o "$tag" = tip ]; then
+ id=`printf '%s' "$hgid" | sed 's/[+ ].*//'`
+ printf '%s%s' -hg "$id"
+ fi
+
+ # Are there uncommitted changes?
+ # These are represented by + after the changeset id.
+ case "$hgid" in
+ *+|*+\ *) printf '%s' -dirty ;;
+ esac
+
+ # All done with mercurial
+ exit
fi