From 5c98fc0360437327e4034ecfe8b818ad82622100 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 24 Oct 2007 15:08:48 -0700 Subject: kernel-doc: fix xml output mode After Randy's patch fixing the HTML output in DOC: sections (6b5b55f6c404fa730a09a8254eb19f5a038afcc2) the same bug remained in XML mode, this fixes it. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/kernel-doc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 1d1401807e95..e4fa8d9568ba 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -182,10 +182,10 @@ my $blankline_html = $local_lt . "p" . $local_gt; # was "

" my %highlights_xml = ( "([^=])\\\"([^\\\"<]+)\\\"", "\$1\$2", $type_constant, "\$1", $type_func, "\$1", - $type_struct, "\$1", + $type_struct_xml, "\$1", $type_env, "\$1", $type_param, "\$1" ); -my $blankline_xml = "\n"; +my $blankline_xml = $local_lt . "/para" . $local_gt . $local_lt . "para" . $local_gt . "\n"; # gnome, docbook format my %highlights_gnome = ( $type_constant, "\$1", @@ -394,7 +394,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; -- cgit v1.2.3 From 1b9bc22d71c75d4145688428c92c5123bd8697e3 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 24 Oct 2007 15:08:48 -0700 Subject: kernel-doc: init kernel version The kernel-doc script triggers a perl warning when invoked without KERNELVERSION in the environment, rather make it use the string "unknown kernel version" instead. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/kernel-doc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index e4fa8d9568ba..8cf528b5e65a 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -334,7 +334,7 @@ while ($ARGV[0] =~ m/^-(.*)/) { # get kernel version from env sub get_kernel_version() { - my $version; + my $version = 'unknown kernel version'; if (defined($ENV{'KERNELVERSION'})) { $version = $ENV{'KERNELVERSION'}; -- cgit v1.2.3 From b112e0f73fe8e9e69e60bc9d6d16217795259c3c Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 24 Oct 2007 15:08:48 -0700 Subject: kernel-doc: single DOC: selection Currently, DOC: sections are always output even if only a single function is requested, fix this and also make it possible to just output a single DOC: section by giving its title as the function name to output. Also fixes docbook XML well-formedness for sections with examples. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/kernel-doc | 63 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 20 deletions(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 8cf528b5e65a..8255f723b7e8 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -54,13 +54,13 @@ use strict; # Set output format using one of -docbook -html -text or -man. Default is man. # # -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 # @@ -373,6 +373,25 @@ 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 (($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 # @@ -564,8 +583,8 @@ sub output_function_html(%) { print "


