From 0ab2a272e6b55e5d58168d6983da99e2dc09b8b2 Mon Sep 17 00:00:00 2001 From: Segher Boessenkool Date: Sat, 19 May 2007 18:49:07 +0200 Subject: kbuild: New 'cc-fullversion' macro Prints a six-digit string including the GCC patchlevel. Also fix the 'usage' comment for cc-version. Signed-off-by: Segher Boessenkool Signed-off-by: Sam Ravnborg --- scripts/Kbuild.include | 7 ++++++- scripts/gcc-version.sh | 15 ++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 06c1a37..677bc6c 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -100,9 +100,14 @@ cc-option-align = $(subst -functions=0,,\ $(call cc-option,-falign-functions=0,-malign-functions=0)) # cc-version -# Usage gcc-ver := $(call cc-version,$(CC)) +# Usage gcc-ver := $(call cc-version) cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC)) +# cc-fullversion +# Usage gcc-ver := $(call cc-fullversion) +cc-fullversion = $(shell $(CONFIG_SHELL) \ + $(srctree)/scripts/gcc-version.sh -p $(CC)) + # cc-ifversion # Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) cc-ifversion = $(shell [ $(call cc-version, $(CC)) $(1) $(2) ] && echo $(3)) diff --git a/scripts/gcc-version.sh b/scripts/gcc-version.sh index bb4fbea..8a1d1879 100644 --- a/scripts/gcc-version.sh +++ b/scripts/gcc-version.sh @@ -1,14 +1,23 @@ #!/bin/sh # -# gcc-version gcc-command +# gcc-version [-p] gcc-command # # Prints the gcc version of `gcc-command' in a canonical 4-digit form # such as `0295' for gcc-2.95, `0303' for gcc-3.3, etc. # +# With the -p option, prints the patchlevel as well, for example `029503' for +# gcc-2.95.3, `030301' for gcc-3.3.1, etc. +# + +if [ $1 = "-p" ] ; then with_patchlevel=1; shift; fi compiler="$*" MAJOR=$(echo __GNUC__ | $compiler -E -xc - | tail -n 1) MINOR=$(echo __GNUC_MINOR__ | $compiler -E -xc - | tail -n 1) -printf "%02d%02d\\n" $MAJOR $MINOR - +if [ "x$with_patchlevel" != "x" ] ; then + PATCHLEVEL=$(echo __GNUC_PATCHLEVEL__ | $compiler -E -xc - | tail -n 1) + printf "%02d%02d%02d\\n" $MAJOR $MINOR $PATCHLEVEL +else + printf "%02d%02d\\n" $MAJOR $MINOR +fi -- cgit v1.1 From d72e5edbf4d13adfe489e9e6114a4922891ddcb2 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 28 May 2007 22:47:48 +0200 Subject: kbuild: avoid environment to set variables used by kbuild A few of the variables used by kbuild has fixed naming. Make sure we do not pick up random values from the environment. Signed-off-by: Sam Ravnborg --- scripts/Makefile.build | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index a525112..3f7b451 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -7,6 +7,22 @@ src := $(obj) PHONY := __build __build: +# Init all relevant variables used in kbuild files so +# 1) they have correct type +# 2) they do not inherit any value from the environment +obj-y := +obj-m := +lib-y := +lib-m := +always := +targets := +subdir-y := +subdir-m := +EXTRA_AFLAGS := +EXTRA_CFLAGS := +EXTRA_CPPFLAGS := +EXTRA_LDFLAGS := + # Read .config if it exist, otherwise ignore -include include/config/auto.conf -- cgit v1.1 From cb3ed5b7e09c6c0462e396d55e3fecc0980a333a Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 25 May 2007 17:58:26 -0700 Subject: scripts: Make cleanfile/cleanpatch warn about long lines Make the "cleanfile" and "cleanpatch" script warn about long lines, by default lines whose visual width exceeds 79 characters. Per suggestion from Auke Kok. Signed-off-by: H. Peter Anvin Signed-off-by: Sam Ravnborg --- scripts/cleanfile | 54 ++++++++++++++++++++++++++++++++++++++++++++++++-- scripts/cleanpatch | 58 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 107 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/cleanfile b/scripts/cleanfile index f1ba8aa..cefd29e 100755 --- a/scripts/cleanfile +++ b/scripts/cleanfile @@ -7,7 +7,9 @@ use bytes; use File::Basename; -# +# Default options +$max_width = 79; + # Clean up space-tab sequences, either by removing spaces or # replacing them with tabs. sub clean_space_tabs($) @@ -48,9 +50,49 @@ sub clean_space_tabs($) return $lo; } +# Compute the visual width of a string +sub strwidth($) { + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($c, $i); + my $pos = 0; + my $mlen = 0; + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li,$i,1); + if ($c eq "\t") { + $pos = ($pos+8) & ~7; + } elsif ($c eq "\n") { + $mlen = $pos if ($pos > $mlen); + $pos = 0; + } else { + $pos++; + } + } + + $mlen = $pos if ($pos > $mlen); + return $mlen; +} + $name = basename($0); -foreach $f ( @ARGV ) { +@files = (); + +while (defined($a = shift(@ARGV))) { + if ($a =~ /^-/) { + if ($a eq '-width' || $a eq '-w') { + $max_width = shift(@ARGV)+0; + } else { + print STDERR "Usage: $name [-width #] files...\n"; + exit 1; + } + } else { + push(@files, $a); + } +} + +foreach $f ( @files ) { print STDERR "$name: $f\n"; if (! -f $f) { @@ -90,8 +132,10 @@ foreach $f ( @ARGV ) { @blanks = (); @lines = (); + $lineno = 0; while ( defined($line = ) ) { + $lineno++; $in_bytes += length($line); $line =~ s/[ \t\r]*$//; # Remove trailing spaces $line = clean_space_tabs($line); @@ -107,6 +151,12 @@ foreach $f ( @ARGV ) { @blanks = (); $blank_bytes = 0; } + + $l_width = strwidth($line); + if ($max_width && $l_width > $max_width) { + print STDERR + "$f:$lineno: line exceeds $max_width characters ($l_width)\n"; + } } # Any blanks at the end of the file are discarded diff --git a/scripts/cleanpatch b/scripts/cleanpatch index a53f987..9680d03 100755 --- a/scripts/cleanpatch +++ b/scripts/cleanpatch @@ -7,7 +7,9 @@ use bytes; use File::Basename; -# +# Default options +$max_width = 79; + # Clean up space-tab sequences, either by removing spaces or # replacing them with tabs. sub clean_space_tabs($) @@ -48,9 +50,49 @@ sub clean_space_tabs($) return $lo; } +# Compute the visual width of a string +sub strwidth($) { + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($c, $i); + my $pos = 0; + my $mlen = 0; + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li,$i,1); + if ($c eq "\t") { + $pos = ($pos+8) & ~7; + } elsif ($c eq "\n") { + $mlen = $pos if ($pos > $mlen); + $pos = 0; + } else { + $pos++; + } + } + + $mlen = $pos if ($pos > $mlen); + return $mlen; +} + $name = basename($0); -foreach $f ( @ARGV ) { +@files = (); + +while (defined($a = shift(@ARGV))) { + if ($a =~ /^-/) { + if ($a eq '-width' || $a eq '-w') { + $max_width = shift(@ARGV)+0; + } else { + print STDERR "Usage: $name [-width #] files...\n"; + exit 1; + } + } else { + push(@files, $a); + } +} + +foreach $f ( @files ) { print STDERR "$name: $f\n"; if (! -f $f) { @@ -86,6 +128,7 @@ foreach $f ( @ARGV ) { $in_bytes = 0; $out_bytes = 0; + $lineno = 0; @lines = (); @@ -93,10 +136,12 @@ foreach $f ( @ARGV ) { $err = 0; while ( defined($line = ) ) { + $lineno++; $in_bytes += length($line); if (!$in_hunk) { - if ($line =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { + if ($line =~ + /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { $minus_lines = $2; $plus_lines = $4; if ($minus_lines || $plus_lines) { @@ -117,6 +162,13 @@ foreach $f ( @ARGV ) { $text =~ s/[ \t\r]*$//; # Remove trailing spaces $text = clean_space_tabs($text); + $l_width = strwidth($text); + if ($max_width && $l_width > $max_width) { + print STDERR + "$f:$lineno: adds line exceeds $max_width ", + "characters ($l_width)\n"; + } + push(@hunk_lines, '+'.$text); } elsif ($line =~ /^\-/) { $minus_lines--; -- cgit v1.1 From e99c343f169cdcb43f1508873a3c9e19ffe4c64a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 23 May 2007 21:37:45 -0400 Subject: kconfig: use POSIX equality test in check-lxdialog.sh The "==" operator is not in POSIX, so use -eq instead. Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg --- scripts/kconfig/lxdialog/check-lxdialog.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/lxdialog/check-lxdialog.sh b/scripts/kconfig/lxdialog/check-lxdialog.sh index cdca738..9681476 100644 --- a/scripts/kconfig/lxdialog/check-lxdialog.sh +++ b/scripts/kconfig/lxdialog/check-lxdialog.sh @@ -51,7 +51,7 @@ usage() { printf "Usage: $0 [-check compiler options|-header|-library]\n" } -if [ $# == 0 ]; then +if [ $# -eq 0 ]; then usage exit 1 fi -- cgit v1.1 From 4c6f2eb979c314b6362e655f3ff15749af565f86 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Thu, 10 May 2007 22:44:28 -0700 Subject: kbuild: add support for squashing uid/gid in gen_initramfs_list.sh Sometimes it is useful to squash all uid's/gid's to 0:0 regardless of current owner. For example, in build systems that get run as arbitrary users (uClinux-dist). This adds a special "squash" keyword so you can do '-g squash -u squash' and have ownership squashed to root. Signed-off-by: Mike Frysinger Cc: Sam Ravnborg Signed-off-by: Andrew Morton --- scripts/gen_initramfs_list.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index 683eb12..684fb9c 100644 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh @@ -19,11 +19,11 @@ $0 [-o ] [-u ] [-g ] {-d | } ... -o Create gzipped initramfs file named using gen_init_cpio and gzip -u User ID to map to user ID 0 (root). - is only meaningful if - is a directory. + is only meaningful if is a + directory. "squash" forces all files to uid 0. -g Group ID to map to group ID 0 (root). - is only meaningful if - is a directory. + is only meaningful if is a + directory. "squash" forces all files to gid 0. File list or directory for cpio archive. If is a .cpio file it will be used as direct input to initramfs. @@ -113,8 +113,8 @@ parse() { local gid="$4" local ftype=$(filetype "${location}") # remap uid/gid to 0 if necessary - [ "$uid" -eq "$root_uid" ] && uid=0 - [ "$gid" -eq "$root_gid" ] && gid=0 + [ "$root_uid" = "squash" ] && uid=0 || [ "$uid" -eq "$root_uid" ] && uid=0 + [ "$root_gid" = "squash" ] && gid=0 || [ "$gid" -eq "$root_gid" ] && gid=0 local str="${mode} ${uid} ${gid}" [ "${ftype}" == "invalid" ] && return 0 -- cgit v1.1 From b70e325cfe824ea0f6a1666b8b8db986e99c9603 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 10 Jun 2007 20:38:27 +0200 Subject: kconfig: fix update-po-config Massimo Maiurana reported that update-po-config was broken: 1) spelling errors in Makefile so arch/um failed 2) UTF-8 was not supported The following patch address the above problems. kxgettext now append the output to the .pot file generated by xgettext - so we have a header. In all places UFT-8 is specifed so we now flawlessly support UTF-8. The Kconfig files had an empty string in a few cases - these are now supressed in kxgettext. With this the translators can now pick up where they left and get it all translated. There are ~11000 strings to be translated... Signed-off-by: Sam Ravnborg Cc: Massimo Maiurana Cc: Arnaldo Carvalho de Melo --- scripts/kconfig/Makefile | 35 ++++++++++++++++++----------------- scripts/kconfig/kxgettext.c | 4 +++- 2 files changed, 21 insertions(+), 18 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index fb2bb30..8986a48 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -22,24 +22,25 @@ oldconfig: $(obj)/conf silentoldconfig: $(obj)/conf $< -s arch/$(ARCH)/Kconfig +# Create new linux.po file +# Adjust charset to UTF-8 in .po file to accept UTF-8 in Kconfig files +# The symlink is used to repair a deficiency in arch/um update-po-config: $(obj)/kxgettext - xgettext --default-domain=linux \ - --add-comments --keyword=_ --keyword=N_ \ - --files-from=scripts/kconfig/POTFILES.in \ - --output scripts/kconfig/config.pot - $(Q)ln -fs Kconfig_i386 arch/um/Kconfig_arch - $(Q)for i in `ls arch/`; \ - do \ - scripts/kconfig/kxgettext arch/$$i/Kconfig \ - | msguniq -o scripts/kconfig/linux_$${i}.pot; \ - done - $(Q)msgcat scripts/kconfig/config.pot \ - `find scripts/kconfig/ -type f -name linux_*.pot` \ - --output scripts/kconfig/linux_raw.pot - $(Q)msguniq --sort-by-file scripts/kconfig/linux_raw.pot \ - --output scripts/kconfig/linux.pot - $(Q)rm -f arch/um/Kconfig_arch - $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot + xgettext --default-domain=linux \ + --add-comments --keyword=_ --keyword=N_ \ + --from-code=UTF-8 \ + --files-from=scripts/kconfig/POTFILES.in \ + --output $(obj)/config.pot + $(Q)sed -i s/CHARSET/UTF-8/ $(obj)/config.pot + $(Q)ln -fs Kconfig.i386 arch/um/Kconfig.arch + (for i in `ls arch/`; \ + do \ + $(obj)/kxgettext arch/$$i/Kconfig; \ + done ) >> $(obj)/config.pot + msguniq --sort-by-file --to-code=UTF-8 $(obj)/config.pot \ + --output $(obj)/linux.pot + $(Q)rm -f arch/um/Kconfig.arch + $(Q)rm -f $(obj)/config.pot PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig diff --git a/scripts/kconfig/kxgettext.c b/scripts/kconfig/kxgettext.c index abee55c..11f7dab 100644 --- a/scripts/kconfig/kxgettext.c +++ b/scripts/kconfig/kxgettext.c @@ -212,7 +212,9 @@ void menu__xgettext(void) struct message *m = message__list; while (m != NULL) { - message__print_gettext_msgid_msgstr(m); + /* skip empty lines ("") */ + if (strlen(m->msg) > sizeof("\"\"")) + message__print_gettext_msgid_msgstr(m); m = m->next; } } -- cgit v1.1 From ae4ac12323c0ff80528cac3269151d580e23f923 Mon Sep 17 00:00:00 2001 From: Atsushi Nemoto Date: Tue, 22 May 2007 18:27:39 +0900 Subject: kbuild: make better section mismatch reports on i386 and mips On i386 and MIPS, warn_sec_mismatch() sometimes fails to show usefull symbol name. This is because empty 'refsym' due to 0 r_addend value. This patch is to adjust r_addend value, consulting with apply_relocate() routine in kernel code. Signed-off-by: Atsushi Nemoto Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/mod/modpost.h | 3 +++ 2 files changed, 76 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3645e98..b83cddb 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -374,6 +374,7 @@ static int parse_elf(struct elf_info *info, const char *filename) hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); hdr->e_shnum = TO_NATIVE(hdr->e_shnum); hdr->e_machine = TO_NATIVE(hdr->e_machine); + hdr->e_type = TO_NATIVE(hdr->e_type); sechdrs = (void *)hdr + hdr->e_shoff; info->sechdrs = sechdrs; @@ -384,6 +385,8 @@ static int parse_elf(struct elf_info *info, const char *filename) sechdrs[i].sh_size = TO_NATIVE(sechdrs[i].sh_size); sechdrs[i].sh_link = TO_NATIVE(sechdrs[i].sh_link); sechdrs[i].sh_name = TO_NATIVE(sechdrs[i].sh_name); + sechdrs[i].sh_info = TO_NATIVE(sechdrs[i].sh_info); + sechdrs[i].sh_addr = TO_NATIVE(sechdrs[i].sh_addr); } /* Find symbol table. */ for (i = 1; i < hdr->e_shnum; i++) { @@ -753,6 +756,8 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { if (sym->st_shndx != relsym->st_shndx) continue; + if (ELF_ST_TYPE(sym->st_info) == STT_SECTION) + continue; if (sym->st_value == addr) return sym; } @@ -895,6 +900,58 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, } } +static unsigned int *reloc_location(struct elf_info *elf, + int rsection, Elf_Rela *r) +{ + Elf_Shdr *sechdrs = elf->sechdrs; + int section = sechdrs[rsection].sh_info; + + return (void *)elf->hdr + sechdrs[section].sh_offset + + (r->r_offset - sechdrs[section].sh_addr); +} + +static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r) +{ + unsigned int r_typ = ELF_R_TYPE(r->r_info); + unsigned int *location = reloc_location(elf, rsection, r); + + switch (r_typ) { + case R_386_32: + r->r_addend = TO_NATIVE(*location); + break; + case R_386_PC32: + r->r_addend = TO_NATIVE(*location) + 4; + /* For CONFIG_RELOCATABLE=y */ + if (elf->hdr->e_type == ET_EXEC) + r->r_addend += r->r_offset; + break; + } + return 0; +} + +static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r) +{ + unsigned int r_typ = ELF_R_TYPE(r->r_info); + unsigned int *location = reloc_location(elf, rsection, r); + unsigned int inst; + + if (r_typ == R_MIPS_HI16) + return 1; /* skip this */ + inst = TO_NATIVE(*location); + switch (r_typ) { + case R_MIPS_LO16: + r->r_addend = inst & 0xffff; + break; + case R_MIPS_26: + r->r_addend = (inst & 0x03ffffff) << 2; + break; + case R_MIPS_32: + r->r_addend = inst; + break; + } + return 0; +} + /** * A module includes a number of sections that are discarded * either when loaded or when used as built-in. @@ -938,8 +995,11 @@ static void check_sec_ref(struct module *mod, const char *modname, r.r_offset = TO_NATIVE(rela->r_offset); #if KERNEL_ELFCLASS == ELFCLASS64 if (hdr->e_machine == EM_MIPS) { + unsigned int r_typ; r_sym = ELF64_MIPS_R_SYM(rela->r_info); r_sym = TO_NATIVE(r_sym); + r_typ = ELF64_MIPS_R_TYPE(rela->r_info); + r.r_info = ELF64_R_INFO(r_sym, r_typ); } else { r.r_info = TO_NATIVE(rela->r_info); r_sym = ELF_R_SYM(r.r_info); @@ -972,8 +1032,11 @@ static void check_sec_ref(struct module *mod, const char *modname, r.r_offset = TO_NATIVE(rel->r_offset); #if KERNEL_ELFCLASS == ELFCLASS64 if (hdr->e_machine == EM_MIPS) { + unsigned int r_typ; r_sym = ELF64_MIPS_R_SYM(rel->r_info); r_sym = TO_NATIVE(r_sym); + r_typ = ELF64_MIPS_R_TYPE(rel->r_info); + r.r_info = ELF64_R_INFO(r_sym, r_typ); } else { r.r_info = TO_NATIVE(rel->r_info); r_sym = ELF_R_SYM(r.r_info); @@ -983,6 +1046,16 @@ static void check_sec_ref(struct module *mod, const char *modname, r_sym = ELF_R_SYM(r.r_info); #endif r.r_addend = 0; + switch (hdr->e_machine) { + case EM_386: + if (addend_386_rel(elf, i, &r)) + continue; + break; + case EM_MIPS: + if (addend_mips_rel(elf, i, &r)) + continue; + break; + } sym = elf->symtab_start + r_sym; /* Skip special sections */ if (sym->st_shndx >= SHN_LORESERVE) diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 0858caa..4156dd3 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -60,6 +60,9 @@ typedef union #define ELF64_MIPS_R_SYM(i) \ ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_sym) +#define ELF64_MIPS_R_TYPE(i) \ + ((__extension__ (_Elf64_Mips_R_Info_union)(i)).r_info_fields.r_type1) + #if KERNEL_ELFDATA != HOST_ELFDATA static inline void __endian(const void *src, void *dest, unsigned int size) -- cgit v1.1 From 56a974fa2d595fe6ebe433c525b8232ead539b76 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 16 Jul 2007 22:39:35 +0200 Subject: kbuild: make better section mismatch reports on arm With this change we can find more symbols hereby improving the readability of the warnings. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index b83cddb..256b3d2 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -929,6 +929,26 @@ static int addend_386_rel(struct elf_info *elf, int rsection, Elf_Rela *r) return 0; } +static int addend_arm_rel(struct elf_info *elf, int rsection, Elf_Rela *r) +{ + unsigned int r_typ = ELF_R_TYPE(r->r_info); + + switch (r_typ) { + case R_ARM_ABS32: + /* From ARM ABI: (S + A) | T */ + r->r_addend = (int)(long)(elf->symtab_start + ELF_R_SYM(r->r_info)); + break; + case R_ARM_PC24: + /* From ARM ABI: ((S + A) | T) - P */ + r->r_addend = (int)(long)(elf->hdr + elf->sechdrs[rsection].sh_offset + + (r->r_offset - elf->sechdrs[rsection].sh_addr)); + break; + default: + return 1; + } + return 0; +} + static int addend_mips_rel(struct elf_info *elf, int rsection, Elf_Rela *r) { unsigned int r_typ = ELF_R_TYPE(r->r_info); @@ -1051,6 +1071,10 @@ static void check_sec_ref(struct module *mod, const char *modname, if (addend_386_rel(elf, i, &r)) continue; break; + case EM_ARM: + if(addend_arm_rel(elf, i, &r)) + continue; + break; case EM_MIPS: if (addend_mips_rel(elf, i, &r)) continue; -- cgit v1.1 From 1abe02fef95366208c264635a886785d18fd38bb Mon Sep 17 00:00:00 2001 From: Stephen Rothwell Date: Thu, 24 May 2007 14:16:13 +1000 Subject: kbuild: suppress modpost warnings for references from the .toc section as used by powerpc We should do better here by effetively "dereferencing" references to the .toc (or the .got2) section, but that is much harder. Signed-off-by: Stephen Rothwell Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 256b3d2..fa33a6b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -870,9 +870,12 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, return; /* fromsec whitelist - without a valid 'before' - * powerpc has a GOT table in .got2 section */ + * powerpc has a GOT table in .got2 section + * and also a .toc section */ if (strcmp(fromsec, ".got2") == 0) return; + if (strcmp(fromsec, ".toc") == 0) + return; if (before && after) { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " -- cgit v1.1 From 1de564bbf8b630ab356571cdbd15b7d5adb1c20d Mon Sep 17 00:00:00 2001 From: Jeremy Fitzhardinge Date: Tue, 29 May 2007 13:33:01 -0700 Subject: kbuild: .paravirtprobe section is obsolete, so modpost doesn't need to handle it The .paravirtprobe section is obsolete, so modpost doesn't need to handle it. Signed-off-by: Jeremy Fitzhardinge Cc: Rusty Russell Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index fa33a6b..ece09c5 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -637,12 +637,6 @@ static int strrcmp(const char *s, const char *sub) * fromsec = .text* * refsymname = logo_ * - * Pattern 8: - * Symbols contained in .paravirtprobe may safely reference .init.text. - * The pattern is: - * tosec = .init.text - * fromsec = .paravirtprobe - * * Pattern 10: * ia64 has machvec table for each platform and * powerpc has a machine desc table for each platform. @@ -726,11 +720,6 @@ static int secref_whitelist(const char *modname, const char *tosec, (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) return 1; - /* Check for pattern 8 */ - if ((strcmp(tosec, ".init.text") == 0) && - (strcmp(fromsec, ".paravirtprobe") == 0)) - return 1; - /* Check for pattern 10 */ if ((strcmp(fromsec, ".machvec") == 0) || (strcmp(fromsec, ".machine.desc") == 0)) -- cgit v1.1 From b28242e7e3c08072251da6d7bc4895fbd3e58299 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 29 May 2007 23:09:35 +0200 Subject: kbuild: ignore section mismatch warnings originating from .note section .note* sections are ELF notes, which are typically used by external tools to examine the kernel image. Since this is removed from any runtime consideration, it's OK to reference any section from a .note* section. Signed-off-by: Jeremy Fitzhardinge Cc: "Eric W. Biederman" Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index ece09c5..9c35f30 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1152,6 +1152,7 @@ static int init_section_ref_ok(const char *name) ".debug", ".parainstructions", ".rodata", + ".note", /* ignore ELF notes - may contain anything */ NULL }; /* part of section name */ @@ -1228,6 +1229,7 @@ static int exit_section_ref_ok(const char *name) /* Start of section names */ const char *namelist2[] = { ".debug", + ".note", /* ignore ELF notes - may contain anything */ NULL }; /* part of section name */ -- cgit v1.1 From 1087247b7d8f1938425906d2ac983df76c6dcc18 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 2 Jun 2007 21:18:51 +0200 Subject: kbuild: refactor code in modpost to improve maintainability There were a great deal of overlap between the two functions that check which sections may reference .init.text and .exit.text. Factor out common check to a separate function and sort entries in the original functions. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 154 ++++++++++++++++++++++++-------------------------- 1 file changed, 75 insertions(+), 79 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 9c35f30..f22c8b4 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -858,14 +858,6 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, elf->strtab + before->st_name, refsymname)) return; - /* fromsec whitelist - without a valid 'before' - * powerpc has a GOT table in .got2 section - * and also a .toc section */ - if (strcmp(fromsec, ".got2") == 0) - return; - if (strcmp(fromsec, ".toc") == 0) - return; - if (before && after) { warn("%s(%s+0x%llx): Section mismatch: reference to %s:%s " "(between '%s' and '%s')\n", @@ -1087,6 +1079,61 @@ static void check_sec_ref(struct module *mod, const char *modname, } } +/* + * Identify sections from which references to either a + * .init or a .exit section is OK. + * + * [OPD] Keith Ownes commented: + * For our future {in}sanity, add a comment that this is the ppc .opd + * section, not the ia64 .opd section. + * ia64 .opd should not point to discarded sections. + * [.rodata] like for .init.text we ignore .rodata references -same reason + **/ +static int initexit_section_ref_ok(const char *name) +{ + const char **s; + /* Absolute section names */ + const char *namelist1[] = { + "__bug_table", /* used by powerpc for BUG() */ + "__ex_table", + ".altinstructions", + ".cranges", /* used by sh64 */ + ".fixup", + ".opd", /* See comment [OPD] */ + ".parainstructions", + ".pdr", + ".plt", /* seen on ARCH=um build on x86_64. Harmless */ + ".smp_locks", + ".stab", + NULL + }; + /* Start of section names */ + const char *namelist2[] = { + ".debug", + ".eh_frame", + ".note", /* ignore ELF notes - may contain anything */ + ".got", /* powerpc - global offset table */ + ".toc", /* powerpc - table of contents */ + NULL + }; + /* part of section name */ + const char *namelist3 [] = { + ".unwind", /* Sample: IA_64.unwind.exit.text */ + NULL + }; + + for (s = namelist1; *s; s++) + if (strcmp(*s, name) == 0) + return 1; + for (s = namelist2; *s; s++) + if (strncmp(*s, name, strlen(*s)) == 0) + return 1; + for (s = namelist3; *s; s++) + if (strstr(name, *s) != NULL) + return 1; + return 0; +} + /** * Functions used only during module init is marked __init and is stored in * a .init.text section. Likewise data is marked __initdata and stored in @@ -1103,7 +1150,7 @@ static int init_section(const char *name) return 0; } -/** +/* * Identify sections from which references to a .init section is OK. * * Unfortunately references to read only data that referenced .init @@ -1117,59 +1164,41 @@ static int init_section(const char *name) * * where vgacon_startup is __init. If you want to wade through the false * positives, take out the check for rodata. - **/ + */ static int init_section_ref_ok(const char *name) { const char **s; /* Absolute section names */ const char *namelist1[] = { - ".init", - ".opd", /* see comment [OPD] at exit_section_ref_ok() */ - ".toc1", /* used by ppc64 */ - ".stab", - ".data.rel.ro", /* used by parisc64 */ - ".parainstructions", - ".text.lock", - "__bug_table", /* used by powerpc for BUG() */ - ".pci_fixup_header", - ".pci_fixup_final", - ".pdr", - "__param", - "__ex_table", - ".fixup", - ".smp_locks", - ".plt", /* seen on ARCH=um build on x86_64. Harmless */ "__ftr_fixup", /* powerpc cpu feature fixup */ "__fw_ftr_fixup", /* powerpc firmware feature fixup */ - ".cranges", /* used by sh64 */ + "__param", + ".data.rel.ro", /* used by parisc64 */ + ".init", + ".text.lock", NULL }; /* Start of section names */ const char *namelist2[] = { ".init.", - ".altinstructions", - ".eh_frame", - ".debug", - ".parainstructions", + ".pci_fixup", ".rodata", - ".note", /* ignore ELF notes - may contain anything */ - NULL - }; - /* part of section name */ - const char *namelist3 [] = { - ".unwind", /* sample: IA_64.unwind.init.text */ NULL }; + if (initexit_section_ref_ok(name)) + return 1; + for (s = namelist1; *s; s++) if (strcmp(*s, name) == 0) return 1; for (s = namelist2; *s; s++) if (strncmp(*s, name, strlen(*s)) == 0) return 1; - for (s = namelist3; *s; s++) - if (strstr(name, *s) != NULL) - return 1; + + /* If section name ends with ".init" we allow references + * as is the case with .initcallN.init, .early_param.init, .taglist.init etc + */ if (strrcmp(name, ".init") == 0) return 1; return 0; @@ -1194,59 +1223,26 @@ static int exit_section(const char *name) /* * Identify sections from which references to a .exit section is OK. - * - * [OPD] Keith Ownes commented: - * For our future {in}sanity, add a comment that this is the ppc .opd - * section, not the ia64 .opd section. - * ia64 .opd should not point to discarded sections. - * [.rodata] like for .init.text we ignore .rodata references -same reason - **/ + */ static int exit_section_ref_ok(const char *name) { const char **s; /* Absolute section names */ const char *namelist1[] = { - ".exit.text", ".exit.data", + ".exit.text", + ".exitcall.exit", ".init.text", ".rodata", - ".opd", /* See comment [OPD] */ - ".toc1", /* used by ppc64 */ - ".altinstructions", - ".pdr", - "__bug_table", /* used by powerpc for BUG() */ - ".exitcall.exit", - ".eh_frame", - ".parainstructions", - ".stab", - "__ex_table", - ".fixup", - ".smp_locks", - ".plt", /* seen on ARCH=um build on x86_64. Harmless */ - ".cranges", /* used by sh64 */ - NULL - }; - /* Start of section names */ - const char *namelist2[] = { - ".debug", - ".note", /* ignore ELF notes - may contain anything */ - NULL - }; - /* part of section name */ - const char *namelist3 [] = { - ".unwind", /* Sample: IA_64.unwind.exit.text */ NULL }; + if (initexit_section_ref_ok(name)) + return 1; + for (s = namelist1; *s; s++) if (strcmp(*s, name) == 0) return 1; - for (s = namelist2; *s; s++) - if (strncmp(*s, name, strlen(*s)) == 0) - return 1; - for (s = namelist3; *s; s++) - if (strstr(name, *s) != NULL) - return 1; return 0; } -- cgit v1.1 From 1d8af559f9ffd6847856f74658e501ed7ded9f01 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 3 Jun 2007 00:41:22 +0200 Subject: kbuild: consolidate section checks Move more checks from whitelist to the section check functions. Remove the redundent pci_fixup check. Renumber the patterns. No functional changes. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 32 +++++++------------------------- 1 file changed, 7 insertions(+), 25 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f22c8b4..1ef7875 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -612,14 +612,10 @@ static int strrcmp(const char *s, const char *sub) * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console * * Pattern 3: - * Whitelist all references from .pci_fixup* section to .init.text - * This is part of the PCI init when built-in - * - * Pattern 4: * Whitelist all refereces from .text.head to .init.data * Whitelist all refereces from .text.head to .init.text * - * Pattern 5: + * Pattern 4: * Some symbols belong to init section but still it is ok to reference * these from non-init sections as these symbols don't have any memory * allocated for them and symbol address and value are same. So even @@ -628,7 +624,7 @@ static int strrcmp(const char *s, const char *sub) * This pattern is identified by * refsymname = __init_begin, _sinittext, _einittext * - * Pattern 7: + * Pattern 5: * Logos used in drivers/video/logo reside in __initdata but the * funtion that references them are EXPORT_SYMBOL() so cannot be * marker __init. So we whitelist them here. @@ -636,12 +632,6 @@ static int strrcmp(const char *s, const char *sub) * tosec = .init.data * fromsec = .text* * refsymname = logo_ - * - * Pattern 10: - * ia64 has machvec table for each platform and - * powerpc has a machine desc table for each platform. - * It is mixture of function pointers of .init.text and .text. - * fromsec = .machvec | .machine.desc **/ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, @@ -699,32 +689,22 @@ static int secref_whitelist(const char *modname, const char *tosec, return 1; /* Check for pattern 3 */ - if ((strncmp(fromsec, ".pci_fixup", strlen(".pci_fixup")) == 0) && - (strcmp(tosec, ".init.text") == 0)) - return 1; - - /* Check for pattern 4 */ if ((strcmp(fromsec, ".text.head") == 0) && ((strcmp(tosec, ".init.data") == 0) || (strcmp(tosec, ".init.text") == 0))) return 1; - /* Check for pattern 5 */ + /* Check for pattern 4 */ for (s = pat3refsym; *s; s++) if (strcmp(refsymname, *s) == 0) return 1; - /* Check for pattern 7 */ + /* Check for pattern 5 */ if ((strcmp(tosec, ".init.data") == 0) && (strncmp(fromsec, ".text", strlen(".text")) == 0) && (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) return 1; - /* Check for pattern 10 */ - if ((strcmp(fromsec, ".machvec") == 0) || - (strcmp(fromsec, ".machine.desc") == 0)) - return 1; - return 0; } @@ -1088,7 +1068,7 @@ static void check_sec_ref(struct module *mod, const char *modname, * section, not the ia64 .opd section. * ia64 .opd should not point to discarded sections. * [.rodata] like for .init.text we ignore .rodata references -same reason - **/ + */ static int initexit_section_ref_ok(const char *name) { const char **s; @@ -1099,6 +1079,8 @@ static int initexit_section_ref_ok(const char *name) ".altinstructions", ".cranges", /* used by sh64 */ ".fixup", + ".machvec", /* ia64 + powerpc uses these */ + ".machine.desc", ".opd", /* See comment [OPD] */ ".parainstructions", ".pdr", -- cgit v1.1 From 6fc53bae3d5940f1b123afa5ad082359b1a376be Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 2 Jun 2007 21:29:20 +0200 Subject: kbuild: warn about references from .init.text to .exit.text The .exit.text section may be discarded either at build or at runtime. So let modpost warn if this situation is detected. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1ef7875..7f5ff7e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1214,7 +1214,6 @@ static int exit_section_ref_ok(const char *name) ".exit.data", ".exit.text", ".exitcall.exit", - ".init.text", ".rodata", NULL }; -- cgit v1.1 From d3ab78560b9a244bdb2ba2ef0e53193832d311c2 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 3 Jun 2007 00:05:10 +0200 Subject: kbuild: remove hardcoded apic_es7000 from modpost Replace the hardcoded variable name apic_es7000 in modpost with a __initdata_refok marker. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 1 - 1 file changed, 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 7f5ff7e..1921c43 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -647,7 +647,6 @@ static int secref_whitelist(const char *modname, const char *tosec, "_probe", "_probe_one", "_console", - "apic_es7000", NULL }; -- cgit v1.1 From 92cc6b0725d800dcc3b9d62b419724050e4f7872 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 3 Jun 2007 00:47:53 +0200 Subject: kbuild: remove hardcoded _logo names from modpost Replaced this with a __init_refok marker in front of fb_find_logo(). I think that the __initdata marker for the logo's are wrong but I have not justified this so I did not remove it. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1921c43..015c6b0 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -624,14 +624,6 @@ static int strrcmp(const char *s, const char *sub) * This pattern is identified by * refsymname = __init_begin, _sinittext, _einittext * - * Pattern 5: - * Logos used in drivers/video/logo reside in __initdata but the - * funtion that references them are EXPORT_SYMBOL() so cannot be - * marker __init. So we whitelist them here. - * The pattern is: - * tosec = .init.data - * fromsec = .text* - * refsymname = logo_ **/ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, @@ -698,12 +690,6 @@ static int secref_whitelist(const char *modname, const char *tosec, if (strcmp(refsymname, *s) == 0) return 1; - /* Check for pattern 5 */ - if ((strcmp(tosec, ".init.data") == 0) && - (strncmp(fromsec, ".text", strlen(".text")) == 0) && - (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) - return 1; - return 0; } -- cgit v1.1 From 1e29a706eef664f2c5014462d435f54a1952cc7b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 3 Jun 2007 22:19:24 +0200 Subject: kbuild: whitelist references from variables named _timer to .init.text arm uses a lot of ops structures named *_timer that has legitimite references to .init.text. So let's add this variable to the list of variables that may reference .init.text without causing any warning. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 015c6b0..bb895b1 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -609,7 +609,7 @@ static int strrcmp(const char *s, const char *sub) * the pattern is identified by: * tosec = .init.text | .exit.text | .init.data * fromsec = .data - * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console + * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer * * Pattern 3: * Whitelist all refereces from .text.head to .init.data @@ -634,6 +634,7 @@ static int secref_whitelist(const char *modname, const char *tosec, const char *pat2sym[] = { "driver", "_template", /* scsi uses *_template a lot */ + "_timer", /* arm uses ops structures named _timer a lot */ "_sht", /* scsi also used *_sht to some extent */ "_ops", "_probe", -- cgit v1.1 From 741f98fe298a73c9d47ed53703c1279a29718581 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 17 Jul 2007 10:54:06 +0200 Subject: kbuild: do section mismatch check on full vmlinux Previously we did do the check on the .o files used to link vmlinux but that failed to find questionable references across the .o files. Create a dedicated vmlinux.o file used only for section mismatch checks that uses the defualt linker script so section does not get renamed. The vmlinux.o may later be used as part of the the final link of vmlinux but for now it is used fo section mismatch only. For a defconfig build this is instant but for an allyesconfig this add two minutes to a full build (that anyways takes ~2 hours). Signed-off-by: Sam Ravnborg --- scripts/Makefile.modpost | 4 ++-- scripts/mod/modpost.c | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index d5bbbcc..c6fcc59 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -70,10 +70,10 @@ __modpost: $(modules:.ko=.o) FORCE $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) quiet_cmd_kernel-mod = MODPOST $@ - cmd_kernel-mod = $(cmd_modpost) $(KBUILD_VMLINUX_OBJS) + cmd_kernel-mod = $(cmd_modpost) $@ PHONY += vmlinux -vmlinux: FORCE +vmlinux.o: FORCE $(call cmd,kernel-mod) # Declare generated files as targets for modpost diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index bb895b1..ec036c2 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -75,7 +75,8 @@ static int is_vmlinux(const char *modname) else myname = modname; - return strcmp(myname, "vmlinux") == 0; + return (strcmp(myname, "vmlinux") == 0) || + (strcmp(myname, "vmlinux.o") == 0); } void *do_nofail(void *ptr, const char *expr) -- cgit v1.1 From a5eb6a502b71ee6bf1a9768b12ff4545cb7a50fe Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 12 Jun 2007 09:29:41 +0200 Subject: modpost white list pattern adjustment gcc puts data into .data.rel or .data.rel.* on some architectures (e.g. ia64) or under certain conditions, so whatever is legal relative to .data should also be legal for those other sections. Fixes a few modpost warnings on ia64. Signed-off-by: Jan Beulich Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index ec036c2..3f3848f 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -609,7 +609,7 @@ static int strrcmp(const char *s, const char *sub) * warn here. * the pattern is identified by: * tosec = .init.text | .exit.text | .init.data - * fromsec = .data + * fromsec = .data | .data.rel | .data.rel.* * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console, *_timer * * Pattern 3: @@ -672,7 +672,9 @@ static int secref_whitelist(const char *modname, const char *tosec, (strcmp(tosec, ".exit.text") != 0) && (strcmp(tosec, ".init.data") != 0)) f2 = 0; - if (strcmp(fromsec, ".data") != 0) + if ((strcmp(fromsec, ".data") != 0) && + (strcmp(fromsec, ".data.rel") != 0) && + (strncmp(fromsec, ".data.rel.", strlen(".data.rel.")) != 0)) f2 = 0; for (s = pat2sym; *s; s++) -- cgit v1.1 From eec73e887a96b50035c92c57e01137dcbe6c5a39 Mon Sep 17 00:00:00 2001 From: Ralf Baechle Date: Tue, 10 Jul 2007 09:16:32 +0100 Subject: Whitelist references from __dbe_table to .init This is needed on MIPS where the same mechanism as get_user() is used to intercept bus error exceptions for some hardware probes. Without this patch modpost will throw spurious warnings: LD vmlinux SYSMAP System.map SYSMAP .tmp_System.map MODPOST vmlinux WARNING: arch/mips/sgi-ip22/built-in.o(__dbe_table+0x0): Section mismatch: reference to .init.text: Signed-off-by: Ralf Baechle Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3f3848f..04579a5 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1141,6 +1141,7 @@ static int init_section_ref_ok(const char *name) const char **s; /* Absolute section names */ const char *namelist1[] = { + "__dbe_table", /* MIPS generate these */ "__ftr_fixup", /* powerpc cpu feature fixup */ "__fw_ftr_fixup", /* powerpc firmware feature fixup */ "__param", -- cgit v1.1 From c05190371d5ca360b75864cfcf930e8bf3addeb1 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 9 Jul 2007 11:43:55 -0700 Subject: kbuild: use POSIX BRE in headers install target The sed expression used at the moment in scripts/Makefile.headersinst relies on the (handy) GNU extension where you can escape ERE's in an otherwise BRE without using the GNU -r option. The following patch replaces this "\+" usage with a functionally equivalent POSIX BRE compliant "\{1,\}". Tested with `make headers_install` against blackfin/x86_64/i386 targets. Stupid whiny OS X users and their crappy sed ;) Signed-off-by: Mike Frysinger Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg --- scripts/Makefile.headersinst | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.headersinst b/scripts/Makefile.headersinst index f98d772..53dae3e 100644 --- a/scripts/Makefile.headersinst +++ b/scripts/Makefile.headersinst @@ -11,13 +11,13 @@ UNIFDEF := scripts/unifdef -U__KERNEL__ # Eliminate the contents of (and inclusions of) compiler.h HDRSED := sed -e "s/ inline / __inline__ /g" \ - -e "s/[[:space:]]__user[[:space:]]\+/ /g" \ - -e "s/(__user[[:space:]]\+/ (/g" \ - -e "s/[[:space:]]__force[[:space:]]\+/ /g" \ - -e "s/(__force[[:space:]]\+/ (/g" \ - -e "s/[[:space:]]__iomem[[:space:]]\+/ /g" \ - -e "s/(__iomem[[:space:]]\+/ (/g" \ - -e "s/[[:space:]]__attribute_const__[[:space:]]\+/\ /g" \ + -e "s/[[:space:]]__user[[:space:]]\{1,\}/ /g" \ + -e "s/(__user[[:space:]]\{1,\}/ (/g" \ + -e "s/[[:space:]]__force[[:space:]]\{1,\}/ /g" \ + -e "s/(__force[[:space:]]\{1,\}/ (/g" \ + -e "s/[[:space:]]__iomem[[:space:]]\{1,\}/ /g" \ + -e "s/(__iomem[[:space:]]\{1,\}/ (/g" \ + -e "s/[[:space:]]__attribute_const__[[:space:]]\{1,\}/\ /g" \ -e "s/[[:space:]]__attribute_const__$$//" \ -e "/^\#include /d" -- cgit v1.1 From 0584f9f9cb3642274cc0f289f36524827868fe68 Mon Sep 17 00:00:00 2001 From: Bernhard Walle Date: Mon, 9 Jul 2007 11:43:56 -0700 Subject: kconfig: strip 'CONFIG_' automatically in kernel configuration search Modify the ncurses configuration tool ('make menuconfig') in a way that the user can enter the search string (/) both with or without the leading 'CONFIG_'. This simplifies using copy & paste from .config files because you can select the whole word. Signed-off-by: Bernhard Walle Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg --- scripts/kconfig/mconf.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index d0e4fa5..d2c2a42 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -419,11 +419,13 @@ static void search_conf(void) { struct symbol **sym_arr; struct gstr res; + char *dialog_input; int dres; again: dialog_clear(); dres = dialog_inputbox(_("Search Configuration Parameter"), - _("Enter CONFIG_ (sub)string to search for (omit CONFIG_)"), + _("Enter CONFIG_ (sub)string to search for " + "(with or without \"CONFIG\")"), 10, 75, ""); switch (dres) { case 0: @@ -435,7 +437,12 @@ again: return; } - sym_arr = sym_re_search(dialog_input_result); + /* strip CONFIG_ if necessary */ + dialog_input = dialog_input_result; + if (strncasecmp(dialog_input_result, "CONFIG_", 7) == 0) + dialog_input += 7; + + sym_arr = sym_re_search(dialog_input); res = get_relations_str(sym_arr); free(sym_arr); show_textbox(_("Search Results"), str_get(&res), 0, 0); -- cgit v1.1 From d8982ba1f2a24f1db89d23e9f5224f932f8b04a0 Mon Sep 17 00:00:00 2001 From: Roman Zippel Date: Mon, 9 Jul 2007 11:43:58 -0700 Subject: kconfig: reset generated values only if Kconfig and .config agree. Normally generated values (Kconfig entries without a prompt) are cleared as they are regenerated anyway and so they appear as new should they become visible and defaults work as expected (once a value is set defaults aren't used anymore). The detection whether a value is generated or not is only based on its visibility status, which can quickly change for a lot of symbols by just removing a single line from .config or adding a dependency to Kconfig as you noticed. The patch now suppresses this logic when .config and Kconfig aren't in sync and .config needs to be updated, so that you can remove now a random value from .config and oldconfig won't reask for many other values. Signed-off-by: Roman Zippel Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg --- scripts/kconfig/confdata.c | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index 664fe29..b2913e9 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -341,27 +341,42 @@ int conf_read(const char *name) conf_unsaved++; /* maybe print value in verbose mode... */ sym_ok: + if (!sym_is_choice(sym)) + continue; + /* The choice symbol only has a set value (and thus is not new) + * if all its visible childs have values. + */ + prop = sym_get_choice_prop(sym); + flags = sym->flags; + for (e = prop->expr; e; e = e->left.expr) + if (e->right.sym->visible != no) + flags &= e->right.sym->flags; + sym->flags &= flags | ~SYMBOL_DEF_USER; + } + + for_all_symbols(i, sym) { if (sym_has_value(sym) && !sym_is_choice_value(sym)) { - if (sym->visible == no) + /* Reset values of generates values, so they'll appear + * as new, if they should become visible, but that + * doesn't quite work if the Kconfig and the saved + * configuration disagree. + */ + if (sym->visible == no && !conf_unsaved) sym->flags &= ~SYMBOL_DEF_USER; switch (sym->type) { case S_STRING: case S_INT: case S_HEX: - if (!sym_string_within_range(sym, sym->def[S_DEF_USER].val)) - sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); + /* Reset a string value if it's out of range */ + if (sym_string_within_range(sym, sym->def[S_DEF_USER].val)) + break; + sym->flags &= ~(SYMBOL_VALID|SYMBOL_DEF_USER); + conf_unsaved++; + break; default: break; } } - if (!sym_is_choice(sym)) - continue; - prop = sym_get_choice_prop(sym); - flags = sym->flags; - for (e = prop->expr; e; e = e->left.expr) - if (e->right.sym->visible != no) - flags &= e->right.sym->flags; - sym->flags &= flags | ~SYMBOL_DEF_USER; } sym_add_change_count(conf_warnings || conf_unsaved); -- cgit v1.1 From 7c5d249ad3fb6ce3815c1ed5f04bece02a3e7030 Mon Sep 17 00:00:00 2001 From: Paulo Marques Date: Wed, 20 Jun 2007 18:09:00 +0100 Subject: kallsyms: remove usage of memmem and _GNU_SOURCE from scripts/kallsyms.c The only in-kernel user of "memmem" is scripts/kallsyms.c and it only uses it to find tokens that are 2 bytes in size. It is trivial to replace it with a simple function that finds 2-byte tokens. This should help users from systems that don't have the memmem GNU extension available. Signed-off-by: Paulo Marques Signed-off-by: Sam Ravnborg --- scripts/kallsyms.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/kallsyms.c b/scripts/kallsyms.c index 8b809b2..caf4c86 100644 --- a/scripts/kallsyms.c +++ b/scripts/kallsyms.c @@ -24,8 +24,6 @@ * */ -#define _GNU_SOURCE - #include #include #include @@ -378,6 +376,17 @@ static void build_initial_tok_table(void) table_cnt = pos; } +static void *find_token(unsigned char *str, int len, unsigned char *token) +{ + int i; + + for (i = 0; i < len - 1; i++) { + if (str[i] == token[0] && str[i+1] == token[1]) + return &str[i]; + } + return NULL; +} + /* replace a given token in all the valid symbols. Use the sampled symbols * to update the counts */ static void compress_symbols(unsigned char *str, int idx) @@ -391,7 +400,7 @@ static void compress_symbols(unsigned char *str, int idx) p1 = table[i].sym; /* find the token on the symbol */ - p2 = memmem(p1, len, str, 2); + p2 = find_token(p1, len, str); if (!p2) continue; /* decrease the counts for this symbol's tokens */ @@ -410,7 +419,7 @@ static void compress_symbols(unsigned char *str, int idx) if (size < 2) break; /* find the token on the symbol */ - p2 = memmem(p1, size, str, 2); + p2 = find_token(p1, size, str); } while (p2); -- cgit v1.1