From 85bd2fddd68e757da8e1af98f857f61a3c9ce647 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 26 Feb 2007 15:33:52 +0100 Subject: kbuild: fix section mismatch check for vmlinux vmlinux does not contain relocation entries which is used by the section mismatch checks. Reported by: Atsushi Nemoto Use the individual objects as inputs to overcome this limitation. In modpost check the .o files and skip non-ELF files. Signed-off-by: Sam Ravnborg --- scripts/Makefile.modpost | 8 ++++---- scripts/mod/modpost.c | 33 +++++++++++++++++++++------------ 2 files changed, 25 insertions(+), 16 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 65e0a79c36cf..d5bbbcce31ef 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -63,16 +63,16 @@ quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ - $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ - $(wildcard vmlinux) $(filter-out FORCE,$^) + $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) PHONY += __modpost __modpost: $(modules:.ko=.o) FORCE - $(call cmd,modpost) + $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) quiet_cmd_kernel-mod = MODPOST $@ - cmd_kernel-mod = $(cmd_modpost) + cmd_kernel-mod = $(cmd_modpost) $(KBUILD_VMLINUX_OBJS) +PHONY += vmlinux vmlinux: FORCE $(call cmd,kernel-mod) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 65bdfdb56877..1912c752e422 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -333,10 +333,10 @@ void release_file(void *file, unsigned long size) munmap(file, size); } -static void parse_elf(struct elf_info *info, const char *filename) +static int parse_elf(struct elf_info *info, const char *filename) { unsigned int i; - Elf_Ehdr *hdr = info->hdr; + Elf_Ehdr *hdr; Elf_Shdr *sechdrs; Elf_Sym *sym; @@ -346,9 +346,18 @@ static void parse_elf(struct elf_info *info, const char *filename) exit(1); } info->hdr = hdr; - if (info->size < sizeof(*hdr)) - goto truncated; - + if (info->size < sizeof(*hdr)) { + /* file too small, assume this is an empty .o file */ + return 0; + } + /* Is this a valid ELF file? */ + if ((hdr->e_ident[EI_MAG0] != ELFMAG0) || + (hdr->e_ident[EI_MAG1] != ELFMAG1) || + (hdr->e_ident[EI_MAG2] != ELFMAG2) || + (hdr->e_ident[EI_MAG3] != ELFMAG3)) { + /* Not an ELF file - silently ignore it */ + return 0; + } /* Fix endianness in ELF header */ hdr->e_shoff = TO_NATIVE(hdr->e_shoff); hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); @@ -371,8 +380,10 @@ static void parse_elf(struct elf_info *info, const char *filename) = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; const char *secname; - if (sechdrs[i].sh_offset > info->size) - goto truncated; + if (sechdrs[i].sh_offset > info->size) { + fatal("%s is truncated. sechdrs[i].sh_offset=%u > sizeof(*hrd)=%ul\n", filename, (unsigned int)sechdrs[i].sh_offset, sizeof(*hdr)); + return 0; + } secname = secstrings + sechdrs[i].sh_name; if (strcmp(secname, ".modinfo") == 0) { info->modinfo = (void *)hdr + sechdrs[i].sh_offset; @@ -407,10 +418,7 @@ static void parse_elf(struct elf_info *info, const char *filename) sym->st_value = TO_NATIVE(sym->st_value); sym->st_size = TO_NATIVE(sym->st_size); } - return; - - truncated: - fatal("%s is truncated.\n", filename); + return 1; } static void parse_elf_finish(struct elf_info *info) @@ -1089,7 +1097,8 @@ static void read_symbols(char *modname) struct elf_info info = { }; Elf_Sym *sym; - parse_elf(&info, modname); + if (!parse_elf(&info, modname)) + return; mod = new_module(modname); -- cgit v1.2.3 From aae5f662a32c35b1a962627535acb588d48ff5f9 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 26 Feb 2007 16:45:41 +0100 Subject: kbuild: whitelist section mismatch in init/main.c In init/main.c we have a reference from rest_init() to .init.text which is intentional. Rename the function 'init' to 'kernel_init' to make it a kernel wide unique symbol and whitelist the reference. Signed-off-by: Sam Ravnborg --- init/main.c | 6 +++--- scripts/mod/modpost.c | 15 ++++++++++++++- 2 files changed, 17 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/init/main.c b/init/main.c index a92989e7836a..7a92b4ca3aad 100644 --- a/init/main.c +++ b/init/main.c @@ -82,7 +82,7 @@ #warning gcc-4.1.0 is known to miscompile the kernel. A different compiler version is recommended. #endif -static int init(void *); +static int kernel_init(void *); extern void init_IRQ(void); extern void fork_init(unsigned long); @@ -435,7 +435,7 @@ static void __init setup_command_line(char *command_line) static void noinline rest_init(void) __releases(kernel_lock) { - kernel_thread(init, NULL, CLONE_FS | CLONE_SIGHAND); + kernel_thread(kernel_init, NULL, CLONE_FS | CLONE_SIGHAND); numa_default_policy(); unlock_kernel(); @@ -772,7 +772,7 @@ static int noinline init_post(void) panic("No init found. Try passing init= option to kernel."); } -static int __init init(void * unused) +static int __init kernel_init(void * unused) { lock_kernel(); /* diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 1912c752e422..be0827f734c2 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -589,7 +589,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 + * atsym = *driver, *_template, *_sht, *_ops, *_probe, *probe_one, *_console * * Pattern 3: * Some symbols belong to init section but still it is ok to reference @@ -599,6 +599,14 @@ static int strrcmp(const char *s, const char *sub) * For ex. symbols marking the init section boundaries. * This pattern is identified by * refsymname = __init_begin, _sinittext, _einittext + * Pattern 4: + * During the early init phase we have references from .init.text to + * .text we have an intended section mismatch - do not warn about it. + * See kernel_init() in init/main.c + * tosec = .init.text + * fromsec = .text + * atsym = kernel_init + * Some symbols belong to init section but still it is ok to reference **/ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, @@ -668,6 +676,11 @@ static int secref_whitelist(const char *modname, const char *tosec, if (strcmp(refsymname, *s) == 0) return 1; } + /* Check for pattern 4 */ + if ((strcmp(tosec, ".init.text") == 0) && + (strcmp(fromsec, ".text") == 0) && + (strcmp(refsymname, "kernel_init") == 0)) + return 1; return 0; } -- cgit v1.2.3 From 9bf8cb9b7908383752b1842eae78269f7e16d9fb Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 26 Feb 2007 17:49:06 +0100 Subject: kbuild: fix warnings from .pci_fixup section Now where we do not pass vmlinux to modpost we started to see section mismatch warnings from .pci_fixup. Refactored code a little to include these in the whitelist again. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index be0827f734c2..e1f2b31cf34b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -592,6 +592,14 @@ 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: * 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 @@ -599,7 +607,8 @@ static int strrcmp(const char *s, const char *sub) * For ex. symbols marking the init section boundaries. * This pattern is identified by * refsymname = __init_begin, _sinittext, _einittext - * Pattern 4: + * + * Pattern 6: * During the early init phase we have references from .init.text to * .text we have an intended section mismatch - do not warn about it. * See kernel_init() in init/main.c @@ -657,26 +666,23 @@ static int secref_whitelist(const char *modname, const char *tosec, if (f1 && f2) return 1; - /* Whitelist all references from .pci_fixup section if vmlinux - * Whitelist all refereces from .text.head to .init.data if vmlinux - * Whitelist all refereces from .text.head to .init.text if vmlinux - */ - if (is_vmlinux(modname)) { - if ((strcmp(fromsec, ".pci_fixup") == 0) && - (strcmp(tosec, ".init.text") == 0)) - return 1; - - if ((strcmp(fromsec, ".text.head") == 0) && - ((strcmp(tosec, ".init.data") == 0) || - (strcmp(tosec, ".init.text") == 0))) - 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 3 */ - for (s = pat3refsym; *s; s++) - if (strcmp(refsymname, *s) == 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 */ + for (s = pat3refsym; *s; s++) + if (strcmp(refsymname, *s) == 0) + return 1; + + /* Check for pattern 6 */ if ((strcmp(tosec, ".init.text") == 0) && (strcmp(fromsec, ".text") == 0) && (strcmp(refsymname, "kernel_init") == 0)) -- cgit v1.2.3 From a61b2dfd1823506dbf1f9b046e0b09237ec1b985 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Mon, 26 Feb 2007 19:46:52 +0100 Subject: kbuild: fix segmentation fault in modpost If modpost was called manually with filenames without '/' then modpost would segfault. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index e1f2b31cf34b..281abb77e033 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1345,6 +1345,7 @@ static void add_depends(struct buffer *b, struct module *mod, buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n"); buf_printf(b, "\"depends="); for (s = mod->unres; s; s = s->next) { + const char *p; if (!s->module) continue; @@ -1352,8 +1353,11 @@ static void add_depends(struct buffer *b, struct module *mod, continue; s->module->seen = 1; - buf_printf(b, "%s%s", first ? "" : ",", - strrchr(s->module->name, '/') + 1); + if ((p = strrchr(s->module->name, '/')) != NULL) + p++; + else + p = s->module->name; + buf_printf(b, "%s%s", first ? "" : ",", p); first = 0; } buf_printf(b, "\";\n"); -- cgit v1.2.3 From 5a4910fbbeef14cc91daa41086449a1a4acebc96 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 27 Feb 2007 09:14:58 +0100 Subject: kbuild: whitelist logo references from .text to .init.data drivers/video/logo has references from .text to .init.data but function is only used during early init. So reference is OK and we do not want to warn about them => whitelist the reference. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 281abb77e033..5f2ecd51bde3 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -616,6 +616,15 @@ static int strrcmp(const char *s, const char *sub) * fromsec = .text * atsym = kernel_init * Some symbols belong to init section but still it is ok to reference + * + * Pattern 7: + * 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, @@ -687,6 +696,12 @@ static int secref_whitelist(const char *modname, const char *tosec, (strcmp(fromsec, ".text") == 0) && (strcmp(refsymname, "kernel_init") == 0)) return 1; + + /* Check for pattern 7 */ + if ((strcmp(tosec, ".init.data") == 0) && + (strncmp(fromsec, ".text", strlen(".text")) == 0) && + (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) + return 1; return 0; } -- cgit v1.2.3 From dc24f0e708c8a6a27b5b967a2599c04973054398 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 9 Mar 2007 19:59:06 +0100 Subject: kbuild: remove dependency on input.h from file2alias Almost all definitions used by file2alias was already present in mod_devicetable.h. Added the last definition and killed the input.h usage. The errornous include was pointed out by: Jan Engelhardt Signed-off-by: Sam Ravnborg Cc: Jan Engelhardt Cc: Deepak Saxena --- include/linux/input.h | 4 ++++ include/linux/mod_devicetable.h | 1 + scripts/mod/file2alias.c | 21 +++++++++++---------- 3 files changed, 16 insertions(+), 10 deletions(-) (limited to 'scripts') diff --git a/include/linux/input.h b/include/linux/input.h index bde65c8a3519..13d510c3a5aa 100644 --- a/include/linux/input.h +++ b/include/linux/input.h @@ -1010,6 +1010,10 @@ struct input_dev { #error "EV_MAX and INPUT_DEVICE_ID_EV_MAX do not match" #endif +#if KEY_MIN_INTERESTING != INPUT_DEVICE_ID_KEY_MIN_INTERESTING +#error "KEY_MIN_INTERESTING and INPUT_DEVICE_ID_KEY_MIN_INTERESTING do not match" +#endif + #if KEY_MAX != INPUT_DEVICE_ID_KEY_MAX #error "KEY_MAX and INPUT_DEVICE_ID_KEY_MAX do not match" #endif diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index e96b2dee10bb..af04a555b52c 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -262,6 +262,7 @@ struct i2c_device_id { /* Input */ #define INPUT_DEVICE_ID_EV_MAX 0x1f +#define INPUT_DEVICE_ID_KEY_MIN_INTERESTING 0x71 #define INPUT_DEVICE_ID_KEY_MAX 0x1ff #define INPUT_DEVICE_ID_REL_MAX 0x0f #define INPUT_DEVICE_ID_ABS_MAX 0x3f diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index b2f73ffb40bd..ed1244dd58d0 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -37,7 +37,6 @@ typedef unsigned char __u8; * even potentially has different endianness and word sizes, since * we handle those differences explicitly below */ #include "../../include/linux/mod_devicetable.h" -#include "../../include/linux/input.h" #define ADD(str, sep, cond, field) \ do { \ @@ -416,31 +415,33 @@ static int do_input_entry(const char *filename, struct input_device_id *id, sprintf(alias + strlen(alias), "-e*"); if (id->flags & INPUT_DEVICE_ID_MATCH_EVBIT) - do_input(alias, id->evbit, 0, EV_MAX); + do_input(alias, id->evbit, 0, INPUT_DEVICE_ID_EV_MAX); sprintf(alias + strlen(alias), "k*"); if (id->flags & INPUT_DEVICE_ID_MATCH_KEYBIT) - do_input(alias, id->keybit, KEY_MIN_INTERESTING, KEY_MAX); + do_input(alias, id->keybit, + INPUT_DEVICE_ID_KEY_MIN_INTERESTING, + INPUT_DEVICE_ID_KEY_MAX); sprintf(alias + strlen(alias), "r*"); if (id->flags & INPUT_DEVICE_ID_MATCH_RELBIT) - do_input(alias, id->relbit, 0, REL_MAX); + do_input(alias, id->relbit, 0, INPUT_DEVICE_ID_REL_MAX); sprintf(alias + strlen(alias), "a*"); if (id->flags & INPUT_DEVICE_ID_MATCH_ABSBIT) - do_input(alias, id->absbit, 0, ABS_MAX); + do_input(alias, id->absbit, 0, INPUT_DEVICE_ID_ABS_MAX); sprintf(alias + strlen(alias), "m*"); if (id->flags & INPUT_DEVICE_ID_MATCH_MSCIT) - do_input(alias, id->mscbit, 0, MSC_MAX); + do_input(alias, id->mscbit, 0, INPUT_DEVICE_ID_MSC_MAX); sprintf(alias + strlen(alias), "l*"); if (id->flags & INPUT_DEVICE_ID_MATCH_LEDBIT) - do_input(alias, id->ledbit, 0, LED_MAX); + do_input(alias, id->ledbit, 0, INPUT_DEVICE_ID_LED_MAX); sprintf(alias + strlen(alias), "s*"); if (id->flags & INPUT_DEVICE_ID_MATCH_SNDBIT) - do_input(alias, id->sndbit, 0, SND_MAX); + do_input(alias, id->sndbit, 0, INPUT_DEVICE_ID_SND_MAX); sprintf(alias + strlen(alias), "f*"); if (id->flags & INPUT_DEVICE_ID_MATCH_FFBIT) - do_input(alias, id->ffbit, 0, FF_MAX); + do_input(alias, id->ffbit, 0, INPUT_DEVICE_ID_FF_MAX); sprintf(alias + strlen(alias), "w*"); if (id->flags & INPUT_DEVICE_ID_MATCH_SWBIT) - do_input(alias, id->swbit, 0, SW_MAX); + do_input(alias, id->swbit, 0, INPUT_DEVICE_ID_SW_MAX); return 1; } -- cgit v1.2.3 From 12b315603a1eb95b4e4ea3389ba44bd7ded0aa35 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Mon, 12 Mar 2007 12:16:30 -0700 Subject: cleanfile: a script to clean up stealth whitespace This script cleans up various classes of stealth whitespace. In particular, it cleans up: - Whitespace (spaces or tabs)before newline; - DOS line endings (CR before LF); - Space before tab (spaces are deleted or converted to tabs); - Empty lines at end of file. Signed-off-by: H. Peter Anvin Signed-off-by: Sam Ravnborg --- scripts/cleanfile | 126 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 126 insertions(+) create mode 100755 scripts/cleanfile (limited to 'scripts') diff --git a/scripts/cleanfile b/scripts/cleanfile new file mode 100755 index 000000000000..f1ba8aa58a40 --- /dev/null +++ b/scripts/cleanfile @@ -0,0 +1,126 @@ +#!/usr/bin/perl -w +# +# Clean a text file -- or directory of text files -- of stealth whitespace. +# WARNING: this can be a highly destructive operation. Use with caution. +# + +use bytes; +use File::Basename; + +# +# Clean up space-tab sequences, either by removing spaces or +# replacing them with tabs. +sub clean_space_tabs($) +{ + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($lo) = ''; + my $pos = 0; + my $nsp = 0; + my($i, $c); + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li, $i, 1); + if ($c eq "\t") { + my $npos = ($pos+$nsp+8) & ~7; + my $ntab = ($npos >> 3) - ($pos >> 3); + $lo .= "\t" x $ntab; + $pos = $npos; + $nsp = 0; + } elsif ($c eq "\n" || $c eq "\r") { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos = 0; + } elsif ($c eq " ") { + $nsp++; + } else { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos++; + } + } + $lo .= " " x $nsp; + return $lo; +} + +$name = basename($0); + +foreach $f ( @ARGV ) { + print STDERR "$name: $f\n"; + + if (! -f $f) { + print STDERR "$f: not a file\n"; + next; + } + + if (!open(FILE, '+<', $f)) { + print STDERR "$name: Cannot open file: $f: $!\n"; + next; + } + + binmode FILE; + + # First, verify that it is not a binary file; consider any file + # with a zero byte to be a binary file. Is there any better, or + # additional, heuristic that should be applied? + $is_binary = 0; + + while (read(FILE, $data, 65536) > 0) { + if ($data =~ /\0/) { + $is_binary = 1; + last; + } + } + + if ($is_binary) { + print STDERR "$name: $f: binary file\n"; + next; + } + + seek(FILE, 0, 0); + + $in_bytes = 0; + $out_bytes = 0; + $blank_bytes = 0; + + @blanks = (); + @lines = (); + + while ( defined($line = ) ) { + $in_bytes += length($line); + $line =~ s/[ \t\r]*$//; # Remove trailing spaces + $line = clean_space_tabs($line); + + if ( $line eq "\n" ) { + push(@blanks, $line); + $blank_bytes += length($line); + } else { + push(@lines, @blanks); + $out_bytes += $blank_bytes; + push(@lines, $line); + $out_bytes += length($line); + @blanks = (); + $blank_bytes = 0; + } + } + + # Any blanks at the end of the file are discarded + + if ($in_bytes != $out_bytes) { + # Only write to the file if changed + seek(FILE, 0, 0); + print FILE @lines; + + if ( !defined($where = tell(FILE)) || + !truncate(FILE, $where) ) { + die "$name: Failed to truncate modified file: $f: $!\n"; + } + } + + close(FILE); +} -- cgit v1.2.3 From 6e019b001d27c4289f8e48ebc458e92410446259 Mon Sep 17 00:00:00 2001 From: "H. Peter Anvin" Date: Fri, 16 Mar 2007 14:45:06 -0700 Subject: cleanpatch: a script to clean up stealth whitespace added by a patch This script is a companion to the "cleanfile" script. This cleans up a patch in unified diff format *before* it is applied. Note that the empty lines at the end of file detection *requires* that the diff was taken with at least one line of context around each hunk, or bad things will happen. This script cleans up various classes of stealth whitespace. In particular, it cleans up: - Whitespace (spaces or tabs)before newline; - DOS line endings (CR before LF); - Space before tab (spaces are deleted or converted to tabs); - Empty lines at end of file. Signed-off-by: H. Peter Anvin Signed-off-by: Sam Ravnborg --- scripts/cleanpatch | 206 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 206 insertions(+) create mode 100755 scripts/cleanpatch (limited to 'scripts') diff --git a/scripts/cleanpatch b/scripts/cleanpatch new file mode 100755 index 000000000000..a53f987708f5 --- /dev/null +++ b/scripts/cleanpatch @@ -0,0 +1,206 @@ +#!/usr/bin/perl -w +# +# Clean a patch file -- or directory of patch files -- of stealth whitespace. +# WARNING: this can be a highly destructive operation. Use with caution. +# + +use bytes; +use File::Basename; + +# +# Clean up space-tab sequences, either by removing spaces or +# replacing them with tabs. +sub clean_space_tabs($) +{ + no bytes; # Tab alignment depends on characters + + my($li) = @_; + my($lo) = ''; + my $pos = 0; + my $nsp = 0; + my($i, $c); + + for ($i = 0; $i < length($li); $i++) { + $c = substr($li, $i, 1); + if ($c eq "\t") { + my $npos = ($pos+$nsp+8) & ~7; + my $ntab = ($npos >> 3) - ($pos >> 3); + $lo .= "\t" x $ntab; + $pos = $npos; + $nsp = 0; + } elsif ($c eq "\n" || $c eq "\r") { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos = 0; + } elsif ($c eq " ") { + $nsp++; + } else { + $lo .= " " x $nsp; + $pos += $nsp; + $nsp = 0; + $lo .= $c; + $pos++; + } + } + $lo .= " " x $nsp; + return $lo; +} + +$name = basename($0); + +foreach $f ( @ARGV ) { + print STDERR "$name: $f\n"; + + if (! -f $f) { + print STDERR "$f: not a file\n"; + next; + } + + if (!open(FILE, '+<', $f)) { + print STDERR "$name: Cannot open file: $f: $!\n"; + next; + } + + binmode FILE; + + # First, verify that it is not a binary file; consider any file + # with a zero byte to be a binary file. Is there any better, or + # additional, heuristic that should be applied? + $is_binary = 0; + + while (read(FILE, $data, 65536) > 0) { + if ($data =~ /\0/) { + $is_binary = 1; + last; + } + } + + if ($is_binary) { + print STDERR "$name: $f: binary file\n"; + next; + } + + seek(FILE, 0, 0); + + $in_bytes = 0; + $out_bytes = 0; + + @lines = (); + + $in_hunk = 0; + $err = 0; + + while ( defined($line = ) ) { + $in_bytes += length($line); + + if (!$in_hunk) { + if ($line =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@/) { + $minus_lines = $2; + $plus_lines = $4; + if ($minus_lines || $plus_lines) { + $in_hunk = 1; + @hunk_lines = ($line); + } + } else { + push(@lines, $line); + $out_bytes += length($line); + } + } else { + # We're in a hunk + + if ($line =~ /^\+/) { + $plus_lines--; + + $text = substr($line, 1); + $text =~ s/[ \t\r]*$//; # Remove trailing spaces + $text = clean_space_tabs($text); + + push(@hunk_lines, '+'.$text); + } elsif ($line =~ /^\-/) { + $minus_lines--; + push(@hunk_lines, $line); + } elsif ($line =~ /^ /) { + $plus_lines--; + $minus_lines--; + push(@hunk_lines, $line); + } else { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + last; + } + + if ($plus_lines < 0 || $minus_lines < 0) { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + last; + } elsif ($plus_lines == 0 && $minus_lines == 0) { + # End of a hunk. Process this hunk. + my $i; + my $l; + my @h = (); + my $adj = 0; + my $done = 0; + + for ($i = scalar(@hunk_lines)-1; $i > 0; $i--) { + $l = $hunk_lines[$i]; + if (!$done && $l eq "+\n") { + $adj++; # Skip this line + } elsif ($l =~ /^[ +]/) { + $done = 1; + unshift(@h, $l); + } else { + unshift(@h, $l); + } + } + + $l = $hunk_lines[0]; # Hunk header + undef @hunk_lines; # Free memory + + if ($adj) { + die unless + ($l =~ /^\@\@\s+\-([0-9]+),([0-9]+)\s+\+([0-9]+),([0-9]+)\s\@\@(.*)$/); + my $mstart = $1; + my $mlin = $2; + my $pstart = $3; + my $plin = $4; + my $tail = $5; # doesn't include the final newline + + $l = sprintf("@@ -%d,%d +%d,%d @@%s\n", + $mstart, $mlin, $pstart, $plin-$adj, + $tail); + } + unshift(@h, $l); + + # Transfer to the output array + foreach $l (@h) { + $out_bytes += length($l); + push(@lines, $l); + } + + $in_hunk = 0; + } + } + } + + if ($in_hunk) { + print STDERR "$name: $f: malformed patch\n"; + $err = 1; + } + + if (!$err) { + if ($in_bytes != $out_bytes) { + # Only write to the file if changed + seek(FILE, 0, 0); + print FILE @lines; + + if ( !defined($where = tell(FILE)) || + !truncate(FILE, $where) ) { + die "$name: Failed to truncate modified file: $f: $!\n"; + } + } + } + + close(FILE); +} -- cgit v1.2.3 From f88d205501e35195444bdd41983e26546af3f56a Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Sat, 17 Mar 2007 02:37:07 -0400 Subject: menuconfig: dont use obsolete index() function in lxdialog The index() function is obsolete, use strchr() instead. Signed-off-by: Mike Frysinger Signed-off-by: Sam Ravnborg --- scripts/kconfig/lxdialog/util.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index d54440fc166c..a1a1354ba238 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -336,7 +336,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) newl = 1; word = tempstr; while (word && *word) { - sp = index(word, ' '); + sp = strchr(word, ' '); if (sp) *sp++ = 0; @@ -348,7 +348,7 @@ void print_autowrap(WINDOW * win, const char *prompt, int width, int y, int x) if (wlen > room || (newl && wlen < 4 && sp && wlen + 1 + strlen(sp) > room - && (!(sp2 = index(sp, ' ')) + && (!(sp2 = strchr(sp, ' ')) || wlen + 1 + (sp2 - sp) > room))) { cur_y++; cur_x = x; -- cgit v1.2.3 From 63431e75691c410819023ab0e6cd047cbfcf64e2 Mon Sep 17 00:00:00 2001 From: Marco Costalba Date: Thu, 5 Oct 2006 19:12:59 +0200 Subject: kconfig/xconfig: sync main view with search dialog current menu When changing current menu in search dialog update also main view Signed-off-by: Marco Costalba Signed-off-by: Sam Ravnborg --- scripts/kconfig/qconf.cc | 5 ++++- scripts/kconfig/qconf.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/qconf.cc b/scripts/kconfig/qconf.cc index 512c2f5c341d..f2a23a9c3938 100644 --- a/scripts/kconfig/qconf.cc +++ b/scripts/kconfig/qconf.cc @@ -1182,7 +1182,7 @@ void ConfigInfoView::contentsContextMenuEvent(QContextMenuEvent *e) Parent::contentsContextMenuEvent(e); } -ConfigSearchWindow::ConfigSearchWindow(QWidget* parent, const char *name) +ConfigSearchWindow::ConfigSearchWindow(ConfigMainWindow* parent, const char *name) : Parent(parent, name), result(NULL) { setCaption("Search Config"); @@ -1206,6 +1206,9 @@ ConfigSearchWindow::ConfigSearchWindow(QWidget* parent, const char *name) info = new ConfigInfoView(split, name); connect(list->list, SIGNAL(menuChanged(struct menu *)), info, SLOT(setInfo(struct menu *))); + connect(list->list, SIGNAL(menuChanged(struct menu *)), + parent, SLOT(setMenuLink(struct menu *))); + layout1->addWidget(split); if (name) { diff --git a/scripts/kconfig/qconf.h b/scripts/kconfig/qconf.h index 6fc1c5f14425..b3b5657b6b35 100644 --- a/scripts/kconfig/qconf.h +++ b/scripts/kconfig/qconf.h @@ -279,7 +279,7 @@ class ConfigSearchWindow : public QDialog { Q_OBJECT typedef class QDialog Parent; public: - ConfigSearchWindow(QWidget* parent, const char *name = 0); + ConfigSearchWindow(ConfigMainWindow* parent, const char *name = 0); public slots: void saveSettings(void); -- cgit v1.2.3 From 2a11665945d510e1a4df8dc44dc3668b01945ade Mon Sep 17 00:00:00 2001 From: Matthew Wilcox Date: Sat, 7 Oct 2006 05:35:32 -0600 Subject: kbuild: distinguish between errors and warnings in modpost Some of modpost's warnings are fatal, and some are not. Adopt the compiler distinction between errors and warnings by calling merror() for fatal diagnostics and warn() for non-fatal ones. merror() was used as replacemtn for error() to avoid clash with glibc Signed-off-by: Matthew Wilcox Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 22 +++++++++++++++++++--- scripts/mod/modpost.h | 1 + 2 files changed, 20 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5f2ecd51bde3..b10b69b56a31 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -55,6 +55,17 @@ void warn(const char *fmt, ...) va_end(arglist); } +void merror(const char *fmt, ...) +{ + va_list arglist; + + fprintf(stderr, "ERROR: "); + + va_start(arglist, fmt); + vfprintf(stderr, fmt, arglist); + va_end(arglist); +} + static int is_vmlinux(const char *modname) { const char *myname; @@ -1307,9 +1318,14 @@ static int add_versions(struct buffer *b, struct module *mod) exp = find_symbol(s->name); if (!exp || exp->module == mod) { if (have_vmlinux && !s->weak) { - warn("\"%s\" [%s.ko] undefined!\n", - s->name, mod->name); - err = warn_unresolved ? 0 : 1; + if (warn_unresolved) { + warn("\"%s\" [%s.ko] undefined!\n", + s->name, mod->name); + } else { + merror("\"%s\" [%s.ko] undefined!\n", + s->name, mod->name); + err = 1; + } } continue; } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index d398c61e55ef..0858caa9c03f 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -145,3 +145,4 @@ void release_file(void *file, unsigned long size); void fatal(const char *fmt, ...); void warn(const char *fmt, ...); +void merror(const char *fmt, ...); -- cgit v1.2.3 From 95e30f9593ebf39e26227a20ae8d9f160c50fb67 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 18 Mar 2007 10:48:46 +0100 Subject: menuconfig: remember alternate config filename When loading an alternate configuration use that file as current configuration filename. Make the filename visible in the dialog. Default continue to be .config. Inspired by patch from: Cyrill Gorcunov Signed-off-by: Sam Ravnborg Cc: Cyrill Gorcunov --- scripts/kconfig/lxdialog/dialog.h | 1 + scripts/kconfig/lxdialog/util.c | 5 +++++ scripts/kconfig/mconf.c | 43 ++++++++++++++++++++++++++++----------- 3 files changed, 37 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/lxdialog/dialog.h b/scripts/kconfig/lxdialog/dialog.h index fd695e1070f7..7e17eba75ae8 100644 --- a/scripts/kconfig/lxdialog/dialog.h +++ b/scripts/kconfig/lxdialog/dialog.h @@ -188,6 +188,7 @@ int on_key_esc(WINDOW *win); int on_key_resize(void); void init_dialog(const char *backtitle); +void set_dialog_backtitle(const char *backtitle); void reset_dialog(void); void end_dialog(void); void attr_clear(WINDOW * win, int height, int width, chtype attr); diff --git a/scripts/kconfig/lxdialog/util.c b/scripts/kconfig/lxdialog/util.c index a1a1354ba238..a1bddefe73d0 100644 --- a/scripts/kconfig/lxdialog/util.c +++ b/scripts/kconfig/lxdialog/util.c @@ -272,6 +272,11 @@ void init_dialog(const char *backtitle) color_setup(getenv("MENUCONFIG_COLOR")); } +void set_dialog_backtitle(const char *backtitle) +{ + dlg.backtitle = backtitle; +} + void reset_dialog(void) { initscr(); /* Init curses */ diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 3f9a1321b3e6..462256d72baa 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -26,7 +26,6 @@ #include "lkc.h" #include "lxdialog/dialog.h" -static char menu_backtitle[128]; static const char mconf_readme[] = N_( "Overview\n" "--------\n" @@ -271,7 +270,6 @@ search_help[] = N_( " USB$ => find all CONFIG_ symbols ending with USB\n" "\n"); -static char filename[PATH_MAX+1] = ".config"; static int indent; static struct termios ios_org; static int rows = 0, cols = 0; @@ -395,6 +393,28 @@ static struct gstr get_relations_str(struct symbol **sym_arr) return res; } +static char filename[PATH_MAX+1]; +static void set_config_filename(const char *config_filename) +{ + static char menu_backtitle[PATH_MAX+128]; + int size; + struct symbol *sym; + + sym = sym_lookup("KERNELVERSION", 0); + sym_calc_value(sym); + size = snprintf(menu_backtitle, sizeof(menu_backtitle), + _("%s - Linux Kernel v%s Configuration"), + config_filename, sym_get_string_value(sym)); + if (size >= sizeof(menu_backtitle)) + menu_backtitle[sizeof(menu_backtitle)-1] = '\0'; + set_dialog_backtitle(menu_backtitle); + + size = snprintf(filename, sizeof(filename), "%s", config_filename); + if (size >= sizeof(filename)) + filename[sizeof(filename)-1] = '\0'; +} + + static void search_conf(void) { struct symbol **sym_arr; @@ -816,8 +836,10 @@ static void conf_load(void) case 0: if (!dialog_input_result[0]) return; - if (!conf_read(dialog_input_result)) + if (!conf_read(dialog_input_result)) { + set_config_filename(dialog_input_result); return; + } show_textbox(NULL, _("File does not exist!"), 5, 38); break; case 1: @@ -840,8 +862,10 @@ static void conf_save(void) case 0: if (!dialog_input_result[0]) return; - if (!conf_write(dialog_input_result)) + if (!conf_write(dialog_input_result)) { + set_config_filename(dialog_input_result); return; + } show_textbox(NULL, _("Can't create file! Probably a nonexistent directory."), 5, 60); break; case 1: @@ -860,7 +884,6 @@ static void conf_cleanup(void) int main(int ac, char **av) { - struct symbol *sym; char *mode; int res; @@ -871,11 +894,6 @@ int main(int ac, char **av) conf_parse(av[1]); conf_read(NULL); - sym = sym_lookup("KERNELVERSION", 0); - sym_calc_value(sym); - sprintf(menu_backtitle, _("Linux Kernel v%s Configuration"), - sym_get_string_value(sym)); - mode = getenv("MENUCONFIG_MODE"); if (mode) { if (!strcasecmp(mode, "single_menu")) @@ -886,7 +904,8 @@ int main(int ac, char **av) atexit(conf_cleanup); init_wsize(); reset_dialog(); - init_dialog(menu_backtitle); + init_dialog(NULL); + set_config_filename(".config"); do { conf(&rootmenu); dialog_clear(); @@ -903,7 +922,7 @@ int main(int ac, char **av) switch (res) { case 0: - if (conf_write(NULL)) { + if (conf_write(filename)) { fprintf(stderr, _("\n\n" "Error during writing of the kernel configuration.\n" "Your kernel configuration changes were NOT saved." -- cgit v1.2.3 From 4be40e22233cfe6254bbf039ec09a5d7bff2ad14 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 20 Mar 2007 21:30:23 +0100 Subject: kbuild: do not emit src version warning for non-modules modpost is now called with .o files that are not modules. So do not warn if there is no corresponding .mod file listing .o files (in .tmp_versions/). Signed-off-by: Sam Ravnborg --- scripts/mod/sumversion.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 8a2875689e4d..6873d5af80d5 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -397,10 +397,9 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) (int) strlen(basename) - 2, basename); file = grab_file(filelist, &len); - if (!file) { - warn("could not find versions for %s\n", filelist); + if (!file) + /* not a module or .mod file missing - ignore */ return; - } sources = strchr(file, '\n'); if (!sources) { -- cgit v1.2.3 From c53aeca059c4d2108335810fba6ba89ab6a944dd Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 27 Mar 2007 22:50:29 +0200 Subject: kbuild: complain about missing system calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most system calls seems to get added to i386 first. This patch automatically generates a warning for any new system call which is implemented on i386 but not the architecture currently being compiled. On PowerPC at the moment, for example, it results in these warnings: init/missing_syscalls.h:935:3: warning: #warning syscall sync_file_range not implemented init/missing_syscalls.h:947:3: warning: #warning syscall getcpu not implemented init/missing_syscalls.h:950:3: warning: #warning syscall epoll_pwait not implemented The file scripts/checksyscalls.sh list a number of legacy system calls that are ignored because they only makes sense on i386 systems. Other contributors to this patch are Russell King and Stéphane Jourdois Signed-off-by: David Woodhouse Signed-off-by: Sam Ravnborg --- Kbuild | 11 +++++ Makefile | 1 + scripts/checksyscalls.sh | 118 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 130 insertions(+) create mode 100755 scripts/checksyscalls.sh (limited to 'scripts') diff --git a/Kbuild b/Kbuild index 0451f69353ba..163f8cb020a4 100644 --- a/Kbuild +++ b/Kbuild @@ -2,6 +2,7 @@ # Kbuild for top-level directory of the kernel # This file takes care of the following: # 1) Generate asm-offsets.h +# 2) Check for missing system calls ##### # 1) Generate asm-offsets.h @@ -46,3 +47,13 @@ $(obj)/$(offsets-file): arch/$(ARCH)/kernel/asm-offsets.s Kbuild $(Q)mkdir -p $(dir $@) $(call cmd,offsets) +##### +# 2) Check for missing system calls +# + +quiet_cmd_syscalls = CALL $< + cmd_syscalls = $(CONFIG_SHELL) $< $(CC) $(c_flags) + +PHONY += missing-syscalls +missing-syscalls: scripts/checksyscalls.sh FORCE + $(call cmd,syscalls) diff --git a/Makefile b/Makefile index 92cbc05c31ad..2910c2d5ee9f 100644 --- a/Makefile +++ b/Makefile @@ -856,6 +856,7 @@ archprepare: prepare1 scripts_basic prepare0: archprepare FORCE $(Q)$(MAKE) $(build)=. + $(Q)$(MAKE) $(build)=. missing-syscalls # All the preparing.. prepare: prepare0 diff --git a/scripts/checksyscalls.sh b/scripts/checksyscalls.sh new file mode 100755 index 000000000000..f98171f5a3df --- /dev/null +++ b/scripts/checksyscalls.sh @@ -0,0 +1,118 @@ +#!/bin/sh +# +# Check if current architecture are missing any function calls compared +# to i386. +# i386 define a number of legacy system calls that are i386 specific +# and listed below so they are ignored. +# +# Usage: +# syscallchk gcc gcc-options +# + +ignore_list() { +cat << EOF +#include +#include + +/* System calls for 32-bit kernels only */ +#if BITS_PER_LONG == 64 +#define __IGNORE_sendfile64 +#define __IGNORE_ftruncate64 +#define __IGNORE_truncate64 +#define __IGNORE_stat64 +#define __IGNORE_lstat64 +#define __IGNORE_fstat64 +#define __IGNORE_fcntl64 +#define __IGNORE_fadvise64_64 +#define __IGNORE_fstatat64 +#define __IGNORE_fstatfs64 +#define __IGNORE_statfs64 +#endif + +/* i386-specific or historical system calls */ +#define __IGNORE_break +#define __IGNORE_stty +#define __IGNORE_gtty +#define __IGNORE_ftime +#define __IGNORE_prof +#define __IGNORE_lock +#define __IGNORE_mpx +#define __IGNORE_ulimit +#define __IGNORE_profil +#define __IGNORE_ioperm +#define __IGNORE_iopl +#define __IGNORE_idle +#define __IGNORE_modify_ldt +#define __IGNORE_ugetrlimit +#define __IGNORE_mmap2 +#define __IGNORE_vm86 +#define __IGNORE_vm86old +#define __IGNORE_set_thread_area +#define __IGNORE_get_thread_area +#define __IGNORE_madvise1 +#define __IGNORE_oldstat +#define __IGNORE_oldfstat +#define __IGNORE_oldlstat +#define __IGNORE_oldolduname +#define __IGNORE_olduname +#define __IGNORE_umount2 +#define __IGNORE_umount +#define __IGNORE_waitpid +#define __IGNORE_stime +#define __IGNORE_nice +#define __IGNORE_signal +#define __IGNORE_sigaction +#define __IGNORE_sgetmask +#define __IGNORE_sigsuspend +#define __IGNORE_sigpending +#define __IGNORE_ssetmask +#define __IGNORE_readdir +#define __IGNORE_socketcall +#define __IGNORE_ipc +#define __IGNORE_sigreturn +#define __IGNORE_sigprocmask +#define __IGNORE_bdflush +#define __IGNORE__llseek +#define __IGNORE__newselect +#define __IGNORE_create_module +#define __IGNORE_delete_module +#define __IGNORE_query_module +#define __IGNORE_get_kernel_syms +/* ... including the "new" 32-bit uid syscalls */ +#define __IGNORE_lchown32 +#define __IGNORE_getuid32 +#define __IGNORE_getgid32 +#define __IGNORE_geteuid32 +#define __IGNORE_getegid32 +#define __IGNORE_setreuid32 +#define __IGNORE_setregid32 +#define __IGNORE_getgroups32 +#define __IGNORE_setgroups32 +#define __IGNORE_fchown32 +#define __IGNORE_setresuid32 +#define __IGNORE_getresuid32 +#define __IGNORE_setresgid32 +#define __IGNORE_getresgid32 +#define __IGNORE_chown32 +#define __IGNORE_setuid32 +#define __IGNORE_setgid32 +#define __IGNORE_setfsuid32 +#define __IGNORE_setfsgid32 + +/* Unmerged syscalls for AFS, STREAMS, etc. */ +#define __IGNORE_afs_syscall +#define __IGNORE_getpmsg +#define __IGNORE_putpmsg +#define __IGNORE_vserver +EOF +} + +syscall_list() { +sed -n -e '/^\#define/ { s/[^_]*__NR_\([^[:space:]]*\).*/\ +\#if !defined \(__NR_\1\) \&\& !defined \(__IGNORE_\1\)\ +\#warning syscall \1 not implemented\ +\#endif/p }' $1 +} + +(ignore_list && syscall_list ${srctree}/include/asm-i386/unistd.h) | \ +$* -E -x c - > /dev/null -- cgit v1.2.3 From 87c94bfb8ad354fb43d2caf870d7ca0b3f98dab3 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 1 Apr 2007 21:49:27 +0200 Subject: kbuild: override build timestamp & version Introduce KBUILD_BUILD_VERSION to make it possible to override kernel build version during build time. Introduce KBUILD_BUILD_TIMESTAMP to make it possible to override kernel build timestamp during build time. But variables are useful mainly by distros that want to pass info from an SCM when building the kernel. Timestamp could be last checkin date for a file etc. The idea came from Olaf Hering Cc: Olaf Hering Signed-off-by: Sam Ravnborg --- scripts/mkcompile_h | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'scripts') diff --git a/scripts/mkcompile_h b/scripts/mkcompile_h index 82d0af46f0ef..a8740df07b09 100755 --- a/scripts/mkcompile_h +++ b/scripts/mkcompile_h @@ -18,19 +18,32 @@ fi # Do not expand names set -f -if [ -r .version ]; then - VERSION=`cat .version` +# Fix the language to get consistent output +LC_ALL=C +export LC_ALL + +if [ -z "$KBUILD_BUILD_VERSION" ]; then + if [ -r .version ]; then + VERSION=`cat .version` + else + VERSION=0 + echo 0 > .version + fi else - VERSION=0 - echo 0 > .version + VERSION=$KBUILD_BUILD_VERSION fi +if [ -z "$KBUILD_BUILD_TIMESTAMP" ]; then + TIMESTAMP=`date` +else + TIMESTAMP=$KBUILD_BUILD_TIMESTAMP +fi UTS_VERSION="#$VERSION" CONFIG_FLAGS="" if [ -n "$SMP" ] ; then CONFIG_FLAGS="SMP"; fi if [ -n "$PREEMPT" ] ; then CONFIG_FLAGS="$CONFIG_FLAGS PREEMPT"; fi -UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS `LC_ALL=C LANG=C date`" +UTS_VERSION="$UTS_VERSION $CONFIG_FLAGS $TIMESTAMP" # Truncate to maximum length @@ -46,7 +59,7 @@ UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/" echo \#define UTS_VERSION \"`echo $UTS_VERSION | $UTS_TRUNCATE`\" - echo \#define LINUX_COMPILE_TIME \"`LC_ALL=C LANG=C date +%T`\" + echo \#define LINUX_COMPILE_TIME \"`date +%T`\" echo \#define LINUX_COMPILE_BY \"`whoami`\" echo \#define LINUX_COMPILE_HOST \"`hostname | $UTS_TRUNCATE`\" @@ -58,7 +71,7 @@ UTS_TRUNCATE="sed -e s/\(.\{1,$UTS_LEN\}\).*/\1/" echo \#define LINUX_COMPILE_DOMAIN fi - echo \#define LINUX_COMPILER \"`LC_ALL=C LANG=C $CC -v 2>&1 | tail -n 1`\" + echo \#define LINUX_COMPILER \"`$CC -v 2>&1 | tail -n 1`\" ) > .tmpcompile # Only replace the real compile.h if the new one is different, -- cgit v1.2.3 From d802b50f0d63d2d18d8dae15d7e3285e99e7e7b6 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 1 Apr 2007 22:29:38 +0200 Subject: kconfig/menuconfig: do not hardcode '.config' Export and use the function conf_get_configname() to retreive the default configuration filename. Suggested by: Roman Zippel Signed-off-by: Sam Ravnborg --- scripts/kconfig/lkc.h | 1 + scripts/kconfig/mconf.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/lkc.h b/scripts/kconfig/lkc.h index 9b2706a41548..8a07ee4f6bd4 100644 --- a/scripts/kconfig/lkc.h +++ b/scripts/kconfig/lkc.h @@ -64,6 +64,7 @@ int zconf_lineno(void); char *zconf_curname(void); /* confdata.c */ +const char *conf_get_configname(void); char *conf_get_default_confname(void); void sym_set_change_count(int count); void sym_add_change_count(int count); diff --git a/scripts/kconfig/mconf.c b/scripts/kconfig/mconf.c index 462256d72baa..d0e4fa594fc7 100644 --- a/scripts/kconfig/mconf.c +++ b/scripts/kconfig/mconf.c @@ -905,7 +905,7 @@ int main(int ac, char **av) init_wsize(); reset_dialog(); init_dialog(NULL); - set_config_filename(".config"); + set_config_filename(conf_get_configname()); do { conf(&rootmenu); dialog_clear(); -- cgit v1.2.3 From 145c90475f809060c8601828f14543191e06a0bb Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 1 Apr 2007 23:14:11 +0200 Subject: kbuild: remove kconfig binaries during make mrproper Nigel Cunningham noticed that 'make mrproper' did not remove mconf. Fixed so we now remove all relevant binaries. Signed-off-by: Sam Ravnborg Cc: Nigel Cunningham --- scripts/kconfig/Makefile | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 7e7e147875bf..2e421bd5675f 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -140,6 +140,7 @@ endif clean-files := lkc_defs.h qconf.moc .tmp_qtcheck \ .tmp_gtkcheck zconf.tab.c lex.zconf.c zconf.hash.c +clean-files += mconf qconf gconf # Needed for systems without gettext KBUILD_HAVE_NLS := $(shell \ -- cgit v1.2.3 From f03e1666d6164da6f098dc1a2e539eced3e4461a Mon Sep 17 00:00:00 2001 From: Uwe kleine-König Date: Wed, 28 Mar 2007 16:55:55 +0200 Subject: kbuild/mkuboot.sh: allow spaces in CROSS_COMPILE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I'm currently using CROSS_COMPILE="ccache arm-linux-". With that the bash builtin command "type" searches for ccache and arm-linux-mkimage and so sets MKIMAGE="/path/to/ccache" as I don't have arm-linux-mkimage. Then the script dies with an error, that ccache doesn't support the argument -A. This patch adds some quoting such that it works again for me. Please note that this patch doesn't help you if you use ${CROSSCOMPILE}-mkimage and ccache as mkuboot.sh now searches for the command "ccache arm-linux-mkimage". Signed-off-by: Uwe Kleine-König Signed-off-by: Sam Ravnborg --- scripts/mkuboot.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mkuboot.sh b/scripts/mkuboot.sh index 4b06c5eea728..2e3d3cd916b8 100755 --- a/scripts/mkuboot.sh +++ b/scripts/mkuboot.sh @@ -4,7 +4,7 @@ # Build U-Boot image when `mkimage' tool is available. # -MKIMAGE=$(type -path ${CROSS_COMPILE}mkimage) +MKIMAGE=$(type -path "${CROSS_COMPILE}mkimage") if [ -z "${MKIMAGE}" ]; then MKIMAGE=$(type -path mkimage) -- cgit v1.2.3 From 66bd32e443203735b00f22bede637ec98f3070ca Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 29 Apr 2007 20:40:53 +0200 Subject: kbuild: remove stale comment in modpost.c 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 b10b69b56a31..b81157cf4527 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -626,7 +626,6 @@ static int strrcmp(const char *s, const char *sub) * tosec = .init.text * fromsec = .text * atsym = kernel_init - * Some symbols belong to init section but still it is ok to reference * * Pattern 7: * Logos used in drivers/video/logo reside in __initdata but the -- cgit v1.2.3 From b4d5171ac7d9806b1ea61903ff954cd9620135bf Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 29 Apr 2007 20:53:01 +0200 Subject: kbuild: ignore section mismatch warning for references from .paravirtprobe to .init.text Added on request from: Rusty Russell Signed-off-by: Sam Ravnborg Cc: Rusty Russell --- scripts/mod/modpost.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index b81157cf4527..628f393ecaa6 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -635,6 +635,13 @@ static int strrcmp(const char *s, const char *sub) * tosec = .init.data * fromsec = .text* * refsymname = logo_ + * + * Pattern 8: + * Symbols contained in .paravirtprobe may safely reference .init.text. + * The pattern is: + * tosec = .init.text + * fromsec = .paravirtprobe + * **/ static int secref_whitelist(const char *modname, const char *tosec, const char *fromsec, const char *atsym, @@ -712,6 +719,12 @@ static int secref_whitelist(const char *modname, const char *tosec, (strncmp(fromsec, ".text", strlen(".text")) == 0) && (strncmp(refsymname, "logo_", strlen("logo_")) == 0)) return 1; + + /* Check for pattern 8 */ + if ((strcmp(tosec, ".init.text") == 0) && + (strcmp(fromsec, ".paravirtprobe") == 0)) + return 1; + return 0; } -- cgit v1.2.3 From c299ec2d8e8d2f1a99d5c993fca485257b950d40 Mon Sep 17 00:00:00 2001 From: Alex Landau Date: Thu, 26 Apr 2007 00:17:29 -0700 Subject: kbuild: handle compressed cpio initramfs-es Make kbuild handle compressed cpio initramfs-es. An already compressed cpio is copied directly to usr/, while a non-compressed cpio is filtered through gzip (no changes here) on its way to usr/. If the user has created a compressed cpio by other means, this saves him from uncompressing it, just to be compressed again by kbuild. Signed-off-by: Alex Landau Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg --- scripts/gen_initramfs_list.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index 43f75d6e4d96..3111f4ac23c4 100644 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh @@ -191,9 +191,10 @@ input_file() { source="$1" if [ -f "$1" ]; then ${dep_list}header "$1" - is_cpio="$(echo "$1" | sed 's/^.*\.cpio/cpio/')" + is_cpio="$(echo "$1" | sed 's/^.*\.cpio\(\..*\)\?/cpio/')" if [ $2 -eq 0 -a ${is_cpio} == "cpio" ]; then cpio_file=$1 + echo "$1" | grep -q '^.*\.cpio\..*' && is_cpio_compressed="compressed" [ ! -z ${dep_list} ] && echo "$1" return 0 fi @@ -223,6 +224,7 @@ cpio_file= cpio_list= output="/dev/stdout" output_file="" +is_cpio_compressed= arg="$1" case "$arg" in @@ -282,7 +284,11 @@ if [ ! -z ${output_file} ]; then cpio_tfile=${cpio_file} fi rm ${cpio_list} - cat ${cpio_tfile} | gzip -f -9 - > ${output_file} + if [ "${is_cpio_compressed}" = "compressed" ]; then + cat ${cpio_tfile} > ${output_file} + else + cat ${cpio_tfile} | gzip -f -9 - > ${output_file} + fi [ -z ${cpio_file} ] && rm ${cpio_tfile} fi exit 0 -- cgit v1.2.3 From 9ae57004ca9c38ff8292c38a475c98b0ebbc0d74 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 29 Apr 2007 21:01:52 +0200 Subject: kconfig: refer to qt3 if we cannot find qt libraries We do not support qt4 (yet) so the simple fix was to warn that qt3 are missing. The better fix would have been to implment qt4 support but that has failed so far. This solves http://bugzilla.kernel.org/show_bug.cgi?id=8277 Signed-off-by: Sam Ravnborg --- scripts/kconfig/Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 2e421bd5675f..fb2bb3099dd9 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -184,8 +184,8 @@ $(obj)/.tmp_qtcheck: done; \ if [ -z "$$dir" ]; then \ echo "*"; \ - echo "* Unable to find the QT installation. Please make sure that"; \ - echo "* the QT development package is correctly installed and"; \ + echo "* Unable to find the QT3 installation. Please make sure that"; \ + echo "* the QT3 development package is correctly installed and"; \ echo "* either install pkg-config or set the QTDIR environment"; \ echo "* variable to the correct location."; \ echo "*"; \ -- cgit v1.2.3 From eda890af7959a79ab10a7a8ae979dadcdba41c58 Mon Sep 17 00:00:00 2001 From: Michael Ellerman Date: Mon, 30 Apr 2007 15:34:15 +1000 Subject: kbuild: propagate errors from find in scripts/gen_initramfs_list.sh If the find(1) in scripts/gen_initramfs_list.sh generates any errors, it will cause gen_initramfs_list.sh to fail (because of "set -e"), however the errors from find are not printed to the user. This is rather confusing: ~/src/powerpc$ make O=~/build/powerpc-cell32/ make[2]: *** [usr/initramfs_data.cpio.gz] Error 1 make[1]: *** [usr] Error 2 make[1]: *** Waiting for unfinished jobs.... make[1]: *** wait: No child processes. Stop. make: *** [_all] Error 2 It is much easier to work out what the problem is if we let the errors from find hit the console, eg: ~/src/powerpc$ make O=~/build/powerpc-cell32/ find: /home/michael/initramfs-source/home: Permission denied find: /home/michael/initramfs-source/lost+found: Permission denied find: /home/michael/initramfs-source/opt: Permission denied find: /home/michael/initramfs-source/root: Permission denied make[2]: *** [usr/initramfs_data.cpio.gz] Error 1 make[1]: *** [usr] Error 2 make[1]: *** Waiting for unfinished jobs.... make[1]: *** wait: No child processes. Stop. make: *** [_all] Error 2 Signed-off-by: Michael Ellerman Signed-off-by: Sam Ravnborg --- scripts/gen_initramfs_list.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh index 3111f4ac23c4..683eb12babbb 100644 --- a/scripts/gen_initramfs_list.sh +++ b/scripts/gen_initramfs_list.sh @@ -171,7 +171,7 @@ dir_filelist() { ${dep_list}header "$1" srcdir=$(echo "$1" | sed -e 's://*:/:g') - dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n" 2>/dev/null) + dirlist=$(find "${srcdir}" -printf "%p %m %U %G\n") # If $dirlist is only one line, then the directory is empty if [ "$(echo "${dirlist}" | wc -l)" -gt 1 ]; then -- cgit v1.2.3 From 7ac1c145250adaccf4dbde77a8f811e937aa43c8 Mon Sep 17 00:00:00 2001 From: Randy Dunlap Date: Wed, 4 Apr 2007 21:58:41 -0700 Subject: kbuild: be more explicit on missing .config file Somewhat in reponse to kernel bugzilla #8197, be more explicit about why 'make all' fails when there is no .config file. Signed-off-by: Randy Dunlap Signed-off-by: Sam Ravnborg --- scripts/kconfig/conf.c | 1 + 1 file changed, 1 insertion(+) (limited to 'scripts') diff --git a/scripts/kconfig/conf.c b/scripts/kconfig/conf.c index 124b341a18c0..1199baf866ca 100644 --- a/scripts/kconfig/conf.c +++ b/scripts/kconfig/conf.c @@ -558,6 +558,7 @@ int main(int ac, char **av) if (stat(".config", &tmpstat)) { printf(_("***\n" "*** You have not yet configured your kernel!\n" + "*** (missing kernel .config file)\n" "***\n" "*** Please run some configurator (e.g. \"make oldconfig\" or\n" "*** \"make menuconfig\" or \"make xconfig\").\n" -- cgit v1.2.3 From 1e093ecd4a850ad61b93d84c221e342a67ea9d56 Mon Sep 17 00:00:00 2001 From: "Robert P. J. Day" Date: Mon, 30 Apr 2007 15:44:27 -0400 Subject: kconfig: correct minor typo in Kconfig warning message. Correct a minor spelling mistake in a Kconfig warning message. Signed-off-by: Robert P. J. Day Signed-off-by: Sam Ravnborg --- scripts/kconfig/menu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/menu.c b/scripts/kconfig/menu.c index c86c27f2c761..f14aeac67d4f 100644 --- a/scripts/kconfig/menu.c +++ b/scripts/kconfig/menu.c @@ -203,7 +203,7 @@ void sym_check_prop(struct symbol *sym) else if (sym2->type == S_UNKNOWN) prop_warn(prop, "'select' used by config symbol '%s' " - "refer to undefined symbol '%s'", + "refers to undefined symbol '%s'", sym->name, sym2->name); else if (sym2->type != S_BOOLEAN && sym2->type != S_TRISTATE) prop_warn(prop, -- cgit v1.2.3 From 04c58f8196b386948abf68128605de3d2db3c6ba Mon Sep 17 00:00:00 2001 From: Andy Green Date: Wed, 2 May 2007 12:49:06 +0100 Subject: kbuild: scripts/basic/fixdep segfault on pathological string-o-death build scripts: fixdep blows segfault on string CONFIG_MODULE seen The string "CONFIG_MODULE" appearing anywhere in a source file causes fixdep to segfault. This string appeared in the wild in the current mISDN sources (I think they meant CONFIG_MODULES). But it shouldn't segfault (esp as CONFIG_MODULE appeared in a quoted string). Signed-off-by: Andy Green Signed-off-by: Sam Ravnborg --- scripts/basic/fixdep.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scripts') diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 6bc7e7cfccf6..8912c0f5460b 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -249,6 +249,8 @@ void parse_config_file(char *map, size_t len) found: if (!memcmp(q - 7, "_MODULE", 7)) q -= 7; + if( (q-p-7) < 0 ) + continue; use_config(p+7, q-p-7); } } -- cgit v1.2.3 From 5447d34b080a1e3e312b05a91e87eff4710a1152 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 6 May 2007 09:20:10 +0200 Subject: kconfig: error out if recursive dependencies are found Sample: config FOO bool "This is foo" depends on BAR config BAR bool "This is bar" depends on FOO This will result in following error message: error: found recursive dependency: FOO -> BAR -> FOO And will then exit with exit code equal 1 so make will stop. Inspired by patch from: Adrian Bunk Signed-off-by: Sam Ravnborg Cc: Adrian Bunk Cc: Roman Zippel --- scripts/kconfig/symbol.c | 13 +++++-------- scripts/kconfig/zconf.tab.c_shipped | 6 ++++-- scripts/kconfig/zconf.y | 6 ++++-- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c index 8f06c474d800..c35dcc5d6189 100644 --- a/scripts/kconfig/symbol.c +++ b/scripts/kconfig/symbol.c @@ -786,13 +786,15 @@ static struct symbol *sym_check_expr_deps(struct expr *e) return NULL; } +/* return NULL when dependencies are OK */ struct symbol *sym_check_deps(struct symbol *sym) { struct symbol *sym2; struct property *prop; if (sym->flags & SYMBOL_CHECK) { - printf("Warning! Found recursive dependency: %s", sym->name); + fprintf(stderr, "%s:%d:error: found recursive dependency: %s", + sym->prop->file->name, sym->prop->lineno, sym->name); return sym; } if (sym->flags & SYMBOL_CHECKED) @@ -816,13 +818,8 @@ struct symbol *sym_check_deps(struct symbol *sym) goto out; } out: - if (sym2) { - printf(" %s", sym->name); - if (sym2 == sym) { - printf("\n"); - sym2 = NULL; - } - } + if (sym2) + fprintf(stderr, " -> %s%s", sym->name, sym2 == sym? "\n": ""); sym->flags &= ~SYMBOL_CHECK; return sym2; } diff --git a/scripts/kconfig/zconf.tab.c_shipped b/scripts/kconfig/zconf.tab.c_shipped index d777fe85627f..9a06b6771eee 100644 --- a/scripts/kconfig/zconf.tab.c_shipped +++ b/scripts/kconfig/zconf.tab.c_shipped @@ -2132,9 +2132,11 @@ void conf_parse(const char *name) } menu_finalize(&rootmenu); for_all_symbols(i, sym) { - sym_check_deps(sym); + if (sym_check_deps(sym)) + zconfnerrs++; } - + if (zconfnerrs) + exit(1); sym_set_change_count(1); } diff --git a/scripts/kconfig/zconf.y b/scripts/kconfig/zconf.y index 04a5864c03b1..92eb02bdf9c5 100644 --- a/scripts/kconfig/zconf.y +++ b/scripts/kconfig/zconf.y @@ -501,9 +501,11 @@ void conf_parse(const char *name) } menu_finalize(&rootmenu); for_all_symbols(i, sym) { - sym_check_deps(sym); + if (sym_check_deps(sym)) + zconfnerrs++; } - + if (zconfnerrs) + exit(1); sym_set_change_count(1); } -- cgit v1.2.3 From 767e581d759fe6adfef5e676cd1cd8e11f603d1a Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 6 May 2007 09:23:45 +0200 Subject: kbuild: enable use of code from a different dir To introduce support for source in one directory but output files in another directory during a non O= build prefix all paths with $(src) repsectively $(obj). Signed-off-by: Sam Ravnborg --- scripts/Makefile.build | 19 +++++++++---------- scripts/Makefile.host | 14 +++++++------- 2 files changed, 16 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index e2ad2dccccdb..a525112847fd 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -131,13 +131,13 @@ $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< -%.s: %.c FORCE +$(obj)/%.s: $(src)/%.c FORCE $(call if_changed_dep,cc_s_c) quiet_cmd_cc_i_c = CPP $(quiet_modtag) $@ cmd_cc_i_c = $(CPP) $(c_flags) -o $@ $< -%.i: %.c FORCE +$(obj)/%.i: $(src)/%.c FORCE $(call if_changed_dep,cc_i_c) quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@ @@ -146,7 +146,7 @@ cmd_cc_symtypes_c = \ | $(GENKSYMS) -T $@ >/dev/null; \ test -s $@ || rm -f $@ -%.symtypes : %.c FORCE +$(obj)/%.symtypes : $(src)/%.c FORCE $(call if_changed_dep,cc_symtypes_c) # C (.c) files @@ -198,14 +198,13 @@ define rule_cc_o_c endef # Built-in and composite module parts - -%.o: %.c FORCE +$(obj)/%.o: $(src)/%.c FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) # Single-part modules are special since we need to mark them in $(MODVERDIR) -$(single-used-m): %.o: %.c FORCE +$(single-used-m): $(obj)/%.o: $(src)/%.c FORCE $(call cmd,force_checksrc) $(call if_changed_rule,cc_o_c) @{ echo $(@:.o=.ko); echo $@; } > $(MODVERDIR)/$(@F:.o=.mod) @@ -215,7 +214,7 @@ quiet_cmd_cc_lst_c = MKLST $@ $(CONFIG_SHELL) $(srctree)/scripts/makelst $*.o \ System.map $(OBJDUMP) > $@ -%.lst: %.c FORCE +$(obj)/%.lst: $(src)/%.c FORCE $(call if_changed_dep,cc_lst_c) # Compile assembler sources (.S) @@ -229,13 +228,13 @@ $(real-objs-m:.o=.s): modkern_aflags := $(AFLAGS_MODULE) quiet_cmd_as_s_S = CPP $(quiet_modtag) $@ cmd_as_s_S = $(CPP) $(a_flags) -o $@ $< -%.s: %.S FORCE +$(obj)/%.s: $(src)/%.S FORCE $(call if_changed_dep,as_s_S) quiet_cmd_as_o_S = AS $(quiet_modtag) $@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< -%.o: %.S FORCE +$(obj)/%.o: $(src)/%.S FORCE $(call if_changed_dep,as_o_S) targets += $(real-objs-y) $(real-objs-m) $(lib-y) @@ -246,7 +245,7 @@ targets += $(extra-y) $(MAKECMDGOALS) $(always) quiet_cmd_cpp_lds_S = LDS $@ cmd_cpp_lds_S = $(CPP) $(cpp_flags) -D__ASSEMBLY__ -o $@ $< -%.lds: %.lds.S FORCE +$(obj)/%.lds: $(src)/%.lds.S FORCE $(call if_changed_dep,cpp_lds_S) # Build the compiled-in targets diff --git a/scripts/Makefile.host b/scripts/Makefile.host index 575afbe5e370..6943a7a5bb98 100644 --- a/scripts/Makefile.host +++ b/scripts/Makefile.host @@ -114,7 +114,7 @@ hostcxx_flags = -Wp,-MD,$(depfile) $(__hostcxx_flags) quiet_cmd_host-csingle = HOSTCC $@ cmd_host-csingle = $(HOSTCC) $(hostc_flags) -o $@ $< \ $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-csingle): %: %.c FORCE +$(host-csingle): $(obj)/%: $(src)/%.c FORCE $(call if_changed_dep,host-csingle) # Link an executable based on list of .o files, all plain c @@ -123,14 +123,14 @@ quiet_cmd_host-cmulti = HOSTLD $@ cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ $(addprefix $(obj)/,$($(@F)-objs)) \ $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cmulti): %: $(host-cobjs) $(host-cshlib) FORCE +$(host-cmulti): $(obj)/%: $(host-cobjs) $(host-cshlib) FORCE $(call if_changed,host-cmulti) # Create .o file from a single .c file # host-cobjs -> .o quiet_cmd_host-cobjs = HOSTCC $@ cmd_host-cobjs = $(HOSTCC) $(hostc_flags) -c -o $@ $< -$(host-cobjs): %.o: %.c FORCE +$(host-cobjs): $(obj)/%.o: $(src)/%.c FORCE $(call if_changed_dep,host-cobjs) # Link an executable based on list of .o files, a mixture of .c and .cc @@ -140,20 +140,20 @@ quiet_cmd_host-cxxmulti = HOSTLD $@ $(foreach o,objs cxxobjs,\ $(addprefix $(obj)/,$($(@F)-$(o)))) \ $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cxxmulti): %: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE +$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE $(call if_changed,host-cxxmulti) # Create .o file from a single .cc (C++) file quiet_cmd_host-cxxobjs = HOSTCXX $@ cmd_host-cxxobjs = $(HOSTCXX) $(hostcxx_flags) -c -o $@ $< -$(host-cxxobjs): %.o: %.cc FORCE +$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE $(call if_changed_dep,host-cxxobjs) # Compile .c file, create position independent .o file # host-cshobjs -> .o quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< -$(host-cshobjs): %.o: %.c FORCE +$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE $(call if_changed_dep,host-cshobjs) # Link a shared library, based on position independent .o files @@ -162,7 +162,7 @@ quiet_cmd_host-cshlib = HOSTLLD -shared $@ cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \ $(addprefix $(obj)/,$($(@F:.so=-objs))) \ $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) -$(host-cshlib): %: $(host-cshobjs) FORCE +$(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE $(call if_changed,host-cshlib) targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ -- cgit v1.2.3 From 11de39e2fbbc592018e0a231d0ee773653dcc8d6 Mon Sep 17 00:00:00 2001 From: Marcin Garski Date: Sat, 5 May 2007 22:49:00 +0200 Subject: kconfig: fix mconf segmentation fault I have found small bug in mconf, when you run it without any argument it will sigsegv. Without patch: $ scripts/kconfig/mconf Segmentation fault With patch: $ scripts/kconfig/mconf can't find file (null) Signed-off-by: Marcin Garski Signed-off-by: Sam Ravnborg --- scripts/kconfig/lex.zconf.c_shipped | 2 +- scripts/kconfig/zconf.l | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/kconfig/lex.zconf.c_shipped b/scripts/kconfig/lex.zconf.c_shipped index 800f8c71c407..0fdc9049296f 100644 --- a/scripts/kconfig/lex.zconf.c_shipped +++ b/scripts/kconfig/lex.zconf.c_shipped @@ -2264,7 +2264,7 @@ FILE *zconf_fopen(const char *name) FILE *f; f = fopen(name, "r"); - if (!f && name[0] != '/') { + if (!f && name != NULL && name[0] != '/') { env = getenv(SRCTREE); if (env) { sprintf(fullname, "%s/%s", env, name); diff --git a/scripts/kconfig/zconf.l b/scripts/kconfig/zconf.l index cfa46077c6b4..187d38ccadd5 100644 --- a/scripts/kconfig/zconf.l +++ b/scripts/kconfig/zconf.l @@ -265,7 +265,7 @@ FILE *zconf_fopen(const char *name) FILE *f; f = fopen(name, "r"); - if (!f && name[0] != '/') { + if (!f && name != NULL && name[0] != '/') { env = getenv(SRCTREE); if (env) { sprintf(fullname, "%s/%s", env, name); -- cgit v1.2.3