diff options
Diffstat (limited to 'scripts')
38 files changed, 1460 insertions, 287 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 982dcae7bbe..c29be8f9024 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include | |||
| @@ -25,6 +25,13 @@ basetarget = $(basename $(notdir $@)) | |||
| 25 | escsq = $(subst $(squote),'\$(squote)',$1) | 25 | escsq = $(subst $(squote),'\$(squote)',$1) |
| 26 | 26 | ||
| 27 | ### | 27 | ### |
| 28 | # Easy method for doing a status message | ||
| 29 | kecho := : | ||
| 30 | quiet_kecho := echo | ||
| 31 | silent_kecho := : | ||
| 32 | kecho := $($(quiet)kecho) | ||
| 33 | |||
| 34 | ### | ||
| 28 | # filechk is used to check if the content of a generated file is updated. | 35 | # filechk is used to check if the content of a generated file is updated. |
| 29 | # Sample usage: | 36 | # Sample usage: |
| 30 | # define filechk_sample | 37 | # define filechk_sample |
| @@ -39,22 +46,15 @@ escsq = $(subst $(squote),'\$(squote)',$1) | |||
| 39 | # - If they are equal no change, and no timestamp update | 46 | # - If they are equal no change, and no timestamp update |
| 40 | # - stdin is piped in from the first prerequisite ($<) so one has | 47 | # - stdin is piped in from the first prerequisite ($<) so one has |
| 41 | # to specify a valid file as first prerequisite (often the kbuild file) | 48 | # to specify a valid file as first prerequisite (often the kbuild file) |
| 42 | chk_filechk = : | ||
| 43 | quiet_chk_filechk = echo ' CHK $@' | ||
| 44 | silent_chk_filechk = : | ||
| 45 | upd_filechk = : | ||
| 46 | quiet_upd_filechk = echo ' UPD $@' | ||
| 47 | silent_upd_filechk = : | ||
| 48 | |||
| 49 | define filechk | 49 | define filechk |
| 50 | $(Q)set -e; \ | 50 | $(Q)set -e; \ |
| 51 | $($(quiet)chk_filechk); \ | 51 | $(kecho) ' CHK $@'; \ |
| 52 | mkdir -p $(dir $@); \ | 52 | mkdir -p $(dir $@); \ |
| 53 | $(filechk_$(1)) < $< > $@.tmp; \ | 53 | $(filechk_$(1)) < $< > $@.tmp; \ |
| 54 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ | 54 | if [ -r $@ ] && cmp -s $@ $@.tmp; then \ |
| 55 | rm -f $@.tmp; \ | 55 | rm -f $@.tmp; \ |
| 56 | else \ | 56 | else \ |
| 57 | $($(quiet)upd_filechk); \ | 57 | $(kecho) ' UPD $@'; \ |
| 58 | mv -f $@.tmp $@; \ | 58 | mv -f $@.tmp $@; \ |
| 59 | fi | 59 | fi |
| 60 | endef | 60 | endef |
| @@ -144,7 +144,9 @@ ld-option = $(call try-run,\ | |||
| 144 | build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj | 144 | build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj |
| 145 | 145 | ||
| 146 | # Prefix -I with $(srctree) if it is not an absolute path. | 146 | # Prefix -I with $(srctree) if it is not an absolute path. |
| 147 | addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1) | 147 | # skip if -I has no parameter |
| 148 | addtree = $(if $(patsubst -I%,%,$(1)), \ | ||
| 149 | $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)) | ||
| 148 | 150 | ||
| 149 | # Find all -I options and call addtree | 151 | # Find all -I options and call addtree |
| 150 | flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) | 152 | flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o))) |
diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 5ed4cbf1e0e..5d900307de3 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build | |||
| @@ -151,14 +151,20 @@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< | |||
| 151 | $(obj)/%.i: $(src)/%.c FORCE | 151 | $(obj)/%.i: $(src)/%.c FORCE |
| 152 | $(call if_changed_dep,cc_i_c) | 152 | $(call if_changed_dep,cc_i_c) |
| 153 | 153 | ||
| 154 | cmd_genksyms = \ | ||
| 155 | $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ | ||
| 156 | $(GENKSYMS) -T $@ -A -a $(ARCH) \ | ||
| 157 | $(if $(KBUILD_PRESERVE),-p) \ | ||
| 158 | $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null))) | ||
| 159 | |||
| 154 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ | 160 | quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ |
| 155 | cmd_cc_symtypes_c = \ | 161 | cmd_cc_symtypes_c = \ |
| 156 | $(CPP) -D__GENKSYMS__ $(c_flags) $< \ | 162 | set -e; \ |
| 157 | | $(GENKSYMS) -T $@ >/dev/null; \ | 163 | $(call cmd_genksyms, true) >/dev/null; \ |
| 158 | test -s $@ || rm -f $@ | 164 | test -s $@ || rm -f $@ |
| 159 | 165 | ||
| 160 | $(obj)/%.symtypes : $(src)/%.c FORCE | 166 | $(obj)/%.symtypes : $(src)/%.c FORCE |
| 161 | $(call if_changed_dep,cc_symtypes_c) | 167 | $(call cmd,cc_symtypes_c) |
| 162 | 168 | ||
| 163 | # C (.c) files | 169 | # C (.c) files |
| 164 | # The C file is compiled and updated dependency information is generated. | 170 | # The C file is compiled and updated dependency information is generated. |
| @@ -171,37 +177,45 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< | |||
| 171 | 177 | ||
| 172 | else | 178 | else |
| 173 | # When module versioning is enabled the following steps are executed: | 179 | # When module versioning is enabled the following steps are executed: |
| 174 | # o compile a .tmp_<file>.o from <file>.c | 180 | # o compile a .tmp_<file>.s from <file>.c |
| 175 | # o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does | 181 | # o if .tmp_<file>.s doesn't contain a __ksymtab version, i.e. does |
| 176 | # not export symbols, we just rename .tmp_<file>.o to <file>.o and | 182 | # not export symbols, we just assemble .tmp_<file>.s to <file>.o and |
| 177 | # are done. | 183 | # are done. |
| 178 | # o otherwise, we calculate symbol versions using the good old | 184 | # o otherwise, we calculate symbol versions using the good old |
| 179 | # genksyms on the preprocessed source and postprocess them in a way | 185 | # genksyms on the preprocessed source and postprocess them in a way |
| 180 | # that they are usable as a linker script | 186 | # that they are usable as assembly source |
| 181 | # o generate <file>.o from .tmp_<file>.o using the linker to | 187 | # o assemble <file>.o from .tmp_<file>.s forcing inclusion of directives |
| 182 | # replace the unresolved symbols __crc_exported_symbol with | 188 | # defining the actual values of __crc_*, followed by objcopy-ing them |
| 183 | # the actual value of the checksum generated by genksyms | 189 | # to force these symbols to be local to permit stripping them later. |
| 190 | s_file = $(@D)/.tmp_$(@F:.o=.s) | ||
| 191 | v_file = $(@D)/.tmp_$(@F:.o=.v) | ||
| 192 | tmp_o_file = $(@D)/.tmp_$(@F) | ||
| 193 | no_g_c_flags = $(filter-out -g%,$(c_flags)) | ||
| 194 | |||
| 195 | cmd_cc_o_c = $(CC) $(c_flags) -S -o $(s_file) $< | ||
| 184 | 196 | ||
| 185 | cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< | ||
| 186 | cmd_modversions = \ | 197 | cmd_modversions = \ |
| 187 | if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ | 198 | if grep -q __ksymtab $(s_file); then \ |
| 188 | $(CPP) -D__GENKSYMS__ $(c_flags) $< \ | 199 | if $(call cmd_genksyms, $(KBUILD_SYMTYPES)) > $(v_file) \ |
| 189 | | $(GENKSYMS) $(if $(KBUILD_SYMTYPES), \ | 200 | && $(CC) $(no_g_c_flags) -c -Wa,$(v_file) \ |
| 190 | -T $(@D)/$(@F:.o=.symtypes)) -a $(ARCH) \ | 201 | -o $(tmp_o_file) $(s_file) \ |
| 191 | > $(@D)/.tmp_$(@F:.o=.ver); \ | 202 | && $(OBJCOPY) -L '__crc_*' -L '___crc_*' -w \ |
| 192 | \ | 203 | $(tmp_o_file) $@; \ |
| 193 | $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ | 204 | then \ |
| 194 | -T $(@D)/.tmp_$(@F:.o=.ver); \ | 205 | : ; \ |
| 195 | rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \ | 206 | else \ |
| 207 | rm -f $@; exit 1; \ | ||
| 208 | fi; \ | ||
| 196 | else \ | 209 | else \ |
| 197 | mv -f $(@D)/.tmp_$(@F) $@; \ | 210 | rm -f $(v_file); \ |
| 211 | $(CC) $(no_g_c_flags) -c -o $@ $(s_file); \ | ||
| 198 | fi; | 212 | fi; |
| 199 | endif | 213 | endif |
| 200 | 214 | ||
| 201 | ifdef CONFIG_FTRACE_MCOUNT_RECORD | 215 | ifdef CONFIG_FTRACE_MCOUNT_RECORD |
| 202 | cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl \ | 216 | cmd_record_mcount = perl $(srctree)/scripts/recordmcount.pl "$(ARCH)" \ |
| 203 | "$(ARCH)" "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" \ | 217 | "$(if $(CONFIG_64BIT),64,32)" \ |
| 204 | "$(MV)" "$(@)"; | 218 | "$(OBJDUMP)" "$(OBJCOPY)" "$(CC)" "$(LD)" "$(NM)" "$(RM)" "$(MV)" "$(@)"; |
| 205 | endif | 219 | endif |
| 206 | 220 | ||
| 207 | define rule_cc_o_c | 221 | define rule_cc_o_c |
| @@ -211,7 +225,12 @@ define rule_cc_o_c | |||
| 211 | $(cmd_record_mcount) \ | 225 | $(cmd_record_mcount) \ |
| 212 | scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ | 226 | scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > \ |
| 213 | $(dot-target).tmp; \ | 227 | $(dot-target).tmp; \ |
| 214 | rm -f $(depfile); \ | 228 | if [ -r $(@D)/.tmp_$(@F:.o=.v) ]; then \ |
| 229 | echo >> $(dot-target).tmp; \ | ||
| 230 | echo '$@: $(GENKSYMS)' >> $(dot-target).tmp; \ | ||
| 231 | echo '$(GENKSYMS):: ;' >> $(dot-target).tmp; \ | ||
| 232 | fi; \ | ||
| 233 | rm -f $(depfile) $(@D)/.tmp_$(@F:.o=.?); \ | ||
| 215 | mv -f $(dot-target).tmp $(dot-target).cmd | 234 | mv -f $(dot-target).tmp $(dot-target).cmd |
| 216 | endef | 235 | endef |
| 217 | 236 | ||
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index b4ca38a2115..e06365775bd 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
| @@ -104,9 +104,11 @@ else | |||
| 104 | debug_flags = | 104 | debug_flags = |
| 105 | endif | 105 | endif |
| 106 | 106 | ||
| 107 | orig_c_flags = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o) | 107 | orig_c_flags = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) \ |
| 108 | $(ccflags-y) $(CFLAGS_$(basetarget).o) | ||
| 108 | _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) | 109 | _c_flags = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags)) |
| 109 | _a_flags = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o) | 110 | _a_flags = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS) \ |
| 111 | $(asflags-y) $(AFLAGS_$(basetarget).o) | ||
| 110 | _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) | 112 | _cpp_flags = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F)) |
| 111 | 113 | ||
| 112 | # If building the kernel in a separate objtree expand all occurrences | 114 | # If building the kernel in a separate objtree expand all occurrences |
| @@ -127,15 +129,16 @@ __a_flags = $(call flags,_a_flags) | |||
| 127 | __cpp_flags = $(call flags,_cpp_flags) | 129 | __cpp_flags = $(call flags,_cpp_flags) |
| 128 | endif | 130 | endif |
| 129 | 131 | ||
| 130 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ | 132 | c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
| 131 | $(__c_flags) $(modkern_cflags) \ | 133 | $(__c_flags) $(modkern_cflags) \ |
| 132 | -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \ | 134 | -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \ |
| 133 | $(debug_flags) | 135 | $(debug_flags) |
| 134 | 136 | ||
| 135 | a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \ | 137 | a_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
| 136 | $(__a_flags) $(modkern_aflags) | 138 | $(__a_flags) $(modkern_aflags) |
| 137 | 139 | ||
| 138 | cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags) | 140 | cpp_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \ |
| 141 | $(__cpp_flags) | ||
| 139 | 142 | ||
| 140 | ld_flags = $(LDFLAGS) $(ldflags-y) | 143 | ld_flags = $(LDFLAGS) $(ldflags-y) |
| 141 | 144 | ||
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index efa5d940e63..a5122dce126 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst | |||
| @@ -17,7 +17,8 @@ __modinst: $(modules) | |||
| 17 | @: | 17 | @: |
| 18 | 18 | ||
| 19 | quiet_cmd_modules_install = INSTALL $@ | 19 | quiet_cmd_modules_install = INSTALL $@ |
| 20 | cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@) | 20 | cmd_modules_install = mkdir -p $(2); \ |
| 21 | $(mod_strip_cmd) $@ $(2)/$(notdir $@) || cp $@ $(2) | ||
| 21 | 22 | ||
| 22 | # Modules built outside the kernel source tree go into extra by default | 23 | # Modules built outside the kernel source tree go into extra by default |
| 23 | INSTALL_MOD_DIR ?= extra | 24 | INSTALL_MOD_DIR ?= extra |
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 9ee9783aea5..f4053dc7b5d 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
| @@ -82,7 +82,7 @@ modpost = scripts/mod/modpost \ | |||
| 82 | $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ | 82 | $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ |
| 83 | $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ | 83 | $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ |
| 84 | $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ | 84 | $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ |
| 85 | $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(EXTRA_SYMBOLS))) \ | 85 | $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ |
| 86 | $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ | 86 | $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ |
| 87 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ | 87 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ |
| 88 | $(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \ | 88 | $(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \ |
diff --git a/scripts/bootgraph.pl b/scripts/bootgraph.pl index 5e7316e5aa3..f0af9aa9b24 100644 --- a/scripts/bootgraph.pl +++ b/scripts/bootgraph.pl | |||
| @@ -37,7 +37,10 @@ | |||
| 37 | # dmesg | perl scripts/bootgraph.pl > output.svg | 37 | # dmesg | perl scripts/bootgraph.pl > output.svg |
| 38 | # | 38 | # |
| 39 | 39 | ||
| 40 | my %start, %end; | 40 | use strict; |
| 41 | |||
| 42 | my %start; | ||
| 43 | my %end; | ||
| 41 | my $done = 0; | 44 | my $done = 0; |
| 42 | my $maxtime = 0; | 45 | my $maxtime = 0; |
| 43 | my $firsttime = 100; | 46 | my $firsttime = 100; |
| @@ -75,11 +78,13 @@ while (<>) { | |||
| 75 | } | 78 | } |
| 76 | 79 | ||
| 77 | if ($count == 0) { | 80 | if ($count == 0) { |
| 78 | print "No data found in the dmesg. Make sure that 'printk.time=1' and\n"; | 81 | print STDERR <<END; |
| 79 | print "'initcall_debug' are passed on the kernel command line.\n\n"; | 82 | No data found in the dmesg. Make sure that 'printk.time=1' and |
| 80 | print "Usage: \n"; | 83 | 'initcall_debug' are passed on the kernel command line. |
| 81 | print " dmesg | perl scripts/bootgraph.pl > output.svg\n\n"; | 84 | Usage: |
| 82 | exit; | 85 | dmesg | perl scripts/bootgraph.pl > output.svg |
| 86 | END | ||
| 87 | exit 1; | ||
| 83 | } | 88 | } |
| 84 | 89 | ||
| 85 | print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; | 90 | print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; |
| @@ -105,18 +110,20 @@ my $threshold = ($maxtime - $firsttime) / 60.0; | |||
| 105 | my $stylecounter = 0; | 110 | my $stylecounter = 0; |
| 106 | my %rows; | 111 | my %rows; |
| 107 | my $rowscount = 1; | 112 | my $rowscount = 1; |
| 108 | while (($key,$value) = each %start) { | 113 | my @initcalls = sort { $start{$a} <=> $start{$b} } keys(%start); |
| 114 | |||
| 115 | foreach my $key (@initcalls) { | ||
| 109 | my $duration = $end{$key} - $start{$key}; | 116 | my $duration = $end{$key} - $start{$key}; |
| 110 | 117 | ||
| 111 | if ($duration >= $threshold) { | 118 | if ($duration >= $threshold) { |
| 112 | my $s, $s2, $e, $y; | 119 | my ($s, $s2, $e, $w, $y, $y2, $style); |
| 113 | $pid = $pids{$key}; | 120 | my $pid = $pids{$key}; |
| 114 | 121 | ||
| 115 | if (!defined($rows{$pid})) { | 122 | if (!defined($rows{$pid})) { |
| 116 | $rows{$pid} = $rowscount; | 123 | $rows{$pid} = $rowscount; |
| 117 | $rowscount = $rowscount + 1; | 124 | $rowscount = $rowscount + 1; |
| 118 | } | 125 | } |
| 119 | $s = ($value - $firsttime) * $mult; | 126 | $s = ($start{$key} - $firsttime) * $mult; |
| 120 | $s2 = $s + 6; | 127 | $s2 = $s + 6; |
| 121 | $e = ($end{$key} - $firsttime) * $mult; | 128 | $e = ($end{$key} - $firsttime) * $mult; |
| 122 | $w = $e - $s; | 129 | $w = $e - $s; |
| @@ -140,9 +147,9 @@ while (($key,$value) = each %start) { | |||
| 140 | my $time = $firsttime; | 147 | my $time = $firsttime; |
| 141 | my $step = ($maxtime - $firsttime) / 15; | 148 | my $step = ($maxtime - $firsttime) / 15; |
| 142 | while ($time < $maxtime) { | 149 | while ($time < $maxtime) { |
| 143 | my $s2 = ($time - $firsttime) * $mult; | 150 | my $s3 = ($time - $firsttime) * $mult; |
| 144 | my $tm = int($time * 100) / 100.0; | 151 | my $tm = int($time * 100) / 100.0; |
| 145 | print "<text transform=\"translate($s2,89) rotate(90)\">$tm</text>\n"; | 152 | print "<text transform=\"translate($s3,89) rotate(90)\">$tm</text>\n"; |
| 146 | $time = $time + $step; | 153 | $time = $time + $step; |
| 147 | } | 154 | } |
| 148 | 155 | ||
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index f7e8e93ff30..14ee68e991d 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl | |||
| @@ -14,6 +14,7 @@ | |||
| 14 | # M68k port by Geert Uytterhoeven and Andreas Schwab | 14 | # M68k port by Geert Uytterhoeven and Andreas Schwab |
| 15 | # AVR32 port by Haavard Skinnemoen <hskinnemoen@atmel.com> | 15 | # AVR32 port by Haavard Skinnemoen <hskinnemoen@atmel.com> |
| 16 | # PARISC port by Kyle McMartin <kyle@parisc-linux.org> | 16 | # PARISC port by Kyle McMartin <kyle@parisc-linux.org> |
| 17 | # sparc port by Martin Habets <errandir_news@mph.eclipse.co.uk> | ||
| 17 | # | 18 | # |
| 18 | # Usage: | 19 | # Usage: |
| 19 | # objdump -d vmlinux | scripts/checkstack.pl [arch] | 20 | # objdump -d vmlinux | scripts/checkstack.pl [arch] |
| @@ -94,6 +95,9 @@ my (@stack, $re, $dre, $x, $xs); | |||
| 94 | } elsif ($arch =~ /^blackfin$/) { | 95 | } elsif ($arch =~ /^blackfin$/) { |
| 95 | # 0: 00 e8 38 01 LINK 0x4e0; | 96 | # 0: 00 e8 38 01 LINK 0x4e0; |
| 96 | $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o; | 97 | $re = qr/.*[[:space:]]LINK[[:space:]]*(0x$x{1,8})/o; |
| 98 | } elsif ($arch eq 'sparc' || $arch eq 'sparc64') { | ||
| 99 | # f0019d10: 9d e3 bf 90 save %sp, -112, %sp | ||
| 100 | $re = qr/.*save.*%sp, -(([0-9]{2}|[3-9])[0-9]{2}), %sp/o; | ||
| 97 | } else { | 101 | } else { |
| 98 | print("wrong or unknown architecture \"$arch\"\n"); | 102 | print("wrong or unknown architecture \"$arch\"\n"); |
| 99 | exit | 103 | exit |
diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh index 366f8c7f62b..60d00d1c4ee 100755 --- a/scripts/checksyscalls.sh +++ b/scripts/checksyscalls.sh | |||
| @@ -113,11 +113,11 @@ EOF | |||
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | syscall_list() { | 115 | syscall_list() { |
| 116 | sed -n -e '/^\#define/ { s/[^_]*__NR_\([^[:space:]]*\).*/\ | 116 | sed -n -e '/^\#define/ s/[^_]*__NR_\([^[:space:]]*\).*/\ |
| 117 | \#if !defined \(__NR_\1\) \&\& !defined \(__IGNORE_\1\)\ | 117 | \#if !defined \(__NR_\1\) \&\& !defined \(__IGNORE_\1\)\ |
| 118 | \#warning syscall \1 not implemented\ | 118 | \#warning syscall \1 not implemented\ |
| 119 | \#endif/p }' $1 | 119 | \#endif/p' $1 |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | (ignore_list && syscall_list ${srctree}/include/asm-x86/unistd_32.h) | \ | 122 | (ignore_list && syscall_list ${srctree}/arch/x86/include/asm/unistd_32.h) | \ |
| 123 | $* -E -x c - > /dev/null | 123 | $* -E -x c - > /dev/null |
diff --git a/scripts/decodecode b/scripts/decodecode index 235d3938529..4b00647814b 100755 --- a/scripts/decodecode +++ b/scripts/decodecode | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | # AFLAGS=--32 decodecode < 386.oops | 7 | # AFLAGS=--32 decodecode < 386.oops |
| 8 | 8 | ||
| 9 | cleanup() { | 9 | cleanup() { |
| 10 | rm -f $T $T.s $T.o | 10 | rm -f $T $T.s $T.o $T.oo $T.aa $T.aaa |
| 11 | exit 1 | 11 | exit 1 |
| 12 | } | 12 | } |
| 13 | 13 | ||
| @@ -44,21 +44,33 @@ if [ $marker -eq 0 ]; then | |||
| 44 | marker=`expr index "$code" "\("` | 44 | marker=`expr index "$code" "\("` |
| 45 | fi | 45 | fi |
| 46 | 46 | ||
| 47 | touch $T.oo | ||
| 47 | if [ $marker -ne 0 ]; then | 48 | if [ $marker -ne 0 ]; then |
| 48 | beforemark=`echo "$code" | cut -c-$((${marker} - 1))` | 49 | echo All code >> $T.oo |
| 50 | echo ======== >> $T.oo | ||
| 51 | beforemark=`echo "$code"` | ||
| 49 | echo -n " .byte 0x" > $T.s | 52 | echo -n " .byte 0x" > $T.s |
| 50 | echo $beforemark | sed -e 's/ /,0x/g' >> $T.s | 53 | echo $beforemark | sed -e 's/ /,0x/g' | sed -e 's/<//g' | sed -e 's/>//g' >> $T.s |
| 51 | as $AFLAGS -o $T.o $T.s | 54 | as $AFLAGS -o $T.o $T.s &> /dev/null |
| 52 | objdump -S $T.o | 55 | objdump -S $T.o | grep -v "/tmp" | grep -v "Disassembly" | grep -v "\.text" | grep -v "^$" &> $T.ooo |
| 53 | rm $T.o $T.s | 56 | cat $T.ooo >> $T.oo |
| 57 | rm -f $T.o $T.s $T.ooo | ||
| 54 | 58 | ||
| 55 | # and fix code at-and-after marker | 59 | # and fix code at-and-after marker |
| 56 | code=`echo "$code" | cut -c$((${marker} + 1))-` | 60 | code=`echo "$code" | cut -c$((${marker} + 1))-` |
| 57 | fi | 61 | fi |
| 58 | 62 | echo Code starting with the faulting instruction > $T.aa | |
| 63 | echo =========================================== >> $T.aa | ||
| 59 | code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'` | 64 | code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'` |
| 60 | echo -n " .byte 0x" > $T.s | 65 | echo -n " .byte 0x" > $T.s |
| 61 | echo $code >> $T.s | 66 | echo $code >> $T.s |
| 62 | as $AFLAGS -o $T.o $T.s | 67 | as $AFLAGS -o $T.o $T.s &> /dev/null |
| 63 | objdump -S $T.o | 68 | objdump -S $T.o | grep -v "Disassembly" | grep -v "/tmp" | grep -v "\.text" | grep -v "^$" &> $T.aaa |
| 64 | rm $T $T.s $T.o | 69 | cat $T.aaa >> $T.aa |
| 70 | |||
| 71 | faultline=`cat $T.aaa | head -1 | cut -d":" -f2` | ||
| 72 | |||
| 73 | cat $T.oo | sed -e "s/\($faultline\)/\*\1 <-- trapping instruction/g" | ||
| 74 | echo | ||
| 75 | cat $T.aa | ||
| 76 | cleanup | ||
diff --git a/scripts/extract-ikconfig b/scripts/extract-ikconfig index 8187e6f0dc2..72997c353cb 100755 --- a/scripts/extract-ikconfig +++ b/scripts/extract-ikconfig | |||
| @@ -8,8 +8,8 @@ test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1 | |||
| 8 | 8 | ||
| 9 | IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54" | 9 | IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54" |
| 10 | IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44" | 10 | IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44" |
| 11 | function dump_config { | 11 | dump_config() { |
| 12 | typeset file="$1" | 12 | file="$1" |
| 13 | 13 | ||
| 14 | start=`$binoffset $file $IKCFG_ST 2>/dev/null` | 14 | start=`$binoffset $file $IKCFG_ST 2>/dev/null` |
| 15 | [ "$?" != "0" ] && start="-1" | 15 | [ "$?" != "0" ] && start="-1" |
| @@ -18,8 +18,8 @@ function dump_config { | |||
| 18 | fi | 18 | fi |
| 19 | end=`$binoffset $file $IKCFG_ED 2>/dev/null` | 19 | end=`$binoffset $file $IKCFG_ED 2>/dev/null` |
| 20 | 20 | ||
| 21 | let start="$start + 8" | 21 | start=`expr $start + 8` |
| 22 | let size="$end - $start" | 22 | size=`expr $end - $start` |
| 23 | 23 | ||
| 24 | dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat | 24 | dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat |
| 25 | 25 | ||
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index c249274e005..f8bb4cabd62 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c | |||
| @@ -42,7 +42,8 @@ static FILE *debugfile; | |||
| 42 | int cur_line = 1; | 42 | int cur_line = 1; |
| 43 | char *cur_filename; | 43 | char *cur_filename; |
| 44 | 44 | ||
| 45 | static int flag_debug, flag_dump_defs, flag_dump_types, flag_warnings; | 45 | static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, |
| 46 | flag_preserve, flag_warnings, flag_asm; | ||
| 46 | static const char *arch = ""; | 47 | static const char *arch = ""; |
| 47 | static const char *mod_prefix = ""; | 48 | static const char *mod_prefix = ""; |
| 48 | 49 | ||
| @@ -58,6 +59,8 @@ static const char *const symbol_type_name[] = { | |||
| 58 | 59 | ||
| 59 | static int equal_list(struct string_list *a, struct string_list *b); | 60 | static int equal_list(struct string_list *a, struct string_list *b); |
| 60 | static void print_list(FILE * f, struct string_list *list); | 61 | static void print_list(FILE * f, struct string_list *list); |
| 62 | static void print_location(void); | ||
| 63 | static void print_type_name(enum symbol_type type, const char *name); | ||
| 61 | 64 | ||
| 62 | /*----------------------------------------------------------------------*/ | 65 | /*----------------------------------------------------------------------*/ |
| 63 | 66 | ||
| @@ -151,27 +154,83 @@ struct symbol *find_symbol(const char *name, enum symbol_type ns) | |||
| 151 | 154 | ||
| 152 | for (sym = symtab[h]; sym; sym = sym->hash_next) | 155 | for (sym = symtab[h]; sym; sym = sym->hash_next) |
| 153 | if (map_to_ns(sym->type) == map_to_ns(ns) && | 156 | if (map_to_ns(sym->type) == map_to_ns(ns) && |
| 154 | strcmp(name, sym->name) == 0) | 157 | strcmp(name, sym->name) == 0 && |
| 158 | sym->is_declared) | ||
| 155 | break; | 159 | break; |
| 156 | 160 | ||
| 157 | return sym; | 161 | return sym; |
| 158 | } | 162 | } |
| 159 | 163 | ||
| 160 | struct symbol *add_symbol(const char *name, enum symbol_type type, | 164 | static int is_unknown_symbol(struct symbol *sym) |
| 161 | struct string_list *defn, int is_extern) | 165 | { |
| 166 | struct string_list *defn; | ||
| 167 | |||
| 168 | return ((sym->type == SYM_STRUCT || | ||
| 169 | sym->type == SYM_UNION || | ||
| 170 | sym->type == SYM_ENUM) && | ||
| 171 | (defn = sym->defn) && defn->tag == SYM_NORMAL && | ||
| 172 | strcmp(defn->string, "}") == 0 && | ||
| 173 | (defn = defn->next) && defn->tag == SYM_NORMAL && | ||
| 174 | strcmp(defn->string, "UNKNOWN") == 0 && | ||
| 175 | (defn = defn->next) && defn->tag == SYM_NORMAL && | ||
| 176 | strcmp(defn->string, "{") == 0); | ||
| 177 | } | ||
| 178 | |||
| 179 | struct symbol *__add_symbol(const char *name, enum symbol_type type, | ||
| 180 | struct string_list *defn, int is_extern, | ||
| 181 | int is_reference) | ||
| 162 | { | 182 | { |
| 163 | unsigned long h = crc32(name) % HASH_BUCKETS; | 183 | unsigned long h = crc32(name) % HASH_BUCKETS; |
| 164 | struct symbol *sym; | 184 | struct symbol *sym; |
| 185 | enum symbol_status status = STATUS_UNCHANGED; | ||
| 165 | 186 | ||
| 166 | for (sym = symtab[h]; sym; sym = sym->hash_next) { | 187 | for (sym = symtab[h]; sym; sym = sym->hash_next) { |
| 167 | if (map_to_ns(sym->type) == map_to_ns(type) | 188 | if (map_to_ns(sym->type) == map_to_ns(type) && |
| 168 | && strcmp(name, sym->name) == 0) { | 189 | strcmp(name, sym->name) == 0) { |
| 169 | if (!equal_list(sym->defn, defn)) | 190 | if (is_reference) |
| 191 | /* fall through */ ; | ||
| 192 | else if (sym->type == type && | ||
| 193 | equal_list(sym->defn, defn)) { | ||
| 194 | if (!sym->is_declared && sym->is_override) { | ||
| 195 | print_location(); | ||
| 196 | print_type_name(type, name); | ||
| 197 | fprintf(stderr, " modversion is " | ||
| 198 | "unchanged\n"); | ||
| 199 | } | ||
| 200 | sym->is_declared = 1; | ||
| 201 | return sym; | ||
| 202 | } else if (!sym->is_declared) { | ||
| 203 | if (sym->is_override && flag_preserve) { | ||
| 204 | print_location(); | ||
| 205 | fprintf(stderr, "ignoring "); | ||
| 206 | print_type_name(type, name); | ||
| 207 | fprintf(stderr, " modversion change\n"); | ||
| 208 | sym->is_declared = 1; | ||
| 209 | return sym; | ||
| 210 | } else { | ||
| 211 | status = is_unknown_symbol(sym) ? | ||
| 212 | STATUS_DEFINED : STATUS_MODIFIED; | ||
| 213 | } | ||
| 214 | } else { | ||
| 170 | error_with_pos("redefinition of %s", name); | 215 | error_with_pos("redefinition of %s", name); |
| 171 | return sym; | 216 | return sym; |
| 217 | } | ||
| 218 | break; | ||
| 172 | } | 219 | } |
| 173 | } | 220 | } |
| 174 | 221 | ||
| 222 | if (sym) { | ||
| 223 | struct symbol **psym; | ||
| 224 | |||
| 225 | for (psym = &symtab[h]; *psym; psym = &(*psym)->hash_next) { | ||
| 226 | if (*psym == sym) { | ||
| 227 | *psym = sym->hash_next; | ||
| 228 | break; | ||
| 229 | } | ||
| 230 | } | ||
| 231 | --nsyms; | ||
| 232 | } | ||
| 233 | |||
| 175 | sym = xmalloc(sizeof(*sym)); | 234 | sym = xmalloc(sizeof(*sym)); |
| 176 | sym->name = name; | 235 | sym->name = name; |
| 177 | sym->type = type; | 236 | sym->type = type; |
| @@ -183,6 +242,10 @@ struct symbol *add_symbol(const char *name, enum symbol_type type, | |||
| 183 | sym->hash_next = symtab[h]; | 242 | sym->hash_next = symtab[h]; |
| 184 | symtab[h] = sym; | 243 | symtab[h] = sym; |
| 185 | 244 | ||
| 245 | sym->is_declared = !is_reference; | ||
| 246 | sym->status = status; | ||
| 247 | sym->is_override = 0; | ||
| 248 | |||
| 186 | if (flag_debug) { | 249 | if (flag_debug) { |
| 187 | fprintf(debugfile, "Defn for %s %s == <", | 250 | fprintf(debugfile, "Defn for %s %s == <", |
| 188 | symbol_type_name[type], name); | 251 | symbol_type_name[type], name); |
| @@ -196,6 +259,18 @@ struct symbol *add_symbol(const char *name, enum symbol_type type, | |||
| 196 | return sym; | 259 | return sym; |
| 197 | } | 260 | } |
| 198 | 261 | ||
| 262 | struct symbol *add_symbol(const char *name, enum symbol_type type, | ||
| 263 | struct string_list *defn, int is_extern) | ||
| 264 | { | ||
| 265 | return __add_symbol(name, type, defn, is_extern, 0); | ||
| 266 | } | ||
| 267 | |||
| 268 | struct symbol *add_reference_symbol(const char *name, enum symbol_type type, | ||
| 269 | struct string_list *defn, int is_extern) | ||
| 270 | { | ||
| 271 | return __add_symbol(name, type, defn, is_extern, 1); | ||
| 272 | } | ||
| 273 | |||
| 199 | /*----------------------------------------------------------------------*/ | 274 | /*----------------------------------------------------------------------*/ |
| 200 | 275 | ||
| 201 | void free_node(struct string_list *node) | 276 | void free_node(struct string_list *node) |
| @@ -236,6 +311,90 @@ static int equal_list(struct string_list *a, struct string_list *b) | |||
| 236 | return !a && !b; | 311 | return !a && !b; |
| 237 | } | 312 | } |
| 238 | 313 | ||
| 314 | #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0])) | ||
| 315 | |||
| 316 | struct string_list *read_node(FILE *f) | ||
| 317 | { | ||
| 318 | char buffer[256]; | ||
| 319 | struct string_list node = { | ||
| 320 | .string = buffer, | ||
| 321 | .tag = SYM_NORMAL }; | ||
| 322 | int c; | ||
| 323 | |||
| 324 | while ((c = fgetc(f)) != EOF) { | ||
| 325 | if (c == ' ') { | ||
| 326 | if (node.string == buffer) | ||
| 327 | continue; | ||
| 328 | break; | ||
| 329 | } else if (c == '\n') { | ||
| 330 | if (node.string == buffer) | ||
| 331 | return NULL; | ||
| 332 | ungetc(c, f); | ||
| 333 | break; | ||
| 334 | } | ||
| 335 | if (node.string >= buffer + sizeof(buffer) - 1) { | ||
| 336 | fprintf(stderr, "Token too long\n"); | ||
| 337 | exit(1); | ||
| 338 | } | ||
| 339 | *node.string++ = c; | ||
| 340 | } | ||
| 341 | if (node.string == buffer) | ||
| 342 | return NULL; | ||
| 343 | *node.string = 0; | ||
| 344 | node.string = buffer; | ||
| 345 | |||
| 346 | if (node.string[1] == '#') { | ||
| 347 | int n; | ||
| 348 | |||
| 349 | for (n = 0; n < ARRAY_SIZE(symbol_type_name); n++) { | ||
| 350 | if (node.string[0] == symbol_type_name[n][0]) { | ||
| 351 | node.tag = n; | ||
| 352 | node.string += 2; | ||
| 353 | return copy_node(&node); | ||
| 354 | } | ||
| 355 | } | ||
| 356 | fprintf(stderr, "Unknown type %c\n", node.string[0]); | ||
| 357 | exit(1); | ||
| 358 | } | ||
| 359 | return copy_node(&node); | ||
| 360 | } | ||
| 361 | |||
| 362 | static void read_reference(FILE *f) | ||
| 363 | { | ||
| 364 | while (!feof(f)) { | ||
| 365 | struct string_list *defn = NULL; | ||
| 366 | struct string_list *sym, *def; | ||
| 367 | int is_extern = 0, is_override = 0; | ||
| 368 | struct symbol *subsym; | ||
| 369 | |||
| 370 | sym = read_node(f); | ||
| 371 | if (sym && sym->tag == SYM_NORMAL && | ||
| 372 | !strcmp(sym->string, "override")) { | ||
| 373 | is_override = 1; | ||
| 374 | free_node(sym); | ||
| 375 | sym = read_node(f); | ||
| 376 | } | ||
| 377 | if (!sym) | ||
| 378 | continue; | ||
| 379 | def = read_node(f); | ||
| 380 | if (def && def->tag == SYM_NORMAL && | ||
| 381 | !strcmp(def->string, "extern")) { | ||
| 382 | is_extern = 1; | ||
| 383 | free_node(def); | ||
| 384 | def = read_node(f); | ||
| 385 | } | ||
| 386 | while (def) { | ||
| 387 | def->next = defn; | ||
| 388 | defn = def; | ||
| 389 | def = read_node(f); | ||
| 390 | } | ||
| 391 | subsym = add_reference_symbol(xstrdup(sym->string), sym->tag, | ||
| 392 | defn, is_extern); | ||
| 393 | subsym->is_override = is_override; | ||
| 394 | free_node(sym); | ||
| 395 | } | ||
| 396 | } | ||
| 397 | |||
| 239 | static void print_node(FILE * f, struct string_list *list) | 398 | static void print_node(FILE * f, struct string_list *list) |
| 240 | { | 399 | { |
| 241 | if (list->tag != SYM_NORMAL) { | 400 | if (list->tag != SYM_NORMAL) { |
| @@ -311,6 +470,7 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc) | |||
| 311 | 470 | ||
| 312 | case SYM_TYPEDEF: | 471 | case SYM_TYPEDEF: |
| 313 | subsym = find_symbol(cur->string, cur->tag); | 472 | subsym = find_symbol(cur->string, cur->tag); |
| 473 | /* FIXME: Bad reference files can segfault here. */ | ||
| 314 | if (subsym->expansion_trail) { | 474 | if (subsym->expansion_trail) { |
| 315 | if (flag_dump_defs) | 475 | if (flag_dump_defs) |
| 316 | fprintf(debugfile, "%s ", cur->string); | 476 | fprintf(debugfile, "%s ", cur->string); |
| @@ -347,9 +507,22 @@ static unsigned long expand_and_crc_sym(struct symbol *sym, unsigned long crc) | |||
| 347 | t = n; | 507 | t = n; |
| 348 | 508 | ||
| 349 | n = xmalloc(sizeof(*n)); | 509 | n = xmalloc(sizeof(*n)); |
| 350 | n->string = xstrdup("{ UNKNOWN }"); | 510 | n->string = xstrdup("{"); |
| 511 | n->tag = SYM_NORMAL; | ||
| 512 | n->next = t; | ||
| 513 | t = n; | ||
| 514 | |||
| 515 | n = xmalloc(sizeof(*n)); | ||
| 516 | n->string = xstrdup("UNKNOWN"); | ||
| 517 | n->tag = SYM_NORMAL; | ||
| 518 | n->next = t; | ||
| 519 | t = n; | ||
| 520 | |||
| 521 | n = xmalloc(sizeof(*n)); | ||
| 522 | n->string = xstrdup("}"); | ||
| 351 | n->tag = SYM_NORMAL; | 523 | n->tag = SYM_NORMAL; |
| 352 | n->next = t; | 524 | n->next = t; |
| 525 | t = n; | ||
| 353 | 526 | ||
| 354 | subsym = | 527 | subsym = |
| 355 | add_symbol(cur->string, cur->tag, n, 0); | 528 | add_symbol(cur->string, cur->tag, n, 0); |
| @@ -397,37 +570,75 @@ void export_symbol(const char *name) | |||
| 397 | error_with_pos("export undefined symbol %s", name); | 570 | error_with_pos("export undefined symbol %s", name); |
| 398 | else { | 571 | else { |
| 399 | unsigned long crc; | 572 | unsigned long crc; |
| 573 | int has_changed = 0; | ||
| 400 | 574 | ||
| 401 | if (flag_dump_defs) | 575 | if (flag_dump_defs) |
| 402 | fprintf(debugfile, "Export %s == <", name); | 576 | fprintf(debugfile, "Export %s == <", name); |
| 403 | 577 | ||
| 404 | expansion_trail = (struct symbol *)-1L; | 578 | expansion_trail = (struct symbol *)-1L; |
| 405 | 579 | ||
| 580 | sym->expansion_trail = expansion_trail; | ||
| 581 | expansion_trail = sym; | ||
| 406 | crc = expand_and_crc_sym(sym, 0xffffffff) ^ 0xffffffff; | 582 | crc = expand_and_crc_sym(sym, 0xffffffff) ^ 0xffffffff; |
| 407 | 583 | ||
| 408 | sym = expansion_trail; | 584 | sym = expansion_trail; |
| 409 | while (sym != (struct symbol *)-1L) { | 585 | while (sym != (struct symbol *)-1L) { |
| 410 | struct symbol *n = sym->expansion_trail; | 586 | struct symbol *n = sym->expansion_trail; |
| 587 | |||
| 588 | if (sym->status != STATUS_UNCHANGED) { | ||
| 589 | if (!has_changed) { | ||
| 590 | print_location(); | ||
| 591 | fprintf(stderr, "%s: %s: modversion " | ||
| 592 | "changed because of changes " | ||
| 593 | "in ", flag_preserve ? "error" : | ||
| 594 | "warning", name); | ||
| 595 | } else | ||
| 596 | fprintf(stderr, ", "); | ||
| 597 | print_type_name(sym->type, sym->name); | ||
| 598 | if (sym->status == STATUS_DEFINED) | ||
| 599 | fprintf(stderr, " (became defined)"); | ||
| 600 | has_changed = 1; | ||
| 601 | if (flag_preserve) | ||
| 602 | errors++; | ||
| 603 | } | ||
| 411 | sym->expansion_trail = 0; | 604 | sym->expansion_trail = 0; |
| 412 | sym = n; | 605 | sym = n; |
| 413 | } | 606 | } |
| 607 | if (has_changed) | ||
| 608 | fprintf(stderr, "\n"); | ||
| 414 | 609 | ||
| 415 | if (flag_dump_defs) | 610 | if (flag_dump_defs) |
| 416 | fputs(">\n", debugfile); | 611 | fputs(">\n", debugfile); |
| 417 | 612 | ||
| 418 | /* Used as a linker script. */ | 613 | /* Used as assembly source or a linker script. */ |
| 419 | printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc); | 614 | printf(flag_asm |
| 615 | ? ".equiv %s__crc_%s, %#08lx\n" | ||
| 616 | : "%s__crc_%s = %#08lx ;\n", | ||
| 617 | mod_prefix, name, crc); | ||
| 420 | } | 618 | } |
| 421 | } | 619 | } |
| 422 | 620 | ||
| 423 | /*----------------------------------------------------------------------*/ | 621 | /*----------------------------------------------------------------------*/ |
| 622 | |||
| 623 | static void print_location(void) | ||
| 624 | { | ||
| 625 | fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>", cur_line); | ||
| 626 | } | ||
| 627 | |||
| 628 | static void print_type_name(enum symbol_type type, const char *name) | ||
| 629 | { | ||
| 630 | if (type != SYM_NORMAL) | ||
| 631 | fprintf(stderr, "%s %s", symbol_type_name[type], name); | ||
| 632 | else | ||
| 633 | fprintf(stderr, "%s", name); | ||
| 634 | } | ||
| 635 | |||
| 424 | void error_with_pos(const char *fmt, ...) | 636 | void error_with_pos(const char *fmt, ...) |
| 425 | { | 637 | { |
| 426 | va_list args; | 638 | va_list args; |
| 427 | 639 | ||
| 428 | if (flag_warnings) { | 640 | if (flag_warnings) { |
| 429 | fprintf(stderr, "%s:%d: ", cur_filename ? : "<stdin>", | 641 | print_location(); |
| 430 | cur_line); | ||
| 431 | 642 | ||
| 432 | va_start(args, fmt); | 643 | va_start(args, fmt); |
| 433 | vfprintf(stderr, fmt, args); | 644 | vfprintf(stderr, fmt, args); |
| @@ -440,21 +651,27 @@ void error_with_pos(const char *fmt, ...) | |||
| 440 | 651 | ||
| 441 | static void genksyms_usage(void) | 652 | static void genksyms_usage(void) |
| 442 | { | 653 | { |
| 443 | fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" | 654 | fputs("Usage:\n" "genksyms [-aAdDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" |
| 444 | #ifdef __GNU_LIBRARY__ | 655 | #ifdef __GNU_LIBRARY__ |
| 445 | " -a, --arch Select architecture\n" | 656 | " -a, --arch Select architecture\n" |
| 657 | " -A, --asm Generate assembly rather than linker script\n" | ||
| 446 | " -d, --debug Increment the debug level (repeatable)\n" | 658 | " -d, --debug Increment the debug level (repeatable)\n" |
| 447 | " -D, --dump Dump expanded symbol defs (for debugging only)\n" | 659 | " -D, --dump Dump expanded symbol defs (for debugging only)\n" |
| 448 | " -T, --dump-types file Dump expanded types into file (for debugging only)\n" | 660 | " -r, --reference file Read reference symbols from a file\n" |
| 661 | " -T, --dump-types file Dump expanded types into file\n" | ||
| 662 | " -p, --preserve Preserve reference modversions or fail\n" | ||
| 449 | " -w, --warnings Enable warnings\n" | 663 | " -w, --warnings Enable warnings\n" |
| 450 | " -q, --quiet Disable warnings (default)\n" | 664 | " -q, --quiet Disable warnings (default)\n" |
| 451 | " -h, --help Print this message\n" | 665 | " -h, --help Print this message\n" |
| 452 | " -V, --version Print the release version\n" | 666 | " -V, --version Print the release version\n" |
| 453 | #else /* __GNU_LIBRARY__ */ | 667 | #else /* __GNU_LIBRARY__ */ |
| 454 | " -a Select architecture\n" | 668 | " -a Select architecture\n" |
| 669 | " -A Generate assembly rather than linker script\n" | ||
| 455 | " -d Increment the debug level (repeatable)\n" | 670 | " -d Increment the debug level (repeatable)\n" |
| 456 | " -D Dump expanded symbol defs (for debugging only)\n" | 671 | " -D Dump expanded symbol defs (for debugging only)\n" |
| 457 | " -T file Dump expanded types into file (for debugging only)\n" | 672 | " -r file Read reference symbols from a file\n" |
| 673 | " -T file Dump expanded types into file\n" | ||
| 674 | " -p Preserve reference modversions or fail\n" | ||
| 458 | " -w Enable warnings\n" | 675 | " -w Enable warnings\n" |
| 459 | " -q Disable warnings (default)\n" | 676 | " -q Disable warnings (default)\n" |
| 460 | " -h Print this message\n" | 677 | " -h Print this message\n" |
| @@ -465,26 +682,29 @@ static void genksyms_usage(void) | |||
| 465 | 682 | ||
| 466 | int main(int argc, char **argv) | 683 | int main(int argc, char **argv) |
| 467 | { | 684 | { |
| 468 | FILE *dumpfile = NULL; | 685 | FILE *dumpfile = NULL, *ref_file = NULL; |
| 469 | int o; | 686 | int o; |
| 470 | 687 | ||
| 471 | #ifdef __GNU_LIBRARY__ | 688 | #ifdef __GNU_LIBRARY__ |
| 472 | struct option long_opts[] = { | 689 | struct option long_opts[] = { |
| 473 | {"arch", 1, 0, 'a'}, | 690 | {"arch", 1, 0, 'a'}, |
| 691 | {"asm", 0, 0, 'A'}, | ||
| 474 | {"debug", 0, 0, 'd'}, | 692 | {"debug", 0, 0, 'd'}, |
| 475 | {"warnings", 0, 0, 'w'}, | 693 | {"warnings", 0, 0, 'w'}, |
| 476 | {"quiet", 0, 0, 'q'}, | 694 | {"quiet", 0, 0, 'q'}, |
| 477 | {"dump", 0, 0, 'D'}, | 695 | {"dump", 0, 0, 'D'}, |
| 696 | {"reference", 1, 0, 'r'}, | ||
| 478 | {"dump-types", 1, 0, 'T'}, | 697 | {"dump-types", 1, 0, 'T'}, |
| 698 | {"preserve", 0, 0, 'p'}, | ||
| 479 | {"version", 0, 0, 'V'}, | 699 | {"version", 0, 0, 'V'}, |
| 480 | {"help", 0, 0, 'h'}, | 700 | {"help", 0, 0, 'h'}, |
| 481 | {0, 0, 0, 0} | 701 | {0, 0, 0, 0} |
| 482 | }; | 702 | }; |
| 483 | 703 | ||
| 484 | while ((o = getopt_long(argc, argv, "a:dwqVDT:h", | 704 | while ((o = getopt_long(argc, argv, "a:dwqVADr:T:ph", |
| 485 | &long_opts[0], NULL)) != EOF) | 705 | &long_opts[0], NULL)) != EOF) |
| 486 | #else /* __GNU_LIBRARY__ */ | 706 | #else /* __GNU_LIBRARY__ */ |
| 487 | while ((o = getopt(argc, argv, "a:dwqVDT:h")) != EOF) | 707 | while ((o = getopt(argc, argv, "a:dwqVADr:T:ph")) != EOF) |
| 488 | #endif /* __GNU_LIBRARY__ */ | 708 | #endif /* __GNU_LIBRARY__ */ |
| 489 | switch (o) { | 709 | switch (o) { |
| 490 | case 'a': | 710 | case 'a': |
| @@ -502,9 +722,20 @@ int main(int argc, char **argv) | |||
| 502 | case 'V': | 722 | case 'V': |
| 503 | fputs("genksyms version 2.5.60\n", stderr); | 723 | fputs("genksyms version 2.5.60\n", stderr); |
| 504 | break; | 724 | break; |
| 725 | case 'A': | ||
| 726 | flag_asm = 1; | ||
| 727 | break; | ||
| 505 | case 'D': | 728 | case 'D': |
| 506 | flag_dump_defs = 1; | 729 | flag_dump_defs = 1; |
| 507 | break; | 730 | break; |
| 731 | case 'r': | ||
| 732 | flag_reference = 1; | ||
| 733 | ref_file = fopen(optarg, "r"); | ||
| 734 | if (!ref_file) { | ||
| 735 | perror(optarg); | ||
| 736 | return 1; | ||
| 737 | } | ||
| 738 | break; | ||
| 508 | case 'T': | 739 | case 'T': |
| 509 | flag_dump_types = 1; | 740 | flag_dump_types = 1; |
| 510 | dumpfile = fopen(optarg, "w"); | 741 | dumpfile = fopen(optarg, "w"); |
| @@ -513,6 +744,9 @@ int main(int argc, char **argv) | |||
| 513 | return 1; | 744 | return 1; |
| 514 | } | 745 | } |
| 515 | break; | 746 | break; |
| 747 | case 'p': | ||
| 748 | flag_preserve = 1; | ||
| 749 | break; | ||
| 516 | case 'h': | 750 | case 'h': |
| 517 | genksyms_usage(); | 751 | genksyms_usage(); |
| 518 | return 0; | 752 | return 0; |
| @@ -533,12 +767,17 @@ int main(int argc, char **argv) | |||
| 533 | /* setlinebuf(debugfile); */ | 767 | /* setlinebuf(debugfile); */ |
| 534 | } | 768 | } |
| 535 | 769 | ||
| 770 | if (flag_reference) | ||
| 771 | read_reference(ref_file); | ||
| 772 | |||
| 536 | yyparse(); | 773 | yyparse(); |
| 537 | 774 | ||
| 538 | if (flag_dump_types && visited_symbols) { | 775 | if (flag_dump_types && visited_symbols) { |
| 539 | while (visited_symbols != (struct symbol *)-1L) { | 776 | while (visited_symbols != (struct symbol *)-1L) { |
| 540 | struct symbol *sym = visited_symbols; | 777 | struct symbol *sym = visited_symbols; |
| 541 | 778 | ||
| 779 | if (sym->is_override) | ||
| 780 | fputs("override ", dumpfile); | ||
| 542 | if (sym->type != SYM_NORMAL) { | 781 | if (sym->type != SYM_NORMAL) { |
| 543 | putc(symbol_type_name[sym->type][0], dumpfile); | 782 | putc(symbol_type_name[sym->type][0], dumpfile); |
| 544 | putc('#', dumpfile); | 783 | putc('#', dumpfile); |
diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h index 2668287aa49..25c4d40cefc 100644 --- a/scripts/genksyms/genksyms.h +++ b/scripts/genksyms/genksyms.h | |||
| @@ -29,6 +29,10 @@ enum symbol_type { | |||
| 29 | SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION | 29 | SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION |
| 30 | }; | 30 | }; |
| 31 | 31 | ||
| 32 | enum symbol_status { | ||
| 33 | STATUS_UNCHANGED, STATUS_DEFINED, STATUS_MODIFIED | ||
| 34 | }; | ||
| 35 | |||
| 32 | struct string_list { | 36 | struct string_list { |
| 33 | struct string_list *next; | 37 | struct string_list *next; |
| 34 | enum symbol_type tag; | 38 | enum symbol_type tag; |
| @@ -43,6 +47,9 @@ struct symbol { | |||
| 43 | struct symbol *expansion_trail; | 47 | struct symbol *expansion_trail; |
| 44 | struct symbol *visited; | 48 | struct symbol *visited; |
| 45 | int is_extern; | 49 | int is_extern; |
| 50 | int is_declared; | ||
| 51 | enum symbol_status status; | ||
| 52 | int is_override; | ||
| 46 | }; | 53 | }; |
| 47 | 54 | ||
| 48 | typedef struct string_list **yystype; | 55 | typedef struct string_list **yystype; |
diff --git a/scripts/genksyms/keywords.c_shipped b/scripts/genksyms/keywords.c_shipped index 971e0113ae7..83484fe93ed 100644 --- a/scripts/genksyms/keywords.c_shipped +++ b/scripts/genksyms/keywords.c_shipped | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* ANSI-C code produced by gperf version 3.0.2 */ | 1 | /* ANSI-C code produced by gperf version 3.0.1 */ |
| 2 | /* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */ | 2 | /* Command-line: gperf -L ANSI-C -a -C -E -g -H is_reserved_hash -k '1,3,$' -N is_reserved_word -p -t scripts/genksyms/keywords.gperf */ |
| 3 | 3 | ||
| 4 | #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ | 4 | #if !((' ' == 32) && ('!' == 33) && ('"' == 34) && ('#' == 35) \ |
| @@ -32,7 +32,7 @@ | |||
| 32 | 32 | ||
| 33 | #line 3 "scripts/genksyms/keywords.gperf" | 33 | #line 3 "scripts/genksyms/keywords.gperf" |
| 34 | struct resword { const char *name; int token; }; | 34 | struct resword { const char *name; int token; }; |
| 35 | /* maximum key range = 62, duplicates = 0 */ | 35 | /* maximum key range = 64, duplicates = 0 */ |
| 36 | 36 | ||
| 37 | #ifdef __GNUC__ | 37 | #ifdef __GNUC__ |
| 38 | __inline | 38 | __inline |
| @@ -46,32 +46,32 @@ is_reserved_hash (register const char *str, register unsigned int len) | |||
| 46 | { | 46 | { |
| 47 | static const unsigned char asso_values[] = | 47 | static const unsigned char asso_values[] = |
| 48 | { | 48 | { |
| 49 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 49 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 50 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 50 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 51 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 51 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 52 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 52 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 53 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 53 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 54 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 54 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 55 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 5, | 55 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 0, |
| 56 | 65, 65, 65, 65, 65, 65, 35, 65, 65, 65, | 56 | 67, 67, 67, 67, 67, 67, 15, 67, 67, 67, |
| 57 | 0, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 57 | 0, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 58 | 65, 65, 65, 65, 65, 0, 65, 0, 65, 5, | 58 | 67, 67, 67, 67, 67, 0, 67, 0, 67, 5, |
| 59 | 20, 15, 10, 30, 65, 15, 65, 65, 20, 0, | 59 | 25, 20, 15, 30, 67, 15, 67, 67, 10, 0, |
| 60 | 10, 35, 20, 65, 10, 5, 0, 10, 5, 65, | 60 | 10, 40, 20, 67, 10, 5, 0, 10, 15, 67, |
| 61 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 61 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 62 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 62 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 63 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 63 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 64 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 64 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 65 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 65 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 66 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 66 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 67 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 67 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 68 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 68 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 69 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 69 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 70 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 70 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 71 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 71 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 72 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 72 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 73 | 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, | 73 | 67, 67, 67, 67, 67, 67, 67, 67, 67, 67, |
| 74 | 65, 65, 65, 65, 65, 65 | 74 | 67, 67, 67, 67, 67, 67 |
| 75 | }; | 75 | }; |
| 76 | return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]]; | 76 | return len + asso_values[(unsigned char)str[2]] + asso_values[(unsigned char)str[0]] + asso_values[(unsigned char)str[len - 1]]; |
| 77 | } | 77 | } |
| @@ -84,116 +84,119 @@ is_reserved_word (register const char *str, register unsigned int len) | |||
| 84 | { | 84 | { |
| 85 | enum | 85 | enum |
| 86 | { | 86 | { |
| 87 | TOTAL_KEYWORDS = 43, | 87 | TOTAL_KEYWORDS = 45, |
| 88 | MIN_WORD_LENGTH = 3, | 88 | MIN_WORD_LENGTH = 3, |
| 89 | MAX_WORD_LENGTH = 24, | 89 | MAX_WORD_LENGTH = 24, |
| 90 | MIN_HASH_VALUE = 3, | 90 | MIN_HASH_VALUE = 3, |
| 91 | MAX_HASH_VALUE = 64 | 91 | MAX_HASH_VALUE = 66 |
| 92 | }; | 92 | }; |
| 93 | 93 | ||
| 94 | static const struct resword wordlist[] = | 94 | static const struct resword wordlist[] = |
| 95 | { | 95 | { |
| 96 | {""}, {""}, {""}, | 96 | {""}, {""}, {""}, |
| 97 | #line 26 "scripts/genksyms/keywords.gperf" | 97 | #line 28 "scripts/genksyms/keywords.gperf" |
| 98 | {"asm", ASM_KEYW}, | 98 | {"asm", ASM_KEYW}, |
| 99 | {""}, | 99 | {""}, |
| 100 | #line 8 "scripts/genksyms/keywords.gperf" | 100 | #line 10 "scripts/genksyms/keywords.gperf" |
| 101 | {"__asm", ASM_KEYW}, | 101 | {"__asm", ASM_KEYW}, |
| 102 | {""}, | 102 | {""}, |
| 103 | #line 9 "scripts/genksyms/keywords.gperf" | 103 | #line 11 "scripts/genksyms/keywords.gperf" |
| 104 | {"__asm__", ASM_KEYW}, | 104 | {"__asm__", ASM_KEYW}, |
| 105 | {""}, {""}, | 105 | {""}, {""}, |
| 106 | #line 52 "scripts/genksyms/keywords.gperf" | 106 | #line 54 "scripts/genksyms/keywords.gperf" |
| 107 | {"__typeof__", TYPEOF_KEYW}, | 107 | {"__typeof__", TYPEOF_KEYW}, |
| 108 | {""}, | 108 | {""}, |
| 109 | #line 12 "scripts/genksyms/keywords.gperf" | 109 | #line 14 "scripts/genksyms/keywords.gperf" |
| 110 | {"__const", CONST_KEYW}, | 110 | {"__const", CONST_KEYW}, |
| 111 | #line 11 "scripts/genksyms/keywords.gperf" | ||
| 112 | {"__attribute__", ATTRIBUTE_KEYW}, | ||
| 113 | #line 13 "scripts/genksyms/keywords.gperf" | 111 | #line 13 "scripts/genksyms/keywords.gperf" |
| 112 | {"__attribute__", ATTRIBUTE_KEYW}, | ||
| 113 | #line 15 "scripts/genksyms/keywords.gperf" | ||
| 114 | {"__const__", CONST_KEYW}, | 114 | {"__const__", CONST_KEYW}, |
| 115 | #line 18 "scripts/genksyms/keywords.gperf" | 115 | #line 20 "scripts/genksyms/keywords.gperf" |
| 116 | {"__signed__", SIGNED_KEYW}, | 116 | {"__signed__", SIGNED_KEYW}, |
| 117 | #line 44 "scripts/genksyms/keywords.gperf" | 117 | #line 46 "scripts/genksyms/keywords.gperf" |
| 118 | {"static", STATIC_KEYW}, | 118 | {"static", STATIC_KEYW}, |
| 119 | #line 20 "scripts/genksyms/keywords.gperf" | 119 | {""}, |
| 120 | {"__volatile__", VOLATILE_KEYW}, | 120 | #line 41 "scripts/genksyms/keywords.gperf" |
| 121 | #line 39 "scripts/genksyms/keywords.gperf" | ||
| 122 | {"int", INT_KEYW}, | 121 | {"int", INT_KEYW}, |
| 123 | #line 32 "scripts/genksyms/keywords.gperf" | 122 | #line 34 "scripts/genksyms/keywords.gperf" |
| 124 | {"char", CHAR_KEYW}, | 123 | {"char", CHAR_KEYW}, |
| 125 | #line 33 "scripts/genksyms/keywords.gperf" | 124 | #line 35 "scripts/genksyms/keywords.gperf" |
| 126 | {"const", CONST_KEYW}, | 125 | {"const", CONST_KEYW}, |
| 127 | #line 45 "scripts/genksyms/keywords.gperf" | 126 | #line 47 "scripts/genksyms/keywords.gperf" |
| 128 | {"struct", STRUCT_KEYW}, | 127 | {"struct", STRUCT_KEYW}, |
| 129 | #line 24 "scripts/genksyms/keywords.gperf" | 128 | #line 26 "scripts/genksyms/keywords.gperf" |
| 130 | {"__restrict__", RESTRICT_KEYW}, | 129 | {"__restrict__", RESTRICT_KEYW}, |
| 131 | #line 25 "scripts/genksyms/keywords.gperf" | 130 | #line 27 "scripts/genksyms/keywords.gperf" |
| 132 | {"restrict", RESTRICT_KEYW}, | 131 | {"restrict", RESTRICT_KEYW}, |
| 133 | #line 23 "scripts/genksyms/keywords.gperf" | 132 | #line 7 "scripts/genksyms/keywords.gperf" |
| 134 | {"_restrict", RESTRICT_KEYW}, | 133 | {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW}, |
| 135 | #line 16 "scripts/genksyms/keywords.gperf" | 134 | #line 18 "scripts/genksyms/keywords.gperf" |
| 136 | {"__inline__", INLINE_KEYW}, | 135 | {"__inline__", INLINE_KEYW}, |
| 137 | #line 10 "scripts/genksyms/keywords.gperf" | ||
| 138 | {"__attribute", ATTRIBUTE_KEYW}, | ||
| 139 | {""}, | 136 | {""}, |
| 140 | #line 14 "scripts/genksyms/keywords.gperf" | 137 | #line 22 "scripts/genksyms/keywords.gperf" |
| 138 | {"__volatile__", VOLATILE_KEYW}, | ||
| 139 | #line 5 "scripts/genksyms/keywords.gperf" | ||
| 140 | {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW}, | ||
| 141 | #line 25 "scripts/genksyms/keywords.gperf" | ||
| 142 | {"_restrict", RESTRICT_KEYW}, | ||
| 143 | {""}, | ||
| 144 | #line 12 "scripts/genksyms/keywords.gperf" | ||
| 145 | {"__attribute", ATTRIBUTE_KEYW}, | ||
| 146 | #line 6 "scripts/genksyms/keywords.gperf" | ||
| 147 | {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, | ||
| 148 | #line 16 "scripts/genksyms/keywords.gperf" | ||
| 141 | {"__extension__", EXTENSION_KEYW}, | 149 | {"__extension__", EXTENSION_KEYW}, |
| 142 | #line 35 "scripts/genksyms/keywords.gperf" | 150 | #line 37 "scripts/genksyms/keywords.gperf" |
| 143 | {"enum", ENUM_KEYW}, | 151 | {"enum", ENUM_KEYW}, |
| 144 | #line 19 "scripts/genksyms/keywords.gperf" | 152 | #line 8 "scripts/genksyms/keywords.gperf" |
| 145 | {"__volatile", VOLATILE_KEYW}, | 153 | {"EXPORT_UNUSED_SYMBOL", EXPORT_SYMBOL_KEYW}, |
| 146 | #line 36 "scripts/genksyms/keywords.gperf" | 154 | #line 38 "scripts/genksyms/keywords.gperf" |
| 147 | {"extern", EXTERN_KEYW}, | 155 | {"extern", EXTERN_KEYW}, |
| 148 | {""}, | 156 | {""}, |
| 149 | #line 17 "scripts/genksyms/keywords.gperf" | 157 | #line 19 "scripts/genksyms/keywords.gperf" |
| 150 | {"__signed", SIGNED_KEYW}, | 158 | {"__signed", SIGNED_KEYW}, |
| 151 | #line 7 "scripts/genksyms/keywords.gperf" | 159 | #line 9 "scripts/genksyms/keywords.gperf" |
| 152 | {"EXPORT_SYMBOL_GPL_FUTURE", EXPORT_SYMBOL_KEYW}, | 160 | {"EXPORT_UNUSED_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, |
| 153 | {""}, | 161 | #line 49 "scripts/genksyms/keywords.gperf" |
| 154 | #line 51 "scripts/genksyms/keywords.gperf" | 162 | {"union", UNION_KEYW}, |
| 163 | #line 53 "scripts/genksyms/keywords.gperf" | ||
| 155 | {"typeof", TYPEOF_KEYW}, | 164 | {"typeof", TYPEOF_KEYW}, |
| 156 | #line 46 "scripts/genksyms/keywords.gperf" | 165 | #line 48 "scripts/genksyms/keywords.gperf" |
| 157 | {"typedef", TYPEDEF_KEYW}, | 166 | {"typedef", TYPEDEF_KEYW}, |
| 158 | #line 15 "scripts/genksyms/keywords.gperf" | 167 | #line 17 "scripts/genksyms/keywords.gperf" |
| 159 | {"__inline", INLINE_KEYW}, | 168 | {"__inline", INLINE_KEYW}, |
| 160 | #line 31 "scripts/genksyms/keywords.gperf" | 169 | #line 33 "scripts/genksyms/keywords.gperf" |
| 161 | {"auto", AUTO_KEYW}, | 170 | {"auto", AUTO_KEYW}, |
| 162 | #line 47 "scripts/genksyms/keywords.gperf" | 171 | #line 21 "scripts/genksyms/keywords.gperf" |
| 163 | {"union", UNION_KEYW}, | 172 | {"__volatile", VOLATILE_KEYW}, |
| 164 | {""}, {""}, | ||
| 165 | #line 48 "scripts/genksyms/keywords.gperf" | ||
| 166 | {"unsigned", UNSIGNED_KEYW}, | ||
| 167 | #line 49 "scripts/genksyms/keywords.gperf" | ||
| 168 | {"void", VOID_KEYW}, | ||
| 169 | #line 42 "scripts/genksyms/keywords.gperf" | ||
| 170 | {"short", SHORT_KEYW}, | ||
| 171 | {""}, {""}, | 173 | {""}, {""}, |
| 172 | #line 50 "scripts/genksyms/keywords.gperf" | 174 | #line 50 "scripts/genksyms/keywords.gperf" |
| 173 | {"volatile", VOLATILE_KEYW}, | 175 | {"unsigned", UNSIGNED_KEYW}, |
| 174 | {""}, | ||
| 175 | #line 37 "scripts/genksyms/keywords.gperf" | ||
| 176 | {"float", FLOAT_KEYW}, | ||
| 177 | #line 34 "scripts/genksyms/keywords.gperf" | ||
| 178 | {"double", DOUBLE_KEYW}, | ||
| 179 | {""}, | 176 | {""}, |
| 180 | #line 5 "scripts/genksyms/keywords.gperf" | 177 | #line 44 "scripts/genksyms/keywords.gperf" |
| 181 | {"EXPORT_SYMBOL", EXPORT_SYMBOL_KEYW}, | 178 | {"short", SHORT_KEYW}, |
| 182 | {""}, {""}, | 179 | #line 40 "scripts/genksyms/keywords.gperf" |
| 183 | #line 38 "scripts/genksyms/keywords.gperf" | ||
| 184 | {"inline", INLINE_KEYW}, | 180 | {"inline", INLINE_KEYW}, |
| 185 | #line 6 "scripts/genksyms/keywords.gperf" | ||
| 186 | {"EXPORT_SYMBOL_GPL", EXPORT_SYMBOL_KEYW}, | ||
| 187 | #line 41 "scripts/genksyms/keywords.gperf" | ||
| 188 | {"register", REGISTER_KEYW}, | ||
| 189 | {""}, | 181 | {""}, |
| 190 | #line 22 "scripts/genksyms/keywords.gperf" | 182 | #line 52 "scripts/genksyms/keywords.gperf" |
| 183 | {"volatile", VOLATILE_KEYW}, | ||
| 184 | #line 42 "scripts/genksyms/keywords.gperf" | ||
| 185 | {"long", LONG_KEYW}, | ||
| 186 | #line 24 "scripts/genksyms/keywords.gperf" | ||
| 191 | {"_Bool", BOOL_KEYW}, | 187 | {"_Bool", BOOL_KEYW}, |
| 192 | #line 43 "scripts/genksyms/keywords.gperf" | ||
| 193 | {"signed", SIGNED_KEYW}, | ||
| 194 | {""}, {""}, | 188 | {""}, {""}, |
| 195 | #line 40 "scripts/genksyms/keywords.gperf" | 189 | #line 43 "scripts/genksyms/keywords.gperf" |
| 196 | {"long", LONG_KEYW} | 190 | {"register", REGISTER_KEYW}, |
| 191 | #line 51 "scripts/genksyms/keywords.gperf" | ||
| 192 | {"void", VOID_KEYW}, | ||
| 193 | #line 39 "scripts/genksyms/keywords.gperf" | ||
| 194 | {"float", FLOAT_KEYW}, | ||
| 195 | #line 36 "scripts/genksyms/keywords.gperf" | ||
| 196 | {"double", DOUBLE_KEYW}, | ||
| 197 | {""}, {""}, {""}, {""}, | ||
| 198 | #line 45 "scripts/genksyms/keywords.gperf" | ||
| 199 | {"signed", SIGNED_KEYW} | ||
| 197 | }; | 200 | }; |
| 198 | 201 | ||
| 199 | if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) | 202 | if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) |
diff --git a/scripts/genksyms/keywords.gperf b/scripts/genksyms/keywords.gperf index 5ef3733225f..8abe7ab8d88 100644 --- a/scripts/genksyms/keywords.gperf +++ b/scripts/genksyms/keywords.gperf | |||
| @@ -5,6 +5,8 @@ struct resword { const char *name; int token; } | |||
| 5 | EXPORT_SYMBOL, EXPORT_SYMBOL_KEYW | 5 | EXPORT_SYMBOL, EXPORT_SYMBOL_KEYW |
| 6 | EXPORT_SYMBOL_GPL, EXPORT_SYMBOL_KEYW | 6 | EXPORT_SYMBOL_GPL, EXPORT_SYMBOL_KEYW |
| 7 | EXPORT_SYMBOL_GPL_FUTURE, EXPORT_SYMBOL_KEYW | 7 | EXPORT_SYMBOL_GPL_FUTURE, EXPORT_SYMBOL_KEYW |
| 8 | EXPORT_UNUSED_SYMBOL, EXPORT_SYMBOL_KEYW | ||
| 9 | EXPORT_UNUSED_SYMBOL_GPL, EXPORT_SYMBOL_KEYW | ||
| 8 | __asm, ASM_KEYW | 10 | __asm, ASM_KEYW |
| 9 | __asm__, ASM_KEYW | 11 | __asm__, ASM_KEYW |
| 10 | __attribute, ATTRIBUTE_KEYW | 12 | __attribute, ATTRIBUTE_KEYW |
diff --git a/scripts/headerdep.pl b/scripts/headerdep.pl new file mode 100755 index 00000000000..97399da89ef --- /dev/null +++ b/scripts/headerdep.pl | |||
| @@ -0,0 +1,193 @@ | |||
| 1 | #! /usr/bin/perl | ||
| 2 | # | ||
| 3 | # Detect cycles in the header file dependency graph | ||
| 4 | # Vegard Nossum <vegardno@ifi.uio.no> | ||
| 5 | # | ||
| 6 | |||
| 7 | use strict; | ||
| 8 | use warnings; | ||
| 9 | |||
| 10 | use Getopt::Long; | ||
| 11 | |||
| 12 | my $opt_all; | ||
| 13 | my @opt_include; | ||
| 14 | my $opt_graph; | ||
| 15 | |||
| 16 | &Getopt::Long::Configure(qw(bundling pass_through)); | ||
| 17 | &GetOptions( | ||
| 18 | help => \&help, | ||
| 19 | version => \&version, | ||
| 20 | |||
| 21 | all => \$opt_all, | ||
| 22 | I => \@opt_include, | ||
| 23 | graph => \$opt_graph, | ||
| 24 | ); | ||
| 25 | |||
| 26 | push @opt_include, 'include'; | ||
| 27 | my %deps = (); | ||
| 28 | my %linenos = (); | ||
| 29 | |||
| 30 | my @headers = grep { strip($_) } @ARGV; | ||
| 31 | |||
| 32 | parse_all(@headers); | ||
| 33 | |||
| 34 | if($opt_graph) { | ||
| 35 | graph(); | ||
| 36 | } else { | ||
| 37 | detect_cycles(@headers); | ||
| 38 | } | ||
| 39 | |||
| 40 | |||
| 41 | sub help { | ||
| 42 | print "Usage: $0 [options] file...\n"; | ||
| 43 | print "\n"; | ||
| 44 | print "Options:\n"; | ||
| 45 | print " --all\n"; | ||
| 46 | print " --graph\n"; | ||
| 47 | print "\n"; | ||
| 48 | print " -I includedir\n"; | ||
| 49 | print "\n"; | ||
| 50 | print "To make nice graphs, try:\n"; | ||
| 51 | print " $0 --graph include/linux/kernel.h | dot -Tpng -o graph.png\n"; | ||
| 52 | exit; | ||
| 53 | } | ||
| 54 | |||
| 55 | sub version { | ||
| 56 | print "headerdep version 2\n"; | ||
| 57 | exit; | ||
| 58 | } | ||
| 59 | |||
| 60 | # Get a file name that is relative to our include paths | ||
| 61 | sub strip { | ||
| 62 | my $filename = shift; | ||
| 63 | |||
| 64 | for my $i (@opt_include) { | ||
| 65 | my $stripped = $filename; | ||
| 66 | $stripped =~ s/^$i\///; | ||
| 67 | |||
| 68 | return $stripped if $stripped ne $filename; | ||
| 69 | } | ||
| 70 | |||
| 71 | return $filename; | ||
| 72 | } | ||
| 73 | |||
| 74 | # Search for the file name in the list of include paths | ||
| 75 | sub search { | ||
| 76 | my $filename = shift; | ||
| 77 | return $filename if -f $filename; | ||
| 78 | |||
| 79 | for my $i (@opt_include) { | ||
| 80 | my $path = "$i/$filename"; | ||
| 81 | return $path if -f $path; | ||
| 82 | } | ||
| 83 | |||
| 84 | return undef; | ||
| 85 | } | ||
| 86 | |||
| 87 | sub parse_all { | ||
| 88 | # Parse all the headers. | ||
| 89 | my @queue = @_; | ||
| 90 | while(@queue) { | ||
| 91 | my $header = pop @queue; | ||
| 92 | next if exists $deps{$header}; | ||
| 93 | |||
| 94 | $deps{$header} = [] unless exists $deps{$header}; | ||
| 95 | |||
| 96 | my $path = search($header); | ||
| 97 | next unless $path; | ||
| 98 | |||
| 99 | open(my $file, '<', $path) or die($!); | ||
| 100 | chomp(my @lines = <$file>); | ||
| 101 | close($file); | ||
| 102 | |||
| 103 | for my $i (0 .. $#lines) { | ||
| 104 | my $line = $lines[$i]; | ||
| 105 | if(my($dep) = ($line =~ m/^#\s*include\s*<(.*?)>/)) { | ||
| 106 | push @queue, $dep; | ||
| 107 | push @{$deps{$header}}, [$i + 1, $dep]; | ||
| 108 | } | ||
| 109 | } | ||
| 110 | } | ||
| 111 | } | ||
| 112 | |||
| 113 | sub print_cycle { | ||
| 114 | # $cycle[n] includes $cycle[n + 1]; | ||
| 115 | # $cycle[-1] will be the culprit | ||
| 116 | my $cycle = shift; | ||
| 117 | |||
| 118 | # Adjust the line numbers | ||
| 119 | for my $i (0 .. $#$cycle - 1) { | ||
| 120 | $cycle->[$i]->[0] = $cycle->[$i + 1]->[0]; | ||
| 121 | } | ||
| 122 | $cycle->[-1]->[0] = 0; | ||
| 123 | |||
| 124 | my $first = shift @$cycle; | ||
| 125 | my $last = pop @$cycle; | ||
| 126 | |||
| 127 | my $msg = "In file included"; | ||
| 128 | printf "%s from %s,\n", $msg, $last->[1] if defined $last; | ||
| 129 | |||
| 130 | for my $header (reverse @$cycle) { | ||
| 131 | printf "%s from %s:%d%s\n", | ||
| 132 | " " x length $msg, | ||
| 133 | $header->[1], $header->[0], | ||
| 134 | $header->[1] eq $last->[1] ? ' <-- here' : ''; | ||
| 135 | } | ||
| 136 | |||
| 137 | printf "%s:%d: warning: recursive header inclusion\n", | ||
| 138 | $first->[1], $first->[0]; | ||
| 139 | } | ||
| 140 | |||
| 141 | # Find and print the smallest cycle starting in the specified node. | ||
| 142 | sub detect_cycles { | ||
| 143 | my @queue = map { [[0, $_]] } @_; | ||
| 144 | while(@queue) { | ||
| 145 | my $top = pop @queue; | ||
| 146 | my $name = $top->[-1]->[1]; | ||
| 147 | |||
| 148 | for my $dep (@{$deps{$name}}) { | ||
| 149 | my $chain = [@$top, [$dep->[0], $dep->[1]]]; | ||
| 150 | |||
| 151 | # If the dep already exists in the chain, we have a | ||
| 152 | # cycle... | ||
| 153 | if(grep { $_->[1] eq $dep->[1] } @$top) { | ||
| 154 | print_cycle($chain); | ||
| 155 | next if $opt_all; | ||
| 156 | return; | ||
| 157 | } | ||
| 158 | |||
| 159 | push @queue, $chain; | ||
| 160 | } | ||
| 161 | } | ||
| 162 | } | ||
| 163 | |||
| 164 | sub mangle { | ||
| 165 | $_ = shift; | ||
| 166 | s/\//__/g; | ||
| 167 | s/\./_/g; | ||
| 168 | s/-/_/g; | ||
| 169 | $_; | ||
| 170 | } | ||
| 171 | |||
| 172 | # Output dependency graph in GraphViz language. | ||
| 173 | sub graph { | ||
| 174 | print "digraph {\n"; | ||
| 175 | |||
| 176 | print "\t/* vertices */\n"; | ||
| 177 | for my $header (keys %deps) { | ||
| 178 | printf "\t%s [label=\"%s\"];\n", | ||
| 179 | mangle($header), $header; | ||
| 180 | } | ||
| 181 | |||
| 182 | print "\n"; | ||
| 183 | |||
| 184 | print "\t/* edges */\n"; | ||
| 185 | for my $header (keys %deps) { | ||
| 186 | for my $dep (@{$deps{$header}}) { | ||
| 187 | printf "\t%s -> %s;\n", | ||
| 188 | mangle($header), mangle($dep->[1]); | ||
| 189 | } | ||
| 190 | } | ||
| 191 | |||
| 192 | print "}\n"; | ||
| 193 | } | ||
diff --git a/scripts/headers_check.pl b/scripts/headers_check.pl index 15d53a6b1a1..db30fac3083 100644 --- a/scripts/headers_check.pl +++ b/scripts/headers_check.pl | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl -w |
| 2 | # | 2 | # |
| 3 | # headers_check.pl execute a number of trivial consistency checks | 3 | # headers_check.pl execute a number of trivial consistency checks |
| 4 | # | 4 | # |
| @@ -14,10 +14,11 @@ | |||
| 14 | # Only include files located in asm* and linux* are checked. | 14 | # Only include files located in asm* and linux* are checked. |
| 15 | # The rest are assumed to be system include files. | 15 | # The rest are assumed to be system include files. |
| 16 | # | 16 | # |
| 17 | # 2) TODO: check for leaked CONFIG_ symbols | 17 | # 2) It is checked that prototypes does not use "extern" |
| 18 | # | ||
| 19 | # 3) Check for leaked CONFIG_ symbols | ||
| 18 | 20 | ||
| 19 | use strict; | 21 | use strict; |
| 20 | use warnings; | ||
| 21 | 22 | ||
| 22 | my ($dir, $arch, @files) = @ARGV; | 23 | my ($dir, $arch, @files) = @ARGV; |
| 23 | 24 | ||
| @@ -27,14 +28,19 @@ my $lineno = 0; | |||
| 27 | my $filename; | 28 | my $filename; |
| 28 | 29 | ||
| 29 | foreach my $file (@files) { | 30 | foreach my $file (@files) { |
| 31 | local *FH; | ||
| 30 | $filename = $file; | 32 | $filename = $file; |
| 31 | open(my $fh, '<', "$filename") or die "$filename: $!\n"; | 33 | open(FH, "<$filename") or die "$filename: $!\n"; |
| 32 | $lineno = 0; | 34 | $lineno = 0; |
| 33 | while ($line = <$fh>) { | 35 | while ($line = <FH>) { |
| 34 | $lineno++; | 36 | $lineno++; |
| 35 | check_include(); | 37 | &check_include(); |
| 38 | &check_asm_types(); | ||
| 39 | &check_sizetypes(); | ||
| 40 | &check_prototypes(); | ||
| 41 | &check_config(); | ||
| 36 | } | 42 | } |
| 37 | close $fh; | 43 | close FH; |
| 38 | } | 44 | } |
| 39 | exit $ret; | 45 | exit $ret; |
| 40 | 46 | ||
| @@ -54,3 +60,63 @@ sub check_include | |||
| 54 | } | 60 | } |
| 55 | } | 61 | } |
| 56 | } | 62 | } |
| 63 | |||
| 64 | sub check_prototypes | ||
| 65 | { | ||
| 66 | if ($line =~ m/^\s*extern\b/) { | ||
| 67 | printf STDERR "$filename:$lineno: extern's make no sense in userspace\n"; | ||
| 68 | } | ||
| 69 | } | ||
| 70 | |||
| 71 | sub check_config | ||
| 72 | { | ||
| 73 | if ($line =~ m/[^a-zA-Z0-9_]+CONFIG_([a-zA-Z0-9]+)[^a-zA-Z0-9]/) { | ||
| 74 | printf STDERR "$filename:$lineno: leaks CONFIG_$1 to userspace where it is not valid\n"; | ||
| 75 | } | ||
| 76 | } | ||
| 77 | |||
| 78 | my $linux_asm_types; | ||
| 79 | sub check_asm_types() | ||
| 80 | { | ||
| 81 | if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { | ||
| 82 | return; | ||
| 83 | } | ||
| 84 | if ($lineno == 1) { | ||
| 85 | $linux_asm_types = 0; | ||
| 86 | } elsif ($linux_asm_types >= 1) { | ||
| 87 | return; | ||
| 88 | } | ||
| 89 | if ($line =~ m/^\s*#\s*include\s+<asm\/types.h>/) { | ||
| 90 | $linux_asm_types = 1; | ||
| 91 | printf STDERR "$filename:$lineno: " . | ||
| 92 | "include of <linux/types.h> is preferred over <asm/types.h>\n" | ||
| 93 | # Warn until headers are all fixed | ||
| 94 | #$ret = 1; | ||
| 95 | } | ||
| 96 | } | ||
| 97 | |||
| 98 | my $linux_types; | ||
| 99 | sub check_sizetypes | ||
| 100 | { | ||
| 101 | if ($filename =~ /types.h|int-l64.h|int-ll64.h/o) { | ||
| 102 | return; | ||
| 103 | } | ||
| 104 | if ($lineno == 1) { | ||
| 105 | $linux_types = 0; | ||
| 106 | } elsif ($linux_types >= 1) { | ||
| 107 | return; | ||
| 108 | } | ||
| 109 | if ($line =~ m/^\s*#\s*include\s+<linux\/types.h>/) { | ||
| 110 | $linux_types = 1; | ||
| 111 | return; | ||
| 112 | } | ||
| 113 | if ($line =~ m/__[us](8|16|32|64)\b/) { | ||
| 114 | printf STDERR "$filename:$lineno: " . | ||
| 115 | "found __[us]{8,16,32,64} type " . | ||
| 116 | "without #include <linux/types.h>\n"; | ||
| 117 | $linux_types = 2; | ||
| 118 | # Warn until headers are all fixed | ||
| 119 | #$ret = 1; | ||
| 120 | } | ||
| 121 | } | ||
| 122 | |||
diff --git a/scripts/headers_install.pl b/scripts/headers_install.pl index 68591cd0873..c6ae4052ab4 100644 --- a/scripts/headers_install.pl +++ b/scripts/headers_install.pl | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | #!/usr/bin/perl | 1 | #!/usr/bin/perl -w |
| 2 | # | 2 | # |
| 3 | # headers_install prepare the listed header files for use in | 3 | # headers_install prepare the listed header files for use in |
| 4 | # user space and copy the files to their destination. | 4 | # user space and copy the files to their destination. |
| @@ -17,28 +17,32 @@ | |||
| 17 | # 3) Drop all sections defined out by __KERNEL__ (using unifdef) | 17 | # 3) Drop all sections defined out by __KERNEL__ (using unifdef) |
| 18 | 18 | ||
| 19 | use strict; | 19 | use strict; |
| 20 | use warnings; | ||
| 21 | 20 | ||
| 22 | my ($readdir, $installdir, $arch, @files) = @ARGV; | 21 | my ($readdir, $installdir, $arch, @files) = @ARGV; |
| 23 | 22 | ||
| 24 | my $unifdef = "scripts/unifdef -U__KERNEL__"; | 23 | my $unifdef = "scripts/unifdef -U__KERNEL__"; |
| 25 | 24 | ||
| 26 | foreach my $file (@files) { | 25 | foreach my $file (@files) { |
| 26 | local *INFILE; | ||
| 27 | local *OUTFILE; | ||
| 27 | my $tmpfile = "$installdir/$file.tmp"; | 28 | my $tmpfile = "$installdir/$file.tmp"; |
| 28 | open(my $infile, '<', "$readdir/$file") | 29 | open(INFILE, "<$readdir/$file") |
| 29 | or die "$readdir/$file: $!\n"; | 30 | or die "$readdir/$file: $!\n"; |
| 30 | open(my $outfile, '>', "$tmpfile") or die "$tmpfile: $!\n"; | 31 | open(OUTFILE, ">$tmpfile") or die "$tmpfile: $!\n"; |
| 31 | while (my $line = <$infile>) { | 32 | while (my $line = <INFILE>) { |
| 32 | $line =~ s/([\s(])__user\s/$1/g; | 33 | $line =~ s/([\s(])__user\s/$1/g; |
| 33 | $line =~ s/([\s(])__force\s/$1/g; | 34 | $line =~ s/([\s(])__force\s/$1/g; |
| 34 | $line =~ s/([\s(])__iomem\s/$1/g; | 35 | $line =~ s/([\s(])__iomem\s/$1/g; |
| 35 | $line =~ s/\s__attribute_const__\s/ /g; | 36 | $line =~ s/\s__attribute_const__\s/ /g; |
| 36 | $line =~ s/\s__attribute_const__$//g; | 37 | $line =~ s/\s__attribute_const__$//g; |
| 37 | $line =~ s/^#include <linux\/compiler.h>//; | 38 | $line =~ s/^#include <linux\/compiler.h>//; |
| 38 | printf $outfile "%s", $line; | 39 | $line =~ s/(^|\s)(inline)\b/$1__$2__/g; |
| 40 | $line =~ s/(^|\s)(asm)\b(\s|[(]|$)/$1__$2__$3/g; | ||
| 41 | $line =~ s/(^|\s|[(])(volatile)\b(\s|[(]|$)/$1__$2__$3/g; | ||
| 42 | printf OUTFILE "%s", $line; | ||
| 39 | } | 43 | } |
| 40 | close $outfile; | 44 | close OUTFILE; |
| 41 | close $infile; | 45 | close INFILE; |
| 42 | system $unifdef . " $tmpfile > $installdir/$file"; | 46 | system $unifdef . " $tmpfile > $installdir/$file"; |
| 43 | unlink $tmpfile; | 47 | unlink $tmpfile; |
| 44 | } | 48 | } |
diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index ad2434b2697..92758120a76 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c | |||
| @@ -130,18 +130,9 @@ static int read_symbol(FILE *in, struct sym_entry *s) | |||
| 130 | static int symbol_valid(struct sym_entry *s) | 130 | static int symbol_valid(struct sym_entry *s) |
| 131 | { | 131 | { |
| 132 | /* Symbols which vary between passes. Passes 1 and 2 must have | 132 | /* Symbols which vary between passes. Passes 1 and 2 must have |
| 133 | * identical symbol lists. The kallsyms_* symbols below are only added | 133 | * identical symbol lists. |
| 134 | * after pass 1, they would be included in pass 2 when --all-symbols is | ||
| 135 | * specified so exclude them to get a stable symbol list. | ||
| 136 | */ | 134 | */ |
| 137 | static char *special_symbols[] = { | 135 | static char *special_symbols[] = { |
| 138 | "kallsyms_addresses", | ||
| 139 | "kallsyms_num_syms", | ||
| 140 | "kallsyms_names", | ||
| 141 | "kallsyms_markers", | ||
| 142 | "kallsyms_token_table", | ||
| 143 | "kallsyms_token_index", | ||
| 144 | |||
| 145 | /* Exclude linker generated symbols which vary between passes */ | 136 | /* Exclude linker generated symbols which vary between passes */ |
| 146 | "_SDA_BASE_", /* ppc */ | 137 | "_SDA_BASE_", /* ppc */ |
| 147 | "_SDA2_BASE_", /* ppc */ | 138 | "_SDA2_BASE_", /* ppc */ |
| @@ -173,7 +164,9 @@ static int symbol_valid(struct sym_entry *s) | |||
| 173 | } | 164 | } |
| 174 | 165 | ||
| 175 | /* Exclude symbols which vary between passes. */ | 166 | /* Exclude symbols which vary between passes. */ |
| 176 | if (strstr((char *)s->sym + offset, "_compiled.")) | 167 | if (strstr((char *)s->sym + offset, "_compiled.") || |
| 168 | strncmp((char*)s->sym + offset, "__compound_literal.", 19) == 0 || | ||
| 169 | strncmp((char*)s->sym + offset, "__compound_literal$", 19) == 0) | ||
| 177 | return 0; | 170 | return 0; |
| 178 | 171 | ||
| 179 | for (i = 0; special_symbols[i]; i++) | 172 | for (i = 0; special_symbols[i]; i++) |
| @@ -550,8 +543,10 @@ int main(int argc, char **argv) | |||
| 550 | usage(); | 543 | usage(); |
| 551 | 544 | ||
| 552 | read_map(stdin); | 545 | read_map(stdin); |
| 553 | sort_symbols(); | 546 | if (table_cnt) { |
| 554 | optimize_token_table(); | 547 | sort_symbols(); |
| 548 | optimize_token_table(); | ||
| 549 | } | ||
| 555 | write_src(); | 550 | write_src(); |
| 556 | 551 | ||
| 557 | return 0; | 552 | return 0; |
diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index fa1a7d56590..fa8c2dd9c98 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile | |||
| @@ -4,7 +4,11 @@ | |||
| 4 | 4 | ||
| 5 | PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config | 5 | PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config |
| 6 | 6 | ||
| 7 | ifdef KBUILD_KCONFIG | ||
| 8 | Kconfig := $(KBUILD_KCONFIG) | ||
| 9 | else | ||
| 7 | Kconfig := arch/$(SRCARCH)/Kconfig | 10 | Kconfig := arch/$(SRCARCH)/Kconfig |
| 11 | endif | ||
| 8 | 12 | ||
| 9 | xconfig: $(obj)/qconf | 13 | xconfig: $(obj)/qconf |
| 10 | $< $(Kconfig) | 14 | $< $(Kconfig) |
diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index b91cf241a53..830d9eae11f 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c | |||
| @@ -852,8 +852,7 @@ void conf_set_all_new_symbols(enum conf_def_mode mode) | |||
| 852 | 852 | ||
| 853 | } | 853 | } |
| 854 | 854 | ||
| 855 | if (modules_sym) | 855 | sym_clear_all_valid(); |
| 856 | sym_calc_value(modules_sym); | ||
| 857 | 856 | ||
| 858 | if (mode != def_random) | 857 | if (mode != def_random) |
| 859 | return; | 858 | return; |
diff --git a/scripts/kconfig/expr.h b/scripts/kconfig/expr.h index 9d4cba1c001..6408fefae08 100644 --- a/scripts/kconfig/expr.h +++ b/scripts/kconfig/expr.h | |||
| @@ -65,9 +65,13 @@ enum symbol_type { | |||
| 65 | S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER | 65 | S_UNKNOWN, S_BOOLEAN, S_TRISTATE, S_INT, S_HEX, S_STRING, S_OTHER |
| 66 | }; | 66 | }; |
| 67 | 67 | ||
| 68 | /* enum values are used as index to symbol.def[] */ | ||
| 68 | enum { | 69 | enum { |
| 69 | S_DEF_USER, /* main user value */ | 70 | S_DEF_USER, /* main user value */ |
| 70 | S_DEF_AUTO, | 71 | S_DEF_AUTO, /* values read from auto.conf */ |
| 72 | S_DEF_DEF3, /* Reserved for UI usage */ | ||
| 73 | S_DEF_DEF4, /* Reserved for UI usage */ | ||
| 74 | S_DEF_COUNT | ||
| 71 | }; | 75 | }; |
| 72 | 76 | ||
| 73 | struct symbol { | 77 | struct symbol { |
| @@ -75,7 +79,7 @@ struct symbol { | |||
| 75 | char *name; | 79 | char *name; |
| 76 | enum symbol_type type; | 80 | enum symbol_type type; |
| 77 | struct symbol_value curr; | 81 | struct symbol_value curr; |
| 78 | struct symbol_value def[4]; | 82 | struct symbol_value def[S_DEF_COUNT]; |
| 79 | tristate visible; | 83 | tristate visible; |
| 80 | int flags; | 84 | int flags; |
| 81 | struct property *prop; | 85 | struct property *prop; |
| @@ -84,42 +88,64 @@ struct symbol { | |||
| 84 | 88 | ||
| 85 | #define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) | 89 | #define for_all_symbols(i, sym) for (i = 0; i < 257; i++) for (sym = symbol_hash[i]; sym; sym = sym->next) if (sym->type != S_OTHER) |
| 86 | 90 | ||
| 87 | #define SYMBOL_CONST 0x0001 | 91 | #define SYMBOL_CONST 0x0001 /* symbol is const */ |
| 88 | #define SYMBOL_CHECK 0x0008 | 92 | #define SYMBOL_CHECK 0x0008 /* used during dependency checking */ |
| 89 | #define SYMBOL_CHOICE 0x0010 | 93 | #define SYMBOL_CHOICE 0x0010 /* start of a choice block (null name) */ |
| 90 | #define SYMBOL_CHOICEVAL 0x0020 | 94 | #define SYMBOL_CHOICEVAL 0x0020 /* used as a value in a choice block */ |
| 91 | #define SYMBOL_VALID 0x0080 | 95 | #define SYMBOL_VALID 0x0080 /* set when symbol.curr is calculated */ |
| 92 | #define SYMBOL_OPTIONAL 0x0100 | 96 | #define SYMBOL_OPTIONAL 0x0100 /* choice is optional - values can be 'n' */ |
| 93 | #define SYMBOL_WRITE 0x0200 | 97 | #define SYMBOL_WRITE 0x0200 /* ? */ |
| 94 | #define SYMBOL_CHANGED 0x0400 | 98 | #define SYMBOL_CHANGED 0x0400 /* ? */ |
| 95 | #define SYMBOL_AUTO 0x1000 | 99 | #define SYMBOL_AUTO 0x1000 /* value from environment variable */ |
| 96 | #define SYMBOL_CHECKED 0x2000 | 100 | #define SYMBOL_CHECKED 0x2000 /* used during dependency checking */ |
| 97 | #define SYMBOL_WARNED 0x8000 | 101 | #define SYMBOL_WARNED 0x8000 /* warning has been issued */ |
| 98 | #define SYMBOL_DEF 0x10000 | 102 | |
| 99 | #define SYMBOL_DEF_USER 0x10000 | 103 | /* Set when symbol.def[] is used */ |
| 100 | #define SYMBOL_DEF_AUTO 0x20000 | 104 | #define SYMBOL_DEF 0x10000 /* First bit of SYMBOL_DEF */ |
| 101 | #define SYMBOL_DEF3 0x40000 | 105 | #define SYMBOL_DEF_USER 0x10000 /* symbol.def[S_DEF_USER] is valid */ |
| 102 | #define SYMBOL_DEF4 0x80000 | 106 | #define SYMBOL_DEF_AUTO 0x20000 /* symbol.def[S_DEF_AUTO] is valid */ |
| 107 | #define SYMBOL_DEF3 0x40000 /* symbol.def[S_DEF_3] is valid */ | ||
| 108 | #define SYMBOL_DEF4 0x80000 /* symbol.def[S_DEF_4] is valid */ | ||
| 103 | 109 | ||
| 104 | #define SYMBOL_MAXLENGTH 256 | 110 | #define SYMBOL_MAXLENGTH 256 |
| 105 | #define SYMBOL_HASHSIZE 257 | 111 | #define SYMBOL_HASHSIZE 257 |
| 106 | #define SYMBOL_HASHMASK 0xff | 112 | #define SYMBOL_HASHMASK 0xff |
| 107 | 113 | ||
| 114 | /* A property represent the config options that can be associated | ||
| 115 | * with a config "symbol". | ||
| 116 | * Sample: | ||
| 117 | * config FOO | ||
| 118 | * default y | ||
| 119 | * prompt "foo prompt" | ||
| 120 | * select BAR | ||
| 121 | * config BAZ | ||
| 122 | * int "BAZ Value" | ||
| 123 | * range 1..255 | ||
| 124 | */ | ||
| 108 | enum prop_type { | 125 | enum prop_type { |
| 109 | P_UNKNOWN, P_PROMPT, P_COMMENT, P_MENU, P_DEFAULT, P_CHOICE, | 126 | P_UNKNOWN, |
| 110 | P_SELECT, P_RANGE, P_ENV | 127 | P_PROMPT, /* prompt "foo prompt" or "BAZ Value" */ |
| 128 | P_COMMENT, /* text associated with a comment */ | ||
| 129 | P_MENU, /* prompt associated with a menuconfig option */ | ||
| 130 | P_DEFAULT, /* default y */ | ||
| 131 | P_CHOICE, /* choice value */ | ||
| 132 | P_SELECT, /* select BAR */ | ||
| 133 | P_RANGE, /* range 7..100 (for a symbol) */ | ||
| 134 | P_ENV, /* value from environment variable */ | ||
| 111 | }; | 135 | }; |
| 112 | 136 | ||
| 113 | struct property { | 137 | struct property { |
| 114 | struct property *next; | 138 | struct property *next; /* next property - null if last */ |
| 115 | struct symbol *sym; | 139 | struct symbol *sym; /* the symbol for which the property is associated */ |
| 116 | enum prop_type type; | 140 | enum prop_type type; /* type of property */ |
| 117 | const char *text; | 141 | const char *text; /* the prompt value - P_PROMPT, P_MENU, P_COMMENT */ |
| 118 | struct expr_value visible; | 142 | struct expr_value visible; |
| 119 | struct expr *expr; | 143 | struct expr *expr; /* the optional conditional part of the property */ |
| 120 | struct menu *menu; | 144 | struct menu *menu; /* the menu the property are associated with |
| 121 | struct file *file; | 145 | * valid for: P_SELECT, P_RANGE, P_CHOICE, |
| 122 | int lineno; | 146 | * P_PROMPT, P_DEFAULT, P_MENU, P_COMMENT */ |
| 147 | struct file *file; /* what file was this property defined */ | ||
| 148 | int lineno; /* what lineno was this property defined */ | ||
| 123 | }; | 149 | }; |
| 124 | 150 | ||
| 125 | #define for_all_properties(sym, st, tok) \ | 151 | #define for_all_properties(sym, st, tok) \ |
diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index 7342ce0a778..dc3e81807d1 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/lex.zconf.c_shipped | |||
| @@ -2370,11 +2370,14 @@ void zconf_nextfile(const char *name) | |||
| 2370 | current_buf = buf; | 2370 | current_buf = buf; |
| 2371 | 2371 | ||
| 2372 | if (file->flags & FILE_BUSY) { | 2372 | if (file->flags & FILE_BUSY) { |
| 2373 | printf("recursive scan (%s)?\n", name); | 2373 | printf("%s:%d: do not source '%s' from itself\n", |
| 2374 | zconf_curname(), zconf_lineno(), name); | ||
| 2374 | exit(1); | 2375 | exit(1); |
| 2375 | } | 2376 | } |
| 2376 | if (file->flags & FILE_SCANNED) { | 2377 | if (file->flags & FILE_SCANNED) { |
| 2377 | printf("file %s already scanned?\n", name); | 2378 | printf("%s:%d: file '%s' is already sourced from '%s'\n", |
| 2379 | zconf_curname(), zconf_lineno(), name, | ||
| 2380 | file->parent->name); | ||
| 2378 | exit(1); | 2381 | exit(1); |
| 2379 | } | 2382 | } |
| 2380 | file->flags |= FILE_BUSY; | 2383 | file->flags |= FILE_BUSY; |
diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh index 5552154cbed..fcef0f59d55 100644 --- a/scripts/kconfig/lxdialog/check-lxdialog.sh +++ b/scripts/kconfig/lxdialog/check-lxdialog.sh | |||
| @@ -52,7 +52,7 @@ EOF | |||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | usage() { | 54 | usage() { |
| 55 | printf "Usage: $0 [-check compiler options|-header|-library]\n" | 55 | printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n" |
| 56 | } | 56 | } |
| 57 | 57 | ||
| 58 | if [ $# -eq 0 ]; then | 58 | if [ $# -eq 0 ]; then |
diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index 5164ef7ce49..21ff69c9ad4 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l | |||
| @@ -314,11 +314,14 @@ void zconf_nextfile(const char *name) | |||
| 314 | current_buf = buf; | 314 | current_buf = buf; |
| 315 | 315 | ||
| 316 | if (file->flags & FILE_BUSY) { | 316 | if (file->flags & FILE_BUSY) { |
| 317 | printf("recursive scan (%s)?\n", name); | 317 | printf("%s:%d: do not source '%s' from itself\n", |
| 318 | zconf_curname(), zconf_lineno(), name); | ||
| 318 | exit(1); | 319 | exit(1); |
| 319 | } | 320 | } |
| 320 | if (file->flags & FILE_SCANNED) { | 321 | if (file->flags & FILE_SCANNED) { |
| 321 | printf("file %s already scanned?\n", name); | 322 | printf("%s:%d: file '%s' is already sourced from '%s'\n", |
| 323 | zconf_curname(), zconf_lineno(), name, | ||
| 324 | file->parent->name); | ||
| 322 | exit(1); | 325 | exit(1); |
| 323 | } | 326 | } |
| 324 | file->flags |= FILE_BUSY; | 327 | file->flags |= FILE_BUSY; |
diff --git a/scripts/kernel-doc b/scripts/kernel-doc index 44ee94d2ab7..8bb83a100ed 100755 --- a/scripts/kernel-doc +++ b/scripts/kernel-doc | |||
| @@ -289,6 +289,8 @@ my %parameterdescs; | |||
| 289 | my @parameterlist; | 289 | my @parameterlist; |
| 290 | my %sections; | 290 | my %sections; |
| 291 | my @sectionlist; | 291 | my @sectionlist; |
| 292 | my $sectcheck; | ||
| 293 | my $struct_actual; | ||
| 292 | 294 | ||
| 293 | my $contents = ""; | 295 | my $contents = ""; |
| 294 | my $section_default = "Description"; # default section | 296 | my $section_default = "Description"; # default section |
| @@ -378,6 +380,12 @@ sub dump_section { | |||
| 378 | # print STDERR "parameter def '$1' = '$contents'\n"; | 380 | # print STDERR "parameter def '$1' = '$contents'\n"; |
| 379 | $name = $1; | 381 | $name = $1; |
| 380 | $parameterdescs{$name} = $contents; | 382 | $parameterdescs{$name} = $contents; |
| 383 | $sectcheck = $sectcheck . $name . " "; | ||
| 384 | } elsif ($name eq "@\.\.\.") { | ||
| 385 | # print STDERR "parameter def '...' = '$contents'\n"; | ||
| 386 | $name = "..."; | ||
| 387 | $parameterdescs{$name} = $contents; | ||
| 388 | $sectcheck = $sectcheck . $name . " "; | ||
| 381 | } else { | 389 | } else { |
| 382 | # print STDERR "other section '$name' = '$contents'\n"; | 390 | # print STDERR "other section '$name' = '$contents'\n"; |
| 383 | if (defined($sections{$name}) && ($sections{$name} ne "")) { | 391 | if (defined($sections{$name}) && ($sections{$name} ne "")) { |
| @@ -1401,21 +1409,25 @@ sub dump_union($$) { | |||
| 1401 | sub dump_struct($$) { | 1409 | sub dump_struct($$) { |
| 1402 | my $x = shift; | 1410 | my $x = shift; |
| 1403 | my $file = shift; | 1411 | my $file = shift; |
| 1412 | my $nested; | ||
| 1404 | 1413 | ||
| 1405 | if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) { | 1414 | if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) { |
| 1406 | $declaration_name = $2; | 1415 | $declaration_name = $2; |
| 1407 | my $members = $3; | 1416 | my $members = $3; |
| 1408 | 1417 | ||
| 1409 | # ignore embedded structs or unions | 1418 | # ignore embedded structs or unions |
| 1410 | $members =~ s/{.*}//g; | 1419 | $members =~ s/({.*})//g; |
| 1420 | $nested = $1; | ||
| 1411 | 1421 | ||
| 1412 | # ignore members marked private: | 1422 | # ignore members marked private: |
| 1413 | $members =~ s/\/\*.*?private:.*?public:.*?\*\///gos; | 1423 | $members =~ s/\/\*.*?private:.*?public:.*?\*\///gos; |
| 1414 | $members =~ s/\/\*.*?private:.*//gos; | 1424 | $members =~ s/\/\*.*?private:.*//gos; |
| 1415 | # strip comments: | 1425 | # strip comments: |
| 1416 | $members =~ s/\/\*.*?\*\///gos; | 1426 | $members =~ s/\/\*.*?\*\///gos; |
| 1427 | $nested =~ s/\/\*.*?\*\///gos; | ||
| 1417 | 1428 | ||
| 1418 | create_parameterlist($members, ';', $file); | 1429 | create_parameterlist($members, ';', $file); |
| 1430 | check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested); | ||
| 1419 | 1431 | ||
| 1420 | output_declaration($declaration_name, | 1432 | output_declaration($declaration_name, |
| 1421 | 'struct', | 1433 | 'struct', |
| @@ -1501,6 +1513,14 @@ sub dump_typedef($$) { | |||
| 1501 | } | 1513 | } |
| 1502 | } | 1514 | } |
| 1503 | 1515 | ||
| 1516 | sub save_struct_actual($) { | ||
| 1517 | my $actual = shift; | ||
| 1518 | |||
| 1519 | # strip all spaces from the actual param so that it looks like one string item | ||
| 1520 | $actual =~ s/\s*//g; | ||
| 1521 | $struct_actual = $struct_actual . $actual . " "; | ||
| 1522 | } | ||
| 1523 | |||
| 1504 | sub create_parameterlist($$$) { | 1524 | sub create_parameterlist($$$) { |
| 1505 | my $args = shift; | 1525 | my $args = shift; |
| 1506 | my $splitter = shift; | 1526 | my $splitter = shift; |
| @@ -1533,6 +1553,7 @@ sub create_parameterlist($$$) { | |||
| 1533 | $param = $1; | 1553 | $param = $1; |
| 1534 | $type = $arg; | 1554 | $type = $arg; |
| 1535 | $type =~ s/([^\(]+\(\*?)\s*$param/$1/; | 1555 | $type =~ s/([^\(]+\(\*?)\s*$param/$1/; |
| 1556 | save_struct_actual($param); | ||
| 1536 | push_parameter($param, $type, $file); | 1557 | push_parameter($param, $type, $file); |
| 1537 | } elsif ($arg) { | 1558 | } elsif ($arg) { |
| 1538 | $arg =~ s/\s*:\s*/:/g; | 1559 | $arg =~ s/\s*:\s*/:/g; |
| @@ -1557,14 +1578,17 @@ sub create_parameterlist($$$) { | |||
| 1557 | 1578 | ||
| 1558 | foreach $param (@args) { | 1579 | foreach $param (@args) { |
| 1559 | if ($param =~ m/^(\*+)\s*(.*)/) { | 1580 | if ($param =~ m/^(\*+)\s*(.*)/) { |
| 1581 | save_struct_actual($2); | ||
| 1560 | push_parameter($2, "$type $1", $file); | 1582 | push_parameter($2, "$type $1", $file); |
| 1561 | } | 1583 | } |
| 1562 | elsif ($param =~ m/(.*?):(\d+)/) { | 1584 | elsif ($param =~ m/(.*?):(\d+)/) { |
| 1563 | if ($type ne "") { # skip unnamed bit-fields | 1585 | if ($type ne "") { # skip unnamed bit-fields |
| 1586 | save_struct_actual($1); | ||
| 1564 | push_parameter($1, "$type:$2", $file) | 1587 | push_parameter($1, "$type:$2", $file) |
| 1565 | } | 1588 | } |
| 1566 | } | 1589 | } |
| 1567 | else { | 1590 | else { |
| 1591 | save_struct_actual($param); | ||
| 1568 | push_parameter($param, $type, $file); | 1592 | push_parameter($param, $type, $file); |
| 1569 | } | 1593 | } |
| 1570 | } | 1594 | } |
| @@ -1588,12 +1612,12 @@ sub push_parameter($$$) { | |||
| 1588 | 1612 | ||
| 1589 | if ($type eq "" && $param =~ /\.\.\.$/) | 1613 | if ($type eq "" && $param =~ /\.\.\.$/) |
| 1590 | { | 1614 | { |
| 1591 | $type=""; | 1615 | if (!defined $parameterdescs{$param} || $parameterdescs{$param} eq "") { |
| 1592 | $parameterdescs{$param} = "variable arguments"; | 1616 | $parameterdescs{$param} = "variable arguments"; |
| 1617 | } | ||
| 1593 | } | 1618 | } |
| 1594 | elsif ($type eq "" && ($param eq "" or $param eq "void")) | 1619 | elsif ($type eq "" && ($param eq "" or $param eq "void")) |
| 1595 | { | 1620 | { |
| 1596 | $type=""; | ||
| 1597 | $param="void"; | 1621 | $param="void"; |
| 1598 | $parameterdescs{void} = "no arguments"; | 1622 | $parameterdescs{void} = "no arguments"; |
| 1599 | } | 1623 | } |
| @@ -1630,6 +1654,46 @@ sub push_parameter($$$) { | |||
| 1630 | $parametertypes{$param} = $type; | 1654 | $parametertypes{$param} = $type; |
| 1631 | } | 1655 | } |
| 1632 | 1656 | ||
| 1657 | sub check_sections($$$$$$) { | ||
| 1658 | my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck, $nested) = @_; | ||
| 1659 | my @sects = split ' ', $sectcheck; | ||
| 1660 | my @prms = split ' ', $prmscheck; | ||
| 1661 | my $err; | ||
| 1662 | my ($px, $sx); | ||
| 1663 | my $prm_clean; # strip trailing "[array size]" and/or beginning "*" | ||
| 1664 | |||
| 1665 | foreach $sx (0 .. $#sects) { | ||
| 1666 | $err = 1; | ||
| 1667 | foreach $px (0 .. $#prms) { | ||
| 1668 | $prm_clean = $prms[$px]; | ||
| 1669 | $prm_clean =~ s/\[.*\]//; | ||
| 1670 | $prm_clean =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//; | ||
| 1671 | ##$prm_clean =~ s/^\**//; | ||
| 1672 | if ($prm_clean eq $sects[$sx]) { | ||
| 1673 | $err = 0; | ||
| 1674 | last; | ||
| 1675 | } | ||
| 1676 | } | ||
| 1677 | if ($err) { | ||
| 1678 | if ($decl_type eq "function") { | ||
| 1679 | print STDERR "Warning(${file}:$.): " . | ||
| 1680 | "Excess function parameter " . | ||
| 1681 | "'$sects[$sx]' " . | ||
| 1682 | "description in '$decl_name'\n"; | ||
| 1683 | ++$warnings; | ||
| 1684 | } else { | ||
| 1685 | if ($nested !~ m/\Q$sects[$sx]\E/) { | ||
| 1686 | print STDERR "Warning(${file}:$.): " . | ||
| 1687 | "Excess struct/union/enum/typedef member " . | ||
| 1688 | "'$sects[$sx]' " . | ||
| 1689 | "description in '$decl_name'\n"; | ||
| 1690 | ++$warnings; | ||
| 1691 | } | ||
| 1692 | } | ||
| 1693 | } | ||
| 1694 | } | ||
| 1695 | } | ||
| 1696 | |||
| 1633 | ## | 1697 | ## |
| 1634 | # takes a function prototype and the name of the current file being | 1698 | # takes a function prototype and the name of the current file being |
| 1635 | # processed and spits out all the details stored in the global | 1699 | # processed and spits out all the details stored in the global |
| @@ -1648,7 +1712,7 @@ sub dump_function($$) { | |||
| 1648 | $prototype =~ s/^noinline +//; | 1712 | $prototype =~ s/^noinline +//; |
| 1649 | $prototype =~ s/__devinit +//; | 1713 | $prototype =~ s/__devinit +//; |
| 1650 | $prototype =~ s/__init +//; | 1714 | $prototype =~ s/__init +//; |
| 1651 | $prototype =~ s/^#define\s+//; #ak added | 1715 | $prototype =~ s/^#\s*define\s+//; #ak added |
| 1652 | $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; | 1716 | $prototype =~ s/__attribute__\s*\(\([a-z,]*\)\)//; |
| 1653 | 1717 | ||
| 1654 | # Yes, this truly is vile. We are looking for: | 1718 | # Yes, this truly is vile. We are looking for: |
| @@ -1695,6 +1759,9 @@ sub dump_function($$) { | |||
| 1695 | return; | 1759 | return; |
| 1696 | } | 1760 | } |
| 1697 | 1761 | ||
| 1762 | my $prms = join " ", @parameterlist; | ||
| 1763 | check_sections($file, $declaration_name, "function", $sectcheck, $prms, ""); | ||
| 1764 | |||
| 1698 | output_declaration($declaration_name, | 1765 | output_declaration($declaration_name, |
| 1699 | 'function', | 1766 | 'function', |
| 1700 | {'function' => $declaration_name, | 1767 | {'function' => $declaration_name, |
| @@ -1753,6 +1820,8 @@ sub reset_state { | |||
| 1753 | @parameterlist = (); | 1820 | @parameterlist = (); |
| 1754 | %sections = (); | 1821 | %sections = (); |
| 1755 | @sectionlist = (); | 1822 | @sectionlist = (); |
| 1823 | $sectcheck = ""; | ||
| 1824 | $struct_actual = ""; | ||
| 1756 | $prototype = ""; | 1825 | $prototype = ""; |
| 1757 | 1826 | ||
| 1758 | $state = 0; | 1827 | $state = 0; |
| @@ -1764,13 +1833,13 @@ sub process_state3_function($$) { | |||
| 1764 | 1833 | ||
| 1765 | $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line | 1834 | $x =~ s@\/\/.*$@@gos; # strip C99-style comments to end of line |
| 1766 | 1835 | ||
| 1767 | if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#define/)) { | 1836 | if ($x =~ m#\s*/\*\s+MACDOC\s*#io || ($x =~ /^#/ && $x !~ /^#\s*define/)) { |
| 1768 | # do nothing | 1837 | # do nothing |
| 1769 | } | 1838 | } |
| 1770 | elsif ($x =~ /([^\{]*)/) { | 1839 | elsif ($x =~ /([^\{]*)/) { |
| 1771 | $prototype .= $1; | 1840 | $prototype .= $1; |
| 1772 | } | 1841 | } |
| 1773 | if (($x =~ /\{/) || ($x =~ /\#define/) || ($x =~ /;/)) { | 1842 | if (($x =~ /\{/) || ($x =~ /\#\s*define/) || ($x =~ /;/)) { |
| 1774 | $prototype =~ s@/\*.*?\*/@@gos; # strip comments. | 1843 | $prototype =~ s@/\*.*?\*/@@gos; # strip comments. |
| 1775 | $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. | 1844 | $prototype =~ s@[\r\n]+@ @gos; # strip newlines/cr's. |
| 1776 | $prototype =~ s@^\s+@@gos; # strip leading spaces | 1845 | $prototype =~ s@^\s+@@gos; # strip leading spaces |
diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index a8740df07b0..6a12dd9f118 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h | |||
| @@ -4,6 +4,8 @@ SMP=$3 | |||
| 4 | PREEMPT=$4 | 4 | PREEMPT=$4 |
| 5 | CC=$5 | 5 | CC=$5 |
| 6 | 6 | ||
| 7 | vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; } | ||
| 8 | |||
| 7 | # If compile.h exists already and we don't own autoconf.h | 9 | # If compile.h exists already and we don't own autoconf.h |
| 8 | # (i.e. we're not the same user who did make *config), don't | 10 | # (i.e. we're not the same user who did make *config), don't |
| 9 | # modify compile.h | 11 | # modify compile.h |
| @@ -11,7 +13,7 @@ CC=$5 | |||
| 11 | # do "compiled by root" | 13 | # do "compiled by root" |
| 12 | 14 | ||
| 13 | if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then | 15 | if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then |
| 14 | echo " SKIPPED $TARGET" | 16 | vecho " SKIPPED $TARGET" |
| 15 | exit 0 | 17 | exit 0 |
| 16 | fi | 18 | fi |
| 17 | 19 | ||
| @@ -89,7 +91,7 @@ if [ -r $TARGET ] && \ | |||
| 89 | cmp -s .tmpver.1 .tmpver.2; then | 91 | cmp -s .tmpver.1 .tmpver.2; then |
| 90 | rm -f .tmpcompile | 92 | rm -f .tmpcompile |
| 91 | else | 93 | else |
| 92 | echo " UPD $TARGET" | 94 | vecho " UPD $TARGET" |
| 93 | mv -f .tmpcompile $TARGET | 95 | mv -f .tmpcompile $TARGET |
| 94 | fi | 96 | fi |
| 95 | rm -f .tmpver.1 .tmpver.2 | 97 | rm -f .tmpver.1 .tmpver.2 |
diff --git a/scripts/mkmakefile b/scripts/mkmakefile index e65d8b33faa..67d59c7a18d 100644 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile | |||
| @@ -17,7 +17,9 @@ if test -e $2/Makefile && ! grep -q Automatically $2/Makefile | |||
| 17 | then | 17 | then |
| 18 | exit 0 | 18 | exit 0 |
| 19 | fi | 19 | fi |
| 20 | echo " GEN $2/Makefile" | 20 | if [ "${quiet}" != "silent_" ]; then |
| 21 | echo " GEN $2/Makefile" | ||
| 22 | fi | ||
| 21 | 23 | ||
| 22 | cat << EOF > $2/Makefile | 24 | cat << EOF > $2/Makefile |
| 23 | # Automatically generated by $0: don't edit | 25 | # Automatically generated by $0: don't edit |
diff --git a/scripts/mksysmap b/scripts/mksysmap index 6e133a0bae7..1db316a3712 100644 --- a/scripts/mksysmap +++ b/scripts/mksysmap | |||
| @@ -37,9 +37,6 @@ | |||
| 37 | 37 | ||
| 38 | # readprofile starts reading symbols when _stext is found, and | 38 | # readprofile starts reading symbols when _stext is found, and |
| 39 | # continue until it finds a symbol which is not either of 'T', 't', | 39 | # continue until it finds a symbol which is not either of 'T', 't', |
| 40 | # 'W' or 'w'. __crc_ are 'A' and placed in the middle | 40 | # 'W' or 'w'. |
| 41 | # so we just ignore them to let readprofile continue to work. | ||
| 42 | # (At least sparc64 has __crc_ in the middle). | ||
| 43 | |||
| 44 | $NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $2 | ||
| 45 | 41 | ||
| 42 | $NM -n $1 | grep -v '\( [aNUw] \)\|\( \$[adt]\)' > $2 | ||
diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index d9cc6901d68..aadc5223dcd 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c | |||
| @@ -290,6 +290,15 @@ static int parse_file(const char *fname, struct md4_ctx *md) | |||
| 290 | release_file(file, len); | 290 | release_file(file, len); |
| 291 | return 1; | 291 | return 1; |
| 292 | } | 292 | } |
| 293 | /* Check whether the file is a static library or not */ | ||
| 294 | static int is_static_library(const char *objfile) | ||
| 295 | { | ||
| 296 | int len = strlen(objfile); | ||
| 297 | if (objfile[len - 2] == '.' && objfile[len - 1] == 'a') | ||
| 298 | return 1; | ||
| 299 | else | ||
| 300 | return 0; | ||
| 301 | } | ||
| 293 | 302 | ||
| 294 | /* We have dir/file.o. Open dir/.file.o.cmd, look for deps_ line to | 303 | /* We have dir/file.o. Open dir/.file.o.cmd, look for deps_ line to |
| 295 | * figure out source file. */ | 304 | * figure out source file. */ |
| @@ -420,7 +429,8 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) | |||
| 420 | while ((fname = strsep(&sources, " ")) != NULL) { | 429 | while ((fname = strsep(&sources, " ")) != NULL) { |
| 421 | if (!*fname) | 430 | if (!*fname) |
| 422 | continue; | 431 | continue; |
| 423 | if (!parse_source_files(fname, &md)) | 432 | if (!(is_static_library(fname)) && |
| 433 | !parse_source_files(fname, &md)) | ||
| 424 | goto release; | 434 | goto release; |
| 425 | } | 435 | } |
| 426 | 436 | ||
diff --git a/scripts/package/Makefile b/scripts/package/Makefile index 5e326078a4a..8c6b7b09606 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile | |||
| @@ -1,10 +1,6 @@ | |||
| 1 | # Makefile for the different targets used to generate full packages of a kernel | 1 | # Makefile for the different targets used to generate full packages of a kernel |
| 2 | # It uses the generic clean infrastructure of kbuild | 2 | # It uses the generic clean infrastructure of kbuild |
| 3 | 3 | ||
| 4 | # Ignore the following files/directories during tar operation | ||
| 5 | TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS | ||
| 6 | |||
| 7 | |||
| 8 | # RPM target | 4 | # RPM target |
| 9 | # --------------------------------------------------------------------------- | 5 | # --------------------------------------------------------------------------- |
| 10 | # The rpm target generates two rpm files: | 6 | # The rpm target generates two rpm files: |
| @@ -47,7 +43,7 @@ rpm-pkg rpm: $(objtree)/kernel.spec FORCE | |||
| 47 | set -e; \ | 43 | set -e; \ |
| 48 | mv -f $(objtree)/.tmp_version $(objtree)/.version | 44 | mv -f $(objtree)/.tmp_version $(objtree)/.version |
| 49 | 45 | ||
| 50 | $(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz | 46 | $(RPM) $(RPMOPTS) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz |
| 51 | rm ../$(KERNELPATH).tar.gz | 47 | rm ../$(KERNELPATH).tar.gz |
| 52 | 48 | ||
| 53 | clean-files := $(objtree)/kernel.spec | 49 | clean-files := $(objtree)/kernel.spec |
| @@ -64,7 +60,8 @@ binrpm-pkg: $(objtree)/binkernel.spec FORCE | |||
| 64 | set -e; \ | 60 | set -e; \ |
| 65 | mv -f $(objtree)/.tmp_version $(objtree)/.version | 61 | mv -f $(objtree)/.tmp_version $(objtree)/.version |
| 66 | 62 | ||
| 67 | $(RPM) --define "_builddir $(srctree)" --target $(UTS_MACHINE) -bb $< | 63 | $(RPM) $(RPMOPTS) --define "_builddir $(srctree)" --target \ |
| 64 | $(UTS_MACHINE) -bb $< | ||
| 68 | 65 | ||
| 69 | clean-files += $(objtree)/binkernel.spec | 66 | clean-files += $(objtree)/binkernel.spec |
| 70 | 67 | ||
diff --git a/scripts/package/builddeb b/scripts/package/builddeb index ba6bf5d5abf..1264b8e2829 100644 --- a/scripts/package/builddeb +++ b/scripts/package/builddeb | |||
| @@ -15,15 +15,18 @@ set -e | |||
| 15 | version=$KERNELRELEASE | 15 | version=$KERNELRELEASE |
| 16 | revision=`cat .version` | 16 | revision=`cat .version` |
| 17 | tmpdir="$objtree/debian/tmp" | 17 | tmpdir="$objtree/debian/tmp" |
| 18 | fwdir="$objtree/debian/fwtmp" | ||
| 18 | packagename=linux-$version | 19 | packagename=linux-$version |
| 20 | fwpackagename=linux-firmware-image | ||
| 19 | 21 | ||
| 20 | if [ "$ARCH" == "um" ] ; then | 22 | if [ "$ARCH" == "um" ] ; then |
| 21 | packagename=user-mode-linux-$version | 23 | packagename=user-mode-linux-$version |
| 22 | fi | 24 | fi |
| 23 | 25 | ||
| 24 | # Setup the directory structure | 26 | # Setup the directory structure |
| 25 | rm -rf "$tmpdir" | 27 | rm -rf "$tmpdir" "$fwdir" |
| 26 | mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" | 28 | mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot" |
| 29 | mkdir -p "$fwdir/DEBIAN" "$fwdir/lib" | ||
| 27 | if [ "$ARCH" == "um" ] ; then | 30 | if [ "$ARCH" == "um" ] ; then |
| 28 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin" | 31 | mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin" |
| 29 | fi | 32 | fi |
| @@ -107,6 +110,7 @@ Standards-Version: 3.6.1 | |||
| 107 | 110 | ||
| 108 | Package: $packagename | 111 | Package: $packagename |
| 109 | Provides: kernel-image-$version, linux-image-$version | 112 | Provides: kernel-image-$version, linux-image-$version |
| 113 | Suggests: $fwpackagename | ||
| 110 | Architecture: any | 114 | Architecture: any |
| 111 | Description: Linux kernel, version $version | 115 | Description: Linux kernel, version $version |
| 112 | This package contains the Linux kernel, modules and corresponding other | 116 | This package contains the Linux kernel, modules and corresponding other |
| @@ -118,8 +122,24 @@ fi | |||
| 118 | chown -R root:root "$tmpdir" | 122 | chown -R root:root "$tmpdir" |
| 119 | chmod -R go-w "$tmpdir" | 123 | chmod -R go-w "$tmpdir" |
| 120 | 124 | ||
| 125 | # Do we have firmware? Move it out of the way and build it into a package. | ||
| 126 | if [ -e "$tmpdir/lib/firmware" ]; then | ||
| 127 | mv "$tmpdir/lib/firmware" "$fwdir/lib/" | ||
| 128 | |||
| 129 | cat <<EOF >> debian/control | ||
| 130 | |||
| 131 | Package: $fwpackagename | ||
| 132 | Architecture: all | ||
| 133 | Description: Linux kernel firmware, version $version | ||
| 134 | This package contains firmware from the Linux kernel, version $version | ||
| 135 | EOF | ||
| 136 | |||
| 137 | dpkg-gencontrol -isp -p$fwpackagename -P"$fwdir" | ||
| 138 | dpkg --build "$fwdir" .. | ||
| 139 | fi | ||
| 140 | |||
| 121 | # Perform the final magic | 141 | # Perform the final magic |
| 122 | dpkg-gencontrol -isp | 142 | dpkg-gencontrol -isp -p$packagename |
| 123 | dpkg --build "$tmpdir" .. | 143 | dpkg --build "$tmpdir" .. |
| 124 | 144 | ||
| 125 | exit 0 | 145 | exit 0 |
diff --git a/scripts/package/mkspec b/scripts/package/mkspec index ffd61fe0c1a..2500886fb90 100755 --- a/scripts/package/mkspec +++ b/scripts/package/mkspec | |||
| @@ -57,15 +57,17 @@ fi | |||
| 57 | echo "%build" | 57 | echo "%build" |
| 58 | 58 | ||
| 59 | if ! $PREBUILT; then | 59 | if ! $PREBUILT; then |
| 60 | echo "make clean && make %{_smp_mflags}" | 60 | echo "make clean && make %{?_smp_mflags}" |
| 61 | echo "" | 61 | echo "" |
| 62 | fi | 62 | fi |
| 63 | 63 | ||
| 64 | echo "%install" | 64 | echo "%install" |
| 65 | echo "%ifarch ia64" | 65 | echo "%ifarch ia64" |
| 66 | echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' | 66 | echo 'mkdir -p $RPM_BUILD_ROOT/boot/efi $RPM_BUILD_ROOT/lib/modules' |
| 67 | echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' | ||
| 67 | echo "%else" | 68 | echo "%else" |
| 68 | echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' | 69 | echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules' |
| 70 | echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware' | ||
| 69 | echo "%endif" | 71 | echo "%endif" |
| 70 | 72 | ||
| 71 | echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} modules_install' | 73 | echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} modules_install' |
| @@ -92,5 +94,6 @@ echo "%files" | |||
| 92 | echo '%defattr (-, root, root)' | 94 | echo '%defattr (-, root, root)' |
| 93 | echo "%dir /lib/modules" | 95 | echo "%dir /lib/modules" |
| 94 | echo "/lib/modules/$KERNELRELEASE" | 96 | echo "/lib/modules/$KERNELRELEASE" |
| 97 | echo "/lib/firmware" | ||
| 95 | echo "/boot/*" | 98 | echo "/boot/*" |
| 96 | echo "" | 99 | echo "" |
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl index f56d760bd58..fe831412bea 100755 --- a/scripts/recordmcount.pl +++ b/scripts/recordmcount.pl | |||
| @@ -106,7 +106,16 @@ if ($#ARGV < 6) { | |||
| 106 | exit(1); | 106 | exit(1); |
| 107 | } | 107 | } |
| 108 | 108 | ||
| 109 | my ($arch, $objdump, $objcopy, $cc, $ld, $nm, $rm, $mv, $inputfile) = @ARGV; | 109 | my ($arch, $bits, $objdump, $objcopy, $cc, |
| 110 | $ld, $nm, $rm, $mv, $inputfile) = @ARGV; | ||
| 111 | |||
| 112 | # Acceptable sections to record. | ||
| 113 | my %text_sections = ( | ||
| 114 | ".text" => 1, | ||
| 115 | ".sched.text" => 1, | ||
| 116 | ".spinlock.text" => 1, | ||
| 117 | ".irqentry.text" => 1, | ||
| 118 | ); | ||
| 110 | 119 | ||
| 111 | $objdump = "objdump" if ((length $objdump) == 0); | 120 | $objdump = "objdump" if ((length $objdump) == 0); |
| 112 | $objcopy = "objcopy" if ((length $objcopy) == 0); | 121 | $objcopy = "objcopy" if ((length $objcopy) == 0); |
| @@ -124,16 +133,37 @@ my %weak; # List of weak functions | |||
| 124 | my %convert; # List of local functions used that needs conversion | 133 | my %convert; # List of local functions used that needs conversion |
| 125 | 134 | ||
| 126 | my $type; | 135 | my $type; |
| 136 | my $nm_regex; # Find the local functions (return function) | ||
| 127 | my $section_regex; # Find the start of a section | 137 | my $section_regex; # Find the start of a section |
| 128 | my $function_regex; # Find the name of a function | 138 | my $function_regex; # Find the name of a function |
| 129 | # (return offset and func name) | 139 | # (return offset and func name) |
| 130 | my $mcount_regex; # Find the call site to mcount (return offset) | 140 | my $mcount_regex; # Find the call site to mcount (return offset) |
| 141 | my $alignment; # The .align value to use for $mcount_section | ||
| 142 | my $section_type; # Section header plus possible alignment command | ||
| 143 | |||
| 144 | if ($arch eq "x86") { | ||
| 145 | if ($bits == 64) { | ||
| 146 | $arch = "x86_64"; | ||
| 147 | } else { | ||
| 148 | $arch = "i386"; | ||
| 149 | } | ||
| 150 | } | ||
| 151 | |||
| 152 | # | ||
| 153 | # We base the defaults off of i386, the other archs may | ||
| 154 | # feel free to change them in the below if statements. | ||
| 155 | # | ||
| 156 | $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\S+)"; | ||
| 157 | $section_regex = "Disassembly of section\\s+(\\S+):"; | ||
| 158 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
| 159 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; | ||
| 160 | $section_type = '@progbits'; | ||
| 161 | $type = ".long"; | ||
| 131 | 162 | ||
| 132 | if ($arch eq "x86_64") { | 163 | if ($arch eq "x86_64") { |
| 133 | $section_regex = "Disassembly of section"; | ||
| 134 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
| 135 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; | 164 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount([+-]0x[0-9a-zA-Z]+)?\$"; |
| 136 | $type = ".quad"; | 165 | $type = ".quad"; |
| 166 | $alignment = 8; | ||
| 137 | 167 | ||
| 138 | # force flags for this arch | 168 | # force flags for this arch |
| 139 | $ld .= " -m elf_x86_64"; | 169 | $ld .= " -m elf_x86_64"; |
| @@ -142,10 +172,7 @@ if ($arch eq "x86_64") { | |||
| 142 | $cc .= " -m64"; | 172 | $cc .= " -m64"; |
| 143 | 173 | ||
| 144 | } elsif ($arch eq "i386") { | 174 | } elsif ($arch eq "i386") { |
| 145 | $section_regex = "Disassembly of section"; | 175 | $alignment = 4; |
| 146 | $function_regex = "^([0-9a-fA-F]+)\\s+<(.*?)>:"; | ||
| 147 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\smcount\$"; | ||
| 148 | $type = ".long"; | ||
| 149 | 176 | ||
| 150 | # force flags for this arch | 177 | # force flags for this arch |
| 151 | $ld .= " -m elf_i386"; | 178 | $ld .= " -m elf_i386"; |
| @@ -153,6 +180,27 @@ if ($arch eq "x86_64") { | |||
| 153 | $objcopy .= " -O elf32-i386"; | 180 | $objcopy .= " -O elf32-i386"; |
| 154 | $cc .= " -m32"; | 181 | $cc .= " -m32"; |
| 155 | 182 | ||
| 183 | } elsif ($arch eq "sh") { | ||
| 184 | $alignment = 2; | ||
| 185 | |||
| 186 | # force flags for this arch | ||
| 187 | $ld .= " -m shlelf_linux"; | ||
| 188 | $objcopy .= " -O elf32-sh-linux"; | ||
| 189 | $cc .= " -m32"; | ||
| 190 | |||
| 191 | } elsif ($arch eq "powerpc") { | ||
| 192 | $nm_regex = "^[0-9a-fA-F]+\\s+t\\s+(\\.?\\S+)"; | ||
| 193 | $function_regex = "^([0-9a-fA-F]+)\\s+<(\\.?.*?)>:"; | ||
| 194 | $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s\\.?_mcount\$"; | ||
| 195 | |||
| 196 | if ($bits == 64) { | ||
| 197 | $type = ".quad"; | ||
| 198 | } | ||
| 199 | |||
| 200 | } elsif ($arch eq "arm") { | ||
| 201 | $alignment = 2; | ||
| 202 | $section_type = '%progbits'; | ||
| 203 | |||
| 156 | } else { | 204 | } else { |
| 157 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; | 205 | die "Arch $arch is not supported with CONFIG_FTRACE_MCOUNT_RECORD"; |
| 158 | } | 206 | } |
| @@ -222,7 +270,7 @@ if (!$found_version) { | |||
| 222 | # | 270 | # |
| 223 | open (IN, "$nm $inputfile|") || die "error running $nm"; | 271 | open (IN, "$nm $inputfile|") || die "error running $nm"; |
| 224 | while (<IN>) { | 272 | while (<IN>) { |
| 225 | if (/^[0-9a-fA-F]+\s+t\s+(\S+)/) { | 273 | if (/$nm_regex/) { |
| 226 | $locals{$1} = 1; | 274 | $locals{$1} = 1; |
| 227 | } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) { | 275 | } elsif (/^[0-9a-fA-F]+\s+([wW])\s+(\S+)/) { |
| 228 | $weak{$2} = $1; | 276 | $weak{$2} = $1; |
| @@ -273,7 +321,8 @@ sub update_funcs | |||
| 273 | if (!$opened) { | 321 | if (!$opened) { |
| 274 | open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; | 322 | open(FILE, ">$mcount_s") || die "can't create $mcount_s\n"; |
| 275 | $opened = 1; | 323 | $opened = 1; |
| 276 | print FILE "\t.section $mcount_section,\"a\",\@progbits\n"; | 324 | print FILE "\t.section $mcount_section,\"a\",$section_type\n"; |
| 325 | print FILE "\t.align $alignment\n" if (defined($alignment)); | ||
| 277 | } | 326 | } |
| 278 | printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; | 327 | printf FILE "\t%s %s + %d\n", $type, $ref_func, $offsets[$i] - $offset; |
| 279 | } | 328 | } |
| @@ -289,7 +338,13 @@ my $text; | |||
| 289 | while (<IN>) { | 338 | while (<IN>) { |
| 290 | # is it a section? | 339 | # is it a section? |
| 291 | if (/$section_regex/) { | 340 | if (/$section_regex/) { |
| 292 | $read_function = 1; | 341 | |
| 342 | # Only record text sections that we know are safe | ||
| 343 | if (defined($text_sections{$1})) { | ||
| 344 | $read_function = 1; | ||
| 345 | } else { | ||
| 346 | $read_function = 0; | ||
| 347 | } | ||
| 293 | # print out any recorded offsets | 348 | # print out any recorded offsets |
| 294 | update_funcs() if ($text_found); | 349 | update_funcs() if ($text_found); |
| 295 | 350 | ||
diff --git a/scripts/setlocalversion b/scripts/setlocalversion index 83b75126c9f..f6946cf99ce 100755 --- a/scripts/setlocalversion +++ b/scripts/setlocalversion | |||
| @@ -9,14 +9,21 @@ usage() { | |||
| 9 | cd "${1:-.}" || usage | 9 | cd "${1:-.}" || usage |
| 10 | 10 | ||
| 11 | # Check for git and a git repo. | 11 | # Check for git and a git repo. |
| 12 | if head=`git rev-parse --verify HEAD 2>/dev/null`; then | 12 | if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then |
| 13 | # Do we have an untagged version? | 13 | # Do we have an untagged version? |
| 14 | if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then | 14 | if git name-rev --tags HEAD | grep -E '^HEAD[[:space:]]+(.*~[0-9]*|undefined)$' > /dev/null; then |
| 15 | if tag=`git describe 2>/dev/null`; then | 15 | if tag=`git describe 2>/dev/null`; then |
| 16 | echo $tag | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' | 16 | echo $tag | awk -F- '{printf("-%05d-%s", $(NF-1),$(NF))}' |
| 17 | else | ||
| 18 | printf '%s%s' -g $head | ||
| 17 | fi | 19 | fi |
| 18 | fi | 20 | fi |
| 19 | 21 | ||
| 22 | # Is this git on svn? | ||
| 23 | if git config --get svn-remote.svn.url >/dev/null; then | ||
| 24 | printf -- '-svn%s' "`git-svn find-rev $head`" | ||
| 25 | fi | ||
| 26 | |||
| 20 | # Are there uncommitted changes? | 27 | # Are there uncommitted changes? |
| 21 | git update-index --refresh --unmerged > /dev/null | 28 | git update-index --refresh --unmerged > /dev/null |
| 22 | if git diff-index --name-only HEAD | grep -v "^scripts/package" \ | 29 | if git diff-index --name-only HEAD | grep -v "^scripts/package" \ |
| @@ -49,13 +56,13 @@ if hgid=`hg id 2>/dev/null`; then | |||
| 49 | fi | 56 | fi |
| 50 | 57 | ||
| 51 | # Check for svn and a svn repo. | 58 | # Check for svn and a svn repo. |
| 52 | if rev=`svn info 2>/dev/null | grep '^Revision'`; then | 59 | if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then |
| 53 | rev=`echo $rev | awk '{print $NF}'` | 60 | rev=`echo $rev | awk '{print $NF}'` |
| 54 | changes=`svn status 2>/dev/null | grep '^[AMD]' | wc -l` | 61 | changes=`svn status 2>/dev/null | grep '^[AMD]' | wc -l` |
| 55 | 62 | ||
| 56 | # Are there uncommitted changes? | 63 | # Are there uncommitted changes? |
| 57 | if [ $changes != 0 ]; then | 64 | if [ $changes != 0 ]; then |
| 58 | printf -- '-svn%s%s%s' "$rev" -dirty "$changes" | 65 | printf -- '-svn%s%s' "$rev" -dirty |
| 59 | else | 66 | else |
| 60 | printf -- '-svn%s' "$rev" | 67 | printf -- '-svn%s' "$rev" |
| 61 | fi | 68 | fi |
diff --git a/scripts/strip-symbols b/scripts/strip-symbols new file mode 100644 index 00000000000..29ee8c1a014 --- /dev/null +++ b/scripts/strip-symbols | |||
| @@ -0,0 +1,22 @@ | |||
| 1 | <*> | ||
| 2 | *.h | ||
| 3 | __compound_literal[$.][0-9]* | ||
| 4 | __crc_[a-zA-Z_]* | ||
| 5 | __exitcall_[a-zA-Z_]* | ||
| 6 | __func__[$.][0-9]* | ||
| 7 | __FUNCTION__[$.][0-9]* | ||
| 8 | gcc[0-9]_compiled[$.] | ||
| 9 | __initcall_[a-zA-Z_]* | ||
| 10 | __kcrctab_[a-zA-Z_]* | ||
| 11 | __kstrtab_[a-zA-Z_]* | ||
| 12 | __ksymtab_[a-zA-Z_]* | ||
| 13 | __mod_[a-zA-Z_]*[0-9] | ||
| 14 | __module_depends | ||
| 15 | __param_[a-zA-Z_]* | ||
| 16 | __pci_fixup_*PCI_ANY_IDPCI_ANY_ID* | ||
| 17 | __pci_fixup_*PCI_ANY_IDPCI_DEVICE_ID_* | ||
| 18 | __pci_fixup_*PCI_VENDOR_ID_*PCI_ANY_ID* | ||
| 19 | __pci_fixup_*PCI_VENDOR_ID_*PCI_DEVICE_ID_* | ||
| 20 | __PRETTY_FUNCTION__[$.][0-9]* | ||
| 21 | __setup_[a-zA-Z_]* | ||
| 22 | ____versions | ||
diff --git a/scripts/tags.sh b/scripts/tags.sh new file mode 100755 index 00000000000..9e3451d2c3a --- /dev/null +++ b/scripts/tags.sh | |||
| @@ -0,0 +1,159 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | # Generate tags or cscope files | ||
| 3 | # Usage tags.sh <mode> | ||
| 4 | # | ||
| 5 | # mode may be any of: tags, TAGS, cscope | ||
| 6 | # | ||
| 7 | # Uses the following environment variables: | ||
| 8 | # ARCH, SUBARCH, srctree, src, obj | ||
| 9 | |||
| 10 | if [ "$KBUILD_VERBOSE" = "1" ]; then | ||
| 11 | set -x | ||
| 12 | fi | ||
| 13 | |||
| 14 | # This is a duplicate of RCS_FIND_IGNORE without escaped '()' | ||
| 15 | ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \ | ||
| 16 | -name CVS -o -name .pc -o -name .hg -o \ | ||
| 17 | -name .git ) \ | ||
| 18 | -prune -o" | ||
| 19 | |||
| 20 | # Do not use full path is we do not use O=.. builds | ||
| 21 | if [ "${KBUILD_SRC}" = "" ]; then | ||
| 22 | tree= | ||
| 23 | else | ||
| 24 | tree=${srctree}/ | ||
| 25 | fi | ||
| 26 | |||
| 27 | # find sources in arch/$ARCH | ||
| 28 | find_arch_sources() | ||
| 29 | { | ||
| 30 | find ${tree}arch/$1 $ignore -name "$2" -print; | ||
| 31 | } | ||
| 32 | |||
| 33 | # find sources in arch/$1/include | ||
| 34 | find_arch_include_sources() | ||
| 35 | { | ||
| 36 | find ${tree}arch/$1/include $ignore -name "$2" -print; | ||
| 37 | } | ||
| 38 | |||
| 39 | # find sources in include/ | ||
| 40 | find_include_sources() | ||
| 41 | { | ||
| 42 | find ${tree}include $ignore -name config -prune -o -name "$1" -print; | ||
| 43 | } | ||
| 44 | |||
| 45 | # find sources in rest of tree | ||
| 46 | # we could benefit from a list of dirs to search in here | ||
| 47 | find_other_sources() | ||
| 48 | { | ||
| 49 | find ${tree}* $ignore \ | ||
| 50 | \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \ | ||
| 51 | -name "$1" -print; | ||
| 52 | } | ||
| 53 | |||
| 54 | find_sources() | ||
| 55 | { | ||
| 56 | find_arch_sources $1 "$2" | ||
| 57 | find_include_sources "$2" | ||
| 58 | find_other_sources "$2" | ||
| 59 | } | ||
| 60 | |||
| 61 | all_sources() | ||
| 62 | { | ||
| 63 | find_sources $SRCARCH '*.[chS]' | ||
| 64 | if [ ! -z "$archinclude" ]; then | ||
| 65 | find_arch_include_sources $archinclude '*.[chS]' | ||
| 66 | fi | ||
| 67 | } | ||
| 68 | |||
| 69 | all_kconfigs() | ||
| 70 | { | ||
| 71 | find_sources $SRCARCH 'Kconfig*' | ||
| 72 | } | ||
| 73 | |||
| 74 | all_defconfigs() | ||
| 75 | { | ||
| 76 | find_sources $SRCARCH "defconfig" | ||
| 77 | } | ||
| 78 | |||
| 79 | docscope() | ||
| 80 | { | ||
| 81 | (echo \-k; echo \-q; all_sources) > cscope.files | ||
| 82 | cscope -b -f cscope.out | ||
| 83 | } | ||
| 84 | |||
| 85 | exuberant() | ||
| 86 | { | ||
| 87 | all_sources | xargs $1 -a \ | ||
| 88 | -I __initdata,__exitdata,__acquires,__releases \ | ||
| 89 | -I __read_mostly,____cacheline_aligned \ | ||
| 90 | -I ____cacheline_aligned_in_smp \ | ||
| 91 | -I ____cacheline_internodealigned_in_smp \ | ||
| 92 | -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ | ||
| 93 | --extra=+f --c-kinds=+px \ | ||
| 94 | --regex-asm='/^ENTRY\(([^)]*)\).*/\1/' | ||
| 95 | |||
| 96 | all_kconfigs | xargs $1 -a \ | ||
| 97 | --langdef=kconfig --language-force=kconfig \ | ||
| 98 | --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/' | ||
| 99 | |||
| 100 | all_kconfigs | xargs $1 -a \ | ||
| 101 | --langdef=kconfig --language-force=kconfig \ | ||
| 102 | --regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/CONFIG_\2/' | ||
| 103 | |||
| 104 | all_defconfigs | xargs -r $1 -a \ | ||
| 105 | --langdef=dotconfig --language-force=dotconfig \ | ||
| 106 | --regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/' | ||
| 107 | |||
| 108 | } | ||
| 109 | |||
| 110 | emacs() | ||
| 111 | { | ||
| 112 | all_sources | xargs $1 -a | ||
| 113 | |||
| 114 | all_kconfigs | xargs $1 -a \ | ||
| 115 | --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/' | ||
| 116 | |||
| 117 | all_kconfigs | xargs $1 -a \ | ||
| 118 | --regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/CONFIG_\3/' | ||
| 119 | |||
| 120 | all_defconfigs | xargs -r $1 -a \ | ||
| 121 | --regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/' | ||
| 122 | } | ||
| 123 | |||
| 124 | xtags() | ||
| 125 | { | ||
| 126 | if $1 --version 2>&1 | grep -iq exuberant; then | ||
| 127 | exuberant $1 | ||
| 128 | elif $1 --version 2>&1 | grep -iq emacs; then | ||
| 129 | emacs $1 | ||
| 130 | else | ||
| 131 | all_sources | xargs $1 -a | ||
| 132 | fi | ||
| 133 | } | ||
| 134 | |||
| 135 | |||
| 136 | # Support um (which uses SUBARCH) | ||
| 137 | if [ "${ARCH}" = "um" ]; then | ||
| 138 | if [ "$SUBARCH" = "i386" ]; then | ||
| 139 | archinclude=x86 | ||
| 140 | elif [ "$SUBARCH" = "x86_64" ]; then | ||
| 141 | archinclude=x86 | ||
| 142 | else | ||
| 143 | archinclude=${SUBARCH} | ||
| 144 | fi | ||
| 145 | fi | ||
| 146 | |||
| 147 | case "$1" in | ||
| 148 | "cscope") | ||
| 149 | docscope | ||
| 150 | ;; | ||
| 151 | |||
| 152 | "tags") | ||
| 153 | xtags ctags | ||
| 154 | ;; | ||
| 155 | |||
| 156 | "TAGS") | ||
| 157 | xtags etags | ||
| 158 | ;; | ||
| 159 | esac | ||
diff --git a/scripts/trace/power.pl b/scripts/trace/power.pl new file mode 100644 index 00000000000..4f729b3501e --- /dev/null +++ b/scripts/trace/power.pl | |||
| @@ -0,0 +1,108 @@ | |||
| 1 | #!/usr/bin/perl | ||
| 2 | |||
| 3 | # Copyright 2008, Intel Corporation | ||
| 4 | # | ||
| 5 | # This file is part of the Linux kernel | ||
| 6 | # | ||
| 7 | # This program file is free software; you can redistribute it and/or modify it | ||
| 8 | # under the terms of the GNU General Public License as published by the | ||
| 9 | # Free Software Foundation; version 2 of the License. | ||
| 10 | # | ||
| 11 | # This program is distributed in the hope that it will be useful, but WITHOUT | ||
| 12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
| 13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| 14 | # for more details. | ||
| 15 | # | ||
| 16 | # You should have received a copy of the GNU General Public License | ||
| 17 | # along with this program in a file named COPYING; if not, write to the | ||
| 18 | # Free Software Foundation, Inc., | ||
| 19 | # 51 Franklin Street, Fifth Floor, | ||
| 20 | # Boston, MA 02110-1301 USA | ||
| 21 | # | ||
| 22 | # Authors: | ||
| 23 | # Arjan van de Ven <arjan@linux.intel.com> | ||
| 24 | |||
| 25 | |||
| 26 | # | ||
| 27 | # This script turns a cstate ftrace output into a SVG graphic that shows | ||
| 28 | # historic C-state information | ||
| 29 | # | ||
| 30 | # | ||
| 31 | # cat /sys/kernel/debug/tracing/trace | perl power.pl > out.svg | ||
| 32 | # | ||
| 33 | |||
| 34 | my @styles; | ||
| 35 | my $base = 0; | ||
| 36 | |||
| 37 | my @pstate_last; | ||
| 38 | my @pstate_level; | ||
| 39 | |||
| 40 | $styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 41 | $styles[1] = "fill:rgb(0,255,0);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 42 | $styles[2] = "fill:rgb(255,0,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 43 | $styles[3] = "fill:rgb(255,255,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 44 | $styles[4] = "fill:rgb(255,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 45 | $styles[5] = "fill:rgb(0,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 46 | $styles[6] = "fill:rgb(0,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 47 | $styles[7] = "fill:rgb(0,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 48 | $styles[8] = "fill:rgb(0,25,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)"; | ||
| 49 | |||
| 50 | |||
| 51 | print "<?xml version=\"1.0\" standalone=\"no\"?> \n"; | ||
| 52 | print "<svg width=\"10000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n"; | ||
| 53 | |||
| 54 | my $scale = 30000.0; | ||
| 55 | while (<>) { | ||
| 56 | my $line = $_; | ||
| 57 | if ($line =~ /([0-9\.]+)\] CSTATE: Going to C([0-9]) on cpu ([0-9]+) for ([0-9\.]+)/) { | ||
| 58 | if ($base == 0) { | ||
| 59 | $base = $1; | ||
| 60 | } | ||
| 61 | my $time = $1 - $base; | ||
| 62 | $time = $time * $scale; | ||
| 63 | my $C = $2; | ||
| 64 | my $cpu = $3; | ||
| 65 | my $y = 400 * $cpu; | ||
| 66 | my $duration = $4 * $scale; | ||
| 67 | my $msec = int($4 * 100000)/100.0; | ||
| 68 | my $height = $C * 20; | ||
| 69 | $style = $styles[$C]; | ||
| 70 | |||
| 71 | $y = $y + 140 - $height; | ||
| 72 | |||
| 73 | $x2 = $time + 4; | ||
| 74 | $y2 = $y + 4; | ||
| 75 | |||
| 76 | |||
| 77 | print "<rect x=\"$time\" width=\"$duration\" y=\"$y\" height=\"$height\" style=\"$style\"/>\n"; | ||
| 78 | print "<text transform=\"translate($x2,$y2) rotate(90)\">C$C $msec</text>\n"; | ||
| 79 | } | ||
| 80 | if ($line =~ /([0-9\.]+)\] PSTATE: Going to P([0-9]) on cpu ([0-9]+)/) { | ||
| 81 | my $time = $1 - $base; | ||
| 82 | my $state = $2; | ||
| 83 | my $cpu = $3; | ||
| 84 | |||
| 85 | if (defined($pstate_last[$cpu])) { | ||
| 86 | my $from = $pstate_last[$cpu]; | ||
| 87 | my $oldstate = $pstate_state[$cpu]; | ||
| 88 | my $duration = ($time-$from) * $scale; | ||
| 89 | |||
| 90 | $from = $from * $scale; | ||
| 91 | my $to = $from + $duration; | ||
| 92 | my $height = 140 - ($oldstate * (140/8)); | ||
| 93 | |||
| 94 | my $y = 400 * $cpu + 200 + $height; | ||
| 95 | my $y2 = $y+4; | ||
| 96 | my $style = $styles[8]; | ||
| 97 | |||
| 98 | print "<rect x=\"$from\" y=\"$y\" width=\"$duration\" height=\"5\" style=\"$style\"/>\n"; | ||
| 99 | print "<text transform=\"translate($from,$y2)\">P$oldstate (cpu $cpu)</text>\n"; | ||
| 100 | }; | ||
| 101 | |||
| 102 | $pstate_last[$cpu] = $time; | ||
| 103 | $pstate_state[$cpu] = $state; | ||
| 104 | } | ||
| 105 | } | ||
| 106 | |||
| 107 | |||
| 108 | print "</svg>\n"; | ||
diff --git a/scripts/tracing/draw_functrace.py b/scripts/tracing/draw_functrace.py new file mode 100644 index 00000000000..902f9a99262 --- /dev/null +++ b/scripts/tracing/draw_functrace.py | |||
| @@ -0,0 +1,130 @@ | |||
| 1 | #!/usr/bin/python | ||
| 2 | |||
| 3 | """ | ||
| 4 | Copyright 2008 (c) Frederic Weisbecker <fweisbec@gmail.com> | ||
| 5 | Licensed under the terms of the GNU GPL License version 2 | ||
| 6 | |||
| 7 | This script parses a trace provided by the function tracer in | ||
| 8 | kernel/trace/trace_functions.c | ||
| 9 | The resulted trace is processed into a tree to produce a more human | ||
| 10 | view of the call stack by drawing textual but hierarchical tree of | ||
| 11 | calls. Only the functions's names and the the call time are provided. | ||
| 12 | |||
| 13 | Usage: | ||
| 14 | Be sure that you have CONFIG_FUNCTION_TRACER | ||
| 15 | # mkdir /debugfs | ||
| 16 | # mount -t debug debug /debug | ||
| 17 | # echo function > /debug/tracing/current_tracer | ||
| 18 | $ cat /debug/tracing/trace_pipe > ~/raw_trace_func | ||
| 19 | Wait some times but not too much, the script is a bit slow. | ||
| 20 | Break the pipe (Ctrl + Z) | ||
| 21 | $ scripts/draw_functrace.py < raw_trace_func > draw_functrace | ||
| 22 | Then you have your drawn trace in draw_functrace | ||
| 23 | """ | ||
| 24 | |||
| 25 | |||
| 26 | import sys, re | ||
| 27 | |||
| 28 | class CallTree: | ||
| 29 | """ This class provides a tree representation of the functions | ||
| 30 | call stack. If a function has no parent in the kernel (interrupt, | ||
| 31 | syscall, kernel thread...) then it is attached to a virtual parent | ||
| 32 | called ROOT. | ||
| 33 | """ | ||
| 34 | ROOT = None | ||
| 35 | |||
| 36 | def __init__(self, func, time = None, parent = None): | ||
| 37 | self._func = func | ||
| 38 | self._time = time | ||
| 39 | if parent is None: | ||
| 40 | self._parent = CallTree.ROOT | ||
| 41 | else: | ||
| 42 | self._parent = parent | ||
| 43 | self._children = [] | ||
| 44 | |||
| 45 | def calls(self, func, calltime): | ||
| 46 | """ If a function calls another one, call this method to insert it | ||
| 47 | into the tree at the appropriate place. | ||
| 48 | @return: A reference to the newly created child node. | ||
| 49 | """ | ||
| 50 | child = CallTree(func, calltime, self) | ||
| 51 | self._children.append(child) | ||
| 52 | return child | ||
| 53 | |||
| 54 | def getParent(self, func): | ||
| 55 | """ Retrieve the last parent of the current node that | ||
| 56 | has the name given by func. If this function is not | ||
| 57 | on a parent, then create it as new child of root | ||
| 58 | @return: A reference to the parent. | ||
| 59 | """ | ||
| 60 | tree = self | ||
| 61 | while tree != CallTree.ROOT and tree._func != func: | ||
| 62 | tree = tree._parent | ||
| 63 | if tree == CallTree.ROOT: | ||
| 64 | child = CallTree.ROOT.calls(func, None) | ||
| 65 | return child | ||
| 66 | return tree | ||
| 67 | |||
| 68 | def __repr__(self): | ||
| 69 | return self.__toString("", True) | ||
| 70 | |||
| 71 | def __toString(self, branch, lastChild): | ||
| 72 | if self._time is not None: | ||
| 73 | s = "%s----%s (%s)\n" % (branch, self._func, self._time) | ||
| 74 | else: | ||
| 75 | s = "%s----%s\n" % (branch, self._func) | ||
| 76 | |||
| 77 | i = 0 | ||
| 78 | if lastChild: | ||
| 79 | branch = branch[:-1] + " " | ||
| 80 | while i < len(self._children): | ||
| 81 | if i != len(self._children) - 1: | ||
| 82 | s += "%s" % self._children[i].__toString(branch +\ | ||
| 83 | " |", False) | ||
| 84 | else: | ||
| 85 | s += "%s" % self._children[i].__toString(branch +\ | ||
| 86 | " |", True) | ||
| 87 | i += 1 | ||
| 88 | return s | ||
| 89 | |||
| 90 | class BrokenLineException(Exception): | ||
| 91 | """If the last line is not complete because of the pipe breakage, | ||
| 92 | we want to stop the processing and ignore this line. | ||
| 93 | """ | ||
| 94 | pass | ||
| 95 | |||
| 96 | class CommentLineException(Exception): | ||
| 97 | """ If the line is a comment (as in the beginning of the trace file), | ||
| 98 | just ignore it. | ||
| 99 | """ | ||
| 100 | pass | ||
| 101 | |||
| 102 | |||
| 103 | def parseLine(line): | ||
| 104 | line = line.strip() | ||
| 105 | if line.startswith("#"): | ||
| 106 | raise CommentLineException | ||
| 107 | m = re.match("[^]]+?\\] +([0-9.]+): (\\w+) <-(\\w+)", line) | ||
| 108 | if m is None: | ||
| 109 | raise BrokenLineException | ||
| 110 | return (m.group(1), m.group(2), m.group(3)) | ||
| 111 | |||
| 112 | |||
| 113 | def main(): | ||
| 114 | CallTree.ROOT = CallTree("Root (Nowhere)", None, None) | ||
| 115 | tree = CallTree.ROOT | ||
| 116 | |||
| 117 | for line in sys.stdin: | ||
| 118 | try: | ||
| 119 | calltime, callee, caller = parseLine(line) | ||
| 120 | except BrokenLineException: | ||
| 121 | break | ||
| 122 | except CommentLineException: | ||
| 123 | continue | ||
| 124 | tree = tree.getParent(caller) | ||
| 125 | tree = tree.calls(callee, calltime) | ||
| 126 | |||
| 127 | print CallTree.ROOT | ||
| 128 | |||
| 129 | if __name__ == "__main__": | ||
| 130 | main() | ||
