Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild

* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild: (33 commits)
xtensa: use DATA_DATA in xtensa
powerpc: add missing DATA_DATA to powerpc
cris: use DATA_DATA in cris
kallsyms: remove usage of memmem and _GNU_SOURCE from scripts/kallsyms.c
kbuild: use -fno-optimize-sibling-calls unconditionally
kconfig: reset generated values only if Kconfig and .config agree.
kbuild: fix the warning when running make tags
kconfig: strip 'CONFIG_' automatically in kernel configuration search
kbuild: use POSIX BRE in headers install target
Whitelist references from __dbe_table to .init
modpost white list pattern adjustment
kbuild: do section mismatch check on full vmlinux
kbuild: whitelist references from variables named _timer to .init.text
kbuild: remove hardcoded _logo names from modpost
kbuild: remove hardcoded apic_es7000 from modpost
kbuild: warn about references from .init.text to .exit.text
kbuild: consolidate section checks
kbuild: refactor code in modpost to improve maintainability
kbuild: ignore section mismatch warnings originating from .note section
kbuild: .paravirtprobe section is obsolete, so modpost doesn't need to handle it
...

+476 -202
+14
Documentation/kbuild/makefiles.txt
··· 501 The third parameter may be a text as in this example, but it may also 502 be an expanded variable or a macro. 503 504 505 === 4 Host Program support 506
··· 501 The third parameter may be a text as in this example, but it may also 502 be an expanded variable or a macro. 503 504 + cc-fullversion 505 + cc-fullversion is useful when the exact version of gcc is needed. 506 + One typical use-case is when a specific GCC version is broken. 507 + cc-fullversion points out a more specific version than cc-version does. 508 + 509 + Example: 510 + #arch/powerpc/Makefile 511 + $(Q)if test "$(call cc-fullversion)" = "040200" ; then \ 512 + echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \ 513 + false ; \ 514 + fi 515 + 516 + In this example for a specific GCC version the build will error out explaining 517 + to the user why it stops. 518 519 === 4 Host Program support 520
+1
Kbuild
··· 13 always := $(offsets-file) 14 targets := $(offsets-file) 15 targets += arch/$(ARCH)/kernel/asm-offsets.s 16 17 # Default sed regexp - multiline due to syntax constraints 18 define sed-y
··· 13 always := $(offsets-file) 14 targets := $(offsets-file) 15 targets += arch/$(ARCH)/kernel/asm-offsets.s 16 + clean-files := $(addprefix $(objtree)/,$(targets)) 17 18 # Default sed regexp - multiline due to syntax constraints 19 define sed-y
+21 -5
Makefile
··· 492 include $(srctree)/arch/$(ARCH)/Makefile 493 494 ifdef CONFIG_FRAME_POINTER 495 - CFLAGS += -fno-omit-frame-pointer $(call cc-option,-fno-optimize-sibling-calls,) 496 else 497 CFLAGS += -fomit-frame-pointer 498 endif ··· 618 cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \ 619 -T $(vmlinux-lds) $(vmlinux-init) \ 620 --start-group $(vmlinux-main) --end-group \ 621 - $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) FORCE ,$^) 622 623 # Generate new vmlinux version 624 quiet_cmd_vmlinux_version = GEN .version ··· 742 743 endif # ifdef CONFIG_KALLSYMS 744 745 # vmlinux image - including updated kernel symbols 746 - vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE 747 ifdef CONFIG_HEADERS_CHECK 748 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 749 endif 750 $(call if_changed_rule,vmlinux__) 751 - $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@ 752 $(Q)rm -f .old_version 753 754 # The actual objects are generated when descending, 755 # make sure no implicit rule kicks in ··· 1339 -I __initdata,__exitdata,__acquires,__releases \ 1340 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 1341 --extra=+f --c-kinds=+px \ 1342 - --regex-asm='/ENTRY\(([^)]*)\).*/\1/'; \ 1343 $(all-kconfigs) | xargs $1 -a \ 1344 --langdef=kconfig \ 1345 --language-force=kconfig \
··· 492 include $(srctree)/arch/$(ARCH)/Makefile 493 494 ifdef CONFIG_FRAME_POINTER 495 + CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls 496 else 497 CFLAGS += -fomit-frame-pointer 498 endif ··· 618 cmd_vmlinux__ ?= $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) -o $@ \ 619 -T $(vmlinux-lds) $(vmlinux-init) \ 620 --start-group $(vmlinux-main) --end-group \ 621 + $(filter-out $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) vmlinux.o FORCE ,$^) 622 623 # Generate new vmlinux version 624 quiet_cmd_vmlinux_version = GEN .version ··· 742 743 endif # ifdef CONFIG_KALLSYMS 744 745 + # Do modpost on a prelinked vmlinux. The finally linked vmlinux has 746 + # relevant sections renamed as per the linker script. 747 + quiet_cmd_vmlinux-modpost = LD $@ 748 + cmd_vmlinux-modpost = $(LD) $(LDFLAGS) -r -o $@ \ 749 + $(vmlinux-init) --start-group $(vmlinux-main) --end-group \ 750 + $(filter-out $(vmlinux-init) $(vmlinux-main) $(vmlinux-lds) FORCE ,$^) 751 + define rule_vmlinux-modpost 752 + : 753 + +$(call cmd,vmlinux-modpost) 754 + $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost $@ 755 + $(Q)echo 'cmd_$@ := $(cmd_vmlinux-modpost)' > $(dot-target).cmd 756 + endef 757 + 758 # vmlinux image - including updated kernel symbols 759 + vmlinux: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) vmlinux.o FORCE 760 ifdef CONFIG_HEADERS_CHECK 761 $(Q)$(MAKE) -f $(srctree)/Makefile headers_check 762 endif 763 + $(call vmlinux-modpost) 764 $(call if_changed_rule,vmlinux__) 765 $(Q)rm -f .old_version 766 + 767 + vmlinux.o: $(vmlinux-lds) $(vmlinux-init) $(vmlinux-main) $(kallsyms.o) FORCE 768 + $(call if_changed_rule,vmlinux-modpost) 769 770 # The actual objects are generated when descending, 771 # make sure no implicit rule kicks in ··· 1323 -I __initdata,__exitdata,__acquires,__releases \ 1324 -I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \ 1325 --extra=+f --c-kinds=+px \ 1326 + --regex-asm='/^ENTRY\(([^)]*)\).*/\1/'; \ 1327 $(all-kconfigs) | xargs $1 -a \ 1328 --langdef=kconfig \ 1329 --language-force=kconfig \
+1 -1
arch/cris/arch-v10/vmlinux.lds.S
··· 44 ___data_start = . ; 45 __Sdata = . ; 46 .data : { /* Data */ 47 - *(.data) 48 } 49 __edata = . ; /* End of data section */ 50 _edata = . ;
··· 44 ___data_start = . ; 45 __Sdata = . ; 46 .data : { /* Data */ 47 + DATA_DATA 48 } 49 __edata = . ; /* End of data section */ 50 _edata = . ;
+1 -1
arch/cris/arch-v32/vmlinux.lds.S
··· 49 ___data_start = . ; 50 __Sdata = . ; 51 .data : { /* Data */ 52 - *(.data) 53 } 54 __edata = . ; /* End of data section. */ 55 _edata = . ;
··· 49 ___data_start = . ; 50 __Sdata = . ; 51 .data : { /* Data */ 52 + DATA_DATA 53 } 54 __edata = . ; /* End of data section. */ 55 _edata = . ;
+1 -1
arch/i386/mach-generic/es7000.c
··· 66 } 67 #endif 68 69 - struct genapic apic_es7000 = APIC_INIT("es7000", probe_es7000);
··· 66 } 67 #endif 68 69 + struct genapic __initdata_refok apic_es7000 = APIC_INIT("es7000", probe_es7000);
+8
arch/powerpc/Makefile
··· 201 false; \ 202 fi ; \ 203 fi 204 @if ! /bin/echo dssall | $(AS) -many -o $(TOUT) >/dev/null 2>&1 ; then \ 205 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build ' ; \ 206 echo 'correctly with old versions of binutils.' ; \
··· 201 false; \ 202 fi ; \ 203 fi 204 + @if test "$(call cc-fullversion)" = "040200" \ 205 + && test "x${CONFIG_MODULES}${CONFIG_PPC64}" = "xyy" ; then \ 206 + echo -n '*** GCC-4.2.0 cannot compile the 64-bit powerpc ' ; \ 207 + echo 'kernel with modules enabled.' ; \ 208 + echo -n '*** Please use a different GCC version or ' ; \ 209 + echo 'disable kernel modules' ; \ 210 + false ; \ 211 + fi 212 @if ! /bin/echo dssall | $(AS) -many -o $(TOUT) >/dev/null 2>&1 ; then \ 213 echo -n '*** ${VERSION}.${PATCHLEVEL} kernels no longer build ' ; \ 214 echo 'correctly with old versions of binutils.' ; \
+3 -1
arch/powerpc/kernel/vmlinux.lds.S
··· 177 } 178 #else 179 .data : { 180 - *(.data .data.rel* .toc1) 181 *(.branch_lt) 182 } 183
··· 177 } 178 #else 179 .data : { 180 + DATA_DATA 181 + *(.data.rel*) 182 + *(.toc1) 183 *(.branch_lt) 184 } 185
+2 -1
arch/xtensa/kernel/vmlinux.lds.S
··· 118 _fdata = .; 119 .data : 120 { 121 - *(.data) CONSTRUCTORS 122 . = ALIGN(XCHAL_ICACHE_LINESIZE); 123 *(.data.cacheline_aligned) 124 }
··· 118 _fdata = .; 119 .data : 120 { 121 + DATA_DATA 122 + CONSTRUCTORS 123 . = ALIGN(XCHAL_ICACHE_LINESIZE); 124 *(.data.cacheline_aligned) 125 }
+5 -2
drivers/video/logo/logo.c
··· 34 extern const struct linux_logo logo_superh_clut224; 35 extern const struct linux_logo logo_m32r_clut224; 36 37 - 38 - const struct linux_logo *fb_find_logo(int depth) 39 { 40 const struct linux_logo *logo = NULL; 41
··· 34 extern const struct linux_logo logo_superh_clut224; 35 extern const struct linux_logo logo_m32r_clut224; 36 37 + /* logo's are marked __initdata. Use __init_refok to tell 38 + * modpost that it is intended that this function uses data 39 + * marked __initdata. 40 + */ 41 + const struct linux_logo * __init_refok fb_find_logo(int depth) 42 { 43 const struct linux_logo *logo = NULL; 44
+6 -1
scripts/Kbuild.include
··· 100 $(call cc-option,-falign-functions=0,-malign-functions=0)) 101 102 # cc-version 103 - # Usage gcc-ver := $(call cc-version,$(CC)) 104 cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 105 106 # cc-ifversion 107 # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
··· 100 $(call cc-option,-falign-functions=0,-malign-functions=0)) 101 102 # cc-version 103 + # Usage gcc-ver := $(call cc-version) 104 cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) 105 + 106 + # cc-fullversion 107 + # Usage gcc-ver := $(call cc-fullversion) 108 + cc-fullversion = $(shell $(CONFIG_SHELL) \ 109 + $(srctree)/scripts/gcc-version.sh -p $(CC)) 110 111 # cc-ifversion 112 # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1)
+16
scripts/Makefile.build
··· 7 PHONY := __build 8 __build: 9 10 # Read .config if it exist, otherwise ignore 11 -include include/config/auto.conf 12
··· 7 PHONY := __build 8 __build: 9 10 + # Init all relevant variables used in kbuild files so 11 + # 1) they have correct type 12 + # 2) they do not inherit any value from the environment 13 + obj-y := 14 + obj-m := 15 + lib-y := 16 + lib-m := 17 + always := 18 + targets := 19 + subdir-y := 20 + subdir-m := 21 + EXTRA_AFLAGS := 22 + EXTRA_CFLAGS := 23 + EXTRA_CPPFLAGS := 24 + EXTRA_LDFLAGS := 25 + 26 # Read .config if it exist, otherwise ignore 27 -include include/config/auto.conf 28
+7 -7
scripts/Makefile.headersinst
··· 11 12 # Eliminate the contents of (and inclusions of) compiler.h 13 HDRSED := sed -e "s/ inline / __inline__ /g" \ 14 - -e "s/[[:space:]]__user[[:space:]]\+/ /g" \ 15 - -e "s/(__user[[:space:]]\+/ (/g" \ 16 - -e "s/[[:space:]]__force[[:space:]]\+/ /g" \ 17 - -e "s/(__force[[:space:]]\+/ (/g" \ 18 - -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \ 19 - -e "s/(__iomem[[:space:]]\+/ (/g" \ 20 - -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \ 21 -e "s/[[:space:]]__attribute_const__$$//" \ 22 -e "/^\#include <linux\/compiler.h>/d" 23
··· 11 12 # Eliminate the contents of (and inclusions of) compiler.h 13 HDRSED := sed -e "s/ inline / __inline__ /g" \ 14 + -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ 15 + -e "s/(__user[[:space:]]\{1,\}/ (/g" \ 16 + -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ 17 + -e "s/(__force[[:space:]]\{1,\}/ (/g" \ 18 + -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \ 19 + -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \ 20 + -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \ 21 -e "s/[[:space:]]__attribute_const__$$//" \ 22 -e "/^\#include <linux\/compiler.h>/d" 23
+2 -2
scripts/Makefile.modpost
··· 70 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) 71 72 quiet_cmd_kernel-mod = MODPOST $@ 73 - cmd_kernel-mod = $(cmd_modpost) $(KBUILD_VMLINUX_OBJS) 74 75 PHONY += vmlinux 76 - vmlinux: FORCE 77 $(call cmd,kernel-mod) 78 79 # Declare generated files as targets for modpost
··· 70 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) 71 72 quiet_cmd_kernel-mod = MODPOST $@ 73 + cmd_kernel-mod = $(cmd_modpost) $@ 74 75 PHONY += vmlinux 76 + vmlinux.o: FORCE 77 $(call cmd,kernel-mod) 78 79 # Declare generated files as targets for modpost
+52 -2
scripts/cleanfile
··· 7 use bytes; 8 use File::Basename; 9 10 - # 11 # Clean up space-tab sequences, either by removing spaces or 12 # replacing them with tabs. 13 sub clean_space_tabs($) ··· 50 return $lo; 51 } 52 53 $name = basename($0); 54 55 - foreach $f ( @ARGV ) { 56 print STDERR "$name: $f\n"; 57 58 if (! -f $f) { ··· 132 133 @blanks = (); 134 @lines = (); 135 136 while ( defined($line = <FILE>) ) { 137 $in_bytes += length($line); 138 $line =~ s/[ \t\r]*$//; # Remove trailing spaces 139 $line = clean_space_tabs($line); ··· 150 $out_bytes += length($line); 151 @blanks = (); 152 $blank_bytes = 0; 153 } 154 } 155
··· 7 use bytes; 8 use File::Basename; 9 10 + # Default options 11 + $max_width = 79; 12 + 13 # Clean up space-tab sequences, either by removing spaces or 14 # replacing them with tabs. 15 sub clean_space_tabs($) ··· 48 return $lo; 49 } 50 51 + # Compute the visual width of a string 52 + sub strwidth($) { 53 + no bytes; # Tab alignment depends on characters 54 + 55 + my($li) = @_; 56 + my($c, $i); 57 + my $pos = 0; 58 + my $mlen = 0; 59 + 60 + for ($i = 0; $i < length($li); $i++) { 61 + $c = substr($li,$i,1); 62 + if ($c eq "\t") { 63 + $pos = ($pos+8) & ~7; 64 + } elsif ($c eq "\n") { 65 + $mlen = $pos if ($pos > $mlen); 66 + $pos = 0; 67 + } else { 68 + $pos++; 69 + } 70 + } 71 + 72 + $mlen = $pos if ($pos > $mlen); 73 + return $mlen; 74 + } 75 + 76 $name = basename($0); 77 78 + @files = (); 79 + 80 + while (defined($a = shift(@ARGV))) { 81 + if ($a =~ /^-/) { 82 + if ($a eq '-width' || $a eq '-w') { 83 + $max_width = shift(@ARGV)+0; 84 + } else { 85 + print STDERR "Usage: $name [-width #] files...\n"; 86 + exit 1; 87 + } 88 + } else { 89 + push(@files, $a); 90 + } 91 + } 92 + 93 + foreach $f ( @files ) { 94 print STDERR "$name: $f\n"; 95 96 if (! -f $f) { ··· 90 91 @blanks = (); 92 @lines = (); 93 + $lineno = 0; 94 95 while ( defined($line = <FILE>) ) { 96 + $lineno++; 97 $in_bytes += length($line); 98 $line =~ s/[ \t\r]*$//; # Remove trailing spaces 99 $line = clean_space_tabs($line); ··· 106 $out_bytes += length($line); 107 @blanks = (); 108 $blank_bytes = 0; 109 + } 110 + 111 + $l_width = strwidth($line); 112 + if ($max_width && $l_width > $max_width) { 113 + print STDERR 114 + "$f:$lineno: line exceeds $max_width characters ($l_width)\n"; 115 } 116 } 117
+55 -3
scripts/cleanpatch
··· 7 use bytes; 8 use File::Basename; 9 10 - # 11 # Clean up space-tab sequences, either by removing spaces or 12 # replacing them with tabs. 13 sub clean_space_tabs($) ··· 50 return $lo; 51 } 52 53 $name = basename($0); 54 55 - foreach $f ( @ARGV ) { 56 print STDERR "$name: $f\n"; 57 58 if (! -f $f) { ··· 128 129 $in_bytes = 0; 130 $out_bytes = 0; 131 132 @lines = (); 133 ··· 136 $err = 0; 137 138 while ( defined($line = <FILE>) ) { 139 $in_bytes += length($line); 140 141 if (!$in_hunk) { 142 - if ($line =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { 143 $minus_lines = $2; 144 $plus_lines = $4; 145 if ($minus_lines || $plus_lines) { ··· 161 $text = substr($line, 1); 162 $text =~ s/[ \t\r]*$//; # Remove trailing spaces 163 $text = clean_space_tabs($text); 164 165 push(@hunk_lines, '+'.$text); 166 } elsif ($line =~ /^\-/) {
··· 7 use bytes; 8 use File::Basename; 9 10 + # Default options 11 + $max_width = 79; 12 + 13 # Clean up space-tab sequences, either by removing spaces or 14 # replacing them with tabs. 15 sub clean_space_tabs($) ··· 48 return $lo; 49 } 50 51 + # Compute the visual width of a string 52 + sub strwidth($) { 53 + no bytes; # Tab alignment depends on characters 54 + 55 + my($li) = @_; 56 + my($c, $i); 57 + my $pos = 0; 58 + my $mlen = 0; 59 + 60 + for ($i = 0; $i < length($li); $i++) { 61 + $c = substr($li,$i,1); 62 + if ($c eq "\t") { 63 + $pos = ($pos+8) & ~7; 64 + } elsif ($c eq "\n") { 65 + $mlen = $pos if ($pos > $mlen); 66 + $pos = 0; 67 + } else { 68 + $pos++; 69 + } 70 + } 71 + 72 + $mlen = $pos if ($pos > $mlen); 73 + return $mlen; 74 + } 75 + 76 $name = basename($0); 77 78 + @files = (); 79 + 80 + while (defined($a = shift(@ARGV))) { 81 + if ($a =~ /^-/) { 82 + if ($a eq '-width' || $a eq '-w') { 83 + $max_width = shift(@ARGV)+0; 84 + } else { 85 + print STDERR "Usage: $name [-width #] files...\n"; 86 + exit 1; 87 + } 88 + } else { 89 + push(@files, $a); 90 + } 91 + } 92 + 93 + foreach $f ( @files ) { 94 print STDERR "$name: $f\n"; 95 96 if (! -f $f) { ··· 86 87 $in_bytes = 0; 88 $out_bytes = 0; 89 + $lineno = 0; 90 91 @lines = (); 92 ··· 93 $err = 0; 94 95 while ( defined($line = <FILE>) ) { 96 + $lineno++; 97 $in_bytes += length($line); 98 99 if (!$in_hunk) { 100 + if ($line =~ 101 + /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { 102 $minus_lines = $2; 103 $plus_lines = $4; 104 if ($minus_lines || $plus_lines) { ··· 116 $text = substr($line, 1); 117 $text =~ s/[ \t\r]*$//; # Remove trailing spaces 118 $text = clean_space_tabs($text); 119 + 120 + $l_width = strwidth($text); 121 + if ($max_width && $l_width > $max_width) { 122 + print STDERR 123 + "$f:$lineno: adds line exceeds $max_width ", 124 + "characters ($l_width)\n"; 125 + } 126 127 push(@hunk_lines, '+'.$text); 128 } elsif ($line =~ /^\-/) {
+12 -3
scripts/gcc-version.sh
··· 1 #!/bin/sh 2 # 3 - # gcc-version gcc-command 4 # 5 # Prints the gcc version of `gcc-command' in a canonical 4-digit form 6 # such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. 7 # 8 9 compiler="$*" 10 11 MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1) 12 MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) 13 - printf "%02d%02d\\n" $MAJOR $MINOR 14 -
··· 1 #!/bin/sh 2 # 3 + # gcc-version [-p] gcc-command 4 # 5 # Prints the gcc version of `gcc-command' in a canonical 4-digit form 6 # such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. 7 # 8 + # With the -p option, prints the patchlevel as well, for example `029503' for 9 + # gcc-2.95.3, `030301' for gcc-3.3.1, etc. 10 + # 11 + 12 + if [ $1 = "-p" ] ; then with_patchlevel=1; shift; fi 13 14 compiler="$*" 15 16 MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1) 17 MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) 18 + if [ "x$with_patchlevel" != "x" ] ; then 19 + PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1) 20 + printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL 21 + else 22 + printf "%02d%02d\\n" $MAJOR $MINOR 23 + fi
+6 -6
scripts/gen_initramfs_list.sh
··· 19 -o <file> Create gzipped initramfs file named <file> using 20 gen_init_cpio and gzip 21 -u <uid> User ID to map to user ID 0 (root). 22 - <uid> is only meaningful if <cpio_source> 23 - is a directory. 24 -g <gid> Group ID to map to group ID 0 (root). 25 - <gid> is only meaningful if <cpio_source> 26 - is a directory. 27 <cpio_source> File list or directory for cpio archive. 28 If <cpio_source> is a .cpio file it will be used 29 as direct input to initramfs. ··· 113 local gid="$4" 114 local ftype=$(filetype "${location}") 115 # remap uid/gid to 0 if necessary 116 - [ "$uid" -eq "$root_uid" ] && uid=0 117 - [ "$gid" -eq "$root_gid" ] && gid=0 118 local str="${mode} ${uid} ${gid}" 119 120 [ "${ftype}" == "invalid" ] && return 0
··· 19 -o <file> Create gzipped initramfs file named <file> using 20 gen_init_cpio and gzip 21 -u <uid> User ID to map to user ID 0 (root). 22 + <uid> is only meaningful if <cpio_source> is a 23 + directory. "squash" forces all files to uid 0. 24 -g <gid> Group ID to map to group ID 0 (root). 25 + <gid> is only meaningful if <cpio_source> is a 26 + directory. "squash" forces all files to gid 0. 27 <cpio_source> File list or directory for cpio archive. 28 If <cpio_source> is a .cpio file it will be used 29 as direct input to initramfs. ··· 113 local gid="$4" 114 local ftype=$(filetype "${location}") 115 # remap uid/gid to 0 if necessary 116 + [ "$root_uid" = "squash" ] && uid=0 || [ "$uid" -eq "$root_uid" ] && uid=0 117 + [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0 118 local str="${mode} ${uid} ${gid}" 119 120 [ "${ftype}" == "invalid" ] && return 0
+13 -4
scripts/kallsyms.c
··· 24 * 25 */ 26 27 - #define _GNU_SOURCE 28 - 29 #include <stdio.h> 30 #include <stdlib.h> 31 #include <string.h> ··· 376 table_cnt = pos; 377 } 378 379 /* replace a given token in all the valid symbols. Use the sampled symbols 380 * to update the counts */ 381 static void compress_symbols(unsigned char *str, int idx) ··· 400 p1 = table[i].sym; 401 402 /* find the token on the symbol */ 403 - p2 = memmem(p1, len, str, 2); 404 if (!p2) continue; 405 406 /* decrease the counts for this symbol's tokens */ ··· 419 if (size < 2) break; 420 421 /* find the token on the symbol */ 422 - p2 = memmem(p1, size, str, 2); 423 424 } while (p2); 425
··· 24 * 25 */ 26 27 #include <stdio.h> 28 #include <stdlib.h> 29 #include <string.h> ··· 378 table_cnt = pos; 379 } 380 381 + static void *find_token(unsigned char *str, int len, unsigned char *token) 382 + { 383 + int i; 384 + 385 + for (i = 0; i < len - 1; i++) { 386 + if (str[i] == token[0] && str[i+1] == token[1]) 387 + return &str[i]; 388 + } 389 + return NULL; 390 + } 391 + 392 /* replace a given token in all the valid symbols. Use the sampled symbols 393 * to update the counts */ 394 static void compress_symbols(unsigned char *str, int idx) ··· 391 p1 = table[i].sym; 392 393 /* find the token on the symbol */ 394 + p2 = find_token(p1, len, str); 395 if (!p2) continue; 396 397 /* decrease the counts for this symbol's tokens */ ··· 410 if (size < 2) break; 411 412 /* find the token on the symbol */ 413 + p2 = find_token(p1, size, str); 414 415 } while (p2); 416
+18 -17
scripts/kconfig/Makefile
··· 22 silentoldconfig: $(obj)/conf 23 $< -s arch/$(ARCH)/Kconfig 24 25 update-po-config: $(obj)/kxgettext 26 - xgettext --default-domain=linux \ 27 - --add-comments --keyword=_ --keyword=N_ \ 28 - --files-from=scripts/kconfig/POTFILES.in \ 29 - --output scripts/kconfig/config.pot 30 - $(Q)ln -fs Kconfig_i386 arch/um/Kconfig_arch 31 - $(Q)for i in `ls arch/`; \ 32 - do \ 33 - scripts/kconfig/kxgettext arch/$$i/Kconfig \ 34 - | msguniq -o scripts/kconfig/linux_$${i}.pot; \ 35 - done 36 - $(Q)msgcat scripts/kconfig/config.pot \ 37 - `find scripts/kconfig/ -type f -name linux_*.pot` \ 38 - --output scripts/kconfig/linux_raw.pot 39 - $(Q)msguniq --sort-by-file scripts/kconfig/linux_raw.pot \ 40 - --output scripts/kconfig/linux.pot 41 - $(Q)rm -f arch/um/Kconfig_arch 42 - $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot 43 44 PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig 45
··· 22 silentoldconfig: $(obj)/conf 23 $< -s arch/$(ARCH)/Kconfig 24 25 + # Create new linux.po file 26 + # Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files 27 + # The symlink is used to repair a deficiency in arch/um 28 update-po-config: $(obj)/kxgettext 29 + xgettext --default-domain=linux \ 30 + --add-comments --keyword=_ --keyword=N_ \ 31 + --from-code=UTF-8 \ 32 + --files-from=scripts/kconfig/POTFILES.in \ 33 + --output $(obj)/config.pot 34 + $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot 35 + $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch 36 + (for i in `ls arch/`; \ 37 + do \ 38 + $(obj)/kxgettext arch/$$i/Kconfig; \ 39 + done ) >> $(obj)/config.pot 40 + msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ 41 + --output $(obj)/linux.pot 42 + $(Q)rm -f arch/um/Kconfig.arch 43 + $(Q)rm -f $(obj)/config.pot 44 45 PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig 46
+28 -13
scripts/kconfig/confdata.c
··· 341 conf_unsaved++; 342 /* maybe print value in verbose mode... */ 343 sym_ok: 344 - if (sym_has_value(sym) && !sym_is_choice_value(sym)) { 345 - if (sym->visible == no) 346 - sym->flags &= ~SYMBOL_DEF_USER; 347 - switch (sym->type) { 348 - case S_STRING: 349 - case S_INT: 350 - case S_HEX: 351 - if (!sym_string_within_range(sym, sym->def[S_DEF_USER].val)) 352 - sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); 353 - default: 354 - break; 355 - } 356 - } 357 if (!sym_is_choice(sym)) 358 continue; 359 prop = sym_get_choice_prop(sym); 360 flags = sym->flags; 361 for (e = prop->expr; e; e = e->left.expr) 362 if (e->right.sym->visible != no) 363 flags &= e->right.sym->flags; 364 sym->flags &= flags | ~SYMBOL_DEF_USER; 365 } 366 367 sym_add_change_count(conf_warnings || conf_unsaved);
··· 341 conf_unsaved++; 342 /* maybe print value in verbose mode... */ 343 sym_ok: 344 if (!sym_is_choice(sym)) 345 continue; 346 + /* The choice symbol only has a set value (and thus is not new) 347 + * if all its visible childs have values. 348 + */ 349 prop = sym_get_choice_prop(sym); 350 flags = sym->flags; 351 for (e = prop->expr; e; e = e->left.expr) 352 if (e->right.sym->visible != no) 353 flags &= e->right.sym->flags; 354 sym->flags &= flags | ~SYMBOL_DEF_USER; 355 + } 356 + 357 + for_all_symbols(i, sym) { 358 + if (sym_has_value(sym) && !sym_is_choice_value(sym)) { 359 + /* Reset values of generates values, so they'll appear 360 + * as new, if they should become visible, but that 361 + * doesn't quite work if the Kconfig and the saved 362 + * configuration disagree. 363 + */ 364 + if (sym->visible == no && !conf_unsaved) 365 + sym->flags &= ~SYMBOL_DEF_USER; 366 + switch (sym->type) { 367 + case S_STRING: 368 + case S_INT: 369 + case S_HEX: 370 + /* Reset a string value if it's out of range */ 371 + if (sym_string_within_range(sym, sym->def[S_DEF_USER].val)) 372 + break; 373 + sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); 374 + conf_unsaved++; 375 + break; 376 + default: 377 + break; 378 + } 379 + } 380 } 381 382 sym_add_change_count(conf_warnings || conf_unsaved);
+3 -1
scripts/kconfig/kxgettext.c
··· 212 struct message *m = message__list; 213 214 while (m != NULL) { 215 - message__print_gettext_msgid_msgstr(m); 216 m = m->next; 217 } 218 }
··· 212 struct message *m = message__list; 213 214 while (m != NULL) { 215 + /* skip empty lines ("") */ 216 + if (strlen(m->msg) > sizeof("\"\"")) 217 + message__print_gettext_msgid_msgstr(m); 218 m = m->next; 219 } 220 }
+1 -1
scripts/kconfig/lxdialog/check-lxdialog.sh
··· 51 printf "Usage: $0 [-check compiler options|-header|-library]\n" 52 } 53 54 - if [ $# == 0 ]; then 55 usage 56 exit 1 57 fi
··· 51 printf "Usage: $0 [-check compiler options|-header|-library]\n" 52 } 53 54 + if [ $# -eq 0 ]; then 55 usage 56 exit 1 57 fi
+9 -2
scripts/kconfig/mconf.c
··· 419 { 420 struct symbol **sym_arr; 421 struct gstr res; 422 int dres; 423 again: 424 dialog_clear(); 425 dres = dialog_inputbox(_("Search Configuration Parameter"), 426 - _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"), 427 10, 75, ""); 428 switch (dres) { 429 case 0: ··· 437 return; 438 } 439 440 - sym_arr = sym_re_search(dialog_input_result); 441 res = get_relations_str(sym_arr); 442 free(sym_arr); 443 show_textbox(_("Search Results"), str_get(&res), 0, 0);
··· 419 { 420 struct symbol **sym_arr; 421 struct gstr res; 422 + char *dialog_input; 423 int dres; 424 again: 425 dialog_clear(); 426 dres = dialog_inputbox(_("Search Configuration Parameter"), 427 + _("Enter CONFIG_ (sub)string to search for " 428 + "(with or without \"CONFIG\")"), 429 10, 75, ""); 430 switch (dres) { 431 case 0: ··· 435 return; 436 } 437 438 + /* strip CONFIG_ if necessary */ 439 + dialog_input = dialog_input_result; 440 + if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) 441 + dialog_input += 7; 442 + 443 + sym_arr = sym_re_search(dialog_input); 444 res = get_relations_str(sym_arr); 445 free(sym_arr); 446 show_textbox(_("Search Results"), str_get(&res), 0, 0);
+185 -127
scripts/mod/modpost.c
··· 75 else 76 myname = modname; 77 78 - return strcmp(myname, "vmlinux") == 0; 79 } 80 81 void *do_nofail(void *ptr, const char *expr) ··· 375 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); 376 hdr->e_shnum = TO_NATIVE(hdr->e_shnum); 377 hdr->e_machine = TO_NATIVE(hdr->e_machine); 378 sechdrs = (void *)hdr + hdr->e_shoff; 379 info->sechdrs = sechdrs; 380 ··· 386 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); 387 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); 388 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); 389 } 390 /* Find symbol table. */ 391 for (i = 1; i < hdr->e_shnum; i++) { ··· 609 * warn here. 610 * the pattern is identified by: 611 * tosec = .init.text | .exit.text | .init.data 612 - * fromsec = .data 613 - * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console 614 * 615 * Pattern 3: 616 - * Whitelist all references from .pci_fixup* section to .init.text 617 - * This is part of the PCI init when built-in 618 - * 619 - * Pattern 4: 620 * Whitelist all refereces from .text.head to .init.data 621 * Whitelist all refereces from .text.head to .init.text 622 * 623 - * Pattern 5: 624 * Some symbols belong to init section but still it is ok to reference 625 * these from non-init sections as these symbols don't have any memory 626 * allocated for them and symbol address and value are same. So even ··· 625 * This pattern is identified by 626 * refsymname = __init_begin, _sinittext, _einittext 627 * 628 - * Pattern 7: 629 - * Logos used in drivers/video/logo reside in __initdata but the 630 - * funtion that references them are EXPORT_SYMBOL() so cannot be 631 - * marker __init. So we whitelist them here. 632 - * The pattern is: 633 - * tosec = .init.data 634 - * fromsec = .text* 635 - * refsymname = logo_ 636 - * 637 - * Pattern 8: 638 - * Symbols contained in .paravirtprobe may safely reference .init.text. 639 - * The pattern is: 640 - * tosec = .init.text 641 - * fromsec = .paravirtprobe 642 - * 643 - * Pattern 10: 644 - * ia64 has machvec table for each platform and 645 - * powerpc has a machine desc table for each platform. 646 - * It is mixture of function pointers of .init.text and .text. 647 - * fromsec = .machvec | .machine.desc 648 **/ 649 static int secref_whitelist(const char *modname, const char *tosec, 650 const char *fromsec, const char *atsym, ··· 635 const char *pat2sym[] = { 636 "driver", 637 "_template", /* scsi uses *_template a lot */ 638 "_sht", /* scsi also used *_sht to some extent */ 639 "_ops", 640 "_probe", 641 "_probe_one", 642 "_console", 643 - "apic_es7000", 644 NULL 645 }; 646 ··· 672 (strcmp(tosec, ".exit.text") != 0) && 673 (strcmp(tosec, ".init.data") != 0)) 674 f2 = 0; 675 - if (strcmp(fromsec, ".data") != 0) 676 f2 = 0; 677 678 for (s = pat2sym; *s; s++) ··· 684 return 1; 685 686 /* Check for pattern 3 */ 687 - if ((strncmp(fromsec, ".pci_fixup", strlen(".pci_fixup")) == 0) && 688 - (strcmp(tosec, ".init.text") == 0)) 689 - return 1; 690 - 691 - /* Check for pattern 4 */ 692 if ((strcmp(fromsec, ".text.head") == 0) && 693 ((strcmp(tosec, ".init.data") == 0) || 694 (strcmp(tosec, ".init.text") == 0))) 695 return 1; 696 697 - /* Check for pattern 5 */ 698 for (s = pat3refsym; *s; s++) 699 if (strcmp(refsymname, *s) == 0) 700 return 1; 701 - 702 - /* Check for pattern 7 */ 703 - if ((strcmp(tosec, ".init.data") == 0) && 704 - (strncmp(fromsec, ".text", strlen(".text")) == 0) && 705 - (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) 706 - return 1; 707 - 708 - /* Check for pattern 8 */ 709 - if ((strcmp(tosec, ".init.text") == 0) && 710 - (strcmp(fromsec, ".paravirtprobe") == 0)) 711 - return 1; 712 - 713 - /* Check for pattern 10 */ 714 - if ((strcmp(fromsec, ".machvec") == 0) || 715 - (strcmp(fromsec, ".machine.desc") == 0)) 716 - return 1; 717 718 return 0; 719 } ··· 713 return relsym; 714 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 715 if (sym->st_shndx != relsym->st_shndx) 716 continue; 717 if (sym->st_value == addr) 718 return sym; ··· 827 elf->strtab + before->st_name, refsymname)) 828 return; 829 830 - /* fromsec whitelist - without a valid 'before' 831 - * powerpc has a GOT table in .got2 section */ 832 - if (strcmp(fromsec, ".got2") == 0) 833 - return; 834 - 835 if (before && after) { 836 warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " 837 "(between '%s' and '%s')\n", ··· 851 modname, fromsec, (unsigned long long)r.r_offset, 852 secname, refsymname); 853 } 854 } 855 856 /** ··· 968 r.r_offset = TO_NATIVE(rela->r_offset); 969 #if KERNEL_ELFCLASS == ELFCLASS64 970 if (hdr->e_machine == EM_MIPS) { 971 r_sym = ELF64_MIPS_R_SYM(rela->r_info); 972 r_sym = TO_NATIVE(r_sym); 973 } else { 974 r.r_info = TO_NATIVE(rela->r_info); 975 r_sym = ELF_R_SYM(r.r_info); ··· 1005 r.r_offset = TO_NATIVE(rel->r_offset); 1006 #if KERNEL_ELFCLASS == ELFCLASS64 1007 if (hdr->e_machine == EM_MIPS) { 1008 r_sym = ELF64_MIPS_R_SYM(rel->r_info); 1009 r_sym = TO_NATIVE(r_sym); 1010 } else { 1011 r.r_info = TO_NATIVE(rel->r_info); 1012 r_sym = ELF_R_SYM(r.r_info); ··· 1019 r_sym = ELF_R_SYM(r.r_info); 1020 #endif 1021 r.r_addend = 0; 1022 sym = elf->symtab_start + r_sym; 1023 /* Skip special sections */ 1024 if (sym->st_shndx >= SHN_LORESERVE) ··· 1046 } 1047 } 1048 } 1049 } 1050 1051 /** ··· 1121 return 0; 1122 } 1123 1124 - /** 1125 * Identify sections from which references to a .init section is OK. 1126 * 1127 * Unfortunately references to read only data that referenced .init ··· 1135 * 1136 * where vgacon_startup is __init. If you want to wade through the false 1137 * positives, take out the check for rodata. 1138 - **/ 1139 static int init_section_ref_ok(const char *name) 1140 { 1141 const char **s; 1142 /* Absolute section names */ 1143 const char *namelist1[] = { 1144 - ".init", 1145 - ".opd", /* see comment [OPD] at exit_section_ref_ok() */ 1146 - ".toc1", /* used by ppc64 */ 1147 - ".stab", 1148 - ".data.rel.ro", /* used by parisc64 */ 1149 - ".parainstructions", 1150 - ".text.lock", 1151 - "__bug_table", /* used by powerpc for BUG() */ 1152 - ".pci_fixup_header", 1153 - ".pci_fixup_final", 1154 - ".pdr", 1155 - "__param", 1156 - "__ex_table", 1157 - ".fixup", 1158 - ".smp_locks", 1159 - ".plt", /* seen on ARCH=um build on x86_64. Harmless */ 1160 "__ftr_fixup", /* powerpc cpu feature fixup */ 1161 "__fw_ftr_fixup", /* powerpc firmware feature fixup */ 1162 - ".cranges", /* used by sh64 */ 1163 NULL 1164 }; 1165 /* Start of section names */ 1166 const char *namelist2[] = { 1167 ".init.", 1168 - ".altinstructions", 1169 - ".eh_frame", 1170 - ".debug", 1171 - ".parainstructions", 1172 ".rodata", 1173 NULL 1174 }; 1175 - /* part of section name */ 1176 - const char *namelist3 [] = { 1177 - ".unwind", /* sample: IA_64.unwind.init.text */ 1178 - NULL 1179 - }; 1180 1181 for (s = namelist1; *s; s++) 1182 if (strcmp(*s, name) == 0) ··· 1167 for (s = namelist2; *s; s++) 1168 if (strncmp(*s, name, strlen(*s)) == 0) 1169 return 1; 1170 - for (s = namelist3; *s; s++) 1171 - if (strstr(name, *s) != NULL) 1172 - return 1; 1173 if (strrcmp(name, ".init") == 0) 1174 return 1; 1175 return 0; ··· 1195 1196 /* 1197 * Identify sections from which references to a .exit section is OK. 1198 - * 1199 - * [OPD] Keith Ownes <kaos@sgi.com> commented: 1200 - * For our future {in}sanity, add a comment that this is the ppc .opd 1201 - * section, not the ia64 .opd section. 1202 - * ia64 .opd should not point to discarded sections. 1203 - * [.rodata] like for .init.text we ignore .rodata references -same reason 1204 - **/ 1205 static int exit_section_ref_ok(const char *name) 1206 { 1207 const char **s; 1208 /* Absolute section names */ 1209 const char *namelist1[] = { 1210 - ".exit.text", 1211 ".exit.data", 1212 - ".init.text", 1213 - ".rodata", 1214 - ".opd", /* See comment [OPD] */ 1215 - ".toc1", /* used by ppc64 */ 1216 - ".altinstructions", 1217 - ".pdr", 1218 - "__bug_table", /* used by powerpc for BUG() */ 1219 ".exitcall.exit", 1220 - ".eh_frame", 1221 - ".parainstructions", 1222 - ".stab", 1223 - "__ex_table", 1224 - ".fixup", 1225 - ".smp_locks", 1226 - ".plt", /* seen on ARCH=um build on x86_64. Harmless */ 1227 - ".cranges", /* used by sh64 */ 1228 - NULL 1229 - }; 1230 - /* Start of section names */ 1231 - const char *namelist2[] = { 1232 - ".debug", 1233 - NULL 1234 - }; 1235 - /* part of section name */ 1236 - const char *namelist3 [] = { 1237 - ".unwind", /* Sample: IA_64.unwind.exit.text */ 1238 NULL 1239 }; 1240 1241 for (s = namelist1; *s; s++) 1242 if (strcmp(*s, name) == 0) 1243 - return 1; 1244 - for (s = namelist2; *s; s++) 1245 - if (strncmp(*s, name, strlen(*s)) == 0) 1246 - return 1; 1247 - for (s = namelist3; *s; s++) 1248 - if (strstr(name, *s) != NULL) 1249 return 1; 1250 return 0; 1251 }
··· 75 else 76 myname = modname; 77 78 + return (strcmp(myname, "vmlinux") == 0) || 79 + (strcmp(myname, "vmlinux.o") == 0); 80 } 81 82 void *do_nofail(void *ptr, const char *expr) ··· 374 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); 375 hdr->e_shnum = TO_NATIVE(hdr->e_shnum); 376 hdr->e_machine = TO_NATIVE(hdr->e_machine); 377 + hdr->e_type = TO_NATIVE(hdr->e_type); 378 sechdrs = (void *)hdr + hdr->e_shoff; 379 info->sechdrs = sechdrs; 380 ··· 384 sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); 385 sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); 386 sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); 387 + sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info); 388 + sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr); 389 } 390 /* Find symbol table. */ 391 for (i = 1; i < hdr->e_shnum; i++) { ··· 605 * warn here. 606 * the pattern is identified by: 607 * tosec = .init.text | .exit.text | .init.data 608 + * fromsec = .data | .data.rel | .data.rel.* 609 + * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer 610 * 611 * Pattern 3: 612 * Whitelist all refereces from .text.head to .init.data 613 * Whitelist all refereces from .text.head to .init.text 614 * 615 + * Pattern 4: 616 * Some symbols belong to init section but still it is ok to reference 617 * these from non-init sections as these symbols don't have any memory 618 * allocated for them and symbol address and value are same. So even ··· 625 * This pattern is identified by 626 * refsymname = __init_begin, _sinittext, _einittext 627 * 628 **/ 629 static int secref_whitelist(const char *modname, const char *tosec, 630 const char *fromsec, const char *atsym, ··· 655 const char *pat2sym[] = { 656 "driver", 657 "_template", /* scsi uses *_template a lot */ 658 + "_timer", /* arm uses ops structures named _timer a lot */ 659 "_sht", /* scsi also used *_sht to some extent */ 660 "_ops", 661 "_probe", 662 "_probe_one", 663 "_console", 664 NULL 665 }; 666 ··· 692 (strcmp(tosec, ".exit.text") != 0) && 693 (strcmp(tosec, ".init.data") != 0)) 694 f2 = 0; 695 + if ((strcmp(fromsec, ".data") != 0) && 696 + (strcmp(fromsec, ".data.rel") != 0) && 697 + (strncmp(fromsec, ".data.rel.", strlen(".data.rel.")) != 0)) 698 f2 = 0; 699 700 for (s = pat2sym; *s; s++) ··· 702 return 1; 703 704 /* Check for pattern 3 */ 705 if ((strcmp(fromsec, ".text.head") == 0) && 706 ((strcmp(tosec, ".init.data") == 0) || 707 (strcmp(tosec, ".init.text") == 0))) 708 return 1; 709 710 + /* Check for pattern 4 */ 711 for (s = pat3refsym; *s; s++) 712 if (strcmp(refsymname, *s) == 0) 713 return 1; 714 715 return 0; 716 } ··· 752 return relsym; 753 for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { 754 if (sym->st_shndx != relsym->st_shndx) 755 + continue; 756 + if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) 757 continue; 758 if (sym->st_value == addr) 759 return sym; ··· 864 elf->strtab + before->st_name, refsymname)) 865 return; 866 867 if (before && after) { 868 warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " 869 "(between '%s' and '%s')\n", ··· 893 modname, fromsec, (unsigned long long)r.r_offset, 894 secname, refsymname); 895 } 896 + } 897 + 898 + static unsigned int *reloc_location(struct elf_info *elf, 899 + int rsection, Elf_Rela *r) 900 + { 901 + Elf_Shdr *sechdrs = elf->sechdrs; 902 + int section = sechdrs[rsection].sh_info; 903 + 904 + return (void *)elf->hdr + sechdrs[section].sh_offset + 905 + (r->r_offset - sechdrs[section].sh_addr); 906 + } 907 + 908 + static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r) 909 + { 910 + unsigned int r_typ = ELF_R_TYPE(r->r_info); 911 + unsigned int *location = reloc_location(elf, rsection, r); 912 + 913 + switch (r_typ) { 914 + case R_386_32: 915 + r->r_addend = TO_NATIVE(*location); 916 + break; 917 + case R_386_PC32: 918 + r->r_addend = TO_NATIVE(*location) + 4; 919 + /* For CONFIG_RELOCATABLE=y */ 920 + if (elf->hdr->e_type == ET_EXEC) 921 + r->r_addend += r->r_offset; 922 + break; 923 + } 924 + return 0; 925 + } 926 + 927 + static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r) 928 + { 929 + unsigned int r_typ = ELF_R_TYPE(r->r_info); 930 + 931 + switch (r_typ) { 932 + case R_ARM_ABS32: 933 + /* From ARM ABI: (S + A) | T */ 934 + r->r_addend = (int)(long)(elf->symtab_start + ELF_R_SYM(r->r_info)); 935 + break; 936 + case R_ARM_PC24: 937 + /* From ARM ABI: ((S + A) | T) - P */ 938 + r->r_addend = (int)(long)(elf->hdr + elf->sechdrs[rsection].sh_offset + 939 + (r->r_offset - elf->sechdrs[rsection].sh_addr)); 940 + break; 941 + default: 942 + return 1; 943 + } 944 + return 0; 945 + } 946 + 947 + static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r) 948 + { 949 + unsigned int r_typ = ELF_R_TYPE(r->r_info); 950 + unsigned int *location = reloc_location(elf, rsection, r); 951 + unsigned int inst; 952 + 953 + if (r_typ == R_MIPS_HI16) 954 + return 1; /* skip this */ 955 + inst = TO_NATIVE(*location); 956 + switch (r_typ) { 957 + case R_MIPS_LO16: 958 + r->r_addend = inst & 0xffff; 959 + break; 960 + case R_MIPS_26: 961 + r->r_addend = (inst & 0x03ffffff) << 2; 962 + break; 963 + case R_MIPS_32: 964 + r->r_addend = inst; 965 + break; 966 + } 967 + return 0; 968 } 969 970 /** ··· 938 r.r_offset = TO_NATIVE(rela->r_offset); 939 #if KERNEL_ELFCLASS == ELFCLASS64 940 if (hdr->e_machine == EM_MIPS) { 941 + unsigned int r_typ; 942 r_sym = ELF64_MIPS_R_SYM(rela->r_info); 943 r_sym = TO_NATIVE(r_sym); 944 + r_typ = ELF64_MIPS_R_TYPE(rela->r_info); 945 + r.r_info = ELF64_R_INFO(r_sym, r_typ); 946 } else { 947 r.r_info = TO_NATIVE(rela->r_info); 948 r_sym = ELF_R_SYM(r.r_info); ··· 972 r.r_offset = TO_NATIVE(rel->r_offset); 973 #if KERNEL_ELFCLASS == ELFCLASS64 974 if (hdr->e_machine == EM_MIPS) { 975 + unsigned int r_typ; 976 r_sym = ELF64_MIPS_R_SYM(rel->r_info); 977 r_sym = TO_NATIVE(r_sym); 978 + r_typ = ELF64_MIPS_R_TYPE(rel->r_info); 979 + r.r_info = ELF64_R_INFO(r_sym, r_typ); 980 } else { 981 r.r_info = TO_NATIVE(rel->r_info); 982 r_sym = ELF_R_SYM(r.r_info); ··· 983 r_sym = ELF_R_SYM(r.r_info); 984 #endif 985 r.r_addend = 0; 986 + switch (hdr->e_machine) { 987 + case EM_386: 988 + if (addend_386_rel(elf, i, &r)) 989 + continue; 990 + break; 991 + case EM_ARM: 992 + if(addend_arm_rel(elf, i, &r)) 993 + continue; 994 + break; 995 + case EM_MIPS: 996 + if (addend_mips_rel(elf, i, &r)) 997 + continue; 998 + break; 999 + } 1000 sym = elf->symtab_start + r_sym; 1001 /* Skip special sections */ 1002 if (sym->st_shndx >= SHN_LORESERVE) ··· 996 } 997 } 998 } 999 + } 1000 + 1001 + /* 1002 + * Identify sections from which references to either a 1003 + * .init or a .exit section is OK. 1004 + * 1005 + * [OPD] Keith Ownes <kaos@sgi.com> commented: 1006 + * For our future {in}sanity, add a comment that this is the ppc .opd 1007 + * section, not the ia64 .opd section. 1008 + * ia64 .opd should not point to discarded sections. 1009 + * [.rodata] like for .init.text we ignore .rodata references -same reason 1010 + */ 1011 + static int initexit_section_ref_ok(const char *name) 1012 + { 1013 + const char **s; 1014 + /* Absolute section names */ 1015 + const char *namelist1[] = { 1016 + "__bug_table", /* used by powerpc for BUG() */ 1017 + "__ex_table", 1018 + ".altinstructions", 1019 + ".cranges", /* used by sh64 */ 1020 + ".fixup", 1021 + ".machvec", /* ia64 + powerpc uses these */ 1022 + ".machine.desc", 1023 + ".opd", /* See comment [OPD] */ 1024 + ".parainstructions", 1025 + ".pdr", 1026 + ".plt", /* seen on ARCH=um build on x86_64. Harmless */ 1027 + ".smp_locks", 1028 + ".stab", 1029 + NULL 1030 + }; 1031 + /* Start of section names */ 1032 + const char *namelist2[] = { 1033 + ".debug", 1034 + ".eh_frame", 1035 + ".note", /* ignore ELF notes - may contain anything */ 1036 + ".got", /* powerpc - global offset table */ 1037 + ".toc", /* powerpc - table of contents */ 1038 + NULL 1039 + }; 1040 + /* part of section name */ 1041 + const char *namelist3 [] = { 1042 + ".unwind", /* Sample: IA_64.unwind.exit.text */ 1043 + NULL 1044 + }; 1045 + 1046 + for (s = namelist1; *s; s++) 1047 + if (strcmp(*s, name) == 0) 1048 + return 1; 1049 + for (s = namelist2; *s; s++) 1050 + if (strncmp(*s, name, strlen(*s)) == 0) 1051 + return 1; 1052 + for (s = namelist3; *s; s++) 1053 + if (strstr(name, *s) != NULL) 1054 + return 1; 1055 + return 0; 1056 } 1057 1058 /** ··· 1014 return 0; 1015 } 1016 1017 + /* 1018 * Identify sections from which references to a .init section is OK. 1019 * 1020 * Unfortunately references to read only data that referenced .init ··· 1028 * 1029 * where vgacon_startup is __init. If you want to wade through the false 1030 * positives, take out the check for rodata. 1031 + */ 1032 static int init_section_ref_ok(const char *name) 1033 { 1034 const char **s; 1035 /* Absolute section names */ 1036 const char *namelist1[] = { 1037 + "__dbe_table", /* MIPS generate these */ 1038 "__ftr_fixup", /* powerpc cpu feature fixup */ 1039 "__fw_ftr_fixup", /* powerpc firmware feature fixup */ 1040 + "__param", 1041 + ".data.rel.ro", /* used by parisc64 */ 1042 + ".init", 1043 + ".text.lock", 1044 NULL 1045 }; 1046 /* Start of section names */ 1047 const char *namelist2[] = { 1048 ".init.", 1049 + ".pci_fixup", 1050 ".rodata", 1051 NULL 1052 }; 1053 + 1054 + if (initexit_section_ref_ok(name)) 1055 + return 1; 1056 1057 for (s = namelist1; *s; s++) 1058 if (strcmp(*s, name) == 0) ··· 1077 for (s = namelist2; *s; s++) 1078 if (strncmp(*s, name, strlen(*s)) == 0) 1079 return 1; 1080 + 1081 + /* If section name ends with ".init" we allow references 1082 + * as is the case with .initcallN.init, .early_param.init, .taglist.init etc 1083 + */ 1084 if (strrcmp(name, ".init") == 0) 1085 return 1; 1086 return 0; ··· 1104 1105 /* 1106 * Identify sections from which references to a .exit section is OK. 1107 + */ 1108 static int exit_section_ref_ok(const char *name) 1109 { 1110 const char **s; 1111 /* Absolute section names */ 1112 const char *namelist1[] = { 1113 ".exit.data", 1114 + ".exit.text", 1115 ".exitcall.exit", 1116 + ".rodata", 1117 NULL 1118 }; 1119 1120 + if (initexit_section_ref_ok(name)) 1121 + return 1; 1122 + 1123 for (s = namelist1; *s; s++) 1124 if (strcmp(*s, name) == 0) 1125 return 1; 1126 return 0; 1127 }
+3
scripts/mod/modpost.h
··· 60 #define ELF64_MIPS_R_SYM(i) \ 61 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) 62 63 #if KERNEL_ELFDATA != HOST_ELFDATA 64 65 static inline void __endian(const void *src, void *dest, unsigned int size)
··· 60 #define ELF64_MIPS_R_SYM(i) \ 61 ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) 62 63 + #define ELF64_MIPS_R_TYPE(i) \ 64 + ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1) 65 + 66 #if KERNEL_ELFDATA != HOST_ELFDATA 67 68 static inline void __endian(const void *src, void *dest, unsigned int size)
+3 -1
usr/gen_init_cpio.c
··· 498 exit(1); 499 } 500 501 - if (! (cpio_list = fopen(argv[1], "r"))) { 502 fprintf(stderr, "ERROR: unable to open '%s': %s\n\n", 503 argv[1], strerror(errno)); 504 usage(argv[0]);
··· 498 exit(1); 499 } 500 501 + if (!strcmp(argv[1], "-")) 502 + cpio_list = stdin; 503 + else if (! (cpio_list = fopen(argv[1], "r"))) { 504 fprintf(stderr, "ERROR: unable to open '%s': %s\n\n", 505 argv[1], strerror(errno)); 506 usage(argv[0]);