\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 +890,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 +901,23 @@ sub output_intro_xml(%) { # print out each section $lineprefix=" "; foreach $section (@{$args{'sectionlist'}}) { - print "\n $section\n \n"; + if (!$args{'content-only'}) { + print "\n $section\n"; + } if ($section =~ m/EXAMPLE/i) { print "\n"; + } else { + print "\n"; } output_highlight($args{'sections'}{$section}); if ($section =~ m/EXAMPLE/i) { print "\n"; + } else { + print ""; + } + if (!$args{'content-only'}) { + print "\n\n"; } - print " \n\n"; } print "\n\n"; @@ -1137,7 +1164,7 @@ sub output_typedef_man(%) { } } -sub output_intro_man(%) { +sub output_blockhead_man(%) { my %args = %{$_[0]}; my ($parameter, $section); my $count; @@ -1294,7 +1321,7 @@ sub output_struct_text(%) { output_section_text(@_); } -sub output_intro_text(%) { +sub output_blockhead_text(%) { my %args = %{$_[0]}; my ($parameter, $section); @@ -1325,9 +1352,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 +1953,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 +1971,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 = (); -- cgit v1.2.3 From 4b44595a7b8e0ebf3fce108df65d8cd6a6cf4910 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 24 Oct 2007 15:08:48 -0700 Subject: kernel-doc: process functions, not DOC: This flag is necessary for the next patch for docproc to output only the functions and not DOC: sections when a function list is requested. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/kernel-doc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 8255f723b7e8..ec54f12f57b0 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc @@ -46,13 +46,16 @@ 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) or # DOC: section titles. All other functions and DOC: sections are ignored. @@ -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,6 +333,8 @@ while ($ARGV[0] =~ m/^-(.*)/) { usage(); } elsif ($cmd eq '-filelist') { $filelist = shift @ARGV; + } elsif ($cmd eq '-no-doc-sections') { + $no_doc_sections = 1; } } @@ -380,6 +386,10 @@ 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}))) -- cgit v1.2.3 From 2e95972c44ca7b3dd3c5d6ff08745b56ddfa55bc Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 24 Oct 2007 15:08:48 -0700 Subject: kernel-doc: use no-doc option When asked by a template to include all functions from a file, it will also include DOC: sections wreaking havoc in the generated docbook file. This patch makes it use the new -no-doc-sections flag for kernel-doc to avoid this. Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/basic/docproc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index 0e4bd5459df4..7eae53419a48 100644 --- a/scripts/basic/docproc.c +++ b/scripts/basic/docproc.c @@ -65,6 +65,7 @@ FILELINE * entity_system; #define DOCBOOK "-docbook" #define FUNCTION "-function" #define NOFUNCTION "-nofunction" +#define NODOCSECTIONS "-no-doc-sections" char *srctree; @@ -231,13 +232,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++) { -- cgit v1.2.3 From e662af4281af27f95b1ec2c5eff056328a672fd7 Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Wed, 24 Oct 2007 15:08:48 -0700 Subject: kernel-doc: new P directive for DOC: sections The !P directive includes the contents of a DOC: section given by title, e.g. !Pfilename Title of the section Signed-off-by: Johannes Berg Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/basic/docproc.c | 40 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c index 7eae53419a48..35bdc68b6e66 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 @@ -288,13 +290,37 @@ void singfunc(char * filename, char * line) exec_kernel_doc(vec); } +/* + * 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) { @@ -328,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); } @@ -374,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 */ @@ -383,6 +419,7 @@ int main(int argc, char *argv[]) externalfunctions = extfunc; symbolsonly = printline; singlefunctions = singfunc; + docsection = docsect; parse_file(infile); } @@ -396,6 +433,7 @@ int main(int argc, char *argv[]) externalfunctions = adddep; symbolsonly = adddep; singlefunctions = adddep2; + docsection = adddep2; parse_file(infile); printf("\n"); } -- cgit v1.2.3 From ec2d987f98ba775596d0b17d783669b7eda7bae2 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Sun, 4 Nov 2007 12:01:55 -0800 Subject: kbuild: add 'includecheck' help text Add 'includecheck' to the Static analyzers help list. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 6d419f67939c..2101e4159e38 100644 --- a/Makefile +++ b/Makefile @@ -1188,6 +1188,7 @@ help: @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs' @echo ' namespacecheck - Name space analysis on compiled kernel' + @echo ' includecheck - Check for duplicate included header files' @echo ' export_report - List the usages of all exported symbols' @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ echo ' headers_check - Sanity check on exported headers'; \ -- cgit v1.2.3 From aa025e7d5cfbcf9f397c3d734666c91179c934d6 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 14 Nov 2007 21:34:55 +0100 Subject: kbuild: document versioncheck in make help Signed-off-by: Sam Ravnborg --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 2101e4159e38..d0ffbeb51942 100644 --- a/Makefile +++ b/Makefile @@ -1188,6 +1188,7 @@ help: @echo 'Static analysers' @echo ' checkstack - Generate a list of stack hogs' @echo ' namespacecheck - Name space analysis on compiled kernel' + @echo ' versioncheck - Sanity check on version.h usage' @echo ' includecheck - Check for duplicate included header files' @echo ' export_report - List the usages of all exported symbols' @if [ -r $(srctree)/include/asm-$(SRCARCH)/Kbuild ]; then \ -- cgit v1.2.3 From 800074345544ae6ec06c77b1a3f7ba032f84bd10 Mon Sep 17 00:00:00 2001 From: Geert Uytterhoeven Date: Mon, 5 Nov 2007 11:51:44 +0100 Subject: kbuild: Add missing srctree prefix for includecheck and versioncheck Add missing $(srctree)/ prefix for scripts used by the includecheck and versioncheck make targets Signed-off-by: Geert Uytterhoeven Signed-off-by: Sam Ravnborg --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index d0ffbeb51942..344defd0f918 100644 --- a/Makefile +++ b/Makefile @@ -1430,12 +1430,12 @@ tags: FORCE includecheck: find * $(RCS_FIND_IGNORE) \ -name '*.[hcS]' -type f -print | sort \ - | xargs $(PERL) -w scripts/checkincludes.pl + | xargs $(PERL) -w $(srctree)/scripts/checkincludes.pl versioncheck: find * $(RCS_FIND_IGNORE) \ -name '*.[hcS]' -type f -print | sort \ - | xargs $(PERL) -w scripts/checkversion.pl + | xargs $(PERL) -w $(srctree)/scripts/checkversion.pl namespacecheck: $(PERL) $(srctree)/scripts/namespace.pl -- cgit v1.2.3 From 9e233625fbee1f977929a5406533b96011f1a06b Mon Sep 17 00:00:00 2001 From: Johannes Berg Date: Thu, 8 Nov 2007 12:59:13 +0100 Subject: convert drivers/base/power/Makefile to ccflags This patch converts drivers/base/power/Makefile to use ccflags instead of EXTRA_CFLAGS. Signed-off-by: Johannes Berg Signed-off-by: Sam Ravnborg --- drivers/base/power/Makefile | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/drivers/base/power/Makefile b/drivers/base/power/Makefile index 06a86fe6a78d..de28dfd3b96c 100644 --- a/drivers/base/power/Makefile +++ b/drivers/base/power/Makefile @@ -2,9 +2,5 @@ obj-$(CONFIG_PM) += sysfs.o obj-$(CONFIG_PM_SLEEP) += main.o obj-$(CONFIG_PM_TRACE) += trace.o -ifeq ($(CONFIG_DEBUG_DRIVER),y) -EXTRA_CFLAGS += -DDEBUG -endif -ifeq ($(CONFIG_PM_VERBOSE),y) -EXTRA_CFLAGS += -DDEBUG -endif +ccflags-$(CONFIG_DEBUG_DRIVER) := -DDEBUG +ccflags-$(CONFIG_PM_VERBOSE) += -DDEBUG -- cgit v1.2.3 From 551559e13af1ccd19d0525cb2b0f308905170647 Mon Sep 17 00:00:00 2001 From: Tejun Heo Date: Fri, 7 Dec 2007 21:04:30 +0900 Subject: kbuild: implement modules.order When multiple built-in modules (especially drivers) provide the same capability, they're prioritized by link order specified by the order listed in Makefile. This implicit ordering is lost for loadable modules. When driver modules are loaded by udev, what comes first in modules.alias file is selected. However, the order in this file is indeterministic (depends on filesystem listing order of installed modules). This causes confusion. The solution is two-parted. This patch updates kbuild such that it generates and installs modules.order which contains the name of modules ordered according to Makefile. The second part is update to depmod such that it generates output files according to this file. Note that both obj-y and obj-m subdirs can contain modules and ordering information between those two are lost from beginning. Currently obj-y subdirs are put before obj-m subdirs. Sam Ravnborg cleaned up Makefile modifications and suggested using awk to remove duplicate lines from modules.order instead of using separate C program. Signed-off-by: Tejun Heo Acked-by: Greg Kroah-Hartman Cc: Bill Nottingham Cc: Rusty Russell Cc: Kay Sievers Cc: Jon Masters Signed-off-by: Sam Ravnborg --- Makefile | 8 +++++++- scripts/Makefile.build | 17 ++++++++++++++++- scripts/Makefile.lib | 6 ++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 344defd0f918..f8d1fd525e17 100644 --- a/Makefile +++ b/Makefile @@ -1021,9 +1021,14 @@ ifdef CONFIG_MODULES all: modules # Build modules +# +# A module can be listed more than once in obj-m resulting in +# duplicate lines in modules.order files. Those are removed +# using awk while concatenating to the final file. PHONY += modules modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux) + $(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order @echo ' Building modules, stage 2.'; $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost @@ -1051,6 +1056,7 @@ _modinst_: rm -f $(MODLIB)/build ; \ ln -s $(objtree) $(MODLIB)/build ; \ fi + @cp -f $(objtree)/modules.order $(MODLIB)/ $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modinst # This depmod is only for convenience to give the initial @@ -1110,7 +1116,7 @@ clean: archclean $(clean-dirs) @find . $(RCS_FIND_IGNORE) \ \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ - -o -name '*.symtypes' \) \ + -o -name '*.symtypes' -o -name 'modules.order' \) \ -type f -print | xargs rm -f # mrproper - Delete all generated files, including .config diff --git a/scripts/Makefile.build b/scripts/Makefile.build index de9836eee8bb..db38ef465a63 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) @: @@ -275,6 +277,19 @@ $(builtin-target): $(obj-y) FORCE 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 # diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 3c5e88bfecf1..8e440233c27d 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)) -- cgit v1.2.3 From 6e588f6dcfcffa24decf418b96b4184a907d2bf8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 9 Dec 2007 20:11:15 +0100 Subject: kconfig: if ncurses-devel is missing then say so With this patch when ncurses-devel (or whatever it is named) is missing trying to run menuconfig will result in this: $ make menuconfig HOSTCC scripts/kconfig/conf.o HOSTCC scripts/kconfig/kxgettext.o *** Unable to find the ncurses libraries or the *** required header files. *** 'make menuconfig' requires the ncurses libraries. *** *** Install ncurses (ncurses-devel) and try again. *** make[1]: *** [scripts/kconfig/dochecklxdialog] Error 1 make: *** [menuconfig] Error 2 Much better than before where we just listed some build errors. The other *config targets will work indepenednt on ncurses being present or not. Includes improvements suggested by: Frans Pop Signed-off-by: Sam Ravnborg Cc: Frans Pop --- scripts/kconfig/Makefile | 14 ++++++++------ scripts/kconfig/lxdialog/check-lxdialog.sh | 16 +++++++++------- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 1ad6f7fc490a..80914358817e 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -93,12 +93,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: @@ -145,6 +139,14 @@ clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c clean-files += mconf qconf gconf +# 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)) diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh index 9681476b96e7..62e1e02126e6 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 } -- cgit v1.2.3 From 6d9a89ea4b06146d29e1ffb4d6fded286fa07d29 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Thu, 22 Nov 2007 03:43:08 +0100 Subject: kbuild: declare the modpost error functions as printf like This way gcc can warn for wrong format strings Signed-off-by: Andi Kleen Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 93ac52adb498..3a12c22cc2f8 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -33,7 +33,9 @@ enum export { 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 +48,7 @@ void fatal(const char *fmt, ...) exit(1); } -void warn(const char *fmt, ...) +PRINTF void warn(const char *fmt, ...) { va_list arglist; @@ -57,7 +59,7 @@ void warn(const char *fmt, ...) va_end(arglist); } -void merror(const char *fmt, ...) +PRINTF void merror(const char *fmt, ...) { va_list arglist; -- cgit v1.2.3 From 58b7a68de37face98afe7c705391145795a982b5 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Thu, 22 Nov 2007 03:43:09 +0100 Subject: kbuild: fix format string warnings in modpost Fix wrong format strings in modpost exposed by the previous patch. Including one missing argument -- some random data was printed instead. Signed-off-by: Andi Kleen Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3a12c22cc2f8..404ee0d0aac6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -388,7 +388,7 @@ 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 then filesize=%lu\n", (unsigned long)hdr->e_shoff, filename, info->size); return 0; } @@ -409,7 +409,7 @@ 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)=%lu\n", filename, (unsigned long)sechdrs[i].sh_offset, sizeof(*hdr)); return 0; } secname = secstrings + sechdrs[i].sh_name; @@ -907,7 +907,8 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, "before '%s' (at offset -0x%llx)\n", modname, fromsec, (unsigned long long)r.r_offset, secname, refsymname, - elf->strtab + after->st_name); + elf->strtab + after->st_name, + (unsigned long long)r.r_offset); } else { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s\n", modname, fromsec, (unsigned long long)r.r_offset, -- cgit v1.2.3 From 666ab414fe14e8bbbe86a110437346128e1ec869 Mon Sep 17 00:00:00 2001 From: Andi Kleen Date: Thu, 22 Nov 2007 03:43:10 +0100 Subject: kbuild: fix a buffer overflow in modpost When passing an file name > 1k the stack could be overflowed. Not really a security issue, but still better plugged. Signed-off-by: Andi Kleen Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 404ee0d0aac6..4d1c59063b27 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1656,7 +1656,6 @@ 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; @@ -1709,6 +1708,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; -- cgit v1.2.3 From 2f4b489b77c68b9cba1bd9dec5a1bbf0ab3c47f8 Mon Sep 17 00:00:00 2001 From: Andres Salomon Date: Mon, 17 Dec 2007 01:34:58 -0500 Subject: kconfig: use getopt() in conf.c for handling command line arguments Switch from doing our own parsing of command line arguments to using getopt(3) to do it. Aside from simplifying things, this allows us to specify multiple arguments; the old code could only accept two arguments (input_mode and kconfig name). Note some subtle changes: - The argument '-?' is no longer supported. - '-h' is not treated as an error, so output goes to stdout, and we exit with '0'. - There is no compatibility checking amongst arguments; the last option will simply override earlier options. For example, 'conf -n -y foo' is perfectly valid now (input_mode will be set_yes). Previously, that would have been an error ("can't find file -y"). Signed-off-by: Andres Salomon Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/conf.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 8d6f17490c5e..d4737d35e720 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -495,12 +495,12 @@ 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]) { + while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { + switch (opt) { case 'o': input_mode = ask_new; break; @@ -513,12 +513,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; @@ -534,16 +529,19 @@ int main(int ac, char **av) srandom(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) { -- cgit v1.2.3 From 3dce174cfcba11026b028d33bed0438b80e37124 Mon Sep 17 00:00:00 2001 From: Aron Griffis Date: Wed, 28 Nov 2007 16:55:44 -0500 Subject: kbuild: support mercurial in setlocalversion This represents mercurial changesets similarly to git. For untagged revisions, append the changeset id. If there are uncommitted changes, append -dirty. For example, -hgc60016ba6237-dirty Signed-off-by: Aron Griffis Signed-off-by: Sam Ravnborg --- scripts/setlocalversion | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 82e4993f0a73..a80d6ea8a5bf 100644 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -19,4 +19,27 @@ if head=`git rev-parse --verify HEAD 2>/dev/null`; then if git diff-index HEAD | 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 -- cgit v1.2.3 From 899c38420c56b20e12a31fe9adfa92cd21782370 Mon Sep 17 00:00:00 2001 From: "Robert P. J. Day" Date: Thu, 29 Nov 2007 10:46:38 -0500 Subject: Kbuild: Clarify the rpm-related make packaging targets Signed-off-by: Robert P. J. Day Signed-off-by: Sam Ravnborg --- Makefile | 1 - scripts/package/Makefile | 5 ++--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index f8d1fd525e17..953359ed9871 100644 --- a/Makefile +++ b/Makefile @@ -1181,7 +1181,6 @@ help: @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[ois] - Build specified target only' @echo ' dir/file.ko - Build module including final link' - @echo ' rpm - Build a kernel as an RPM package' @echo ' tags/TAGS - Generate tags file for editors' @echo ' cscope - Generate cscope index' @echo ' kernelrelease - Output the release version string' diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 7c434e037e7f..5e326078a4a2 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' -- cgit v1.2.3 From 0484f1299fb504d57f388e5cdaba85ed59f32ca0 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 31 Dec 2007 14:22:55 +0100 Subject: kbuild: fix buglet in gcc-version.sh Greg Schafer reported: ==== $make mrproper scripts/gcc-version.sh: [[: command not found This is on a very old host with an ancient bash as /bin/sh. But I have CONFIG_SHELL set and pointing to a modern bash. Something is wrong. This doesn't happen with 2.6.23 ==== Fixed using a more common string equality test. Signed-off-by: Sam Ravnborg Cc: Greg Schafer Cc: Jesper Juhl --- scripts/gcc-version.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh index a5121a6d8949..cc767b388baf 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="$*" -- cgit v1.2.3 From c6025f4c8bbe147b8773f04ce5a7d2ca7f4a6a5c Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 31 Dec 2007 14:26:12 +0100 Subject: kbuild: ignore *.order files Introducing the new modules.order patch created a number of additional files. Teach git to ignore them. Signed-off-by: Sam Ravnborg Acked-by: Tejun Heo --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8d14531846b9..8363e48cdcdc 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ *.i *.lst *.symtypes +*.order # # Top-level generic files -- cgit v1.2.3 From 36091fd348e79ab703b0766420c0b06ff7662d2d Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 10 Nov 2007 09:32:20 -0500 Subject: kbuild: fixup genksyms usage/getopt The usage does not mention the "-a,--arch" or "-T,--dump-types" options, so add them. The calls to getopt() seem to mention options that no longer exist (some "k" and "p" thingy) but omits the "h" option which means using '-h' actually triggers the error code path, so update those as well. Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg --- scripts/genksyms/genksyms.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index 511023b430a8..dca5e0dd09bf 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': -- cgit v1.2.3 From 7998a731664ac4988b349e70669bac11e3b3a3ac Mon Sep 17 00:00:00 2001 From: "Robert P. J. Day" Date: Mon, 31 Dec 2007 14:58:38 +0100 Subject: A few corrections to include/linux/Kbuild auxvec.h, i2c-dev.h and vt.h *should* be unifdef'ed i2o-dev.h does not need unifdef'ing Signed-off-by: Robert P. J. Day Cc: David Woodhouse Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg --- include/linux/Kbuild | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/linux/Kbuild b/include/linux/Kbuild index bd694f779346..ad99ce9f9169 100644 --- a/include/linux/Kbuild +++ b/include/linux/Kbuild @@ -34,7 +34,6 @@ header-y += atmsap.h header-y += atmsvc.h header-y += atm_zatm.h header-y += auto_fs4.h -header-y += auxvec.h header-y += ax25.h header-y += b1lli.h header-y += baycom.h @@ -73,7 +72,7 @@ header-y += gen_stats.h header-y += gigaset_dev.h header-y += hdsmart.h header-y += hysdn_if.h -header-y += i2c-dev.h +header-y += i2o-dev.h header-y += i8k.h header-y += if_arcnet.h header-y += if_bonding.h @@ -158,7 +157,6 @@ header-y += veth.h header-y += video_decoder.h header-y += video_encoder.h header-y += videotext.h -header-y += vt.h header-y += x25.h unifdef-y += acct.h @@ -173,6 +171,7 @@ unifdef-y += atm.h unifdef-y += atm_tcp.h unifdef-y += audit.h unifdef-y += auto_fs.h +unifdef-y += auxvec.h unifdef-y += binfmts.h unifdef-y += capability.h unifdef-y += capi.h @@ -214,7 +213,7 @@ unifdef-y += hdreg.h unifdef-y += hiddev.h unifdef-y += hpet.h unifdef-y += i2c.h -unifdef-y += i2o-dev.h +unifdef-y += i2c-dev.h unifdef-y += icmp.h unifdef-y += icmpv6.h unifdef-y += if_addr.h @@ -349,6 +348,7 @@ unifdef-y += videodev.h unifdef-y += virtio_config.h unifdef-y += virtio_blk.h unifdef-y += virtio_net.h +unifdef-y += vt.h unifdef-y += wait.h unifdef-y += wanrouter.h unifdef-y += watchdog.h -- cgit v1.2.3 From 9b213118fa4b79afe9a2718faca244ac581a96b6 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 1 Jan 2008 13:40:28 +0100 Subject: kbuild: fix installing external modules Eric Sandeen reported: Installing external modules is supposed to put them in some path under /lib/modules//extra/subdir/, but this change: http://linux.bkbits.net:8080/linux-2.6/?PAGE=cset&REV=1.1982.9.23 makes them go under /lib/modules//extrasubdir (for example, make M=fs/ext3 modules_install puts ext3.ko in /lib/modules//extrafs/ext3.ko) This was the case only when specifying a trailing slash to M=.. Fixed by removing trailing slash if present so we correctly match dir part of target. Signed-off-by: Sam Ravnborg Cc: Eric Sandeen --- scripts/Makefile.modinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index f0ff248f5e6f..efa5d940e632 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)) -- cgit v1.2.3 From 42d71c44d5fc09ae47783b7e15fe0d6b60711230 Mon Sep 17 00:00:00 2001 From: WANG Cong Date: Wed, 2 Jan 2008 14:27:59 +0800 Subject: CRIS: Remove 'TOPDIR' from Makefiles This patch removes TOPDIR from Cris Makefiles. Cc: Mikael Starvik Cc: Jesper Nilsson Cc: Andreas Schwab Signed-off-by: WANG Cong Signed-off-by: Sam Ravnborg Acked-by: Jesper Nilsson --- arch/cris/arch-v32/boot/compressed/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/cris/arch-v32/boot/compressed/Makefile b/arch/cris/arch-v32/boot/compressed/Makefile index 9f77eda914ba..609692f9d5eb 100644 --- a/arch/cris/arch-v32/boot/compressed/Makefile +++ b/arch/cris/arch-v32/boot/compressed/Makefile @@ -7,7 +7,7 @@ target = $(target_compressed_dir) src = $(src_compressed_dir) -CC = gcc-cris -mlinux -march=v32 -I $(TOPDIR)/include +CC = gcc-cris -mlinux -march=v32 $(LINUXINCLUDE) CFLAGS = -O2 LD = gcc-cris -mlinux -march=v32 -nostdlib OBJCOPY = objcopy-cris -- cgit v1.2.3 From aff5905778d2fb1826ec623e4b1da3a7ff048ca4 Mon Sep 17 00:00:00 2001 From: WANG Cong Date: Tue, 1 Jan 2008 21:41:08 +0800 Subject: INFINIBAND: Remove 'TOPDIR' from Makefiles This patch removes TOPDIR from infiniband Makefile and delete one include statement pointing to a non-existing directory Cc: Roland Dreier Cc: Sean Hefty Cc: Hal Rosenstock Signed-off-by: WANG Cong Signed-off-by: Sam Ravnborg --- drivers/infiniband/hw/cxgb3/Makefile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/infiniband/hw/cxgb3/Makefile b/drivers/infiniband/hw/cxgb3/Makefile index 36b98989b15e..7e7b5a66f042 100644 --- a/drivers/infiniband/hw/cxgb3/Makefile +++ b/drivers/infiniband/hw/cxgb3/Makefile @@ -1,5 +1,4 @@ -EXTRA_CFLAGS += -I$(TOPDIR)/drivers/net/cxgb3 \ - -I$(TOPDIR)/drivers/infiniband/hw/cxgb3/core +EXTRA_CFLAGS += -Idrivers/net/cxgb3 obj-$(CONFIG_INFINIBAND_CXGB3) += iw_cxgb3.o -- cgit v1.2.3 From abee8ed09a2093299673400a9cd3882f21e8e767 Mon Sep 17 00:00:00 2001 From: WANG Cong Date: Tue, 1 Jan 2008 22:00:04 +0800 Subject: FRV: Drop 'TOPDIR' from Makefiles This patch drops TOPDIR from frv Makefiles. Cc: David Howells Signed-off-by: WANG Cong Signed-off-by: Sam Ravnborg --- arch/frv/boot/Makefile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/frv/boot/Makefile b/arch/frv/boot/Makefile index dc6f03824423..6ae3254da019 100644 --- a/arch/frv/boot/Makefile +++ b/arch/frv/boot/Makefile @@ -10,7 +10,7 @@ targets := Image zImage bootpImage -SYSTEM =$(TOPDIR)/$(LINUX) +SYSTEM =$(LINUX) ZTEXTADDR = 0x02080000 PARAMS_PHYS = 0x0207c000 @@ -45,7 +45,7 @@ zImage: $(CONFIGURE) compressed/$(LINUX) bootpImage: bootp/bootp $(OBJCOPY) -O binary -R .note -R .comment -S bootp/bootp $@ -compressed/$(LINUX): $(TOPDIR)/$(LINUX) dep +compressed/$(LINUX): $(LINUX) dep @$(MAKE) -C compressed $(LINUX) bootp/bootp: zImage initrd @@ -59,10 +59,10 @@ initrd: # installation # install: $(CONFIGURE) Image - sh ./install.sh $(KERNELRELEASE) Image $(TOPDIR)/System.map "$(INSTALL_PATH)" + sh ./install.sh $(KERNELRELEASE) Image System.map "$(INSTALL_PATH)" zinstall: $(CONFIGURE) zImage - sh ./install.sh $(KERNELRELEASE) zImage $(TOPDIR)/System.map "$(INSTALL_PATH)" + sh ./install.sh $(KERNELRELEASE) zImage System.map "$(INSTALL_PATH)" # # miscellany -- cgit v1.2.3 From 7491a76b23f5100823098b9d5d74ef18a2ca0dc1 Mon Sep 17 00:00:00 2001 From: WANG Cong Date: Wed, 2 Jan 2008 13:55:33 +0800 Subject: FS: Remove dead code Remove dead code in smbfs makefile. Cc: Al Viro Cc: Tim Shimmin Signed-off-by: WANG Cong Signed-off-by: Sam Ravnborg --- fs/smbfs/Makefile | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/fs/smbfs/Makefile b/fs/smbfs/Makefile index 6673ee82cb4c..4faf8c4722c3 100644 --- a/fs/smbfs/Makefile +++ b/fs/smbfs/Makefile @@ -16,23 +16,3 @@ EXTRA_CFLAGS += -DSMBFS_PARANOIA #EXTRA_CFLAGS += -DDEBUG_SMB_TIMESTAMP #EXTRA_CFLAGS += -Werror -# -# Maintainer rules -# - -# getopt.c not included. It is intentionally separate -SRC = proc.c dir.c cache.c sock.c inode.c file.c ioctl.c smbiod.c request.c \ - symlink.c - -proto: - -rm -f proto.h - @echo > proto2.h "/*" - @echo >> proto2.h " * Autogenerated with cproto on: " `date` - @echo >> proto2.h " */" - @echo >> proto2.h "" - @echo >> proto2.h "struct smb_request;" - @echo >> proto2.h "struct sock;" - @echo >> proto2.h "struct statfs;" - @echo >> proto2.h "" - cproto -E "gcc -E" -e -v -I $(TOPDIR)/include -DMAKING_PROTO -D__KERNEL__ $(SRC) >> proto2.h - mv proto2.h proto.h -- cgit v1.2.3 From 22d6a6a018d897c9c77c6af164722926e70108fa Mon Sep 17 00:00:00 2001 From: Andreas Mohr Date: Sat, 17 Nov 2007 21:51:25 +0100 Subject: kbuild: eradicate bashisms in scripts/patch-kernel Make the patch-kernel shell script sufficiently compatible with POSIX shells, i.e., remove bashisms from scripts/patch-kernel. This means that it now also works on dash 0.5.3-5 and still works on bash 3.1dfsg-8. Full changelog: - replaced non-standard "==" by standard "=" - replaced non-standard "source" statement by POSIX "dot" command - use leading ./ on mktemp filename to force the tempfile to a local directory, so that the search path is not used - replace bash syntax to remove leading dot by similar POSIX syntax - added missing (optional/not required) $ signs to shell variable names Signed-off-by: Andreas Mohr Acked-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/patch-kernel | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/scripts/patch-kernel b/scripts/patch-kernel index 67e4b1868e50..ece46ef0ba54 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*\.* -- cgit v1.2.3 From d882421f4e08ddf0a94245cdbe516db260aa6f41 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 2 Nov 2007 21:52:59 -0400 Subject: kbuild: change CONFIG_LOCALVERSION_AUTO to use a git-describe-ish format Change the automatic local version to have the form -nnnnn-gSHA1SUMID, where 'nnnnn' is the number of commits since the last tag (i.e., 2.6.21-rc7). This makes it much more likely that the package names created for the kernel will look "newer" to a package manager. Signed-off-by: "Theodore Ts'o" Signed-off-by: Sam Ravnborg --- scripts/setlocalversion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index a80d6ea8a5bf..1b31da843672 100644 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -12,7 +12,7 @@ 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? -- cgit v1.2.3 From 4e7434ff028c4280bed620f28fdbf9f4d77d77ce Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 2 Nov 2007 21:53:00 -0400 Subject: kbuild: fix scripts/setlocalversion to avoid erroneous -dirty tag If git's index file is out of date, and some files have been touched such that their timestamp doesn't what is in the index, "git diff-index HEAD" may show that a particular file is dirty, when in fact it really isn't. Running "git update-index" will update the index to avoid these false positives. Signed-off-by: "Theodore Ts'o" Signed-off-by: Sam Ravnborg --- scripts/setlocalversion | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 1b31da843672..acce8ebc5d40 100644 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -16,6 +16,7 @@ if head=`git rev-parse --verify HEAD 2>/dev/null`; then fi # Are there uncommitted changes? + git update-index --refresh --unmerged > /dev/null if git diff-index HEAD | read dummy; then printf '%s' -dirty fi -- cgit v1.2.3 From b052ce4c840e2da3c72ab7dadb97d1094f6e3a89 Mon Sep 17 00:00:00 2001 From: Theodore Ts'o Date: Fri, 2 Nov 2007 21:53:01 -0400 Subject: kbuild: fix false positive -dirty tag caused by make-kpkg make-kpkg modifies scripts/package/Makefile and deletes scripts/package/builddeb as part of its build process. Ignore these changes so the tree isn't marked as -dirty, when it is just an artifact of make-kpkg. (make-kpkg clean restores the files to their original state, and these helper scripts won't affect the final compiled kernel in any way.) Signed-off-by: "Theodore Ts'o" Signed-off-by: Sam Ravnborg --- scripts/setlocalversion | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/setlocalversion b/scripts/setlocalversion index acce8ebc5d40..52f032e409a3 100644 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion @@ -17,7 +17,8 @@ if head=`git rev-parse --verify HEAD 2>/dev/null`; then # Are there uncommitted changes? git update-index --refresh --unmerged > /dev/null - if git diff-index HEAD | read dummy; then + if git diff-index --name-only HEAD | grep -v "^scripts/package" \ + | read dummy; then printf '%s' -dirty fi -- cgit v1.2.3 From 0486bc9098f4556a0aa90d57f717d08164b7647e Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 12 Nov 2007 16:17:55 -0800 Subject: kconfig: add hints/tips/tricks to Documentation/kbuild/kconfig-language.txt Add a section on kconfig hints: how to do in Kconfig files. Fix a few typos/spellos. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- Documentation/kbuild/kconfig-language.txt | 54 +++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index 616043a6da99..53ca12f7999f 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt @@ -24,7 +24,7 @@ visible if its parent entry is also visible. Menu entries ------------ -Most entries define a config option, all other entries help to organize +Most entries define a config option; all other entries help to organize them. A single configuration option is defined like this: config MODVERSIONS @@ -50,7 +50,7 @@ applicable everywhere (see syntax). - type definition: "bool"/"tristate"/"string"/"hex"/"int" Every config option must have a type. There are only two basic types: - tristate and string, the other types are based on these two. The type + tristate and string; the other types are based on these two. The type definition optionally accepts an input prompt, so these two examples are equivalent: @@ -108,7 +108,7 @@ applicable everywhere (see syntax). equal to 'y' without visiting the dependencies. So abusing select you are able to select a symbol FOO even if FOO depends on BAR that is not set. In general use select only for - non-visible symbols (no promts anywhere) and for symbols with + non-visible symbols (no prompts anywhere) and for symbols with no dependencies. That will limit the usefulness but on the other hand avoid the illegal configurations all over. kconfig should one day warn about such things. @@ -162,9 +162,9 @@ An expression can have a value of 'n', 'm' or 'y' (or 0, 1, 2 respectively for calculations). A menu entry becomes visible when it's expression evaluates to 'm' or 'y'. -There are two types of symbols: constant and nonconstant symbols. -Nonconstant symbols are the most common ones and are defined with the -'config' statement. Nonconstant symbols consist entirely of alphanumeric +There are two types of symbols: constant and non-constant symbols. +Non-constant symbols are the most common ones and are defined with the +'config' statement. Non-constant symbols consist entirely of alphanumeric characters or underscores. Constant symbols are only part of expressions. Constant symbols are always surrounded by single or double quotes. Within the quote, any @@ -301,3 +301,45 @@ mainmenu: This sets the config program's title bar if the config program chooses to use it. + + +Kconfig hints +------------- +This is a collection of Kconfig tips, most of which aren't obvious at +first glance and most of which have become idioms in several Kconfig +files. + +Build as module only +~~~~~~~~~~~~~~~~~~~~ +To restrict a component build to module-only, qualify its config symbol +with "depends on m". E.g.: + +config FOO + depends on BAR && m + +limits FOO to module (=m) or disabled (=n). + + +Build limited by a third config symbol which may be =y or =m +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +A common idiom that we see (and sometimes have problems with) is this: + +When option C in B (module or subsystem) uses interfaces from A (module +or subsystem), and both A and B are tristate (could be =y or =m if they +were independent of each other, but they aren't), then we need to limit +C such that it cannot be built statically if A is built as a loadable +module. (C already depends on B, so there is no dependency issue to +take care of here.) + +If A is linked statically into the kernel image, C can be built +statically or as loadable module(s). However, if A is built as loadable +module(s), then C must be restricted to loadable module(s) also. This +can be expressed in kconfig language as: + +config C + depends on A = y || A = B + +or for real examples, use this command in a kernel tree: + +$ find . -name Kconfig\* | xargs grep -ns "depends on.*=.*||.*=" | grep -v orig + -- cgit v1.2.3 From 09af091f50409a60a72086c737b9a6224dde5ab8 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Mon, 17 Dec 2007 19:07:41 +0100 Subject: kconfig: make kconfig MinGW friendly Kconfig is powerfull tool. So powerfull that more and more software projects are using it for configuration. So instead of fixing some of them one by one, lets fix it in kernel and wait for sync. This work was originaly done for PTXdist - GPL licensed build system for userlands and cross-compilers, but it will not hurt kernel kconfig either. PTXdist menuconfig now works on Windows linked with PDCurses and compiled using MinGW - there is no termios and signals. * Do not include and (comes from times when lxdialog was separate process) * Do not mess with termios directly and let curses tell screen size. Comment to commit c8dc68ad0fbd934e78e913b8a8d7b45945db4930 says check for screen size could be removed later, but because it didn't happen for more than year I left it here as well. * Save cursor position added by Sam Signed-off-by: Ladislav Michl Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/lxdialog/dialog.h | 5 ++-- scripts/kconfig/lxdialog/util.c | 32 +++++++++++++------- scripts/kconfig/mconf.c | 61 ++++++--------------------------------- 3 files changed, 32 insertions(+), 66 deletions(-) diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index 7e17eba75ae8..c4ad37fd922c 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -187,10 +187,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/util.c b/scripts/kconfig/lxdialog/util.c index a1bddefe73d0..86d95cca46a7 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/mconf.c b/scripts/kconfig/mconf.c index 47e226fdedd7..ee9ed3059472 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -8,17 +8,13 @@ * i18n, 2005, Arnaldo Carvalho de Melo */ -#include -#include #include #include #include #include -#include #include #include #include -#include #include #include @@ -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,41 +284,6 @@ 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; @@ -900,13 +859,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 +878,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 +898,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: -- cgit v1.2.3 From d84876f9f8042d5536050b83674c4f348ca3c4df Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Thu, 3 Jan 2008 23:33:44 +0100 Subject: kconfig: allow overriding symbols Allow config variables in .config to override earlier ones in the same file. In other words, # CONFIG_SECURITY is not defined CONFIG_SECURITY=y will activate it. This makes it a bit easier to do cat original-config myconfig myconfig2 ... >.config; and run *config as expected. Signed-off-by: Jan Engelhardt Signed-off-by: Sam Ravnborg Cc: Roman Zippel Cc: Randy Dunlap --- scripts/kconfig/confdata.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index e0f402f3b75d..2eccefb03a93 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,11 +295,9 @@ 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); -- cgit v1.2.3 From d6ee35764f270c699e165b15dc59f4e55546bfda Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 7 Jan 2008 21:09:55 +0100 Subject: kconfig: rename E_OR & friends to avoid name clash We had macros named the same as a set of enumeration values. It is legal code but very confusing to read - so rename the macros from E_* to EXPR_* Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/confdata.c | 2 +- scripts/kconfig/expr.c | 6 +++--- scripts/kconfig/expr.h | 6 +++--- scripts/kconfig/symbol.c | 6 +++--- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 2eccefb03a93..497a19e85a07 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -300,7 +300,7 @@ load: 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); diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 6f98dbfe70cf..c8793d1d908f 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -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); diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index a195986eec6f..b7889971e42d 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -45,9 +45,9 @@ 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)) struct expr_value { struct expr *expr; diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index c35dcc5d6189..add068c8e513 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -199,7 +199,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; @@ -303,7 +303,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 +312,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) { -- cgit v1.2.3 From de83cf148aaefac8a538a076f2c3c4f33968e04a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 7 Jan 2008 21:13:04 +0100 Subject: kconfig: delete unused FILE_ and SYMBOL_ flags The *_PRINTED flags were never used - so delete them. Do we need them later then we can re-add them. Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/expr.h | 2 -- scripts/kconfig/gconf.c | 2 -- 2 files changed, 4 deletions(-) diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index b7889971e42d..1ee8b1642d3b 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -25,7 +25,6 @@ struct file { #define FILE_BUSY 0x0001 #define FILE_SCANNED 0x0002 -#define FILE_PRINTED 0x0004 typedef enum tristate { no, mod, yes @@ -86,7 +85,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 diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index 262908cfc2ac..df910cbab2c0 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) -- cgit v1.2.3 From 2c81210a26fb84c0af6aad95f6ec1d61cf276cd0 Mon Sep 17 00:00:00 2001 From: Uwe Kleine-König Date: Tue, 8 Jan 2008 15:16:24 +0100 Subject: kbuild: ignore cache modifiers for generating the tags files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With this patch I'm able to find the definition of _xmit_lock defined in include/linux/netdevice.h as follows: struct net_device { ... spinlock_t _xmit_lock ____cacheline_aligned_in_smp; } Otherwise this counts as definition of ____cacheline_aligned_in_smp. Signed-off-by: Uwe Kleine-König Signed-off-by: Sam Ravnborg --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 953359ed9871..698dfc6ba65c 100644 --- a/Makefile +++ b/Makefile @@ -1378,6 +1378,7 @@ define xtags if $1 --version 2>&1 | grep -iq exuberant; then \ $(all-sources) | xargs $1 -a \ -I __initdata,__exitdata,__acquires,__releases \ + -I __read_mostly,____cacheline_aligned,____cacheline_aligned_in_smp,____cacheline_internodealigned_in_smp \ -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ --extra=+f --c-kinds=+px \ --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'; \ -- cgit v1.2.3 From 75ff4309cdb1d7303750aeed07a5d80382fe2e71 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Wed, 9 Jan 2008 16:36:19 +0100 Subject: kconfig: fix whitespace and sort includes in conf.c Sort includes and remove leading whitespace. Signed-off-by: Ladislav Michl Signed-off-by: Sam Ravnborg Cc: Roman Zippel -#include #include +#include #include -#include #include +#include #include #define LKC_DIRECT_LINK @@ -160,7 +160,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; -- cgit v1.2.3 From 07f766885879a1fd4502fb8dd531d1fe3c575510 Mon Sep 17 00:00:00 2001 From: Ladislav Michl Date: Wed, 9 Jan 2008 16:36:19 +0100 Subject: kconfig: use C89 random functions in conf.c rand and srand functions conform also to C89 in addition to POSIX.1-2001, which makes them a bit more portable (work also on MinGW host). Linux man page also says: "The versions of rand() and srand() in the Linux C Library use the same random number generator as random() and srandom()". * Use C89 conformant functions rand() and srand() Signed-off-by: Ladislav Michl Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/conf.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index a3d2d0b564f4..01c2f3505f5d 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -375,7 +375,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: @@ -526,7 +526,7 @@ int main(int ac, char **av) break; case 'r': input_mode = set_random; - srandom(time(NULL)); + srand(time(NULL)); break; case 'h': printf("See README for usage info\n"); -- cgit v1.2.3 From df578e7d831b4d280bf7c621eafb737e78cd26eb Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 11 Jan 2008 19:17:15 +0100 Subject: kbuild: clean up modpost.c akpm complained about overly long lines in modpost.c and when started additional style issues were fixed: o Updated my copyright o Removed unneeded {} o Drop assignments in if () o Spaces around operators o Break long lines o locate * near variable not type o Fix a format specifier for sizeof() o Corrected placement of '{' and '}' o spaces to tabs (but use tabs only for indention) modpost.c is not checkpatch clean. Readability were favoured on top of checkpatch compliance. But checkpatch were used to find additional stuff to clean up. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 197 ++++++++++++++++++++++++++------------------------ 1 file changed, 101 insertions(+), 96 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 4d1c59063b27..696d2a59e4b8 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 @@ -74,7 +74,8 @@ static int is_vmlinux(const char *modname) { const char *myname; - if ((myname = strrchr(modname, '/'))) + myname = strrchr(modname, '/'); + if (myname) myname++; else myname = modname; @@ -85,14 +86,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) @@ -115,7 +115,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'; @@ -156,7 +157,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); @@ -200,7 +201,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; } @@ -225,9 +226,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++) { @@ -317,7 +319,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; @@ -325,8 +327,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; @@ -388,7 +389,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=%lu in file '%s' is bigger then filesize=%lu\n", (unsigned long)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; } @@ -409,7 +412,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=%lu > sizeof(*hrd)=%lu\n", filename, (unsigned long)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; @@ -436,9 +442,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); @@ -507,11 +513,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 */ @@ -580,21 +588,21 @@ 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); } /* @@ -671,7 +679,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 @@ -731,15 +740,16 @@ static int secref_whitelist(const char *modname, const char *tosec, return 1; /* Check for pattern 2 */ - if ((init_section(tosec) || exit_section(tosec)) && data_section(fromsec)) + if ((init_section(tosec) || exit_section(tosec)) + && data_section(fromsec)) for (s = pat2sym; *s; s++) if (strrcmp(atsym, *s) == 0) return 1; /* Check for pattern 3 */ if ((strcmp(fromsec, ".text.head") == 0) && - ((strcmp(tosec, ".init.data") == 0) || - (strcmp(tosec, ".init.text") == 0))) + ((strcmp(tosec, ".init.data") == 0) || + (strcmp(tosec, ".init.text") == 0))) return 1; /* Check for pattern 4 */ @@ -816,7 +826,7 @@ static inline int is_valid_name(struct elf_info *elf, Elf_Sym *sym) **/ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, const char *sec, - Elf_Sym **before, Elf_Sym **after) + Elf_Sym **before, Elf_Sym **after) { Elf_Sym *sym; Elf_Ehdr *hdr = elf->hdr; @@ -842,20 +852,15 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, if ((addr - sym->st_value) < beforediff) { beforediff = addr - sym->st_value; *before = sym; - } - else if ((addr - sym->st_value) == beforediff) { + } else if ((addr - sym->st_value) == beforediff) { *before = sym; } - } - else - { + } else { if ((sym->st_value - addr) < afterdiff) { afterdiff = sym->st_value - addr; *after = sym; - } - else if ((sym->st_value - addr) == afterdiff) { + } else if ((sym->st_value - addr) == afterdiff) *after = sym; - } } } } @@ -952,12 +957,14 @@ static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r) 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 + + elf->sechdrs[rsection].sh_offset + + (r->r_offset - elf->sechdrs[rsection].sh_addr)); break; default: return 1; @@ -1002,7 +1009,7 @@ static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r) **/ static void check_sec_ref(struct module *mod, const char *modname, struct elf_info *elf, - int section(const char*), + int section(const char *), int section_ref_ok(const char *)) { int i; @@ -1022,7 +1029,7 @@ static void check_sec_ref(struct module *mod, const char *modname, 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; + Elf_Rela *stop = (void *)start + sechdrs[i].sh_size; name += strlen(".rela"); if (section_ref_ok(name)) continue; @@ -1059,7 +1066,7 @@ static void check_sec_ref(struct module *mod, const char *modname, } 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; + Elf_Rel *stop = (void *)start + sechdrs[i].sh_size; name += strlen(".rel"); if (section_ref_ok(name)) continue; @@ -1088,7 +1095,7 @@ static void check_sec_ref(struct module *mod, const char *modname, continue; break; case EM_ARM: - if(addend_arm_rel(elf, i, &r)) + if (addend_arm_rel(elf, i, &r)) continue; break; case EM_MIPS: @@ -1126,32 +1133,32 @@ 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() */ + "__bug_table", /* used by powerpc for BUG() */ "__ex_table", ".altinstructions", - ".cranges", /* used by sh64 */ + ".cranges", /* used by sh64 */ ".fixup", - ".machvec", /* ia64 + powerpc uses these */ + ".machvec", /* ia64 + powerpc uses these */ ".machine.desc", - ".opd", /* See comment [OPD] */ + ".opd", /* See comment [OPD] */ "__dbe_table", ".parainstructions", ".pdr", - ".plt", /* seen on ARCH=um build on x86_64. Harmless */ + ".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 */ + ".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 */ + ".note", /* ignore ELF notes - may contain anything */ + ".got", /* powerpc - global offset table */ + ".toc", /* powerpc - table of contents */ NULL }; /* part of section name */ @@ -1221,7 +1228,8 @@ static int init_section_ref_ok(const char *name) return 1; /* If section name ends with ".init" we allow references - * as is the case with .initcallN.init, .early_param.init, .taglist.init etc + * as is the case with .initcallN.init, .early_param.init, + * .taglist.init etc */ if (strrcmp(name, ".init") == 0) return 1; @@ -1368,7 +1376,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"; @@ -1401,7 +1409,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); - } + } } /** @@ -1465,9 +1473,8 @@ static int add_versions(struct buffer *b, struct module *mod) 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); @@ -1488,9 +1495,8 @@ 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"); @@ -1506,7 +1512,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; @@ -1578,7 +1585,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; @@ -1601,11 +1608,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; } @@ -1662,31 +1668,31 @@ int main(int argc, char **argv) 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); + 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); } } @@ -1695,9 +1701,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) -- cgit v1.2.3 From 1d3b3bfab121cdef07d19797f42f413dccdd65f0 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Fri, 11 Jan 2008 09:09:00 +0000 Subject: kbuild: scripts/mkmakefile: dynamic determination of output directory Rather than fixing the output directory in the generated Makefile, determine it from the placement of Makefile. This allows moving the build tree around or accessing it through different mount paths. (The lastword definition is a compatibility one for make prior to 3.81; newer make will simply ignore it and use the [faster] built-in.) Signed-off-by: Jan Beulich Signed-off-by: Sam Ravnborg --- scripts/mkmakefile | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/mkmakefile b/scripts/mkmakefile index e0f54b9d8fec..e65d8b33faa4 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 -- cgit v1.2.3 From 243f40cecb292cbb2333749614cf54302fc9cdc0 Mon Sep 17 00:00:00 2001 From: "Valdis.Kletnieks@vt.edu" Date: Fri, 28 Dec 2007 21:22:48 -0500 Subject: kbuild: document 'make prepare' in 'make help' The output of 'make help' covers a lot of options, but doesn't include a listing for 'make prepare'. Here's a one-liner to fix that... Signed-off-by: Valdis Kletnieks Signed-off-by: Sam Ravnborg --- Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile b/Makefile index 698dfc6ba65c..6847464402aa 100644 --- a/Makefile +++ b/Makefile @@ -1181,6 +1181,7 @@ help: @echo ' dir/ - Build all files in dir and below' @echo ' dir/file.[ois] - Build specified target only' @echo ' dir/file.ko - Build module including final link' + @echo ' prepare - Set up for building external modules' @echo ' tags/TAGS - Generate tags file for editors' @echo ' cscope - Generate cscope index' @echo ' kernelrelease - Output the release version string' -- cgit v1.2.3 From 1020026f99069976001816b8198bc04ee342cd2e Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:40:00 +0100 Subject: kconfig: update-po-config info This patch adds tracking messages. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/Makefile | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 80914358817e..d28bf8550171 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 \ + $(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 @@ -138,6 +141,7 @@ endif clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c clean-files += mconf qconf gconf +clean-files += config.pot linux.pot # Check that we have the required ncurses stuff installed for lxdialog (menuconfig) PHONY += $(obj)/dochecklxdialog -- cgit v1.2.3 From f7a4b4cdc26846a0ac5b3023cb1b97dc632dfd35 Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:55:20 +0100 Subject: kconfig: whitespace removing This patch removes the unnecessary whitespaces from end of help lines of Kconfig files. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/lex.zconf.c_shipped | 5 +++++ scripts/kconfig/zconf.l | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index a065d5a57c01..bed0f4e2d2f7 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/zconf.l b/scripts/kconfig/zconf.l index 187d38ccadd5..4cea5c85cd0a 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; -- cgit v1.2.3 From bb7ef3905adce28db31933ae77e5397c0b89227a Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:47:58 +0100 Subject: kconfig: missing macros in gconfig This patch adds missing gettext macros. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/gconf.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index df910cbab2c0..dfe748c38b72 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -455,11 +455,15 @@ 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)); @@ -1169,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)) @@ -1219,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); -- cgit v1.2.3 From 46d2631978c05e55b28454ac864aba0287f50322 Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:46:11 +0100 Subject: kconfig: gettext support for gconfig Gettext support for menu and toolbar. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/Makefile | 7 +++++-- scripts/kconfig/POTFILES.in | 1 + 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index d28bf8550171..32e8c5a227c3 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -27,7 +27,7 @@ silentoldconfig: $(obj)/conf # 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 +update-po-config: $(obj)/kxgettext $(obj)/gconf.glade.h $(Q)echo " GEN config" $(Q)xgettext --default-domain=linux \ --add-comments --keyword=_ --keyword=N_ \ @@ -139,7 +139,7 @@ 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 @@ -254,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 cc94e46a79e8..19d0e63fb7ba 100644 --- a/scripts/kconfig/POTFILES.in +++ b/scripts/kconfig/POTFILES.in @@ -2,4 +2,5 @@ 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 -- cgit v1.2.3 From 01771b0fef0f2cbff80e19295394ece2be1ab661 Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:53:43 +0100 Subject: kconfig: macro fix in menu.c This patch removes the indirect I18N support for config file. Signed-off-by: Egry Gabor Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/menu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index f9d0d91a3fe4..e9deebe22eed 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -394,9 +394,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; } -- cgit v1.2.3 From c21a2d9589faa5599c9876bf0e0f48e81ee90284 Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:52:07 +0100 Subject: kconfig: gettext support for xconfig Full gettext support for xconfig. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/qconf.cc | 93 +++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 44 deletions(-) diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index b9bb32dfd628..9fe27ca8a192 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 += ""; head += print_filter(_(menu->prompt->text)); @@ -1167,7 +1172,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 +1194,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 +1318,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 +1384,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 +1393,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 +1409,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 +1457,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 +1473,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 +1617,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 +1636,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 +1646,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 .\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 .\n\n" + "Bug reports and feature request can also be entered at http://bugzilla.kernel.org/\n"); QMessageBox::information(this, "qconf", str); } @@ -1707,7 +1712,7 @@ static const char *progname; static void usage(void) { - printf("%s \n", progname); + printf(_("%s \n"), progname); exit(0); } -- cgit v1.2.3 From 413f006bab3845f12d7b2338a9b548aaf7808548 Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:50:37 +0100 Subject: kconfig: gettext support for menuconfig Full gettext support for menuconfig. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/mconf.c | 51 +++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index ee9ed3059472..50e61c411bc0 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -289,11 +289,11 @@ 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"); } @@ -301,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 : "", + menu->sym->name : _(""), sym_get_string_value(menu->sym)); } str_append(r, "\n"); @@ -337,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"); } @@ -353,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; } @@ -433,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 ? "-->" : "++>", @@ -448,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); } @@ -456,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); } @@ -500,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; @@ -515,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; @@ -558,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; @@ -606,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) @@ -653,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')) { @@ -711,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; @@ -731,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); @@ -739,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(); @@ -785,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) { -- cgit v1.2.3 From 75c0a8a55c31c0a21f7e9e64bc45e87e228a98f6 Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:42:54 +0100 Subject: kconfig: gettext support for lxdialog Gettext support for lxdialog. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/POTFILES.in | 6 ++++++ scripts/kconfig/lxdialog/checklist.c | 4 ++-- scripts/kconfig/lxdialog/dialog.h | 6 ++++++ scripts/kconfig/lxdialog/inputbox.c | 4 ++-- scripts/kconfig/lxdialog/menubox.c | 6 +++--- scripts/kconfig/lxdialog/textbox.c | 2 +- scripts/kconfig/lxdialog/yesno.c | 4 ++-- 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/scripts/kconfig/POTFILES.in b/scripts/kconfig/POTFILES.in index 19d0e63fb7ba..967457396990 100644 --- a/scripts/kconfig/POTFILES.in +++ b/scripts/kconfig/POTFILES.in @@ -1,3 +1,9 @@ +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 diff --git a/scripts/kconfig/lxdialog/checklist.c b/scripts/kconfig/lxdialog/checklist.c index cf697080dddd..b2a878c936d6 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 c4ad37fd922c..b5211fce0d94 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -26,6 +26,12 @@ #include #include +#ifndef KBUILD_NO_NLS +# include +#else +# define gettext(Msgid) ((const char *) (Msgid)) +#endif + #ifdef __sun__ #define CURS_MACROS #endif diff --git a/scripts/kconfig/lxdialog/inputbox.c b/scripts/kconfig/lxdialog/inputbox.c index 05e72066b359..4946bd02b46d 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 0d83159d9012..fa9d633f293c 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 fabfc1ad789d..c704712d0227 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/yesno.c b/scripts/kconfig/lxdialog/yesno.c index ee0a04e3e012..4e6e8090c20b 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); -- cgit v1.2.3 From 534a450c383ef238b0461218bc2d3e54066ae043 Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:44:39 +0100 Subject: kconfig: gettext support for config Gettext support for conf.c [Include locale.h by Kyle]. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel Cc: Kyle McMartin --- scripts/kconfig/conf.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 01c2f3505f5d..d1a0368bd438 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -3,6 +3,7 @@ * Released under the terms of the GNU GPL v2.0. */ +#include #include #include #include @@ -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; @@ -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; @@ -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: ; @@ -499,6 +500,10 @@ int main(int ac, char **av) const char *name; struct stat tmpstat; + setlocale(LC_ALL, ""); + bindtextdomain(PACKAGE, LOCALEDIR); + textdomain(PACKAGE); + while ((opt = getopt(ac, av, "osdD:nmyrh")) != -1) { switch (opt) { case 'o': @@ -529,11 +534,11 @@ int main(int ac, char **av) srand(time(NULL)); break; case 'h': - printf("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"); + fprintf(stderr, _("See README for usage info\n")); exit(1); } } @@ -549,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; -- cgit v1.2.3 From 0ffce8d94487abbd332cd36f98db61b7c8a3db3c Mon Sep 17 00:00:00 2001 From: EGRY Gabor Date: Fri, 11 Jan 2008 23:49:12 +0100 Subject: kconfig: gconfig: symbol fix Gettext support for symbol names are unnecessary. Signed-off-by: Egry Gabor Reviewed-by: Sam Ravnborg Signed-off-by: Sam Ravnborg Cc: Roman Zippel --- scripts/kconfig/gconf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/kconfig/gconf.c b/scripts/kconfig/gconf.c index dfe748c38b72..199b22bb49e2 100644 --- a/scripts/kconfig/gconf.c +++ b/scripts/kconfig/gconf.c @@ -466,7 +466,7 @@ static void text_insert_help(struct menu *menu) 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(""); -- cgit v1.2.3 From 7a962923359768e04137125bd479fd0dfa6117d3 Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Mon, 14 Jan 2008 04:50:23 +0100 Subject: kconfig: explicitly introduce expression list Rename E_CHOICE to E_LIST to explicitly add support for expression lists. Add a helper macro expr_list_for_each_sym to more easily iterate over the list. Signed-off-by: Roman Zippel Signed-off-by: Sam Ravnborg --- scripts/kconfig/confdata.c | 8 ++++---- scripts/kconfig/expr.c | 16 ++++++++-------- scripts/kconfig/expr.h | 5 ++++- scripts/kconfig/menu.c | 2 +- scripts/kconfig/symbol.c | 13 +++++++------ 5 files changed, 24 insertions(+), 20 deletions(-) diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 497a19e85a07..ee5fe943d58d 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -312,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; @@ -353,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 c8793d1d908f..13788ada5228 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 */; @@ -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: @@ -1053,11 +1053,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 1ee8b1642d3b..b6f922c77e0b 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -31,7 +31,7 @@ typedef enum tristate { } 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 { @@ -48,6 +48,9 @@ struct expr { #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; tristate tri; diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e9deebe22eed..3637d1057e13 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -331,7 +331,7 @@ void menu_finalize(struct menu *parent) 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)) { diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index add068c8e513..a7dfc82fc858 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -247,8 +247,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; @@ -361,12 +360,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 +850,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; } -- cgit v1.2.3 From 93449082e905ce73d0346d617dd67c4b668b58af Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Mon, 14 Jan 2008 04:50:54 +0100 Subject: kconfig: environment symbol support Add the possibility to import a value from the environment into kconfig via the option syntax. Beside flexibility this has the advantage providing proper dependencies. Documented the options syntax. Signed-off-by: Roman Zippel Signed-off-by: Sam Ravnborg --- Documentation/kbuild/kconfig-language.txt | 21 +++++++++++++++ scripts/kconfig/expr.h | 3 ++- scripts/kconfig/lkc.h | 5 ++++ scripts/kconfig/menu.c | 5 +++- scripts/kconfig/qconf.cc | 16 ++++------- scripts/kconfig/symbol.c | 45 +++++++++++++++++++++++++++++++ scripts/kconfig/util.c | 23 ++++++++++++++-- scripts/kconfig/zconf.gperf | 1 + scripts/kconfig/zconf.hash.c_shipped | 45 +++++++++++++++++-------------- 9 files changed, 129 insertions(+), 35 deletions(-) diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index 53ca12f7999f..a43fcc68e171 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt @@ -127,6 +127,27 @@ applicable everywhere (see syntax). used to help visually separate configuration logic from help within the file as an aid to developers. +- misc options: "option" [=] + Various less common options can be defined via this option syntax, + which can modify the behaviour of the menu entry and its config + symbol. These options are currently possible: + + - "defconfig_list" + This declares a list of default entries which can be used when + looking for the default configuration (which is used when the main + .config doesn't exists yet.) + + - "modules" + This declares the symbol to be used as the MODULES symbol, which + enables the third modular state for all config symbols. + + - "env"= + This imports the environment variable into Kconfig. It behaves like + a default, except that the value comes from the environment, this + also means that the behaviour when mixing it with normal defaults is + undefined at this point. The symbol is currently not exported back + to the build environment (if this is desired, it can be done via + another symbol). Menu dependencies ----------------- diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index b6f922c77e0b..9d4cba1c001d 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h @@ -106,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/lkc.h b/scripts/kconfig/lkc.h index 8a07ee4f6bd4..4bc68f20a73c 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/menu.c b/scripts/kconfig/menu.c index 3637d1057e13..e6ef171e5b14 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; } } diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 9fe27ca8a192..5d0fd38b089b 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1088,7 +1088,11 @@ QString ConfigInfoView::debug_info(struct symbol *sym) debug += "
"; 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 += "
"; break; @@ -1099,16 +1103,6 @@ QString ConfigInfoView::debug_info(struct symbol *sym) debug += "
"; } break; - case P_SELECT: - debug += "select: "; - expr_print(prop->expr, expr_print_help, &debug, E_NONE); - debug += "
"; - break; - case P_RANGE: - debug += "range: "; - expr_print(prop->expr, expr_print_help, &debug, E_NONE); - debug += "
"; - break; default: debug += "unknown property: "; debug += prop_get_type_name(prop->type); diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index a7dfc82fc858..99e3d02d1cfc 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); @@ -117,6 +119,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; @@ -346,6 +357,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); @@ -860,6 +874,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: @@ -877,3 +893,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 e1cad924c0a4..f8e73c039dc8 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 93538e567bda..4051639c0900 100644 --- a/scripts/kconfig/zconf.gperf +++ b/scripts/kconfig/zconf.gperf @@ -41,4 +41,5 @@ 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 ab28b18153a7..c9d26bc1a214 100644 --- a/scripts/kconfig/zconf.hash.c_shipped +++ b/scripts/kconfig/zconf.hash.c_shipped @@ -53,10 +53,10 @@ 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, 35, 35, 5, 0, 0, 5, 49, 5, 20, 49, 49, 5, 20, - 5, 0, 30, 49, 0, 15, 0, 10, 49, 49, - 25, 49, 49, 49, 49, 49, 49, 49, 49, 49, + 5, 0, 30, 49, 0, 15, 0, 10, 0, 49, + 10, 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, 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")]; @@ -99,30 +100,31 @@ struct kconf_id_strings_t char kconf_id_strings_str12[sizeof("default")]; char kconf_id_strings_str13[sizeof("def_bool")]; char kconf_id_strings_str14[sizeof("help")]; - char kconf_id_strings_str15[sizeof("bool")]; char kconf_id_strings_str16[sizeof("config")]; char kconf_id_strings_str17[sizeof("def_tristate")]; - char kconf_id_strings_str18[sizeof("boolean")]; + char kconf_id_strings_str18[sizeof("hex")]; char kconf_id_strings_str19[sizeof("defconfig_list")]; 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")]; char kconf_id_strings_str29[sizeof("menu")]; char kconf_id_strings_str31[sizeof("source")]; char kconf_id_strings_str32[sizeof("comment")]; - char kconf_id_strings_str33[sizeof("hex")]; char kconf_id_strings_str35[sizeof("menuconfig")]; char kconf_id_strings_str36[sizeof("prompt")]; char kconf_id_strings_str37[sizeof("depends")]; + char kconf_id_strings_str39[sizeof("bool")]; + char kconf_id_strings_str41[sizeof("enable")]; + char kconf_id_strings_str42[sizeof("boolean")]; char kconf_id_strings_str48[sizeof("mainmenu")]; }; static struct kconf_id_strings_t kconf_id_strings_contents = { "on", + "env", "endif", "option", "endmenu", @@ -133,25 +135,25 @@ static struct kconf_id_strings_t kconf_id_strings_contents = "default", "def_bool", "help", - "bool", "config", "def_tristate", - "boolean", + "hex", "defconfig_list", "string", "if", "int", - "enable", "select", "modules", "tristate", "menu", "source", "comment", - "hex", "menuconfig", "prompt", "depends", + "bool", + "enable", + "boolean", "mainmenu" }; #define kconf_id_strings ((const char *) &kconf_id_strings_contents) @@ -163,7 +165,7 @@ kconf_id_lookup (register const char *str, register unsigned int len) { enum { - TOTAL_KEYWORDS = 31, + TOTAL_KEYWORDS = 32, MIN_WORD_LENGTH = 2, MAX_WORD_LENGTH = 14, MIN_HASH_VALUE = 2, @@ -174,7 +176,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}, @@ -185,17 +188,16 @@ kconf_id_lookup (register const char *str, register unsigned int len) {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_HEX}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION}, {-1}, {(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}, @@ -203,13 +205,16 @@ kconf_id_lookup (register const char *str, register unsigned int len) {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX}, - {-1}, + {-1}, {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_PROMPT, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_DEPENDS, TF_COMMAND}, - {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_SELECT, TF_COMMAND}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_TYPE, TF_COMMAND, S_BOOLEAN}, + {-1}, {-1}, {-1}, {-1}, {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND} }; -- cgit v1.2.3 From 80daa56008dad44f08d0b47670cf2513aa98ab53 Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Mon, 14 Jan 2008 04:51:16 +0100 Subject: kconfig: use environment option Use the environment option to provide the ARCH symbol and the KERNELVERSION symbol. Signed-off-by: Roman Zippel Signed-off-by: Sam Ravnborg --- init/Kconfig | 8 ++++++++ scripts/kconfig/symbol.c | 15 --------------- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/init/Kconfig b/init/Kconfig index 288444b4cd8a..0d0bbf218f1f 100644 --- a/init/Kconfig +++ b/init/Kconfig @@ -1,3 +1,11 @@ +config ARCH + string + option env="ARCH" + +config KERNELVERSION + string + option env="KERNELVERSION" + config DEFCONFIG_LIST string depends on !UML diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 99e3d02d1cfc..3929e5b35e79 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -47,7 +47,6 @@ void sym_init(void) { struct symbol *sym; struct utsname uts; - char *p; static bool inited = false; if (inited) @@ -56,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; -- cgit v1.2.3 From fa220d89ad050cf5d970c0418ded019a80efedfb Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Mon, 14 Jan 2008 15:18:31 -0800 Subject: kbuild: minor scripts/decodecode update Remove the tmp file when exiting. Noticed by Arjan van de Ven. Catch mktemp failure and exit with message. Trap kill or other signals and exit cleanly. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/decodecode | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/scripts/decodecode b/scripts/decodecode index 1e1a8f620c47..235d3938529d 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 -- cgit v1.2.3 From d1f25e6658943569f2713dfde1b9d74e2f6c7243 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 17 Jan 2008 21:17:42 +0100 Subject: kbuild: fix so modpost can now check any .o file It is very convinient to say: scripts/mod/modpost mm/built-in.o to check if any section mismatch errors occured in mm/ (as an example). Fix it so this is possible again. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 696d2a59e4b8..46660a4f9e22 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1299,7 +1299,8 @@ 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) { + if (!is_vmlinux(modname) || + (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); } -- cgit v1.2.3 From 9ad21c3f3ecffeb56be7b35030d7ec2f30b6fe11 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 18 Jan 2008 21:04:34 +0100 Subject: kbuild: try harder to find symbol names in modpost The relocation record sometimes contained an address which was not an exactly match for a symbol. Implment some simple logic such that if there is a symbol within 20 bytes of the address contained in the relocation record then print the name of this symbol. With this change modpost could find symbol names for the remaining .init.text symbols in my allyesconfig build for x86_64. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 19 +++++++++++++++++-- scripts/mod/modpost.h | 2 ++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 46660a4f9e22..902ee55f327f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -776,10 +776,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; @@ -790,8 +793,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) diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 0ffed17ec20c..999f15e0e008 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 -- cgit v1.2.3 From 5b24c0715fc4c71e60e9a684248cc49d62dfa900 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 18 Jan 2008 21:49:29 +0100 Subject: kbuild: code refactoring in modpost Split a too long function up in smaller bits to make prgram logic easier to follow. A few related changes done due to parameter changes. No functional changes. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 242 ++++++++++++++++++++++++++++---------------------- 1 file changed, 137 insertions(+), 105 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 902ee55f327f..e4630135979c 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -937,19 +937,19 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, } 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: @@ -965,7 +965,7 @@ 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); @@ -978,8 +978,8 @@ static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r) 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)); + sechdr->sh_offset + + (r->r_offset - sechdr->sh_addr)); break; default: return 1; @@ -987,10 +987,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) @@ -1010,6 +1010,128 @@ 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, int section(const char *), + int section_ref_ok(const char *)) +{ + Elf_Sym *sym; + Elf_Rela *rela; + Elf_Rela r; + unsigned int r_sym; + const char *fromsec; + const char * tosec; + + Elf_Ehdr *hdr = elf->hdr; + Elf_Rela *start = (void *)hdr + sechdr->sh_offset; + Elf_Rela *stop = (void *)start + sechdr->sh_size; + + const char *secstrings = (void *)hdr + + elf->sechdrs[hdr->e_shstrndx].sh_offset; + + fromsec = secstrings + sechdr->sh_name; + fromsec += strlen(".rela"); + /* if from section (name) is know good then skip it */ + if (section_ref_ok(fromsec)) + return; + + 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; + + tosec = secstrings + + elf->sechdrs[sym->st_shndx].sh_name; + if (section(tosec)) + warn_sec_mismatch(modname, fromsec, elf, sym, r); + } +} + +static void section_rel(const char *modname, struct elf_info *elf, + Elf_Shdr *sechdr, int section(const char *), + int section_ref_ok(const char *)) +{ + Elf_Sym *sym; + Elf_Rel *rel; + Elf_Rela r; + unsigned int r_sym; + const char *fromsec; + const char * tosec; + + Elf_Ehdr *hdr = elf->hdr; + Elf_Rel *start = (void *)hdr + sechdr->sh_offset; + Elf_Rel *stop = (void *)start + sechdr->sh_size; + + const char *secstrings = (void *)hdr + + elf->sechdrs[hdr->e_shstrndx].sh_offset; + + fromsec = secstrings + sechdr->sh_name; + fromsec += strlen(".rel"); + /* if from section (name) is know good then skip it */ + if (section_ref_ok(fromsec)) + return; + + 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, 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; + + tosec = secstrings + + elf->sechdrs[sym->st_shndx].sh_name; + if (section(tosec)) + warn_sec_mismatch(modname, fromsec, elf, sym, r); + } +} + /** * A module includes a number of sections that are discarded * either when loaded or when used as built-in. @@ -1028,108 +1150,18 @@ static void check_sec_ref(struct module *mod, const char *modname, int section_ref_ok(const char *)) { 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; /* 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], + section, section_ref_ok); + else if (sechdrs[i].sh_type == SHT_REL) + section_rel(modname, elf, &elf->sechdrs[i], + section, section_ref_ok); } } -- cgit v1.2.3 From 10668220a97cb8b3fa1011a252175737ba750d51 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 13 Jan 2008 22:21:31 +0100 Subject: kbuild: introduce blacklisting in modpost Change the logic in modpost so we identify all the bad combinations of sections that refer to other sections. Compared to the previous approach we are much less dependent on knowledge of what additional sections the tool chain uses and thus we can keep the false positives low. The implmentation is changed to use a table based lookup and we now check all combinations in first pass so we no longer need separate passes for init and exit sections. Tested that the same warnings are generated for an allyesconfig build without CONFIG_HOTPLUG. Signed-off-by: Sam Ravnborg Cc: Randy Dunlap Cc: Adrian Bunk --- scripts/mod/modpost.c | 305 +++++++++++++++++++++----------------------------- 1 file changed, 128 insertions(+), 177 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index e4630135979c..6c206b9212b1 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -605,6 +605,61 @@ static int strrcmp(const char *s, const char *sub) return memcmp(s + slen - sublen, sub, sublen); } +/* 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 number_prefix(const char *sym) +{ + 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 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 (*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; +} + /* * 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 @@ -653,6 +708,68 @@ static int data_section(const char *name) 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 }; + +#define INIT_DATA_SECTIONS ".init.data$" +#define EXIT_DATA_SECTIONS ".exit.data$" + +#define INIT_TEXT_SECTIONS ".init.text$" +#define EXIT_TEXT_SECTIONS ".exit.text$" + +#define INIT_SECTIONS INIT_DATA_SECTIONS, INIT_TEXT_SECTIONS +#define EXIT_SECTIONS EXIT_DATA_SECTIONS, EXIT_TEXT_SECTIONS + +#define DATA_SECTIONS ".data$" +#define TEXT_SECTIONS ".text$" + +struct sectioncheck { + const char *fromsec[20]; + const char *tosec[20]; +}; + +const struct sectioncheck sectioncheck[] = { +/* Do not reference init/exit code/data from + * normal code and data + */ +{ + .fromsec = { TEXT_SECTIONS, DATA_SECTIONS, NULL }, + .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL } +}, +/* Do not use exit code/data from init code */ +{ + .fromsec = { INIT_SECTIONS, NULL }, + .tosec = { EXIT_SECTIONS, NULL }, +}, +/* Do not use init code/data from exit code */ +{ + .fromsec = { EXIT_SECTIONS, NULL }, + .tosec = { INIT_SECTIONS, NULL } +}, +/* Do not export init/exit functions or data */ +{ + .fromsec = { "__ksymtab*", NULL }, + .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL } +} +}; + +static int section_mismatch(const char *fromsec, const char *tosec) +{ + int i; + int elems = sizeof(sectioncheck) / sizeof(struct sectioncheck); + const struct sectioncheck *check = §ioncheck[0]; + + for (i = 0; i < elems; i++) { + if (match(fromsec, check->fromsec) && + match(tosec, check->tosec)) + return 1; + check++; + } + return 0; +} + + /** * Whitelist to allow certain references to pass with no warning. * @@ -695,18 +812,11 @@ 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 =
[.text] - * fromsec =
.literal **/ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, const char *refsymname) { - int len; const char **s; const char *pat2sym[] = { "driver", @@ -757,15 +867,6 @@ static int secref_whitelist(const char *modname, const char *tosec, 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; - return 0; } @@ -1011,8 +1112,7 @@ static int addend_mips_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) } static void section_rela(const char *modname, struct elf_info *elf, - Elf_Shdr *sechdr, int section(const char *), - int section_ref_ok(const char *)) + Elf_Shdr *sechdr) { Elf_Sym *sym; Elf_Rela *rela; @@ -1031,7 +1131,7 @@ static void section_rela(const char *modname, struct elf_info *elf, fromsec = secstrings + sechdr->sh_name; fromsec += strlen(".rela"); /* if from section (name) is know good then skip it */ - if (section_ref_ok(fromsec)) + if (match(fromsec, section_white_list)) return; for (rela = start; rela < stop; rela++) { @@ -1059,14 +1159,13 @@ static void section_rela(const char *modname, struct elf_info *elf, tosec = secstrings + elf->sechdrs[sym->st_shndx].sh_name; - if (section(tosec)) + if (section_mismatch(fromsec, tosec)) warn_sec_mismatch(modname, fromsec, elf, sym, r); } } static void section_rel(const char *modname, struct elf_info *elf, - Elf_Shdr *sechdr, int section(const char *), - int section_ref_ok(const char *)) + Elf_Shdr *sechdr) { Elf_Sym *sym; Elf_Rel *rel; @@ -1085,7 +1184,7 @@ static void section_rel(const char *modname, struct elf_info *elf, fromsec = secstrings + sechdr->sh_name; fromsec += strlen(".rel"); /* if from section (name) is know good then skip it */ - if (section_ref_ok(fromsec)) + if (match(fromsec, section_white_list)) return; for (rel = start; rel < stop; rel++) { @@ -1127,7 +1226,7 @@ static void section_rel(const char *modname, struct elf_info *elf, tosec = secstrings + elf->sechdrs[sym->st_shndx].sh_name; - if (section(tosec)) + if (section_mismatch(fromsec, tosec)) warn_sec_mismatch(modname, fromsec, elf, sym, r); } } @@ -1145,9 +1244,7 @@ static void section_rel(const char *modname, struct elf_info *elf, * 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_Ehdr *hdr = elf->hdr; @@ -1157,156 +1254,12 @@ static void check_sec_ref(struct module *mod, const char *modname, for (i = 0; i < hdr->e_shnum; i++) { /* We want to process only relocation sections and not .init */ if (sechdrs[i].sh_type == SHT_RELA) - section_rela(modname, elf, &elf->sechdrs[i], - section, section_ref_ok); + section_rela(modname, elf, &elf->sechdrs[i]); else if (sechdrs[i].sh_type == SHT_REL) - section_rel(modname, elf, &elf->sechdrs[i], - section, section_ref_ok); + 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 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; @@ -1347,10 +1300,8 @@ static void read_symbols(char *modname) handle_moddevtable(mod, &info, sym, symname); } if (!is_vmlinux(modname) || - (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); - } + (is_vmlinux(modname) && vmlinux_section_warnings)) + check_sec_ref(mod, modname, &info); version = get_modinfo(info.modinfo, info.modinfo_len, "version"); if (version) -- cgit v1.2.3 From 6c5bd235bfd0b92188915465c7dfb377c1a4d451 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 20 Jan 2008 10:43:27 +0100 Subject: kbuild: check section names consistently in modpost Now that match() is introduced use it consistently so we can share the section name definitions. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 146 +++++++++++++++++++++----------------------------- 1 file changed, 60 insertions(+), 86 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 6c206b9212b1..986513dcd700 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -625,6 +625,7 @@ static int number_prefix(const char *sym) /* 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. @@ -638,8 +639,13 @@ int match(const char *sym, const char * const pat[]) p = *pat++; const char *endp = p + strlen(p) - 1; + /* "*foo" */ + if (*p == '*') { + if (strrcmp(sym, p + 1) == 0) + return 1; + } /* "foo*" */ - if (*endp == '*') { + else if (*endp == '*') { if (strncmp(sym, p, strlen(p) - 1) == 0) return 1; } @@ -660,54 +666,6 @@ int match(const char *sym, const char * const pat[]) return 0; } -/* - * 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 int init_section(const char *name) -{ - if (strcmp(name, ".init") == 0) - return 1; - if (strncmp(name, ".init.", strlen(".init.")) == 0) - return 1; - return 0; -} - -/* - * 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) -{ - if (strcmp(name, ".exit.text") == 0) - return 1; - if (strcmp(name, ".exit.data") == 0) - return 1; - return 0; - -} - -/* - * Data sections are named like this: - * .data | .data.rel | .data.rel.* - * Return 1 if the specified section is a data section - */ -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; -} - /* 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 }; @@ -721,9 +679,50 @@ static const char *section_white_list[] = #define INIT_SECTIONS INIT_DATA_SECTIONS, INIT_TEXT_SECTIONS #define EXIT_SECTIONS EXIT_DATA_SECTIONS, EXIT_TEXT_SECTIONS -#define DATA_SECTIONS ".data$" +#define DATA_SECTIONS ".data$", ".data.rel$" #define TEXT_SECTIONS ".text$" +/* init data sections */ +static const char *init_data_sections[] = { INIT_DATA_SECTIONS, NULL }; + +/* all init sections */ +static const char *init_sections[] = { INIT_SECTIONS, NULL }; + +/* All init and exit sections (code + data) */ +static const char *init_exit_sections[] = + {INIT_SECTIONS, 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 }; + struct sectioncheck { const char *fromsec[20]; const char *tosec[20]; @@ -817,55 +816,30 @@ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, const char *refsymname) { - 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)) + if (match(fromsec, initref_sections)) return 1; /* Check for pattern 1 */ - if ((strcmp(tosec, ".init.data") == 0) && - (strncmp(fromsec, ".data", strlen(".data")) == 0) && + if (match(tosec, init_data_sections) && + match(fromsec, data_sections) && (strncmp(atsym, "__param", strlen("__param")) == 0)) return 1; /* 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(atsym, symbol_white_list)) + return 1; /* Check for pattern 3 */ - if ((strcmp(fromsec, ".text.head") == 0) && - ((strcmp(tosec, ".init.data") == 0) || - (strcmp(tosec, ".init.text") == 0))) + if (match(fromsec, head_sections) && + match(tosec, init_sections)) return 1; /* Check for pattern 4 */ - for (s = pat3refsym; *s; s++) - if (strcmp(refsymname, *s) == 0) - return 1; + if (match(refsymname, linker_symbols)) + return 1; return 0; } -- cgit v1.2.3 From 01ba2bdc6b639764745ff678caf3fb9e5bcd745a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 20 Jan 2008 14:15:03 +0100 Subject: all archs: consolidate init and exit sections in vmlinux.lds.h This patch consolidate all definitions of .init.text, .init.data and .exit.text, .exit.data section definitions in the generic vmlinux.lds.h. This is a preparational patch - alone it does not buy us much good. Signed-off-by: Sam Ravnborg --- arch/alpha/kernel/vmlinux.lds.S | 8 ++++---- arch/arm/kernel/vmlinux.lds.S | 10 +++++----- arch/avr32/kernel/vmlinux.lds.S | 8 ++++---- arch/blackfin/kernel/vmlinux.lds.S | 8 ++++---- arch/cris/arch-v10/vmlinux.lds.S | 8 ++++---- arch/cris/arch-v32/vmlinux.lds.S | 8 ++++---- arch/frv/kernel/vmlinux.lds.S | 14 +++++++------- arch/h8300/kernel/vmlinux.lds.S | 8 ++++---- arch/ia64/kernel/vmlinux.lds.S | 8 ++++---- arch/m32r/kernel/vmlinux.lds.S | 12 ++++++------ arch/m68k/kernel/vmlinux-std.lds | 8 ++++---- arch/m68k/kernel/vmlinux-sun3.lds | 8 ++++---- arch/m68knommu/kernel/vmlinux.lds.S | 8 ++++---- arch/mips/kernel/vmlinux.lds.S | 8 ++++---- arch/parisc/kernel/vmlinux.lds.S | 8 ++++---- arch/powerpc/kernel/vmlinux.lds.S | 10 ++++++---- arch/ppc/kernel/vmlinux.lds.S | 8 ++++---- arch/s390/kernel/vmlinux.lds.S | 8 ++++---- arch/sh/kernel/vmlinux_32.lds.S | 8 ++++---- arch/sh/kernel/vmlinux_64.lds.S | 8 ++++---- arch/sparc/kernel/vmlinux.lds.S | 8 ++++---- arch/sparc64/kernel/vmlinux.lds.S | 8 ++++---- arch/um/kernel/dyn.lds.S | 4 ++-- arch/um/kernel/uml.lds.S | 4 ++-- arch/v850/kernel/vmlinux.lds.S | 10 +++++----- arch/x86/kernel/vmlinux_32.lds.S | 14 ++++++++++---- arch/x86/kernel/vmlinux_64.lds.S | 19 +++++++++++++------ arch/xtensa/kernel/vmlinux.lds.S | 9 +++++---- include/asm-generic/vmlinux.lds.h | 7 +++++++ 29 files changed, 140 insertions(+), 117 deletions(-) diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S index 55c05b511f4c..f13249be17c5 100644 --- a/arch/alpha/kernel/vmlinux.lds.S +++ b/arch/alpha/kernel/vmlinux.lds.S @@ -46,11 +46,11 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); @@ -136,8 +136,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/arm/kernel/vmlinux.lds.S b/arch/arm/kernel/vmlinux.lds.S index 30f732c7fdb5..4898bdcfe7dd 100644 --- a/arch/arm/kernel/vmlinux.lds.S +++ b/arch/arm/kernel/vmlinux.lds.S @@ -30,7 +30,7 @@ SECTIONS } .init : { /* Init code and data */ - *(.init.text) + INIT_TEXT _einittext = .; __proc_info_begin = .; *(.proc.info.init) @@ -70,15 +70,15 @@ SECTIONS __per_cpu_end = .; #ifndef CONFIG_XIP_KERNEL __init_begin = _stext; - *(.init.data) + INIT_DATA . = ALIGN(4096); __init_end = .; #endif } /DISCARD/ : { /* Exit code and data */ - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) #ifndef CONFIG_MMU *(.fixup) @@ -130,7 +130,7 @@ SECTIONS #ifdef CONFIG_XIP_KERNEL . = ALIGN(4096); __init_begin = .; - *(.init.data) + INIT_DATA . = ALIGN(4096); __init_end = .; #endif diff --git a/arch/avr32/kernel/vmlinux.lds.S b/arch/avr32/kernel/vmlinux.lds.S index 11f08e35a2eb..481cfd40c053 100644 --- a/arch/avr32/kernel/vmlinux.lds.S +++ b/arch/avr32/kernel/vmlinux.lds.S @@ -27,19 +27,19 @@ SECTIONS __init_begin = .; _sinittext = .; *(.text.reset) - *(.init.text) + INIT_TEXT /* * .exit.text is discarded at runtime, not * link time, to deal with references from * __bug_table */ - *(.exit.text) + EXIT_TEXT _einittext = .; . = ALIGN(4); __tagtable_begin = .; *(.taglist.init) __tagtable_end = .; - *(.init.data) + INIT_DATA . = ALIGN(16); __setup_start = .; *(.init.setup) @@ -135,7 +135,7 @@ SECTIONS * thrown away, as cleanup code is never called unless it's a module. */ /DISCARD/ : { - *(.exit.data) + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/blackfin/kernel/vmlinux.lds.S b/arch/blackfin/kernel/vmlinux.lds.S index 9b75bc83c71f..858722421b40 100644 --- a/arch/blackfin/kernel/vmlinux.lds.S +++ b/arch/blackfin/kernel/vmlinux.lds.S @@ -91,13 +91,13 @@ SECTIONS { . = ALIGN(PAGE_SIZE); __sinittext = .; - *(.init.text) + INIT_TEXT __einittext = .; } .init.data : { . = ALIGN(16); - *(.init.data) + INIT_DATA } .init.setup : { @@ -198,8 +198,8 @@ SECTIONS /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } } diff --git a/arch/cris/arch-v10/vmlinux.lds.S b/arch/cris/arch-v10/vmlinux.lds.S index 97a7876ed681..93c9f0ea286b 100644 --- a/arch/cris/arch-v10/vmlinux.lds.S +++ b/arch/cris/arch-v10/vmlinux.lds.S @@ -57,10 +57,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) } @@ -109,8 +109,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.text.exit) - *(.data.exit) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/cris/arch-v32/vmlinux.lds.S b/arch/cris/arch-v32/vmlinux.lds.S index b076c134c0bb..fead8c59ea63 100644 --- a/arch/cris/arch-v32/vmlinux.lds.S +++ b/arch/cris/arch-v32/vmlinux.lds.S @@ -61,10 +61,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) } @@ -124,8 +124,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.text.exit) - *(.data.exit) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/frv/kernel/vmlinux.lds.S b/arch/frv/kernel/vmlinux.lds.S index a17a81d58bf6..f42b328b1dd0 100644 --- a/arch/frv/kernel/vmlinux.lds.S +++ b/arch/frv/kernel/vmlinux.lds.S @@ -28,14 +28,14 @@ SECTIONS .init.text : { *(.text.head) #ifndef CONFIG_DEBUG_INFO - *(.init.text) - *(.exit.text) - *(.exit.data) + INIT_TEXT + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) #endif } _einittext = .; - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(8); __setup_start = .; @@ -106,8 +106,8 @@ SECTIONS LOCK_TEXT #ifdef CONFIG_DEBUG_INFO *( - .init.text - .exit.text + INIT_TEXT + EXIT_TEXT .exitcall.exit ) #endif @@ -138,7 +138,7 @@ SECTIONS .data : { /* Data */ DATA_DATA *(.data.*) - *(.exit.data) + EXIT_DATA CONSTRUCTORS } diff --git a/arch/h8300/kernel/vmlinux.lds.S b/arch/h8300/kernel/vmlinux.lds.S index a2e72d495551..43a87b9085b6 100644 --- a/arch/h8300/kernel/vmlinux.lds.S +++ b/arch/h8300/kernel/vmlinux.lds.S @@ -110,9 +110,9 @@ SECTIONS . = ALIGN(0x4) ; ___init_begin = .; __sinittext = .; - *(.init.text) + INIT_TEXT __einittext = .; - *(.init.data) + INIT_DATA . = ALIGN(0x4) ; ___setup_start = .; *(.init.setup) @@ -124,8 +124,8 @@ SECTIONS ___con_initcall_start = .; *(.con_initcall.init) ___con_initcall_end = .; - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA #if defined(CONFIG_BLK_DEV_INITRD) . = ALIGN(4); ___initramfs_start = .; diff --git a/arch/ia64/kernel/vmlinux.lds.S b/arch/ia64/kernel/vmlinux.lds.S index 757e419ebcf8..80622acc95de 100644 --- a/arch/ia64/kernel/vmlinux.lds.S +++ b/arch/ia64/kernel/vmlinux.lds.S @@ -27,8 +27,8 @@ SECTIONS { /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) *(.IA_64.unwind.exit.text) *(.IA_64.unwind_info.exit.text) @@ -119,12 +119,12 @@ SECTIONS .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) - { *(.init.data) } + { INIT_DATA } #ifdef CONFIG_BLK_DEV_INITRD .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) diff --git a/arch/m32r/kernel/vmlinux.lds.S b/arch/m32r/kernel/vmlinux.lds.S index 942a8c7a4417..41b07854fcc6 100644 --- a/arch/m32r/kernel/vmlinux.lds.S +++ b/arch/m32r/kernel/vmlinux.lds.S @@ -76,10 +76,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) } @@ -100,8 +100,8 @@ SECTIONS .altinstr_replacement : { *(.altinstr_replacement) } /* .exit.text is discard at runtime, not link time, to deal with references from .altinstructions and .eh_frame */ - .exit.text : { *(.exit.text) } - .exit.data : { *(.exit.data) } + .exit.text : { EXIT_TEXT } + .exit.data : { EXIT_DATA } #ifdef CONFIG_BLK_DEV_INITRD . = ALIGN(4096); @@ -124,8 +124,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/m68k/kernel/vmlinux-std.lds b/arch/m68k/kernel/vmlinux-std.lds index 59fe285865ec..7537cc5e6159 100644 --- a/arch/m68k/kernel/vmlinux-std.lds +++ b/arch/m68k/kernel/vmlinux-std.lds @@ -45,10 +45,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) } @@ -82,8 +82,8 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/m68k/kernel/vmlinux-sun3.lds b/arch/m68k/kernel/vmlinux-sun3.lds index 4adffefb5c48..cdc313e7c299 100644 --- a/arch/m68k/kernel/vmlinux-sun3.lds +++ b/arch/m68k/kernel/vmlinux-sun3.lds @@ -38,10 +38,10 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; .init.setup : { *(.init.setup) } @@ -77,8 +77,8 @@ __init_begin = .; /* Sections to be discarded */ /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/m68knommu/kernel/vmlinux.lds.S b/arch/m68knommu/kernel/vmlinux.lds.S index 07a0055602f4..b44edb08e212 100644 --- a/arch/m68knommu/kernel/vmlinux.lds.S +++ b/arch/m68knommu/kernel/vmlinux.lds.S @@ -143,9 +143,9 @@ SECTIONS { . = ALIGN(4096); __init_begin = .; _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; - *(.init.data) + INIT_DATA . = ALIGN(16); __setup_start = .; *(.init.setup) @@ -170,8 +170,8 @@ SECTIONS { } > INIT /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S index 5fc2398bdb76..b5470ceb418b 100644 --- a/arch/mips/kernel/vmlinux.lds.S +++ b/arch/mips/kernel/vmlinux.lds.S @@ -114,11 +114,11 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); .init.setup : { @@ -144,10 +144,10 @@ SECTIONS * references from .rodata */ .exit.text : { - *(.exit.text) + EXIT_TEXT } .exit.data : { - *(.exit.data) + EXIT_DATA } #if defined(CONFIG_BLK_DEV_INITRD) . = ALIGN(_PAGE_SIZE); diff --git a/arch/parisc/kernel/vmlinux.lds.S b/arch/parisc/kernel/vmlinux.lds.S index 40d0ff9b81ab..50b4a3a25d0a 100644 --- a/arch/parisc/kernel/vmlinux.lds.S +++ b/arch/parisc/kernel/vmlinux.lds.S @@ -172,11 +172,11 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); .init.setup : { @@ -215,10 +215,10 @@ SECTIONS * from .altinstructions and .eh_frame */ .exit.text : { - *(.exit.text) + EXIT_TEXT } .exit.data : { - *(.exit.data) + EXIT_DATA } #ifdef CONFIG_BLK_DEV_INITRD . = ALIGN(PAGE_SIZE); diff --git a/arch/powerpc/kernel/vmlinux.lds.S b/arch/powerpc/kernel/vmlinux.lds.S index f66fa5d966b0..0afb9e31d2a0 100644 --- a/arch/powerpc/kernel/vmlinux.lds.S +++ b/arch/powerpc/kernel/vmlinux.lds.S @@ -23,7 +23,7 @@ SECTIONS /* Sections to be discarded. */ /DISCARD/ : { *(.exitcall.exit) - *(.exit.data) + EXIT_DATA } . = KERNELBASE; @@ -76,17 +76,19 @@ SECTIONS .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } /* .exit.text is discarded at runtime, not link time, * to deal with references from __bug_table */ - .exit.text : { *(.exit.text) } + .exit.text : { + EXIT_TEXT + } .init.data : { - *(.init.data); + INIT_DATA __vtop_table_begin = .; *(.vtop_fixup); __vtop_table_end = .; diff --git a/arch/ppc/kernel/vmlinux.lds.S b/arch/ppc/kernel/vmlinux.lds.S index 98c1212674f6..52b64fcbdfc5 100644 --- a/arch/ppc/kernel/vmlinux.lds.S +++ b/arch/ppc/kernel/vmlinux.lds.S @@ -97,14 +97,14 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } /* .exit.text is discarded at runtime, not link time, to deal with references from __bug_table */ - .exit.text : { *(.exit.text) } + .exit.text : { EXIT_TEXT } .init.data : { - *(.init.data); + INIT_DATA __vtop_table_begin = .; *(.vtop_fixup); __vtop_table_end = .; @@ -164,6 +164,6 @@ SECTIONS /* Sections to be discarded. */ /DISCARD/ : { *(.exitcall.exit) - *(.exit.data) + EXIT_DATA } } diff --git a/arch/s390/kernel/vmlinux.lds.S b/arch/s390/kernel/vmlinux.lds.S index 936159199346..7d43c3cd3ef3 100644 --- a/arch/s390/kernel/vmlinux.lds.S +++ b/arch/s390/kernel/vmlinux.lds.S @@ -97,7 +97,7 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } /* @@ -105,11 +105,11 @@ SECTIONS * to deal with references from __bug_table */ .exit.text : { - *(.exit.text) + EXIT_TEXT } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(0x100); .init.setup : { @@ -156,7 +156,7 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.data) + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/sh/kernel/vmlinux_32.lds.S b/arch/sh/kernel/vmlinux_32.lds.S index d549fac6d3e7..c7113786ecd4 100644 --- a/arch/sh/kernel/vmlinux_32.lds.S +++ b/arch/sh/kernel/vmlinux_32.lds.S @@ -84,9 +84,9 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; _sinittext = .; - .init.text : { *(.init.text) } + .init.text : { INIT_TEXT } _einittext = .; - .init.data : { *(.init.data) } + .init.data : { INIT_DATA } . = ALIGN(16); __setup_start = .; @@ -122,8 +122,8 @@ SECTIONS * .exit.text is discarded at runtime, not link time, to deal with * references from __bug_table */ - .exit.text : { *(.exit.text) } - .exit.data : { *(.exit.data) } + .exit.text : { EXIT_TEXT } + .exit.data : { EXIT_DATA } . = ALIGN(PAGE_SIZE); .bss : { diff --git a/arch/sh/kernel/vmlinux_64.lds.S b/arch/sh/kernel/vmlinux_64.lds.S index 2fd0f7401484..3f1bd6392bb3 100644 --- a/arch/sh/kernel/vmlinux_64.lds.S +++ b/arch/sh/kernel/vmlinux_64.lds.S @@ -96,9 +96,9 @@ SECTIONS . = ALIGN(PAGE_SIZE); /* Init code and data */ __init_begin = .; _sinittext = .; - .init.text : C_PHYS(.init.text) { *(.init.text) } + .init.text : C_PHYS(.init.text) { INIT_TEXT } _einittext = .; - .init.data : C_PHYS(.init.data) { *(.init.data) } + .init.data : C_PHYS(.init.data) { INIT_DATA } . = ALIGN(L1_CACHE_BYTES); /* Better if Cache Line aligned */ __setup_start = .; .init.setup : C_PHYS(.init.setup) { *(.init.setup) } @@ -134,8 +134,8 @@ SECTIONS * .exit.text is discarded at runtime, not link time, to deal with * references from __bug_table */ - .exit.text : C_PHYS(.exit.text) { *(.exit.text) } - .exit.data : C_PHYS(.exit.data) { *(.exit.data) } + .exit.text : C_PHYS(.exit.text) { EXIT_TEXT } + .exit.data : C_PHYS(.exit.data) { EXIT_DATA } . = ALIGN(PAGE_SIZE); .bss : C_PHYS(.bss) { diff --git a/arch/sparc/kernel/vmlinux.lds.S b/arch/sparc/kernel/vmlinux.lds.S index a8b4200f9cc3..216147d6e61f 100644 --- a/arch/sparc/kernel/vmlinux.lds.S +++ b/arch/sparc/kernel/vmlinux.lds.S @@ -48,12 +48,12 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } __init_text_end = .; .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); .init.setup : { @@ -102,8 +102,8 @@ SECTIONS _end = . ; PROVIDE (end = .); /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/sparc64/kernel/vmlinux.lds.S b/arch/sparc64/kernel/vmlinux.lds.S index 9fcd503bc04a..01f809617e5e 100644 --- a/arch/sparc64/kernel/vmlinux.lds.S +++ b/arch/sparc64/kernel/vmlinux.lds.S @@ -56,11 +56,11 @@ SECTIONS .init.text : { __init_begin = .; _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA } . = ALIGN(16); .init.setup : { @@ -137,8 +137,8 @@ SECTIONS PROVIDE (end = .); /DISCARD/ : { - *(.exit.text) - *(.exit.data) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/arch/um/kernel/dyn.lds.S b/arch/um/kernel/dyn.lds.S index 3866f4960f04..26090b7f323e 100644 --- a/arch/um/kernel/dyn.lds.S +++ b/arch/um/kernel/dyn.lds.S @@ -17,7 +17,7 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } @@ -84,7 +84,7 @@ SECTIONS #include "asm/common.lds.S" - init.data : { *(.init.data) } + init.data : { INIT_DATA } /* Ensure the __preinit_array_start label is properly aligned. We could instead move the label definition inside the section, but diff --git a/arch/um/kernel/uml.lds.S b/arch/um/kernel/uml.lds.S index 13df191e2b41..5828c1d54505 100644 --- a/arch/um/kernel/uml.lds.S +++ b/arch/um/kernel/uml.lds.S @@ -23,7 +23,7 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } . = ALIGN(4096); @@ -48,7 +48,7 @@ SECTIONS #include "asm/common.lds.S" - init.data : { *(init.data) } + init.data : { INIT_DATA } .data : { . = ALIGN(KERNEL_STACK_SIZE); /* init_task */ diff --git a/arch/v850/kernel/vmlinux.lds.S b/arch/v850/kernel/vmlinux.lds.S index 6172599b4ce2..d08cd1d27f27 100644 --- a/arch/v850/kernel/vmlinux.lds.S +++ b/arch/v850/kernel/vmlinux.lds.S @@ -114,7 +114,7 @@ #define DATA_CONTENTS \ __sdata = . ; \ DATA_DATA \ - *(.exit.data) /* 2.5 convention */ \ + EXIT_DATA /* 2.5 convention */ \ *(.data.exit) /* 2.4 convention */ \ . = ALIGN (16) ; \ *(.data.cacheline_aligned) \ @@ -157,9 +157,9 @@ . = ALIGN (4096) ; \ __init_start = . ; \ __sinittext = .; \ - *(.init.text) /* 2.5 convention */ \ + INIT_TEXT /* 2.5 convention */ \ __einittext = .; \ - *(.init.data) \ + INIT_DATA \ *(.text.init) /* 2.4 convention */ \ *(.data.init) \ INITCALL_CONTENTS \ @@ -170,7 +170,7 @@ #define ROMK_INIT_RAM_CONTENTS \ . = ALIGN (4096) ; \ __init_start = . ; \ - *(.init.data) /* 2.5 convention */ \ + INIT_DATA /* 2.5 convention */ \ *(.data.init) /* 2.4 convention */ \ __init_end = . ; \ . = ALIGN (4096) ; @@ -179,7 +179,7 @@ should go into ROM. */ #define ROMK_INIT_ROM_CONTENTS \ _sinittext = .; \ - *(.init.text) /* 2.5 convention */ \ + INIT_TEXT /* 2.5 convention */ \ _einittext = .; \ *(.text.init) /* 2.4 convention */ \ INITCALL_CONTENTS \ diff --git a/arch/x86/kernel/vmlinux_32.lds.S b/arch/x86/kernel/vmlinux_32.lds.S index 7d72cce00529..84c913f38f98 100644 --- a/arch/x86/kernel/vmlinux_32.lds.S +++ b/arch/x86/kernel/vmlinux_32.lds.S @@ -131,10 +131,12 @@ SECTIONS .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { __init_begin = .; _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) } + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { + INIT_DATA + } . = ALIGN(16); .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { __setup_start = .; @@ -169,8 +171,12 @@ SECTIONS } /* .exit.text is discard at runtime, not link time, to deal with references from .altinstructions and .eh_frame */ - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) } - .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) } + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { + EXIT_TEXT + } + .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { + EXIT_DATA + } #if defined(CONFIG_BLK_DEV_INITRD) . = ALIGN(4096); .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { diff --git a/arch/x86/kernel/vmlinux_64.lds.S b/arch/x86/kernel/vmlinux_64.lds.S index ba8ea97abd21..ea5386944e67 100644 --- a/arch/x86/kernel/vmlinux_64.lds.S +++ b/arch/x86/kernel/vmlinux_64.lds.S @@ -155,12 +155,15 @@ SECTIONS __init_begin = .; .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { _sinittext = .; - *(.init.text) + INIT_TEXT _einittext = .; } - __initdata_begin = .; - .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { *(.init.data) } - __initdata_end = .; + .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { + __initdata_begin = .; + INIT_DATA + __initdata_end = .; + } + . = ALIGN(16); __setup_start = .; .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { *(.init.setup) } @@ -187,8 +190,12 @@ SECTIONS } /* .exit.text is discard at runtime, not link time, to deal with references from .altinstructions and .eh_frame */ - .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { *(.exit.text) } - .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { *(.exit.data) } + .exit.text : AT(ADDR(.exit.text) - LOAD_OFFSET) { + EXIT_TEXT + } + .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { + EXIT_DATA + } /* vdso blob that is mapped into user space */ vdso_start = . ; diff --git a/arch/xtensa/kernel/vmlinux.lds.S b/arch/xtensa/kernel/vmlinux.lds.S index ac4ed52034db..7d0f55a4982d 100644 --- a/arch/xtensa/kernel/vmlinux.lds.S +++ b/arch/xtensa/kernel/vmlinux.lds.S @@ -136,13 +136,13 @@ SECTIONS __init_begin = .; .init.text : { _sinittext = .; - *(.init.literal) *(.init.text) + *(.init.literal) INIT_TEXT _einittext = .; } .init.data : { - *(.init.data) + INIT_DATA . = ALIGN(0x4); __tagtable_begin = .; *(.taglist) @@ -278,8 +278,9 @@ SECTIONS /* Sections to be discarded */ /DISCARD/ : { - *(.exit.literal .exit.text) - *(.exit.data) + *(.exit.literal) + EXIT_TEXT + EXIT_DATA *(.exitcall.exit) } diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 9f584cc5c5fb..ae0166e83490 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -183,6 +183,13 @@ *(.kprobes.text) \ VMLINUX_SYMBOL(__kprobes_text_end) = .; +/* init and exit section handling */ +#define INIT_TEXT *(.init.text) +#define INIT_DATA *(.init.data) +#define EXIT_TEXT *(.exit.text) +#define EXIT_DATA *(.exit.data) + + /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to the beginning of the section so we begin them at 0. */ -- cgit v1.2.3 From f3fe866d59d707c7a2bba0b23add078e19edb3dc Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 20 Jan 2008 18:54:48 +0100 Subject: compiler.h: introduce __section() Add a new helper: __section() that makes a section definition much shorter and more readable. Signed-off-by: Sam Ravnborg --- include/linux/compiler.h | 5 +++++ include/linux/init.h | 26 +++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index c68b67b86ef1..e0114a61268f 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -175,4 +175,9 @@ extern void __chk_io_ptr(const volatile void __iomem *); #define __cold #endif +/* Simple shorthand for a section definition */ +#ifndef __section +# define __section(S) __attribute__ ((__section__(#S))) +#endif + #endif /* __LINUX_COMPILER_H */ diff --git a/include/linux/init.h b/include/linux/init.h index 5141381a7527..998076818402 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -40,10 +40,10 @@ /* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __attribute__ ((__section__ (".init.text"))) __cold -#define __initdata __attribute__ ((__section__ (".init.data"))) -#define __exitdata __attribute__ ((__section__(".exit.data"))) -#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) +#define __init __section(.init.text) __cold +#define __initdata __section(.init.data) +#define __exitdata __section(.exit.data) +#define __exit_call __attribute_used__ __section(.exitcall.exit) /* modpost check for section mismatches during the kernel build. * A section mismatch happens when there are references from a @@ -55,14 +55,14 @@ * the init/exit section (code or data) is valid and will teach modpost * not to issue a warning. * The markers follow same syntax rules as __init / __initdata. */ -#define __init_refok noinline __attribute__ ((__section__ (".text.init.refok"))) -#define __initdata_refok __attribute__ ((__section__ (".data.init.refok"))) -#define __exit_refok noinline __attribute__ ((__section__ (".exit.text.refok"))) +#define __init_refok noinline __section(.text.init.refok) +#define __initdata_refok __section(.data.init.refok) +#define __exit_refok noinline __section(.exit.text.refok) #ifdef MODULE -#define __exit __attribute__ ((__section__(".exit.text"))) __cold +#define __exit __section(.exit.text) __cold #else -#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) __cold +#define __exit __attribute_used__ __section(.exit.text) __cold #endif /* For assembly routines */ @@ -142,11 +142,11 @@ void prepare_namespace(void); #define console_initcall(fn) \ static initcall_t __initcall_##fn \ - __attribute_used__ __attribute__((__section__(".con_initcall.init")))=fn + __attribute_used__ __section(.con_initcall.init)=fn #define security_initcall(fn) \ static initcall_t __initcall_##fn \ - __attribute_used__ __attribute__((__section__(".security_initcall.init"))) = fn + __attribute_used__ __section(.security_initcall.init) = fn struct obs_kernel_param { const char *str; @@ -164,7 +164,7 @@ struct obs_kernel_param { static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \ static struct obs_kernel_param __setup_##unique_id \ __attribute_used__ \ - __attribute__((__section__(".init.setup"))) \ + __section(.init.setup) \ __attribute__((aligned((sizeof(long))))) \ = { __setup_str_##unique_id, fn, early } @@ -242,7 +242,7 @@ void __init parse_early_param(void); #endif /* Data marked not to be saved by software suspend */ -#define __nosavedata __attribute__ ((__section__ (".data.nosave"))) +#define __nosavedata __section(.data.nosave) /* This means "can be init if no module support, otherwise module load may call it." */ -- cgit v1.2.3 From eb8f689046b857874e964463619f09df06d59fad Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 20 Jan 2008 20:07:28 +0100 Subject: Use separate sections for __dev/__cpu/__mem code/data Introducing separate sections for __dev* (HOTPLUG), __cpu* (HOTPLUG_CPU) and __mem* (MEMORY_HOTPLUG) allows us to do a much more reliable Section mismatch check in modpost. We are no longer dependent on the actual configuration of for example HOTPLUG. This has the effect that all users see much more Section mismatch warnings than before because they were almost all hidden when HOTPLUG was enabled. The advantage of this is that when building a piece of code then it is much more likely that the Section mismatch errors are spotted and the warnings will be felt less random of nature. Signed-off-by: Sam Ravnborg Cc: Greg KH Cc: Randy Dunlap Cc: Adrian Bunk --- include/asm-generic/vmlinux.lds.h | 88 ++++++++++++++++++++++++++++++++++++--- include/linux/init.h | 77 +++++++++++++++++----------------- scripts/mod/modpost.c | 54 +++++++++++++++++------- 3 files changed, 159 insertions(+), 60 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index ae0166e83490..e0a56fb8f813 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -9,10 +9,46 @@ /* Align . to a 8 byte boundary equals to maximum function alignment. */ #define ALIGN_FUNCTION() . = ALIGN(8) +/* The actual configuration determine if the init/exit sections + * are handled as text/data or they can be discarded (which + * often happens at runtime) + */ +#ifdef CONFIG_HOTPLUG +#define DEV_KEEP(sec) *(.dev##sec) +#define DEV_DISCARD(sec) +#else +#define DEV_KEEP(sec) +#define DEV_DISCARD(sec) *(.dev##sec) +#endif + +#ifdef CONFIG_HOTPLUG_CPU +#define CPU_KEEP(sec) *(.cpu##sec) +#define CPU_DISCARD(sec) +#else +#define CPU_KEEP(sec) +#define CPU_DISCARD(sec) *(.cpu##sec) +#endif + +#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_ACPI_HOTPLUG_MEMORY) \ + || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE) +#define MEM_KEEP(sec) *(.mem##sec) +#define MEM_DISCARD(sec) +#else +#define MEM_KEEP(sec) +#define MEM_DISCARD(sec) *(.mem##sec) +#endif + + /* .data section */ #define DATA_DATA \ *(.data) \ *(.data.init.refok) \ + DEV_KEEP(init.data) \ + DEV_KEEP(exit.data) \ + CPU_KEEP(init.data) \ + CPU_KEEP(exit.data) \ + MEM_KEEP(init.data) \ + MEM_KEEP(exit.data) \ . = ALIGN(8); \ VMLINUX_SYMBOL(__start___markers) = .; \ *(__markers) \ @@ -132,6 +168,16 @@ *(__ksymtab_strings) \ } \ \ + /* __*init sections */ \ + __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \ + DEV_KEEP(init.rodata) \ + DEV_KEEP(exit.rodata) \ + CPU_KEEP(init.rodata) \ + CPU_KEEP(exit.rodata) \ + MEM_KEEP(init.rodata) \ + MEM_KEEP(exit.rodata) \ + } \ + \ /* Built-in module parameters. */ \ __param : AT(ADDR(__param) - LOAD_OFFSET) { \ VMLINUX_SYMBOL(__start___param) = .; \ @@ -139,7 +185,6 @@ VMLINUX_SYMBOL(__stop___param) = .; \ VMLINUX_SYMBOL(__end_rodata) = .; \ } \ - \ . = ALIGN((align)); /* RODATA provided for backward compatibility. @@ -159,7 +204,14 @@ ALIGN_FUNCTION(); \ *(.text) \ *(.text.init.refok) \ - *(.exit.text.refok) + *(.exit.text.refok) \ + DEV_KEEP(init.text) \ + DEV_KEEP(exit.text) \ + CPU_KEEP(init.text) \ + CPU_KEEP(exit.text) \ + MEM_KEEP(init.text) \ + MEM_KEEP(exit.text) + /* sched.text is aling to function alignment to secure we have same * address even at second ld pass when generating System.map */ @@ -184,11 +236,35 @@ VMLINUX_SYMBOL(__kprobes_text_end) = .; /* init and exit section handling */ -#define INIT_TEXT *(.init.text) -#define INIT_DATA *(.init.data) -#define EXIT_TEXT *(.exit.text) -#define EXIT_DATA *(.exit.data) +#define INIT_DATA \ + *(.init.data) \ + DEV_DISCARD(init.data) \ + DEV_DISCARD(init.rodata) \ + CPU_DISCARD(init.data) \ + CPU_DISCARD(init.rodata) \ + MEM_DISCARD(init.data) \ + MEM_DISCARD(init.rodata) + +#define INIT_TEXT \ + *(.init.text) \ + DEV_DISCARD(init.text) \ + CPU_DISCARD(init.text) \ + MEM_DISCARD(init.text) + +#define EXIT_DATA \ + *(.exit.data) \ + DEV_DISCARD(exit.data) \ + DEV_DISCARD(exit.rodata) \ + CPU_DISCARD(exit.data) \ + CPU_DISCARD(exit.rodata) \ + MEM_DISCARD(exit.data) \ + MEM_DISCARD(exit.rodata) +#define EXIT_TEXT \ + *(.exit.text) \ + DEV_DISCARD(exit.text) \ + CPU_DISCARD(exit.text) \ + MEM_DISCARD(exit.text) /* DWARF debug sections. Symbols in the DWARF debugging sections are relative to diff --git a/include/linux/init.h b/include/linux/init.h index 998076818402..dcb66c76bd48 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -60,18 +60,54 @@ #define __exit_refok noinline __section(.exit.text.refok) #ifdef MODULE -#define __exit __section(.exit.text) __cold +#define __exitused #else -#define __exit __attribute_used__ __section(.exit.text) __cold +#define __exitused __used #endif +#define __exit __section(.exit.text) __exitused __cold + +/* Used for HOTPLUG */ +#define __devinit __section(.devinit.text) __cold +#define __devinitdata __section(.devinit.data) +#define __devinitconst __section(.devinit.rodata) +#define __devexit __section(.devexit.text) __exitused __cold +#define __devexitdata __section(.devexit.data) +#define __devexitconst __section(.devexit.rodata) + +/* Used for HOTPLUG_CPU */ +#define __cpuinit __section(.cpuinit.text) __cold +#define __cpuinitdata __section(.cpuinit.data) +#define __cpuinitconst __section(.cpuinit.rodata) +#define __cpuexit __section(.cpuexit.text) __exitused __cold +#define __cpuexitdata __section(.cpuexit.data) +#define __cpuexitconst __section(.cpuexit.rodata) + +/* Used for MEMORY_HOTPLUG */ +#define __meminit __section(.meminit.text) __cold +#define __meminitdata __section(.meminit.data) +#define __meminitconst __section(.meminit.rodata) +#define __memexit __section(.memexit.text) __exitused __cold +#define __memexitdata __section(.memexit.data) +#define __memexitconst __section(.memexit.rodata) + /* For assembly routines */ #define __INIT .section ".init.text","ax" #define __INIT_REFOK .section ".text.init.refok","ax" #define __FINIT .previous + #define __INITDATA .section ".init.data","aw" #define __INITDATA_REFOK .section ".data.init.refok","aw" +#define __DEVINIT .section ".devinit.text", "ax" +#define __DEVINITDATA .section ".devinit.data", "aw" + +#define __CPUINIT .section ".cpuinit.text", "ax" +#define __CPUINITDATA .section ".cpuinit.data", "aw" + +#define __MEMINIT .section ".meminit.text", "ax" +#define __MEMINITDATA .section ".meminit.data", "aw" + #ifndef __ASSEMBLY__ /* * Used for initialization calls.. @@ -254,43 +290,6 @@ void __init parse_early_param(void); #define __initdata_or_module __initdata #endif /*CONFIG_MODULES*/ -#ifdef CONFIG_HOTPLUG -#define __devinit -#define __devinitdata -#define __devexit -#define __devexitdata -#else -#define __devinit __init -#define __devinitdata __initdata -#define __devexit __exit -#define __devexitdata __exitdata -#endif - -#ifdef CONFIG_HOTPLUG_CPU -#define __cpuinit -#define __cpuinitdata -#define __cpuexit -#define __cpuexitdata -#else -#define __cpuinit __init -#define __cpuinitdata __initdata -#define __cpuexit __exit -#define __cpuexitdata __exitdata -#endif - -#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_ACPI_HOTPLUG_MEMORY) \ - || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE) -#define __meminit -#define __meminitdata -#define __memexit -#define __memexitdata -#else -#define __meminit __init -#define __meminitdata __initdata -#define __memexit __exit -#define __memexitdata __exitdata -#endif - /* Functions marked as __devexit may be discarded at kernel link time, depending on config options. Newer versions of binutils detect references from retained sections to discarded sections and flag an error. Pointers to diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 986513dcd700..730b321680cd 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -670,27 +670,41 @@ int match(const char *sym, const char * const pat[]) static const char *section_white_list[] = { ".debug*", ".stab*", ".note*", ".got*", ".toc*", NULL }; -#define INIT_DATA_SECTIONS ".init.data$" -#define EXIT_DATA_SECTIONS ".exit.data$" +#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 INIT_TEXT_SECTIONS ".init.text$" -#define EXIT_TEXT_SECTIONS ".exit.text$" +#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 INIT_SECTIONS INIT_DATA_SECTIONS, INIT_TEXT_SECTIONS -#define EXIT_SECTIONS EXIT_DATA_SECTIONS, EXIT_TEXT_SECTIONS +#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[] = { INIT_DATA_SECTIONS, NULL }; +static const char *init_data_sections[] = { ALL_INIT_DATA_SECTIONS, NULL }; /* all init sections */ -static const char *init_sections[] = { INIT_SECTIONS, NULL }; +static const char *init_sections[] = { ALL_INIT_SECTIONS, NULL }; /* All init and exit sections (code + data) */ static const char *init_exit_sections[] = - {INIT_SECTIONS, EXIT_SECTIONS, NULL }; + {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }; /* data section */ static const char *data_sections[] = { DATA_SECTIONS, NULL }; @@ -734,22 +748,32 @@ const struct sectioncheck sectioncheck[] = { */ { .fromsec = { TEXT_SECTIONS, DATA_SECTIONS, NULL }, - .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL } + .tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL } +}, +/* 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 } +}, +/* 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 } }, /* Do not use exit code/data from init code */ { - .fromsec = { INIT_SECTIONS, NULL }, - .tosec = { EXIT_SECTIONS, NULL }, + .fromsec = { ALL_INIT_SECTIONS, NULL }, + .tosec = { ALL_EXIT_SECTIONS, NULL }, }, /* Do not use init code/data from exit code */ { - .fromsec = { EXIT_SECTIONS, NULL }, - .tosec = { INIT_SECTIONS, NULL } + .fromsec = { ALL_EXIT_SECTIONS, NULL }, + .tosec = { ALL_INIT_SECTIONS, NULL } }, /* Do not export init/exit functions or data */ { .fromsec = { "__ksymtab*", NULL }, - .tosec = { INIT_SECTIONS, EXIT_SECTIONS, NULL } + .tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL } } }; -- cgit v1.2.3 From 91341d4b2c196c689acf90e9e96f28f8d5c6665f Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 21 Jan 2008 21:31:44 +0100 Subject: kbuild: introduce new option to enhance section mismatch analysis Setting the option DEBUG_SECTION_MISMATCH will report additional section mismatch'es but this should in the end makes it possible to get rid of all of them. See help text in lib/Kconfig.debug for details. Signed-off-by: Sam Ravnborg --- Makefile | 5 +++++ lib/Kconfig.debug | 30 ++++++++++++++++++++++++++++++ scripts/Makefile.build | 9 +++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 6847464402aa..8533f258c0e4 100644 --- a/Makefile +++ b/Makefile @@ -520,6 +520,11 @@ KBUILD_CFLAGS += -g KBUILD_AFLAGS += -gdwarf-2 endif +# We trigger additional mismatches with less inlining +ifdef CONFIG_DEBUG_SECTION_MISMATCH +KBUILD_CFLAGS += $(call cc-option, -fno-inline-functions-called-once) +endif + # Force gcc to behave correct even for buggy distributions KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 14fb355e3caa..748e72be6e68 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -79,6 +79,36 @@ config HEADERS_CHECK exported to $(INSTALL_HDR_PATH) (usually 'usr/include' in your build tree), to make sure they're suitable. +config DEBUG_SECTION_MISMATCH + bool "Enable full Section mismatch analysis" + default n + help + The section mismatch analysis checks if there are illegal + references from one section to another section. + Linux will during link or during runtime drop some sections + and any use of code/data previously in these sections will + most likely result in an oops. + In the code functions and variables are annotated with + __init, __devinit etc. (see full list in include/linux/init.h) + which result in the code/data being placed in specific sections. + The section mismatch anaylsis are always done after a full + kernel build but enabling this options will in addition + do the following: + - Add the option -fno-inline-functions-called-once to gcc + When inlining a function annotated __init in a non-init + function we would loose the section information and thus + the analysis would not catch the illegal reference. + This options tell gcc to inline less but will also + result in a larger kernel. + - Run the section mismatch analysis for each module/built-in.o + When we run the section mismatch analysis on vmlinux.o we + looses valueable information about where the mismatch was + introduced. + Running the analysis for each module/built-in.o file + will tell where the mismatch happens much closer to the + source. The drawback is that we will report the same + mismatch at least twice. + config DEBUG_KERNEL bool "Kernel debugging" help diff --git a/scripts/Makefile.build b/scripts/Makefile.build index db38ef465a63..67fb4530a6ff 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -103,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) # --------------------------------------------------------------------------- @@ -268,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 @@ -316,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) -- cgit v1.2.3 From 310f8243a602e9ae950e81b17cbd18a4246674f9 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 21 Jan 2008 22:57:09 +0100 Subject: kbuild: link vmlinux.o before kallsyms passes link vmlinux.o so we may report section mismatch bugs before we start with the real link - that may error out. Signed-off-by: Sam Ravnborg --- Makefile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 8533f258c0e4..0f84c742ed0e 100644 --- a/Makefile +++ b/Makefile @@ -798,7 +798,7 @@ define rule_vmlinux-modpost endef # vmlinux image - including updated kernel symbols -vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) vmlinux.o FORCE +vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o $(kallsyms.o) FORCE ifdef CONFIG_HEADERS_CHECK $(Q)$(MAKE) -f $(srctree)/Makefile headers_check endif @@ -809,7 +809,9 @@ endif $(call if_changed_rule,vmlinux__) $(Q)rm -f .old_version -vmlinux.o: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE +# build vmlinux.o first to catch section mismatch errors early +$(kallsyms.o): vmlinux.o +vmlinux.o: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) FORCE $(call if_changed_rule,vmlinux-modpost) # The actual objects are generated when descending, -- cgit v1.2.3 From 157c23c80eed84194440b487658398272eaebaf4 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 22 Jan 2008 21:44:32 +0100 Subject: kbuild: use simpler section mismatch warnings in modpost The typical layout is now: WARNING: vmlinux.o(.text+0x372ec): Section mismatch: reference to .devinit.text:pci_scan_one_pbm in 'psycho_scan_bus' This is first step towards more readable warnings. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 56 +++++++++++++++------------------------------------ 1 file changed, 16 insertions(+), 40 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 730b321680cd..7dfd0395c5b0 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -938,20 +938,16 @@ 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_Sym *near = NULL; Elf_Ehdr *hdr = elf->hdr; - Elf_Addr beforediff = ~0; - Elf_Addr afterdiff = ~0; + Elf_Addr distance = ~0; const char *secstrings = (void *)hdr + elf->sechdrs[hdr->e_shstrndx].sh_offset; - *before = NULL; - *after = NULL; - for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { const char *symsec; @@ -963,20 +959,15 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, 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; } - } else { - if ((sym->st_value - addr) < afterdiff) { - afterdiff = sym->st_value - addr; - *after = sym; - } else if ((sym->st_value - addr) == afterdiff) - *after = sym; } } + return near; } /** @@ -988,7 +979,7 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, struct elf_info *elf, Elf_Sym *sym, Elf_Rela r) { const char *refsymname = ""; - Elf_Sym *before, *after; + Elf_Sym *where; Elf_Sym *refsym; Elf_Ehdr *hdr = elf->hdr; Elf_Shdr *sechdrs = elf->sechdrs; @@ -996,7 +987,7 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, 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); + where = find_elf_symbol2(elf, r.r_offset, fromsec); refsym = find_elf_symbol(elf, r.r_addend, sym); if (refsym && strlen(elf->strtab + refsym->st_name)) @@ -1004,30 +995,15 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, /* check whitelist - we may ignore it */ if (secref_whitelist(modname, secname, fromsec, - before ? elf->strtab + before->st_name : "", + where ? elf->strtab + where->st_name : "", refsymname)) 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) { + if (where) { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " - "before '%s' (at offset -0x%llx)\n", + "in '%s'\n", modname, fromsec, (unsigned long long)r.r_offset, - secname, refsymname, - elf->strtab + after->st_name, - (unsigned long long)r.r_offset); + secname, refsymname, elf->strtab + where->st_name); } else { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s\n", modname, fromsec, (unsigned long long)r.r_offset, -- cgit v1.2.3 From ff13f92690249061311c7cf69a89e5a2fb068811 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 23 Jan 2008 19:54:27 +0100 Subject: kbuild: introduce a few helpers in modpost Introducing helpers to retreive symbol and section names cleaned up the code a bit. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 73 +++++++++++++++++++++++++++------------------------ 1 file changed, 38 insertions(+), 35 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 7dfd0395c5b0..e4099cd5f085 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -605,6 +605,26 @@ static int strrcmp(const char *s, const char *sub) return memcmp(s + slen - sublen, sub, sublen); } +static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) +{ + return elf->strtab + sym->st_name; +} + +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 @@ -943,17 +963,14 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, { Elf_Sym *sym; Elf_Sym *near = NULL; - Elf_Ehdr *hdr = elf->hdr; Elf_Addr distance = ~0; - const char *secstrings = (void *)hdr + - elf->sechdrs[hdr->e_shstrndx].sh_offset; 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)) @@ -978,24 +995,21 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, static void warn_sec_mismatch(const char *modname, const char *fromsec, struct elf_info *elf, Elf_Sym *sym, Elf_Rela r) { - const char *refsymname = ""; Elf_Sym *where; 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; + const char *refsymname = ""; + const char *secname; + secname = sec_name(elf, sym->st_shndx); where = find_elf_symbol2(elf, r.r_offset, fromsec); refsym = find_elf_symbol(elf, r.r_addend, sym); - if (refsym && strlen(elf->strtab + refsym->st_name)) - refsymname = elf->strtab + refsym->st_name; + if (refsym && strlen(sym_name(elf, refsym))) + refsymname = sym_name(elf, refsym); /* check whitelist - we may ignore it */ if (secref_whitelist(modname, secname, fromsec, - where ? elf->strtab + where->st_name : "", + where ? sym_name(elf, where) : "", refsymname)) return; @@ -1003,7 +1017,7 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " "in '%s'\n", modname, fromsec, (unsigned long long)r.r_offset, - secname, refsymname, elf->strtab + where->st_name); + secname, refsymname, sym_name(elf, where)); } else { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s\n", modname, fromsec, (unsigned long long)r.r_offset, @@ -1095,14 +1109,10 @@ static void section_rela(const char *modname, struct elf_info *elf, const char *fromsec; const char * tosec; - Elf_Ehdr *hdr = elf->hdr; - Elf_Rela *start = (void *)hdr + sechdr->sh_offset; + Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset; Elf_Rela *stop = (void *)start + sechdr->sh_size; - const char *secstrings = (void *)hdr + - elf->sechdrs[hdr->e_shstrndx].sh_offset; - - fromsec = secstrings + sechdr->sh_name; + fromsec = sech_name(elf, sechdr); fromsec += strlen(".rela"); /* if from section (name) is know good then skip it */ if (match(fromsec, section_white_list)) @@ -1111,7 +1121,7 @@ static void section_rela(const char *modname, struct elf_info *elf, for (rela = start; rela < stop; rela++) { r.r_offset = TO_NATIVE(rela->r_offset); #if KERNEL_ELFCLASS == ELFCLASS64 - if (hdr->e_machine == EM_MIPS) { + 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); @@ -1131,8 +1141,7 @@ static void section_rela(const char *modname, struct elf_info *elf, if (sym->st_shndx >= SHN_LORESERVE) continue; - tosec = secstrings + - elf->sechdrs[sym->st_shndx].sh_name; + tosec = sec_name(elf, sym->st_shndx); if (section_mismatch(fromsec, tosec)) warn_sec_mismatch(modname, fromsec, elf, sym, r); } @@ -1148,14 +1157,10 @@ static void section_rel(const char *modname, struct elf_info *elf, const char *fromsec; const char * tosec; - Elf_Ehdr *hdr = elf->hdr; - Elf_Rel *start = (void *)hdr + sechdr->sh_offset; + Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset; Elf_Rel *stop = (void *)start + sechdr->sh_size; - const char *secstrings = (void *)hdr + - elf->sechdrs[hdr->e_shstrndx].sh_offset; - - fromsec = secstrings + sechdr->sh_name; + fromsec = sech_name(elf, sechdr); fromsec += strlen(".rel"); /* if from section (name) is know good then skip it */ if (match(fromsec, section_white_list)) @@ -1164,7 +1169,7 @@ static void section_rel(const char *modname, struct elf_info *elf, for (rel = start; rel < stop; rel++) { r.r_offset = TO_NATIVE(rel->r_offset); #if KERNEL_ELFCLASS == ELFCLASS64 - if (hdr->e_machine == EM_MIPS) { + 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); @@ -1179,7 +1184,7 @@ static void section_rel(const char *modname, struct elf_info *elf, r_sym = ELF_R_SYM(r.r_info); #endif r.r_addend = 0; - switch (hdr->e_machine) { + switch (elf->hdr->e_machine) { case EM_386: if (addend_386_rel(elf, sechdr, &r)) continue; @@ -1198,8 +1203,7 @@ static void section_rel(const char *modname, struct elf_info *elf, if (sym->st_shndx >= SHN_LORESERVE) continue; - tosec = secstrings + - elf->sechdrs[sym->st_shndx].sh_name; + tosec = sec_name(elf, sym->st_shndx); if (section_mismatch(fromsec, tosec)) warn_sec_mismatch(modname, fromsec, elf, sym, r); } @@ -1221,11 +1225,10 @@ static void check_sec_ref(struct module *mod, const char *modname, struct elf_info *elf) { int i; - Elf_Ehdr *hdr = elf->hdr; Elf_Shdr *sechdrs = elf->sechdrs; /* Walk through all sections */ - for (i = 0; i < hdr->e_shnum; i++) { + 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) section_rela(modname, elf, &elf->sechdrs[i]); -- cgit v1.2.3 From 58fb0d4f2fd5773ec0158d1f2774dca6a03e6984 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 23 Jan 2008 21:13:50 +0100 Subject: kbuild: simplified warning report in modpost Refactor code so the warning report function does nothing else than reporting warnings. As a side effect some other code paths were cleaned up by this. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 104 +++++++++++++++++++++++++------------------------- 1 file changed, 52 insertions(+), 52 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index e4099cd5f085..0a80acafd212 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -607,7 +607,10 @@ static int strrcmp(const char *s, const char *sub) static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) { - return elf->strtab + sym->st_name; + if (sym) + return elf->strtab + sym->st_name; + else + return ""; } static const char *sec_name(struct elf_info *elf, int shndx) @@ -812,7 +815,6 @@ static int section_mismatch(const char *fromsec, const char *tosec) return 0; } - /** * Whitelist to allow certain references to pass with no warning. * @@ -856,36 +858,35 @@ static int section_mismatch(const char *fromsec, const char *tosec) * refsymname = __init_begin, _sinittext, _einittext * **/ -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) { /* Check for pattern 0 */ if (match(fromsec, initref_sections)) - return 1; + return 0; /* Check for pattern 1 */ if (match(tosec, init_data_sections) && match(fromsec, data_sections) && - (strncmp(atsym, "__param", strlen("__param")) == 0)) - return 1; + (strncmp(fromsym, "__param", strlen("__param")) == 0)) + return 0; /* Check for pattern 2 */ if (match(tosec, init_exit_sections) && match(fromsec, data_sections) && - match(atsym, symbol_white_list)) - return 1; + match(fromsym, symbol_white_list)) + return 0; /* Check for pattern 3 */ if (match(fromsec, head_sections) && match(tosec, init_sections)) - return 1; + return 0; /* Check for pattern 4 */ - if (match(refsymname, linker_symbols)) - return 1; + if (match(tosym, linker_symbols)) + return 0; - return 0; + return 1; } /** @@ -987,41 +988,49 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, return near; } -/** +/* * 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, + const char *fromsec, + unsigned long long fromaddr, + const char *fromsym, + const char *tosec, const char *tosym) { - Elf_Sym *where; - Elf_Sym *refsym; - const char *refsymname = ""; - const char *secname; - - secname = sec_name(elf, sym->st_shndx); - where = find_elf_symbol2(elf, r.r_offset, fromsec); - - refsym = find_elf_symbol(elf, r.r_addend, sym); - if (refsym && strlen(sym_name(elf, refsym))) - refsymname = sym_name(elf, refsym); - - /* check whitelist - we may ignore it */ - if (secref_whitelist(modname, secname, fromsec, - where ? sym_name(elf, where) : "", - refsymname)) - return; - - if (where) { + if (strlen(tosym)) { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " "in '%s'\n", - modname, fromsec, (unsigned long long)r.r_offset, - secname, refsymname, sym_name(elf, where)); + modname, fromsec, fromaddr, + tosec, tosym, fromsym); } else { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s\n", - modname, fromsec, (unsigned long long)r.r_offset, - secname, refsymname); + modname, fromsec, fromaddr, + tosec, tosym); + } +} + +static void check_section_mismatch(const char *modname, struct elf_info *elf, + Elf_Rela *r, Elf_Sym *sym, const char *fromsec) +{ + const char *tosec; + + tosec = sec_name(elf, sym->st_shndx); + if (section_mismatch(fromsec, tosec)) { + const char *fromsym; + const char *tosym; + + fromsym = sym_name(elf, + find_elf_symbol2(elf, r->r_offset, fromsec)); + tosym = sym_name(elf, + find_elf_symbol(elf, r->r_addend, sym)); + + /* check whitelist - we may ignore it */ + if (secref_whitelist(fromsec, fromsym, tosec, tosym)) { + report_sec_mismatch(modname, fromsec, r->r_offset, + fromsym, tosec, tosym); + } } } @@ -1107,7 +1116,6 @@ static void section_rela(const char *modname, struct elf_info *elf, Elf_Rela r; unsigned int r_sym; const char *fromsec; - const char * tosec; Elf_Rela *start = (void *)elf->hdr + sechdr->sh_offset; Elf_Rela *stop = (void *)start + sechdr->sh_size; @@ -1117,7 +1125,6 @@ static void section_rela(const char *modname, struct elf_info *elf, /* if from section (name) is know good then skip it */ if (match(fromsec, section_white_list)) return; - for (rela = start; rela < stop; rela++) { r.r_offset = TO_NATIVE(rela->r_offset); #if KERNEL_ELFCLASS == ELFCLASS64 @@ -1140,10 +1147,7 @@ static void section_rela(const char *modname, struct elf_info *elf, /* Skip special sections */ if (sym->st_shndx >= SHN_LORESERVE) continue; - - tosec = sec_name(elf, sym->st_shndx); - if (section_mismatch(fromsec, tosec)) - warn_sec_mismatch(modname, fromsec, elf, sym, r); + check_section_mismatch(modname, elf, &r, sym, fromsec); } } @@ -1155,7 +1159,6 @@ static void section_rel(const char *modname, struct elf_info *elf, Elf_Rela r; unsigned int r_sym; const char *fromsec; - const char * tosec; Elf_Rel *start = (void *)elf->hdr + sechdr->sh_offset; Elf_Rel *stop = (void *)start + sechdr->sh_size; @@ -1202,10 +1205,7 @@ static void section_rel(const char *modname, struct elf_info *elf, /* Skip special sections */ if (sym->st_shndx >= SHN_LORESERVE) continue; - - tosec = sec_name(elf, sym->st_shndx); - if (section_mismatch(fromsec, tosec)) - warn_sec_mismatch(modname, fromsec, elf, sym, r); + check_section_mismatch(modname, elf, &r, sym, fromsec); } } -- cgit v1.2.3 From 9649ef878d507bbc3abc2a328cd4ad303b2be093 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Wed, 23 Jan 2008 01:54:39 +0200 Subject: kconfig: remove "enable" Kconfig had a synonym "enable" for "select" that was neither documented nor used. Signed-off-by: Adrian Bunk Cc: Roman Zippel Signed-off-by: Sam Ravnborg --- scripts/kconfig/zconf.gperf | 1 - scripts/kconfig/zconf.hash.c_shipped | 38 +++++++++++++++++------------------- 2 files changed, 18 insertions(+), 21 deletions(-) diff --git a/scripts/kconfig/zconf.gperf b/scripts/kconfig/zconf.gperf index 4051639c0900..25ef5d01c0af 100644 --- a/scripts/kconfig/zconf.gperf +++ b/scripts/kconfig/zconf.gperf @@ -35,7 +35,6 @@ 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 diff --git a/scripts/kconfig/zconf.hash.c_shipped b/scripts/kconfig/zconf.hash.c_shipped index c9d26bc1a214..5c73d51339d8 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,10 +53,10 @@ 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, 35, 35, 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, 0, 49, - 10, 49, 49, 49, 49, 49, 49, 49, 49, 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, 49, 49, 49, 49, 49, 49, 49, 49, 49, 49, @@ -100,9 +100,10 @@ struct kconf_id_strings_t char kconf_id_strings_str12[sizeof("default")]; char kconf_id_strings_str13[sizeof("def_bool")]; char kconf_id_strings_str14[sizeof("help")]; + char kconf_id_strings_str15[sizeof("bool")]; char kconf_id_strings_str16[sizeof("config")]; char kconf_id_strings_str17[sizeof("def_tristate")]; - char kconf_id_strings_str18[sizeof("hex")]; + char kconf_id_strings_str18[sizeof("boolean")]; char kconf_id_strings_str19[sizeof("defconfig_list")]; char kconf_id_strings_str21[sizeof("string")]; char kconf_id_strings_str22[sizeof("if")]; @@ -113,12 +114,10 @@ struct kconf_id_strings_t char kconf_id_strings_str29[sizeof("menu")]; char kconf_id_strings_str31[sizeof("source")]; char kconf_id_strings_str32[sizeof("comment")]; + char kconf_id_strings_str33[sizeof("hex")]; char kconf_id_strings_str35[sizeof("menuconfig")]; char kconf_id_strings_str36[sizeof("prompt")]; char kconf_id_strings_str37[sizeof("depends")]; - char kconf_id_strings_str39[sizeof("bool")]; - char kconf_id_strings_str41[sizeof("enable")]; - char kconf_id_strings_str42[sizeof("boolean")]; char kconf_id_strings_str48[sizeof("mainmenu")]; }; static struct kconf_id_strings_t kconf_id_strings_contents = @@ -135,9 +134,10 @@ static struct kconf_id_strings_t kconf_id_strings_contents = "default", "def_bool", "help", + "bool", "config", "def_tristate", - "hex", + "boolean", "defconfig_list", "string", "if", @@ -148,24 +148,25 @@ static struct kconf_id_strings_t kconf_id_strings_contents = "menu", "source", "comment", + "hex", "menuconfig", "prompt", "depends", - "bool", - "enable", - "boolean", "mainmenu" }; #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) { enum { - TOTAL_KEYWORDS = 32, + TOTAL_KEYWORDS = 31, MIN_WORD_LENGTH = 2, MAX_WORD_LENGTH = 14, MIN_HASH_VALUE = 2, @@ -188,10 +189,10 @@ kconf_id_lookup (register const char *str, register unsigned int len) {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str12, T_DEFAULT, TF_COMMAND, S_UNKNOWN}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str13, T_DEFAULT, TF_COMMAND, S_BOOLEAN}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str14, T_HELP, TF_COMMAND}, - {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str15, T_TYPE, TF_COMMAND, S_BOOLEAN}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str16, T_CONFIG, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str17, T_DEFAULT, TF_COMMAND, S_TRISTATE}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_HEX}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str18, T_TYPE, TF_COMMAND, S_BOOLEAN}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str19, T_OPT_DEFCONFIG_LIST,TF_OPTION}, {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str21, T_TYPE, TF_COMMAND, S_STRING}, @@ -205,16 +206,13 @@ kconf_id_lookup (register const char *str, register unsigned int len) {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str31, T_SOURCE, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str32, T_COMMENT, TF_COMMAND}, - {-1}, {-1}, + {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str33, T_TYPE, TF_COMMAND, S_HEX}, + {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str35, T_MENUCONFIG, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str36, T_PROMPT, TF_COMMAND}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str37, T_DEPENDS, TF_COMMAND}, + {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str39, T_TYPE, TF_COMMAND, S_BOOLEAN}, - {-1}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str41, T_SELECT, TF_COMMAND}, - {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str42, T_TYPE, TF_COMMAND, S_BOOLEAN}, - {-1}, {-1}, {-1}, {-1}, {-1}, {(int)(long)&((struct kconf_id_strings_t *)0)->kconf_id_strings_str48, T_MAINMENU, TF_COMMAND} }; -- cgit v1.2.3 From bc395add945659e04cc7cf250755ba0edc1a9fdc Mon Sep 17 00:00:00 2001 From: Daniel De Graaf Date: Mon, 21 Jan 2008 18:21:11 -0600 Subject: kbuild: support ARCH=x86 in buildtar Signed-off-by: Daniel De Graaf Signed-off-by: Sam Ravnborg --- scripts/package/buildtar | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/package/buildtar b/scripts/package/buildtar index aa0ccdbd1f47..28574ae55170 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}" -- cgit v1.2.3 From 3ff6eecca4e5c49a5d1dd8b58ea0e20102ce08f0 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 24 Jan 2008 22:16:20 +0100 Subject: remove __attribute_used__ Remove the deprecated __attribute_used__. [Introduce __section in a few places to silence checkpatch /sam] Signed-off-by: Adrian Bunk Signed-off-by: Sam Ravnborg --- arch/alpha/lib/dec_and_lock.c | 3 +-- arch/powerpc/boot/Makefile | 2 +- arch/powerpc/kernel/sysfs.c | 2 +- arch/powerpc/oprofile/op_model_power4.c | 6 +++--- arch/sparc64/kernel/unaligned.c | 2 +- arch/um/include/init.h | 26 +++++++++++++------------- drivers/rapidio/rio.h | 4 ++-- fs/compat_ioctl.c | 2 +- include/asm-avr32/setup.h | 2 +- include/asm-ia64/gcc_intrin.h | 2 +- include/asm-sh/machvec.h | 2 +- include/asm-sh/thread_info.h | 2 +- include/asm-x86/thread_info_32.h | 2 +- include/linux/compiler-gcc3.h | 2 -- include/linux/compiler-gcc4.h | 1 - include/linux/compiler.h | 4 ---- include/linux/elfnote.h | 2 +- include/linux/init.h | 11 +++++------ include/linux/module.h | 4 ++-- include/linux/moduleparam.h | 4 ++-- include/linux/pci.h | 2 +- scripts/mod/modpost.c | 4 ++-- 22 files changed, 41 insertions(+), 50 deletions(-) diff --git a/arch/alpha/lib/dec_and_lock.c b/arch/alpha/lib/dec_and_lock.c index 6ae2500a9d9e..0f5520d2f45f 100644 --- a/arch/alpha/lib/dec_and_lock.c +++ b/arch/alpha/lib/dec_and_lock.c @@ -30,8 +30,7 @@ _atomic_dec_and_lock: \n\ .previous \n\ .end _atomic_dec_and_lock"); -static int __attribute_used__ -atomic_dec_and_lock_1(atomic_t *atomic, spinlock_t *lock) +static int __used atomic_dec_and_lock_1(atomic_t *atomic, spinlock_t *lock) { /* Slow path */ spin_lock(lock); diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile index 18e32719d0ed..4b1d98b8135e 100644 --- a/arch/powerpc/boot/Makefile +++ b/arch/powerpc/boot/Makefile @@ -65,7 +65,7 @@ obj-wlib := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-wlib)))) obj-plat := $(addsuffix .o, $(basename $(addprefix $(obj)/, $(src-plat)))) quiet_cmd_copy_zlib = COPY $@ - cmd_copy_zlib = sed "s@__attribute_used__@@;s@]*\).*@\"\1\"@" $< > $@ + cmd_copy_zlib = sed "s@__used@@;s@]*\).*@\"\1\"@" $< > $@ quiet_cmd_copy_zlibheader = COPY $@ cmd_copy_zlibheader = sed "s@]*\).*@\"\1\"@" $< > $@ diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index 25d9a96484dd..c8127f832df0 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c @@ -158,7 +158,7 @@ static ssize_t show_##NAME(struct sys_device *dev, char *buf) \ unsigned long val = run_on_cpu(cpu->sysdev.id, read_##NAME, 0); \ return sprintf(buf, "%lx\n", val); \ } \ -static ssize_t __attribute_used__ \ +static ssize_t __used \ store_##NAME(struct sys_device *dev, const char *buf, size_t count) \ { \ struct cpu *cpu = container_of(dev, struct cpu, sysdev); \ diff --git a/arch/powerpc/oprofile/op_model_power4.c b/arch/powerpc/oprofile/op_model_power4.c index cddc250a6a5c..446a8bbb847b 100644 --- a/arch/powerpc/oprofile/op_model_power4.c +++ b/arch/powerpc/oprofile/op_model_power4.c @@ -172,15 +172,15 @@ static void power4_stop(void) } /* Fake functions used by canonicalize_pc */ -static void __attribute_used__ hypervisor_bucket(void) +static void __used hypervisor_bucket(void) { } -static void __attribute_used__ rtas_bucket(void) +static void __used rtas_bucket(void) { } -static void __attribute_used__ kernel_unknown_bucket(void) +static void __used kernel_unknown_bucket(void) { } diff --git a/arch/sparc64/kernel/unaligned.c b/arch/sparc64/kernel/unaligned.c index 953be816fa25..dc7bf1b6321c 100644 --- a/arch/sparc64/kernel/unaligned.c +++ b/arch/sparc64/kernel/unaligned.c @@ -175,7 +175,7 @@ unsigned long compute_effective_address(struct pt_regs *regs, } /* This is just to make gcc think die_if_kernel does return... */ -static void __attribute_used__ unaligned_panic(char *str, struct pt_regs *regs) +static void __used unaligned_panic(char *str, struct pt_regs *regs) { die_if_kernel(str, regs); } diff --git a/arch/um/include/init.h b/arch/um/include/init.h index d4de7c0120ce..cebc6cae9190 100644 --- a/arch/um/include/init.h +++ b/arch/um/include/init.h @@ -42,15 +42,15 @@ typedef void (*exitcall_t)(void); /* These are for everybody (although not all archs will actually discard it in modules) */ -#define __init __attribute__ ((__section__ (".init.text"))) -#define __initdata __attribute__ ((__section__ (".init.data"))) -#define __exitdata __attribute__ ((__section__(".exit.data"))) -#define __exit_call __attribute_used__ __attribute__ ((__section__ (".exitcall.exit"))) +#define __init __section(.init.text) +#define __initdata __section(.init.data) +#define __exitdata __section(.exit.data) +#define __exit_call __used __section(.exitcall.exit) #ifdef MODULE -#define __exit __attribute__ ((__section__(".exit.text"))) +#define __exit __section(.exit.text) #else -#define __exit __attribute_used__ __attribute__ ((__section__(".exit.text"))) +#define __exit __used __section(.exit.text) #endif #endif @@ -103,16 +103,16 @@ extern struct uml_param __uml_setup_start, __uml_setup_end; * Mark functions and data as being only used at initialization * or exit time. */ -#define __uml_init_setup __attribute_used__ __attribute__ ((__section__ (".uml.setup.init"))) -#define __uml_setup_help __attribute_used__ __attribute__ ((__section__ (".uml.help.init"))) -#define __uml_init_call __attribute_used__ __attribute__ ((__section__ (".uml.initcall.init"))) -#define __uml_postsetup_call __attribute_used__ __attribute__ ((__section__ (".uml.postsetup.init"))) -#define __uml_exit_call __attribute_used__ __attribute__ ((__section__ (".uml.exitcall.exit"))) +#define __uml_init_setup __used __section(.uml.setup.init) +#define __uml_setup_help __used __section(.uml.help.init) +#define __uml_init_call __used __section(.uml.initcall.init) +#define __uml_postsetup_call __used __section(.uml.postsetup.init) +#define __uml_exit_call __used __section(.uml.exitcall.exit) #ifndef __KERNEL__ #define __define_initcall(level,fn) \ - static initcall_t __initcall_##fn __attribute_used__ \ + static initcall_t __initcall_##fn __used \ __attribute__((__section__(".initcall" level ".init"))) = fn /* Userspace initcalls shouldn't depend on anything in the kernel, so we'll @@ -122,7 +122,7 @@ extern struct uml_param __uml_setup_start, __uml_setup_end; #define __exitcall(fn) static exitcall_t __exitcall_##fn __exit_call = fn -#define __init_call __attribute_used__ __attribute__ ((__section__ (".initcall.init"))) +#define __init_call __used __section(.initcall.init) #endif diff --git a/drivers/rapidio/rio.h b/drivers/rapidio/rio.h index b242cee656e7..80e3f03b5041 100644 --- a/drivers/rapidio/rio.h +++ b/drivers/rapidio/rio.h @@ -31,8 +31,8 @@ extern struct rio_route_ops __end_rio_route_ops[]; /* Helpers internal to the RIO core code */ #define DECLARE_RIO_ROUTE_SECTION(section, vid, did, add_hook, get_hook) \ - static struct rio_route_ops __rio_route_ops __attribute_used__ \ - __attribute__((__section__(#section))) = { vid, did, add_hook, get_hook }; + static struct rio_route_ops __rio_route_ops __used \ + __section(section)= { vid, did, add_hook, get_hook }; /** * DECLARE_RIO_ROUTE_OPS - Registers switch routing operations diff --git a/fs/compat_ioctl.c b/fs/compat_ioctl.c index da8cb3b3592c..ffdc022cae64 100644 --- a/fs/compat_ioctl.c +++ b/fs/compat_ioctl.c @@ -1376,7 +1376,7 @@ static int do_atm_ioctl(unsigned int fd, unsigned int cmd32, unsigned long arg) return -EINVAL; } -static __attribute_used__ int +static __used int ret_einval(unsigned int fd, unsigned int cmd, unsigned long arg) { return -EINVAL; diff --git a/include/asm-avr32/setup.h b/include/asm-avr32/setup.h index b0828d43e110..ea3070ff13a5 100644 --- a/include/asm-avr32/setup.h +++ b/include/asm-avr32/setup.h @@ -110,7 +110,7 @@ struct tagtable { int (*parse)(struct tag *); }; -#define __tag __attribute_used__ __attribute__((__section__(".taglist.init"))) +#define __tag __used __attribute__((__section__(".taglist.init"))) #define __tagtable(tag, fn) \ static struct tagtable __tagtable_##fn __tag = { tag, fn } diff --git a/include/asm-ia64/gcc_intrin.h b/include/asm-ia64/gcc_intrin.h index e58d3298fa10..5b6665c754c9 100644 --- a/include/asm-ia64/gcc_intrin.h +++ b/include/asm-ia64/gcc_intrin.h @@ -24,7 +24,7 @@ extern void ia64_bad_param_for_setreg (void); extern void ia64_bad_param_for_getreg (void); -register unsigned long ia64_r13 asm ("r13") __attribute_used__; +register unsigned long ia64_r13 asm ("r13") __used; #define ia64_setreg(regnum, val) \ ({ \ diff --git a/include/asm-sh/machvec.h b/include/asm-sh/machvec.h index ddb18ad23303..b2e4124070ae 100644 --- a/include/asm-sh/machvec.h +++ b/include/asm-sh/machvec.h @@ -65,6 +65,6 @@ extern struct sh_machine_vector sh_mv; #define get_system_type() sh_mv.mv_name #define __initmv \ - __attribute_used__ __attribute__((__section__ (".machvec.init"))) + __used __section(.machvec.init) #endif /* _ASM_SH_MACHVEC_H */ diff --git a/include/asm-sh/thread_info.h b/include/asm-sh/thread_info.h index c6577d3dc46d..c50e5d35fe84 100644 --- a/include/asm-sh/thread_info.h +++ b/include/asm-sh/thread_info.h @@ -68,7 +68,7 @@ struct thread_info { #define init_stack (init_thread_union.stack) /* how to get the current stack pointer from C */ -register unsigned long current_stack_pointer asm("r15") __attribute_used__; +register unsigned long current_stack_pointer asm("r15") __used; /* how to get the thread information struct from C */ static inline struct thread_info *current_thread_info(void) diff --git a/include/asm-x86/thread_info_32.h b/include/asm-x86/thread_info_32.h index ef58fd2a6eb0..a516e9192f11 100644 --- a/include/asm-x86/thread_info_32.h +++ b/include/asm-x86/thread_info_32.h @@ -85,7 +85,7 @@ struct thread_info { /* how to get the current stack pointer from C */ -register unsigned long current_stack_pointer asm("esp") __attribute_used__; +register unsigned long current_stack_pointer asm("esp") __used; /* how to get the thread information struct from C */ static inline struct thread_info *current_thread_info(void) diff --git a/include/linux/compiler-gcc3.h b/include/linux/compiler-gcc3.h index 2d8c0f48f55e..e5eb795f78a1 100644 --- a/include/linux/compiler-gcc3.h +++ b/include/linux/compiler-gcc3.h @@ -7,10 +7,8 @@ #if __GNUC_MINOR__ >= 3 # define __used __attribute__((__used__)) -# define __attribute_used__ __used /* deprecated */ #else # define __used __attribute__((__unused__)) -# define __attribute_used__ __used /* deprecated */ #endif #if __GNUC_MINOR__ >= 4 diff --git a/include/linux/compiler-gcc4.h b/include/linux/compiler-gcc4.h index ee7ca5de970c..0ab3a3232330 100644 --- a/include/linux/compiler-gcc4.h +++ b/include/linux/compiler-gcc4.h @@ -15,7 +15,6 @@ #endif #define __used __attribute__((__used__)) -#define __attribute_used__ __used /* deprecated */ #define __must_check __attribute__((warn_unused_result)) #define __compiler_offsetof(a,b) __builtin_offsetof(a,b) #define __always_inline inline __attribute__((always_inline)) diff --git a/include/linux/compiler.h b/include/linux/compiler.h index e0114a61268f..d0e17e1657dc 100644 --- a/include/linux/compiler.h +++ b/include/linux/compiler.h @@ -126,10 +126,6 @@ extern void __chk_io_ptr(const volatile void __iomem *); * Mark functions that are referenced only in inline assembly as __used so * the code is emitted even though it appears to be unreferenced. */ -#ifndef __attribute_used__ -# define __attribute_used__ /* deprecated */ -#endif - #ifndef __used # define __used /* unimplemented */ #endif diff --git a/include/linux/elfnote.h b/include/linux/elfnote.h index e831759b2fb5..278e3ef05336 100644 --- a/include/linux/elfnote.h +++ b/include/linux/elfnote.h @@ -76,7 +76,7 @@ typeof(desc) _desc \ __attribute__((aligned(sizeof(Elf##size##_Word)))); \ } _ELFNOTE_PASTE(_note_, unique) \ - __attribute_used__ \ + __used \ __attribute__((section(".note." name), \ aligned(sizeof(Elf##size##_Word)), \ unused)) = { \ diff --git a/include/linux/init.h b/include/linux/init.h index dcb66c76bd48..dde1eaa7766b 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -43,7 +43,7 @@ #define __init __section(.init.text) __cold #define __initdata __section(.init.data) #define __exitdata __section(.exit.data) -#define __exit_call __attribute_used__ __section(.exitcall.exit) +#define __exit_call __used __section(.exitcall.exit) /* modpost check for section mismatches during the kernel build. * A section mismatch happens when there are references from a @@ -144,7 +144,7 @@ void prepare_namespace(void); */ #define __define_initcall(level,fn,id) \ - static initcall_t __initcall_##fn##id __attribute_used__ \ + static initcall_t __initcall_##fn##id __used \ __attribute__((__section__(".initcall" level ".init"))) = fn /* @@ -178,11 +178,11 @@ void prepare_namespace(void); #define console_initcall(fn) \ static initcall_t __initcall_##fn \ - __attribute_used__ __section(.con_initcall.init)=fn + __used __section(.con_initcall.init) = fn #define security_initcall(fn) \ static initcall_t __initcall_##fn \ - __attribute_used__ __section(.security_initcall.init) = fn + __used __section(.security_initcall.init) = fn struct obs_kernel_param { const char *str; @@ -199,8 +199,7 @@ struct obs_kernel_param { #define __setup_param(str, unique_id, fn, early) \ static char __setup_str_##unique_id[] __initdata __aligned(1) = str; \ static struct obs_kernel_param __setup_##unique_id \ - __attribute_used__ \ - __section(.init.setup) \ + __used __section(.init.setup) \ __attribute__((aligned((sizeof(long))))) \ = { __setup_str_##unique_id, fn, early } diff --git a/include/linux/module.h b/include/linux/module.h index c97bdb7eb957..404838184ea5 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -178,7 +178,7 @@ void *__symbol_get_gpl(const char *symbol); #define __CRC_SYMBOL(sym, sec) \ extern void *__crc_##sym __attribute__((weak)); \ static const unsigned long __kcrctab_##sym \ - __attribute_used__ \ + __used \ __attribute__((section("__kcrctab" sec), unused)) \ = (unsigned long) &__crc_##sym; #else @@ -193,7 +193,7 @@ void *__symbol_get_gpl(const char *symbol); __attribute__((section("__ksymtab_strings"))) \ = MODULE_SYMBOL_PREFIX #sym; \ static const struct kernel_symbol __ksymtab_##sym \ - __attribute_used__ \ + __used \ __attribute__((section("__ksymtab" sec), unused)) \ = { (unsigned long)&sym, __kstrtab_##sym } diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index 13410b20600f..8126e55c5bdc 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -18,7 +18,7 @@ #define __module_cat(a,b) ___module_cat(a,b) #define __MODULE_INFO(tag, name, info) \ static const char __module_cat(name,__LINE__)[] \ - __attribute_used__ \ + __used \ __attribute__((section(".modinfo"),unused)) = __stringify(tag) "=" info #else /* !MODULE */ #define __MODULE_INFO(tag, name, info) @@ -72,7 +72,7 @@ struct kparam_array BUILD_BUG_ON_ZERO((perm) < 0 || (perm) > 0777 || ((perm) & 2)); \ static const char __param_str_##name[] = prefix #name; \ static struct kernel_param const __param_##name \ - __attribute_used__ \ + __used \ __attribute__ ((unused,__section__ ("__param"),aligned(sizeof(void *)))) \ = { __param_str_##name, perm, set, get, { arg } } diff --git a/include/linux/pci.h b/include/linux/pci.h index 0dd93bb62fbe..ae1006322f80 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -867,7 +867,7 @@ enum pci_fixup_pass { /* Anonymous variables would be nice... */ #define DECLARE_PCI_FIXUP_SECTION(section, name, vendor, device, hook) \ - static const struct pci_fixup __pci_fixup_##name __attribute_used__ \ + static const struct pci_fixup __pci_fixup_##name __used \ __attribute__((__section__(#section))) = { vendor, device, hook }; #define DECLARE_PCI_FIXUP_EARLY(vendor, device, hook) \ DECLARE_PCI_FIXUP_SECTION(.pci_fixup_early, \ diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 0a80acafd212..e75739ec9c03 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1445,7 +1445,7 @@ 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) { @@ -1476,7 +1476,7 @@ static void add_depends(struct buffer *b, struct module *mod, 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) { -- cgit v1.2.3 From 1a3fb6d481689d0482eacadcbe3205b49b423c11 Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Thu, 24 Jan 2008 22:20:18 +0100 Subject: asm-generic/vmlix.lds.h: simplify __mem{init,exit}* dependencies Simplify the dependencies on __mem{init,exit}* (ACPI_HOTPLUG_MEMORY requires MEMORY_HOTPLUG). Signed-off-by: Adrian Bunk Signed-off-by: Sam Ravnborg --- include/asm-generic/vmlinux.lds.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index e0a56fb8f813..294853053707 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -29,8 +29,7 @@ #define CPU_DISCARD(sec) *(.cpu##sec) #endif -#if defined(CONFIG_MEMORY_HOTPLUG) || defined(CONFIG_ACPI_HOTPLUG_MEMORY) \ - || defined(CONFIG_ACPI_HOTPLUG_MEMORY_MODULE) +#if defined(CONFIG_MEMORY_HOTPLUG) #define MEM_KEEP(sec) *(.mem##sec) #define MEM_DISCARD(sec) #else -- cgit v1.2.3 From f5eaa323eb6819d2f737ead42464efccaf2b98b9 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 24 Jan 2008 11:54:23 +0000 Subject: kconfig: tristate choices with mixed tristate and boolean values Change kconfig behavior so that mixing bool and tristate config settings in a choice is possible and has the desired effect of offering just the tristate options individually if the choice gets set to M, and a normal boolean selection if the choice gets set to Y. Also fix scripts/kconfig/conf's handling of children of choice values - there may be more than one immediate child, and all of them need to be processed. Signed-off-by: Jan Beulich Cc: "Roman Zippel" Signed-off-by: Sam Ravnborg --- scripts/kconfig/conf.c | 4 ++-- scripts/kconfig/expr.c | 10 ++++++++-- scripts/kconfig/menu.c | 38 +++++++++++++++++++++++++++++++++++--- 3 files changed, 45 insertions(+), 7 deletions(-) diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index d1a0368bd438..fda63136ae68 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -400,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; diff --git a/scripts/kconfig/expr.c b/scripts/kconfig/expr.c index 13788ada5228..579ece4fa584 100644 --- a/scripts/kconfig/expr.c +++ b/scripts/kconfig/expr.c @@ -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, ""); 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, ""); fn(data, NULL, "!="); fn(data, e->right.sym, e->right.sym->name); break; diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index e6ef171e5b14..fdad17367f61 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -242,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; } } @@ -329,7 +331,37 @@ 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) -- cgit v1.2.3 From 588ccd732ba2d32db8228802ef9283b583d3395f Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Thu, 24 Jan 2008 21:12:37 +0100 Subject: kbuild: add verbose option to Section mismatch reporting in modpost If the config option CONFIG_SECTION_MISMATCH is not set and we see a Section mismatch present the following to the user: modpost: Found 1 section mismatch(es). To see additional details select "Enable full Section mismatch analysis" in the Kernel Hacking menu (CONFIG_SECTION_MISMATCH). If the option CONFIG_SECTION_MISMATCH is selected then be verbose in the Section mismatch reporting from mdopost. Sample outputs: WARNING: o-x86_64/vmlinux.o(.text+0x7396): Section mismatch in reference from the function discover_ebda() to the variable .init.data:ebda_addr The function discover_ebda() references the variable __initdata ebda_addr. This is often because discover_ebda lacks a __initdata annotation or the annotation of ebda_addr is wrong. WARNING: o-x86_64/vmlinux.o(.data+0x74d58): Section mismatch in reference from the variable pci_serial_quirks to the function .devexit.text:pci_plx9050_exit() The variable pci_serial_quirks references the function __devexit pci_plx9050_exit() If the reference is valid then annotate the variable with __exit* (see linux/init.h) or name the variable: *driver, *_template, *_timer, *_sht, *_ops, *_probe, *_probe_one, *_console, WARNING: o-x86_64/vmlinux.o(__ksymtab+0x630): Section mismatch in reference from the variable __ksymtab_arch_register_cpu to the function .cpuinit.text:arch_register_cpu() The symbol arch_register_cpu is exported and annotated __cpuinit Fix this by removing the __cpuinit annotation of arch_register_cpu or drop the export. Signed-off-by: Sam Ravnborg --- lib/Kconfig.debug | 2 + scripts/Makefile.modpost | 1 + scripts/mod/modpost.c | 255 +++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 229 insertions(+), 29 deletions(-) diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 748e72be6e68..c4ecb2994ba3 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug @@ -108,6 +108,8 @@ config DEBUG_SECTION_MISMATCH will tell where the mismatch happens much closer to the source. The drawback is that we will report the same mismatch at least twice. + - Enable verbose reporting from modpost to help solving + the section mismatches reported. config DEBUG_KERNEL bool "Kernel debugging" diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index d988f5d21e3d..65e707e1ffc3 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/mod/modpost.c b/scripts/mod/modpost.c index e75739ec9c03..3cf1ba8220d2 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -28,6 +28,9 @@ 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 @@ -760,9 +763,23 @@ 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[] = { @@ -770,33 +787,54 @@ const struct sectioncheck sectioncheck[] = { * normal code and data */ { - .fromsec = { TEXT_SECTIONS, DATA_SECTIONS, NULL }, - .tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL } + .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 } + .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 } + .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 } + .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 } + .tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }, + .mismatch = EXPORT_TO_INIT_EXIT } }; @@ -809,10 +847,10 @@ static int section_mismatch(const char *fromsec, const char *tosec) for (i = 0; i < elems; i++) { if (match(fromsec, check->fromsec) && match(tosec, check->tosec)) - return 1; + return check->mismatch; check++; } - return 0; + return NO_MISMATCH; } /** @@ -988,48 +1026,198 @@ static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr, 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 + 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 report_sec_mismatch(const char *modname, +static void report_sec_mismatch(const char *modname, enum mismatch mismatch, const char *fromsec, unsigned long long fromaddr, const char *fromsym, - const char *tosec, const char *tosym) -{ - if (strlen(tosym)) { - warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " - "in '%s'\n", - modname, fromsec, fromaddr, - tosec, tosym, fromsym); - } else { - warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s\n", - modname, fromsec, fromaddr, - tosec, tosym); + int from_is_func, + const char *tosec, const char *tosym, + int to_is_func) +{ + 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; + + 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); - if (section_mismatch(fromsec, tosec)) { - const char *fromsym; + mismatch = section_mismatch(fromsec, tosec); + if (mismatch != NO_MISMATCH) { + Elf_Sym *to; + Elf_Sym *from; const char *tosym; + const char *fromsym; - fromsym = sym_name(elf, - find_elf_symbol2(elf, r->r_offset, fromsec)); - tosym = sym_name(elf, - find_elf_symbol(elf, r->r_addend, sym)); + 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, fromsec, r->r_offset, - fromsym, tosec, tosym); + report_sec_mismatch(modname, mismatch, + fromsec, r->r_offset, fromsym, + is_function(from), tosec, tosym, + is_function(to)); } } } @@ -1643,7 +1831,7 @@ int main(int argc, char **argv) int opt; int err; - while ((opt = getopt(argc, argv, "i:I:mso:aw")) != -1) { + while ((opt = getopt(argc, argv, "i:I:msSo:aw")) != -1) { switch (opt) { case 'i': kernel_read = optarg; @@ -1664,6 +1852,9 @@ int main(int argc, char **argv) case 's': vmlinux_section_warnings = 0; break; + case 'S': + sec_mismatch_verbose = 0; + break; case 'w': warn_unresolved = 1; break; @@ -1708,6 +1899,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; } -- cgit v1.2.3 From e241a630374e06aecdae2884af8b652d3b4d6c37 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 28 Jan 2008 20:13:13 +0100 Subject: kbuild: warn about ld added unique sections If there is a mixture of specifying sections for code in gcc and assembler then if the assembler code do not add the "ax" flags the linker will see this as two different sections and generate unique sections for each. ld does so by adding a dot and a number. Teach modpost to warn if a section shows up that match this pattern - but do this only for non-debug sections. It will result in warnings like this: WARNING: vmlinux.o (.sched.text.1): unexpected section name. The (.[number]+) following section name are ld generated and not expected. Did you forget to use "ax"/"aw" in a .S file? Note that for example contains section definitions for use in .S files. All warnings seen with a defconfig build for: x86 (32+64bit) and sparc64 has been fixed (via respective maintainers). arm, powerpc (64 bit), s390 (32 bit), ia64, alpha, sh4 checked - no warnings seen with a defconfig build. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3cf1ba8220d2..f8efc93eb700 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -696,6 +696,43 @@ int match(const char *sym, const char * const pat[]) static const char *section_white_list[] = { ".debug*", ".stab*", ".note*", ".got*", ".toc*", NULL }; +/* + * 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) +{ + const char *e = sec + strlen(sec) - 1; + if (match(sec, section_white_list)) + return 1; + + 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 contains\n" + "section definitions for use in .S files.\n\n", + modname, sec); + } + } + return 0; +} + + + #define ALL_INIT_DATA_SECTIONS \ ".init.data$", ".devinit.data$", ".cpuinit.data$", ".meminit.data$" #define ALL_EXIT_DATA_SECTIONS \ @@ -1311,8 +1348,9 @@ static void section_rela(const char *modname, struct elf_info *elf, fromsec = sech_name(elf, sechdr); fromsec += strlen(".rela"); /* if from section (name) is know good then skip it */ - if (match(fromsec, section_white_list)) + if (check_section(modname, fromsec)) return; + for (rela = start; rela < stop; rela++) { r.r_offset = TO_NATIVE(rela->r_offset); #if KERNEL_ELFCLASS == ELFCLASS64 @@ -1354,7 +1392,7 @@ static void section_rel(const char *modname, struct elf_info *elf, fromsec = sech_name(elf, sechdr); fromsec += strlen(".rel"); /* if from section (name) is know good then skip it */ - if (match(fromsec, section_white_list)) + if (check_section(modname, fromsec)) return; for (rel = start; rel < stop; rel++) { -- cgit v1.2.3 From 312b1485fb509c9bc32eda28ad29537896658cb8 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 28 Jan 2008 20:21:15 +0100 Subject: Introduce new section reference annotations tags: __ref, __refdata, __refconst Today we have the following annotations for functions/data referencing __init/__exit functions / data: __init_refok => for init functions __initdata_refok => for init data __exit_refok => for exit functions There is really no difference between the __init and __exit versions and simplify it and to introduce a shorter annotation the following new annotations are introduced: __ref => for functions (code) that references __*init / __*exit __refdata => for variables __refconst => for const variables Whit this annotation is it more obvious what the annotation is for and there is no longer the arbitary division between __init and __exit code. The mechanishm is the same as before - a special section is created which is made part of the usual sections in the linker script. We will start to see annotations like this: -static struct pci_serial_quirk pci_serial_quirks[] = { +static const struct pci_serial_quirk pci_serial_quirks[] __refconst = { ----------------- -static struct notifier_block __cpuinitdata cpuid_class_cpu_notifier = +static struct notifier_block cpuid_class_cpu_notifier __refdata = ---------------- -static int threshold_cpu_callback(struct notifier_block *nfb, +static int __ref threshold_cpu_callback(struct notifier_block *nfb, [The above is just random samples]. Note: No modifications were needed in modpost to support the new sections due to the newly introduced blacklisting. Signed-off-by: Sam Ravnborg --- include/asm-generic/vmlinux.lds.h | 3 +++ include/linux/init.h | 34 +++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 294853053707..76df771be585 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -42,6 +42,7 @@ #define DATA_DATA \ *(.data) \ *(.data.init.refok) \ + *(.ref.data) \ DEV_KEEP(init.data) \ DEV_KEEP(exit.data) \ CPU_KEEP(init.data) \ @@ -169,6 +170,7 @@ \ /* __*init sections */ \ __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \ + *(.ref.rodata) \ DEV_KEEP(init.rodata) \ DEV_KEEP(exit.rodata) \ CPU_KEEP(init.rodata) \ @@ -202,6 +204,7 @@ #define TEXT_TEXT \ ALIGN_FUNCTION(); \ *(.text) \ + *(.ref.text) \ *(.text.init.refok) \ *(.exit.text.refok) \ DEV_KEEP(init.text) \ diff --git a/include/linux/init.h b/include/linux/init.h index dde1eaa7766b..2efbda016741 100644 --- a/include/linux/init.h +++ b/include/linux/init.h @@ -52,12 +52,26 @@ * when early init has completed so all such references are potential bugs. * For exit sections the same issue exists. * The following markers are used for the cases where the reference to - * the init/exit section (code or data) is valid and will teach modpost - * not to issue a warning. + * the *init / *exit section (code or data) is valid and will teach + * modpost not to issue a warning. * The markers follow same syntax rules as __init / __initdata. */ -#define __init_refok noinline __section(.text.init.refok) -#define __initdata_refok __section(.data.init.refok) -#define __exit_refok noinline __section(.exit.text.refok) +#define __ref __section(.ref.text) noinline +#define __refdata __section(.ref.data) +#define __refconst __section(.ref.rodata) + +/* backward compatibility note + * A few places hardcode the old section names: + * .text.init.refok + * .data.init.refok + * .exit.text.refok + * They should be converted to use the defines from this file + */ + +/* compatibility defines */ +#define __init_refok __ref +#define __initdata_refok __refdata +#define __exit_refok __ref + #ifdef MODULE #define __exitused @@ -93,11 +107,9 @@ /* For assembly routines */ #define __INIT .section ".init.text","ax" -#define __INIT_REFOK .section ".text.init.refok","ax" #define __FINIT .previous #define __INITDATA .section ".init.data","aw" -#define __INITDATA_REFOK .section ".data.init.refok","aw" #define __DEVINIT .section ".devinit.text", "ax" #define __DEVINITDATA .section ".devinit.data", "aw" @@ -108,6 +120,14 @@ #define __MEMINIT .section ".meminit.text", "ax" #define __MEMINITDATA .section ".meminit.data", "aw" +/* silence warnings when references are OK */ +#define __REF .section ".ref.text", "ax" +#define __REFDATA .section ".ref.data", "aw" +#define __REFCONST .section ".ref.rodata", "aw" +/* backward compatibility */ +#define __INIT_REFOK .section __REF +#define __INITDATA_REFOK .section __REFDATA + #ifndef __ASSEMBLY__ /* * Used for initialization calls.. -- cgit v1.2.3 From 9b3e4dad7e58405de398faa17cb4691ca85eb050 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 28 Jan 2008 21:49:46 +0100 Subject: kconfig: document use of HAVE_* It has been discussed on lkml several times but we need it documented as this is new stuff. Signed-off-by: Sam Ravnborg --- Documentation/kbuild/kconfig-language.txt | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/Documentation/kbuild/kconfig-language.txt b/Documentation/kbuild/kconfig-language.txt index a43fcc68e171..649cb8799890 100644 --- a/Documentation/kbuild/kconfig-language.txt +++ b/Documentation/kbuild/kconfig-language.txt @@ -330,6 +330,42 @@ This is a collection of Kconfig tips, most of which aren't obvious at first glance and most of which have become idioms in several Kconfig files. +Adding common features and make the usage configurable +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +It is a common idiom to implement a feature/functionality that are +relevant for some architectures but not all. +The recommended way to do so is to use a config variable named HAVE_* +that is defined in a common Kconfig file and selected by the relevant +architectures. +An example is the generic IOMAP functionality. + +We would in lib/Kconfig see: + +# Generic IOMAP is used to ... +config HAVE_GENERIC_IOMAP + +config GENERIC_IOMAP + depends on HAVE_GENERIC_IOMAP && FOO + +And in lib/Makefile we would see: +obj-$(CONFIG_GENERIC_IOMAP) += iomap.o + +For each architecture using the generic IOMAP functionality we would see: + +config X86 + select ... + select HAVE_GENERIC_IOMAP + select ... + +Note: we use the existing config option and avoid creating a new +config variable to select HAVE_GENERIC_IOMAP. + +Note: the use of the internal config variable HAVE_GENERIC_IOMAP, it is +introduced to overcome the limitation of select which will force a +config option to 'y' no matter the dependencies. +The dependencies are moved to the symbol GENERIC_IOMAP and we avoid the +situation where select forces a symbol equals to 'y'. + Build as module only ~~~~~~~~~~~~~~~~~~~~ To restrict a component build to module-only, qualify its config symbol -- cgit v1.2.3 From d3883ecebbf9e095b9e379dabbbe8b2c1ee7a41c Mon Sep 17 00:00:00 2001 From: Adrian Bunk Date: Sun, 11 Nov 2007 07:48:25 +0100 Subject: Remove references to "make dep" "make dep" is no longer required in kernel 2.6, but was still mentioned in some places. Signed-off-by: Adrian Bunk Signed-off-by: Sam Ravnborg --- arch/arm/mach-imx/Makefile | 3 --- arch/arm/mach-netx/Makefile | 3 --- arch/frv/kernel/gdb-stub.c | 2 +- arch/mips/tx4927/common/Makefile | 4 ---- arch/mips/tx4938/common/Makefile | 4 ---- arch/mips/tx4938/toshiba_rbtx4938/Makefile | 4 ---- arch/xtensa/mm/Makefile | 4 ---- arch/xtensa/platform-iss/Makefile | 5 ----- 8 files changed, 1 insertion(+), 28 deletions(-) diff --git a/arch/arm/mach-imx/Makefile b/arch/arm/mach-imx/Makefile index 02272aa36e90..88d5e61a2e13 100644 --- a/arch/arm/mach-imx/Makefile +++ b/arch/arm/mach-imx/Makefile @@ -1,9 +1,6 @@ # # Makefile for the linux kernel. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). # Object file lists. diff --git a/arch/arm/mach-netx/Makefile b/arch/arm/mach-netx/Makefile index 18785ff37657..7ce4ba9eb242 100644 --- a/arch/arm/mach-netx/Makefile +++ b/arch/arm/mach-netx/Makefile @@ -1,9 +1,6 @@ # # Makefile for the linux kernel. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). # Object file lists. diff --git a/arch/frv/kernel/gdb-stub.c b/arch/frv/kernel/gdb-stub.c index e89cad1192a9..48a0393e7cee 100644 --- a/arch/frv/kernel/gdb-stub.c +++ b/arch/frv/kernel/gdb-stub.c @@ -87,7 +87,7 @@ * Example: * $ cd ~/linux * $ make menuconfig - * $ make dep; make vmlinux + * $ make vmlinux * * Step 3: * Download the kernel to the remote target and start diff --git a/arch/mips/tx4927/common/Makefile b/arch/mips/tx4927/common/Makefile index 18375787e094..e8629617f25d 100644 --- a/arch/mips/tx4927/common/Makefile +++ b/arch/mips/tx4927/common/Makefile @@ -1,10 +1,6 @@ # # Makefile for common code for Toshiba TX4927 based systems # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y += tx4927_prom.o tx4927_setup.o tx4927_irq.o diff --git a/arch/mips/tx4938/common/Makefile b/arch/mips/tx4938/common/Makefile index 8352eca67906..eff3d1d47f88 100644 --- a/arch/mips/tx4938/common/Makefile +++ b/arch/mips/tx4938/common/Makefile @@ -1,10 +1,6 @@ # # Makefile for common code for Toshiba TX4927 based systems # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y += prom.o setup.o irq.o obj-$(CONFIG_KGDB) += dbgio.o diff --git a/arch/mips/tx4938/toshiba_rbtx4938/Makefile b/arch/mips/tx4938/toshiba_rbtx4938/Makefile index 675bb1c3e40c..2316dd7dd1bd 100644 --- a/arch/mips/tx4938/toshiba_rbtx4938/Makefile +++ b/arch/mips/tx4938/toshiba_rbtx4938/Makefile @@ -1,10 +1,6 @@ # # Makefile for common code for Toshiba TX4927 based systems # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y += prom.o setup.o irq.o spi_eeprom.o diff --git a/arch/xtensa/mm/Makefile b/arch/xtensa/mm/Makefile index 10aec22a8f98..64e304a2f884 100644 --- a/arch/xtensa/mm/Makefile +++ b/arch/xtensa/mm/Makefile @@ -1,9 +1,5 @@ # # Makefile for the Linux/Xtensa-specific parts of the memory manager. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# obj-y := init.o fault.o tlb.o misc.o cache.o diff --git a/arch/xtensa/platform-iss/Makefile b/arch/xtensa/platform-iss/Makefile index 5b394e9620e5..af96e314d71f 100644 --- a/arch/xtensa/platform-iss/Makefile +++ b/arch/xtensa/platform-iss/Makefile @@ -3,11 +3,6 @@ # Makefile for the Xtensa Instruction Set Simulator (ISS) # "prom monitor" library routines under Linux. # -# Note! Dependencies are done automagically by 'make dep', which also -# removes any old dependencies. DON'T put your own dependencies here -# unless it's something special (ie not a .c file). -# -# Note 2! The CFLAGS definitions are in the main makefile... obj-y = io.o console.o setup.o network.o -- cgit v1.2.3