From cb80514d9c517cc1d101ef304529a0e9b76b4468 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 28 Jan 2006 16:57:26 +0100 Subject: kbuild: use warn()/fatal() consistent in modpost modpost.c provides warn() and fatal() - so use them all over the place. Signed-off-by: Sam Ravnborg --- scripts/mod/file2alias.c | 13 ++++++------- scripts/mod/modpost.c | 16 ++++++---------- scripts/mod/modpost.h | 7 ++++++- scripts/mod/sumversion.c | 23 +++++++++-------------- 4 files changed, 27 insertions(+), 32 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index be97caf..1346223 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -153,8 +153,8 @@ static void do_usb_table(void *symval, unsigned long size, const unsigned long id_size = sizeof(struct usb_device_id); if (size % id_size || size < id_size) { - fprintf(stderr, "*** Warning: %s ids %lu bad size " - "(each on %lu)\n", mod->name, size, id_size); + warn("%s ids %lu bad size " + "(each on %lu)\n", mod->name, size, id_size); } /* Leave last one: it's the terminator. */ size -= id_size; @@ -217,9 +217,8 @@ static int do_pci_entry(const char *filename, if ((baseclass_mask != 0 && baseclass_mask != 0xFF) || (subclass_mask != 0 && subclass_mask != 0xFF) || (interface_mask != 0 && interface_mask != 0xFF)) { - fprintf(stderr, - "*** Warning: Can't handle masks in %s:%04X\n", - filename, id->class_mask); + warn("Can't handle masks in %s:%04X\n", + filename, id->class_mask); return 0; } @@ -445,8 +444,8 @@ static void do_table(void *symval, unsigned long size, int (*do_entry)(const char *, void *entry, char *alias) = function; if (size % id_size || size < id_size) { - fprintf(stderr, "*** Warning: %s ids %lu bad size " - "(each on %lu)\n", mod->name, size, id_size); + warn("%s ids %lu bad size " + "(each on %lu)\n", mod->name, size, id_size); } /* Leave last one: it's the terminator. */ size -= id_size; diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f70ff13..a3c57ec 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -303,8 +303,7 @@ parse_elf(struct elf_info *info, const char *filename) sechdrs[sechdrs[i].sh_link].sh_offset; } if (!info->symtab_start) { - fprintf(stderr, "modpost: %s no symtab?\n", filename); - abort(); + fatal("%s has no symtab?\n", filename); } /* Fix endianness in symbols */ for (sym = info->symtab_start; sym < info->symtab_stop; sym++) { @@ -316,8 +315,7 @@ parse_elf(struct elf_info *info, const char *filename) return; truncated: - fprintf(stderr, "modpost: %s is truncated.\n", filename); - abort(); + fatal("%s is truncated.\n", filename); } void @@ -337,8 +335,7 @@ handle_modversions(struct module *mod, struct elf_info *info, switch (sym->st_shndx) { case SHN_COMMON: - fprintf(stderr, "*** Warning: \"%s\" [%s] is COMMON symbol\n", - symname, mod->name); + warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); break; case SHN_ABS: /* CRC'd symbol */ @@ -562,8 +559,8 @@ add_versions(struct buffer *b, struct module *mod) exp = find_symbol(s->name); if (!exp || exp->module == mod) { if (have_vmlinux && !s->weak) - fprintf(stderr, "*** Warning: \"%s\" [%s.ko] " - "undefined!\n", s->name, mod->name); + warn("\"%s\" [%s.ko] undefined!\n", + s->name, mod->name); continue; } s->module = exp->module; @@ -584,8 +581,7 @@ add_versions(struct buffer *b, struct module *mod) continue; } if (!s->crc_valid) { - fprintf(stderr, "*** Warning: \"%s\" [%s.ko] " - "has no CRC!\n", + warn("\"%s\" [%s.ko] has no CRC!\n", s->name, mod->name); continue; } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 7334d83..c0de7b9 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -91,17 +91,22 @@ struct elf_info { unsigned int modinfo_len; }; +/* file2alias.c */ void handle_moddevtable(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname); - void add_moddevtable(struct buffer *buf, struct module *mod); +/* sumversion.c */ void maybe_frob_rcs_version(const char *modfilename, char *version, void *modinfo, unsigned long modinfo_offset); void get_src_version(const char *modname, char sum[], unsigned sumlen); +/* from modpost.c */ void *grab_file(const char *filename, unsigned long *size); char* get_next_line(unsigned long *pos, void *file, unsigned long size); void release_file(void *file, unsigned long size); + +void fatal(const char *fmt, ...); +void warn(const char *fmt, ...); diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 43271a1..5c07545 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -316,8 +316,7 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) file = grab_file(cmd, &flen); if (!file) { - fprintf(stderr, "Warning: could not find %s for %s\n", - cmd, objfile); + warn("could not find %s for %s\n", cmd, objfile); goto out; } @@ -355,9 +354,8 @@ static int parse_source_files(const char *objfile, struct md4_ctx *md) /* Check if this file is in same dir as objfile */ if ((strstr(line, dir)+strlen(dir)-1) == strrchr(line, '/')) { if (!parse_file(line, md)) { - fprintf(stderr, - "Warning: could not open %s: %s\n", - line, strerror(errno)); + warn("could not open %s: %s\n", + line, strerror(errno)); goto out_file; } @@ -397,23 +395,20 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) file = grab_file(filelist, &len); if (!file) { - fprintf(stderr, "Warning: could not find versions for %s\n", - filelist); + warn("could not find versions for %s\n", filelist); return; } sources = strchr(file, '\n'); if (!sources) { - fprintf(stderr, "Warning: malformed versions file for %s\n", - modname); + warn("malformed versions file for %s\n", modname); goto release; } sources++; end = strchr(sources, '\n'); if (!end) { - fprintf(stderr, "Warning: bad ending versions file for %s\n", - modname); + warn("bad ending versions file for %s\n", modname); goto release; } *end = '\0'; @@ -438,19 +433,19 @@ static void write_version(const char *filename, const char *sum, fd = open(filename, O_RDWR); if (fd < 0) { - fprintf(stderr, "Warning: changing sum in %s failed: %s\n", + warn("changing sum in %s failed: %s\n", filename, strerror(errno)); return; } if (lseek(fd, offset, SEEK_SET) == (off_t)-1) { - fprintf(stderr, "Warning: changing sum in %s:%lu failed: %s\n", + warn("changing sum in %s:%lu failed: %s\n", filename, offset, strerror(errno)); goto out; } if (write(fd, sum, strlen(sum)+1) != strlen(sum)+1) { - fprintf(stderr, "Warning: writing sum in %s failed: %s\n", + warn("writing sum in %s failed: %s\n", filename, strerror(errno)); goto out; } -- cgit v1.1 From 5c3ead8c72788d36d34c9f1689fb529d1339b405 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 28 Jan 2006 17:19:35 +0100 Subject: kbuild: apply CodingStyle to modpost.c Just some light CodingStyle updates - no functional changes. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 124 ++++++++++++++++++++++---------------------------- 1 file changed, 54 insertions(+), 70 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a3c57ec..4a2f2e3 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -21,8 +21,7 @@ int have_vmlinux = 0; /* Is CONFIG_MODULE_SRCVERSION_ALL set? */ static int all_versions = 0; -void -fatal(const char *fmt, ...) +void fatal(const char *fmt, ...) { va_list arglist; @@ -35,8 +34,7 @@ fatal(const char *fmt, ...) exit(1); } -void -warn(const char *fmt, ...) +void warn(const char *fmt, ...) { va_list arglist; @@ -59,8 +57,7 @@ void *do_nofail(void *ptr, const char *expr) static struct module *modules; -struct module * -find_module(char *modname) +static struct module *find_module(char *modname) { struct module *mod; @@ -70,8 +67,7 @@ find_module(char *modname) return mod; } -struct module * -new_module(char *modname) +static struct module *new_module(char *modname) { struct module *mod; char *p, *s; @@ -122,11 +118,12 @@ static inline unsigned int tdb_hash(const char *name) return (1103515243 * value + 12345); } -/* Allocate a new symbols for use in the hash of exported symbols or - * the list of unresolved symbols per module */ - -struct symbol * -alloc_symbol(const char *name, unsigned int weak, struct symbol *next) +/** + * Allocate a new symbols for use in the hash of exported symbols or + * the list of unresolved symbols per module + **/ +static struct symbol *alloc_symbol(const char *name, unsigned int weak, + struct symbol *next) { struct symbol *s = NOFAIL(malloc(sizeof(*s) + strlen(name) + 1)); @@ -138,9 +135,8 @@ alloc_symbol(const char *name, unsigned int weak, struct symbol *next) } /* For the hash of exported symbols */ - -void -new_symbol(const char *name, struct module *module, unsigned int *crc) +static void new_symbol(const char *name, struct module *module, + unsigned int *crc) { unsigned int hash; struct symbol *new; @@ -154,8 +150,7 @@ new_symbol(const char *name, struct module *module, unsigned int *crc) } } -struct symbol * -find_symbol(const char *name) +static struct symbol *find_symbol(const char *name) { struct symbol *s; @@ -170,10 +165,12 @@ find_symbol(const char *name) return NULL; } -/* Add an exported symbol - it may have already been added without a - * CRC, in this case just update the CRC */ -void -add_exported_symbol(const char *name, struct module *module, unsigned int *crc) +/** + * Add an exported symbol - it may have already been added without a + * CRC, in this case just update the CRC + **/ +static void add_exported_symbol(const char *name, struct module *module, + unsigned int *crc) { struct symbol *s = find_symbol(name); @@ -187,8 +184,7 @@ add_exported_symbol(const char *name, struct module *module, unsigned int *crc) } } -void * -grab_file(const char *filename, unsigned long *size) +void *grab_file(const char *filename, unsigned long *size) { struct stat st; void *map; @@ -207,13 +203,12 @@ grab_file(const char *filename, unsigned long *size) return map; } -/* - Return a copy of the next line in a mmap'ed file. - spaces in the beginning of the line is trimmed away. - Return a pointer to a static buffer. -*/ -char* -get_next_line(unsigned long *pos, void *file, unsigned long size) +/** + * Return a copy of the next line in a mmap'ed file. + * spaces in the beginning of the line is trimmed away. + * Return a pointer to a static buffer. + **/ +char* get_next_line(unsigned long *pos, void *file, unsigned long size) { static char line[4096]; int skip = 1; @@ -243,14 +238,12 @@ get_next_line(unsigned long *pos, void *file, unsigned long size) return NULL; } -void -release_file(void *file, unsigned long size) +void release_file(void *file, unsigned long size) { munmap(file, size); } -void -parse_elf(struct elf_info *info, const char *filename) +static void parse_elf(struct elf_info *info, const char *filename) { unsigned int i; Elf_Ehdr *hdr = info->hdr; @@ -318,8 +311,7 @@ parse_elf(struct elf_info *info, const char *filename) fatal("%s is truncated.\n", filename); } -void -parse_elf_finish(struct elf_info *info) +static void parse_elf_finish(struct elf_info *info) { release_file(info->hdr, info->size); } @@ -327,9 +319,8 @@ parse_elf_finish(struct elf_info *info) #define CRC_PFX "__crc_" #define KSYMTAB_PFX "__ksymtab_" -void -handle_modversions(struct module *mod, struct elf_info *info, - Elf_Sym *sym, const char *symname) +static void handle_modversions(struct module *mod, struct elf_info *info, + Elf_Sym *sym, const char *symname) { unsigned int crc; @@ -397,8 +388,7 @@ handle_modversions(struct module *mod, struct elf_info *info, } } -int -is_vmlinux(const char *modname) +static int is_vmlinux(const char *modname) { const char *myname; @@ -410,7 +400,9 @@ is_vmlinux(const char *modname) return strcmp(myname, "vmlinux") == 0; } -/* Parse tag=value strings from .modinfo section */ +/** + * Parse tag=value strings from .modinfo section + **/ static char *next_string(char *string, unsigned long *secsize) { /* Skip non-zero chars */ @@ -443,8 +435,7 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len, return NULL; } -void -read_symbols(char *modname) +static void read_symbols(char *modname) { const char *symname; char *version; @@ -496,8 +487,8 @@ read_symbols(char *modname) * following helper, then compare to the file on disk and * only update the later if anything changed */ -void __attribute__((format(printf, 2, 3))) -buf_printf(struct buffer *buf, const char *fmt, ...) +void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf, + const char *fmt, ...) { char tmp[SZ]; int len; @@ -514,8 +505,7 @@ buf_printf(struct buffer *buf, const char *fmt, ...) va_end(ap); } -void -buf_write(struct buffer *buf, const char *s, int len) +void buf_write(struct buffer *buf, const char *s, int len) { if (buf->size - buf->pos < len) { buf->size += len; @@ -525,10 +515,10 @@ buf_write(struct buffer *buf, const char *s, int len) buf->pos += len; } -/* Header for the generated file */ - -void -add_header(struct buffer *b, struct module *mod) +/** + * Header for the generated file + **/ +static void add_header(struct buffer *b, struct module *mod) { buf_printf(b, "#include \n"); buf_printf(b, "#include \n"); @@ -548,10 +538,10 @@ add_header(struct buffer *b, struct module *mod) buf_printf(b, "};\n"); } -/* Record CRCs for unresolved symbols */ - -void -add_versions(struct buffer *b, struct module *mod) +/** + * Record CRCs for unresolved symbols + **/ +static void add_versions(struct buffer *b, struct module *mod) { struct symbol *s, *exp; @@ -591,8 +581,8 @@ add_versions(struct buffer *b, struct module *mod) buf_printf(b, "};\n"); } -void -add_depends(struct buffer *b, struct module *mod, struct module *modules) +static void add_depends(struct buffer *b, struct module *mod, + struct module *modules) { struct symbol *s; struct module *m; @@ -622,8 +612,7 @@ add_depends(struct buffer *b, struct module *mod, struct module *modules) buf_printf(b, "\";\n"); } -void -add_srcversion(struct buffer *b, struct module *mod) +static void add_srcversion(struct buffer *b, struct module *mod) { if (mod->srcversion[0]) { buf_printf(b, "\n"); @@ -632,8 +621,7 @@ add_srcversion(struct buffer *b, struct module *mod) } } -void -write_if_changed(struct buffer *b, const char *fname) +static void write_if_changed(struct buffer *b, const char *fname) { char *tmp; FILE *file; @@ -677,8 +665,7 @@ write_if_changed(struct buffer *b, const char *fname) fclose(file); } -void -read_dump(const char *fname) +static void read_dump(const char *fname) { unsigned long size, pos = 0; void *file = grab_file(fname, &size); @@ -719,8 +706,7 @@ fail: fatal("parse error in symbol dump file\n"); } -void -write_dump(const char *fname) +static void write_dump(const char *fname) { struct buffer buf = { }; struct symbol *symbol; @@ -744,8 +730,7 @@ write_dump(const char *fname) write_if_changed(&buf, fname); } -int -main(int argc, char **argv) +int main(int argc, char **argv) { struct module *mod; struct buffer buf = { }; @@ -800,4 +785,3 @@ main(int argc, char **argv) return 0; } - -- cgit v1.1 From 040fcc819a2e7783a570f4bdcdd1f2a7f5f06837 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 28 Jan 2006 22:15:55 +0100 Subject: kbuild: improved modversioning support for external modules With following patch a second option is enabled to obtain symbol information from a second external module when a external module is build. The recommended approach is to use a common kbuild file but that may be impractical in certain cases. With this patch one can copy over a Module.symvers from one external module to make symbols (and symbol versions) available for another external module. Updated documentation in Documentation/kbuild/modules.txt Signed-off-by: Sam Ravnborg --- scripts/Makefile.modpost | 7 ++- scripts/mod/modpost.c | 123 ++++++++++++++++++++++++++++------------------- 2 files changed, 78 insertions(+), 52 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index bf96a61..563e3c5 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -39,7 +39,8 @@ include .config include scripts/Kbuild.include include scripts/Makefile.lib -symverfile := $(objtree)/Module.symvers +kernelsymfile := $(objtree)/Module.symvers +modulesymfile := $(KBUILD_EXTMOD)/Modules.symvers # Step 1), find all modules listed in $(MODVERDIR)/ __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) @@ -54,7 +55,9 @@ quiet_cmd_modpost = MODPOST cmd_modpost = scripts/mod/modpost \ $(if $(CONFIG_MODVERSIONS),-m) \ $(if $(CONFIG_MODULE_SRCVERSION_ALL),-a,) \ - $(if $(KBUILD_EXTMOD),-i,-o) $(symverfile) \ + $(if $(KBUILD_EXTMOD),-i,-o) $(kernelsymfile) \ + $(if $(KBUILD_EXTMOD),-I $(modulesymfile)) \ + $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(filter-out FORCE,$^) .PHONY: __modpost diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 4a2f2e3..976adf1 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -20,6 +20,8 @@ int modversions = 0; int have_vmlinux = 0; /* Is CONFIG_MODULE_SRCVERSION_ALL set? */ static int all_versions = 0; +/* If we are modposting external module set to 1 */ +static int external_module = 0; void fatal(const char *fmt, ...) { @@ -45,6 +47,18 @@ void warn(const char *fmt, ...) va_end(arglist); } +static int is_vmlinux(const char *modname) +{ + const char *myname; + + if ((myname = strrchr(modname, '/'))) + myname++; + else + myname = modname; + + return strcmp(myname, "vmlinux") == 0; +} + void *do_nofail(void *ptr, const char *expr) { if (!ptr) { @@ -100,6 +114,9 @@ struct symbol { unsigned int crc; int crc_valid; unsigned int weak:1; + unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ + unsigned int kernel:1; /* 1 if symbol is from kernel + * (only for external modules) **/ char name[0]; }; @@ -135,8 +152,7 @@ static struct symbol *alloc_symbol(const char *name, unsigned int weak, } /* For the hash of exported symbols */ -static void new_symbol(const char *name, struct module *module, - unsigned int *crc) +static struct symbol *new_symbol(const char *name, struct module *module) { unsigned int hash; struct symbol *new; @@ -144,10 +160,7 @@ static void new_symbol(const char *name, struct module *module, hash = tdb_hash(name) % SYMBOL_HASH_SIZE; new = symbolhash[hash] = alloc_symbol(name, 0, symbolhash[hash]); new->module = module; - if (crc) { - new->crc = *crc; - new->crc_valid = 1; - } + return new; } static struct symbol *find_symbol(const char *name) @@ -169,19 +182,27 @@ static struct symbol *find_symbol(const char *name) * Add an exported symbol - it may have already been added without a * CRC, in this case just update the CRC **/ -static void add_exported_symbol(const char *name, struct module *module, - unsigned int *crc) +static struct symbol *sym_add_exported(const char *name, struct module *mod) { struct symbol *s = find_symbol(name); - if (!s) { - new_symbol(name, module, crc); - return; - } - if (crc) { - s->crc = *crc; - s->crc_valid = 1; - } + if (!s) + s = new_symbol(name, mod); + + s->vmlinux = is_vmlinux(mod->name); + s->kernel = 0; + return s; +} + +static void sym_update_crc(const char *name, struct module *mod, + unsigned int crc) +{ + struct symbol *s = find_symbol(name); + + if (!s) + s = new_symbol(name, mod); + s->crc = crc; + s->crc_valid = 1; } void *grab_file(const char *filename, unsigned long *size) @@ -332,8 +353,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, /* CRC'd symbol */ if (memcmp(symname, CRC_PFX, strlen(CRC_PFX)) == 0) { crc = (unsigned int) sym->st_value; - add_exported_symbol(symname + strlen(CRC_PFX), - mod, &crc); + sym_update_crc(symname + strlen(CRC_PFX), mod, crc); } break; case SHN_UNDEF: @@ -377,8 +397,7 @@ static void handle_modversions(struct module *mod, struct elf_info *info, default: /* All exported symbols */ if (memcmp(symname, KSYMTAB_PFX, strlen(KSYMTAB_PFX)) == 0) { - add_exported_symbol(symname + strlen(KSYMTAB_PFX), - mod, NULL); + sym_add_exported(symname + strlen(KSYMTAB_PFX), mod); } if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0) mod->has_init = 1; @@ -388,18 +407,6 @@ static void handle_modversions(struct module *mod, struct elf_info *info, } } -static int is_vmlinux(const char *modname) -{ - const char *myname; - - if ((myname = strrchr(modname, '/'))) - myname++; - else - myname = modname; - - return strcmp(myname, "vmlinux") == 0; -} - /** * Parse tag=value strings from .modinfo section **/ @@ -450,9 +457,7 @@ static void read_symbols(char *modname) /* When there's no vmlinux, don't print warnings about * unresolved symbols (since there'll be too many ;) */ if (is_vmlinux(modname)) { - unsigned int fake_crc = 0; have_vmlinux = 1; - add_exported_symbol("struct_module", mod, &fake_crc); mod->skip = 1; } @@ -665,7 +670,7 @@ static void write_if_changed(struct buffer *b, const char *fname) fclose(file); } -static void read_dump(const char *fname) +static void read_dump(const char *fname, unsigned int kernel) { unsigned long size, pos = 0; void *file = grab_file(fname, &size); @@ -679,6 +684,7 @@ static void read_dump(const char *fname) char *symname, *modname, *d; unsigned int crc; struct module *mod; + struct symbol *s; if (!(symname = strchr(line, '\t'))) goto fail; @@ -699,13 +705,28 @@ static void read_dump(const char *fname) mod = new_module(NOFAIL(strdup(modname))); mod->skip = 1; } - add_exported_symbol(symname, mod, &crc); + s = sym_add_exported(symname, mod); + s->kernel = kernel; + sym_update_crc(symname, mod, crc); } return; fail: fatal("parse error in symbol dump file\n"); } +/* For normal builds always dump all symbols. + * For external modules only dump symbols + * that are not read from kernel Module.symvers. + **/ +static int dump_sym(struct symbol *sym) +{ + if (!external_module) + return 1; + if (sym->vmlinux || sym->kernel) + return 0; + return 1; +} + static void write_dump(const char *fname) { struct buffer buf = { }; @@ -715,15 +736,10 @@ static void write_dump(const char *fname) for (n = 0; n < SYMBOL_HASH_SIZE ; n++) { symbol = symbolhash[n]; while (symbol) { - symbol = symbol->next; - } - } - - for (n = 0; n < SYMBOL_HASH_SIZE ; n++) { - symbol = symbolhash[n]; - while (symbol) { - buf_printf(&buf, "0x%08x\t%s\t%s\n", symbol->crc, - symbol->name, symbol->module->name); + if (dump_sym(symbol)) + buf_printf(&buf, "0x%08x\t%s\t%s\n", + symbol->crc, symbol->name, + symbol->module->name); symbol = symbol->next; } } @@ -735,13 +751,18 @@ int main(int argc, char **argv) struct module *mod; struct buffer buf = { }; char fname[SZ]; - char *dump_read = NULL, *dump_write = NULL; + char *kernel_read = NULL, *module_read = NULL; + char *dump_write = NULL; int opt; - while ((opt = getopt(argc, argv, "i:mo:a")) != -1) { + while ((opt = getopt(argc, argv, "i:I:mo:a")) != -1) { switch(opt) { case 'i': - dump_read = optarg; + kernel_read = optarg; + break; + case 'I': + module_read = optarg; + external_module = 1; break; case 'm': modversions = 1; @@ -757,8 +778,10 @@ int main(int argc, char **argv) } } - if (dump_read) - read_dump(dump_read); + if (kernel_read) + read_dump(kernel_read, 1); + if (module_read) + read_dump(module_read, 0); while (optind < argc) { read_symbols(argv[optind++]); -- cgit v1.1 From 8e70c45887a6bbe40393342ea5b426b0dd836dff Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 28 Jan 2006 22:22:33 +0100 Subject: kbuild: warn about duplicate exported symbols In modpost introduce a check for symbols exported twice. This check caught only one victim (inet_bind_bucket_create) for which a patch is already sent to netdev. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 976adf1..d901095 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -117,6 +117,7 @@ struct symbol { unsigned int vmlinux:1; /* 1 if symbol is defined in vmlinux */ unsigned int kernel:1; /* 1 if symbol is from kernel * (only for external modules) **/ + unsigned int preloaded:1; /* 1 if symbol from Module.symvers */ char name[0]; }; @@ -186,9 +187,17 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod) { struct symbol *s = find_symbol(name); - if (!s) + if (!s) { s = new_symbol(name, mod); - + } else { + if (!s->preloaded) { + warn("%s: duplicate symbol '%s' previous definition " + "was in %s%s\n", mod->name, name, + s->module->name, + is_vmlinux(s->module->name) ?"":".ko"); + } + } + s->preloaded = 0; s->vmlinux = is_vmlinux(mod->name); s->kernel = 0; return s; @@ -706,7 +715,8 @@ static void read_dump(const char *fname, unsigned int kernel) mod->skip = 1; } s = sym_add_exported(symname, mod); - s->kernel = kernel; + s->kernel = kernel; + s->preloaded = 1; sym_update_crc(symname, mod, crc); } return; -- cgit v1.1 From b39927cf4cc5a9123d2b157ffd396884cb8156eb Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 17 Feb 2006 22:42:02 +0100 Subject: kbuild: check for section mismatch during modpost stage Section mismatch is identified as references to .init* sections from non .init sections. And likewise references to .exit.* sections outside .exit sections. .init.* sections are discarded after a module is initialized and references to .init.* sections are oops candidates. .exit.* sections are discarded when a module is built-in and thus references to .exit are also oops candidates. The checks were possible to do using 'make buildcheck' which called the two perl scripts: reference_discarded.pl and reference_init.pl. This patch just moves the same functionality inside modpost and the scripts are then obsoleted. They will though be kept for a while so users can do double checks - but note that some .o files are skipped by the perl scripts so result is not 1:1. All credit for the concept goes to Keith Owens who implemented the original perl scrips - this patch just moves it to modpost. Compared to the perl script the implmentation in modpost will be run for each kernel build - thus catching the error much sooner, but the downside is that the individual .o file are not always identified. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 258 ++++++++++++++++++++++++++++++++++++++++++++++++++ scripts/mod/modpost.h | 10 ++ 2 files changed, 268 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index d901095..a7360c3 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -451,6 +451,262 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len, return NULL; } +/* + * Find symbols before or equal addr and after addr - in the section sec + **/ +static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, + const char *sec, + Elf_Sym **before, Elf_Sym **after) +{ + Elf_Sym *sym; + Elf_Ehdr *hdr = elf->hdr; + Elf_Addr beforediff = ~0; + Elf_Addr afterdiff = ~0; + const char *secstrings = (void *)hdr + + elf->sechdrs[hdr->e_shstrndx].sh_offset; + + *before = NULL; + *after = NULL; + + for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { + const char *symsec; + + if (sym->st_shndx >= SHN_LORESERVE) + continue; + symsec = secstrings + elf->sechdrs[sym->st_shndx].sh_name; + if (strcmp(symsec, sec) != 0) + continue; + if (sym->st_value <= addr) { + if ((addr - sym->st_value) < beforediff) { + beforediff = addr - sym->st_value; + *before = sym; + } + } + else + { + if ((sym->st_value - addr) < afterdiff) { + afterdiff = sym->st_value - addr; + *after = sym; + } + } + } +} + +/** + * Print a warning about a section mismatch. + * Try to find symbols near it so user can find it. + **/ +static void warn_sec_mismatch(const char *modname, const char *fromsec, + struct elf_info *elf, Elf_Sym *sym, Elf_Rela r) +{ + Elf_Sym *before; + Elf_Sym *after; + Elf_Ehdr *hdr = elf->hdr; + Elf_Shdr *sechdrs = elf->sechdrs; + const char *secstrings = (void *)hdr + + sechdrs[hdr->e_shstrndx].sh_offset; + const char *secname = secstrings + sechdrs[sym->st_shndx].sh_name; + + find_symbols_between(elf, r.r_offset, fromsec, &before, &after); + + if (before && after) { + warn("%s - Section mismatch: reference to %s from %s " + "between '%s' (at offset 0x%lx) and '%s'\n", + modname, secname, fromsec, + elf->strtab + before->st_name, + (long)(r.r_offset - before->st_value), + elf->strtab + after->st_name); + } else if (before) { + warn("%s - Section mismatch: reference to %s from %s " + "after '%s' (at offset 0x%lx)\n", + modname, secname, fromsec, + elf->strtab + before->st_name, + (long)(r.r_offset - before->st_value)); + } else if (after) { + warn("%s - Section mismatch: reference to %s from %s " + "before '%s' (at offset -0x%lx)\n", + modname, secname, fromsec, + elf->strtab + before->st_name, + (long)(before->st_value - r.r_offset)); + } else { + warn("%s - Section mismatch: reference to %s from %s " + "(offset 0x%lx)\n", + modname, secname, fromsec, (long)r.r_offset); + } +} + +/** + * A module includes a number of sections that are discarded + * either when loaded or when used as built-in. + * For loaded modules all functions marked __init and all data + * marked __initdata will be discarded when the module has been intialized. + * Likewise for modules used built-in the sections marked __exit + * are discarded because __exit marked function are supposed to be called + * only when a moduel is unloaded which never happes for built-in modules. + * The check_sec_ref() function traverses all relocation records + * to find all references to a section that reference a section that will + * be discarded and warns about it. + **/ +static void check_sec_ref(struct module *mod, const char *modname, + struct elf_info *elf, + int section(const char*), + int section_ref_ok(const char *)) +{ + int i; + Elf_Sym *sym; + Elf_Ehdr *hdr = elf->hdr; + Elf_Shdr *sechdrs = elf->sechdrs; + const char *secstrings = (void *)hdr + + sechdrs[hdr->e_shstrndx].sh_offset; + + /* Walk through all sections */ + for (i = 0; i < hdr->e_shnum; i++) { + const char *name = secstrings + sechdrs[i].sh_name + + strlen(".rela"); + /* We want to process only relocation sections and not .init */ + if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA)) + continue; + Elf_Rela *rela; + Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset; + Elf_Rela *stop = (void*)start + sechdrs[i].sh_size; + + for (rela = start; rela < stop; rela++) { + Elf_Rela r; + const char *secname; + r.r_offset = TO_NATIVE(rela->r_offset); + r.r_info = TO_NATIVE(rela->r_info); + sym = elf->symtab_start + ELF_R_SYM(r.r_info); + secname = secstrings + sechdrs[sym->st_shndx].sh_name; + /* Skip special sections */ + if (sym->st_shndx >= SHN_LORESERVE) + continue; + + if (section(secname)) + warn_sec_mismatch(modname, name, elf, sym, r); + } + } +} + +/** + * Functions used only during module init is marked __init and is stored in + * a .init.text section. Likewise data is marked __initdata and stored in + * a .init.data section. + * If this section is one of these sections return 1 + * See include/linux/init.h for the details + **/ +static int init_section(const char *name) +{ + if (strcmp(name, ".init") == 0) + return 1; + if (strncmp(name, ".init.", strlen(".init.")) == 0) + return 1; + return 0; +} + +/** + * Identify sections from which references to a .init section is OK. + * + * Unfortunately references to read only data that referenced .init + * sections had to be excluded. Almost all of these are false + * positives, they are created by gcc. The downside of excluding rodata + * is that there really are some user references from rodata to + * init code, e.g. drivers/video/vgacon.c: + * + * const struct consw vga_con = { + * con_startup: vgacon_startup, + * + * where vgacon_startup is __init. If you want to wade through the false + * positives, take out the check for rodata. + **/ +static int init_section_ref_ok(const char *name) +{ + const char **s; + /* Absolute section names */ + const char *namelist1[] = { + ".init", + ".stab", + ".rodata", + ".text.lock", + ".pci_fixup_header", + ".pci_fixup_final", + ".pdr", + "__param", + NULL + }; + /* Start of section names */ + const char *namelist2[] = { + ".init.", + ".altinstructions", + ".eh_frame", + ".debug", + 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; + return 0; +} + +/* + * Functions used only during module exit is marked __exit and is stored in + * a .exit.text section. Likewise data is marked __exitdata and stored in + * a .exit.data section. + * If this section is one of these sections return 1 + * See include/linux/init.h for the details + **/ +static int exit_section(const char *name) +{ + if (strcmp(name, ".exit.text") == 0) + return 1; + if (strcmp(name, ".exit.data") == 0) + return 1; + return 0; + +} + +/* + * 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. + **/ +static int exit_section_ref_ok(const char *name) +{ + const char **s; + /* Absolute section names */ + const char *namelist1[] = { + ".exit.text", + ".exit.data", + ".init.text", + ".opd", /* See comment [OPD] */ + ".altinstructions", + ".pdr", + ".exitcall.exit", + ".eh_frame", + ".stab", + NULL + }; + /* Start of section names */ + const char *namelist2[] = { + ".debug", + 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; + return 0; +} + static void read_symbols(char *modname) { const char *symname; @@ -476,6 +732,8 @@ static void read_symbols(char *modname) handle_modversions(mod, &info, sym, symname); handle_moddevtable(mod, &info, sym, symname); } + check_sec_ref(mod, modname, &info, init_section, init_section_ref_ok); + check_sec_ref(mod, modname, &info, exit_section, exit_section_ref_ok); version = get_modinfo(info.modinfo, info.modinfo_len, "version"); if (version) diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index c0de7b9..3b5319d 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -16,17 +16,27 @@ #define Elf_Ehdr Elf32_Ehdr #define Elf_Shdr Elf32_Shdr #define Elf_Sym Elf32_Sym +#define Elf_Addr Elf32_Addr +#define Elf_Section Elf32_Section #define ELF_ST_BIND ELF32_ST_BIND #define ELF_ST_TYPE ELF32_ST_TYPE +#define Elf_Rela Elf32_Rela +#define ELF_R_SYM ELF32_R_SYM +#define ELF_R_TYPE ELF32_R_TYPE #else #define Elf_Ehdr Elf64_Ehdr #define Elf_Shdr Elf64_Shdr #define Elf_Sym Elf64_Sym +#define Elf_Addr Elf64_Addr +#define Elf_Section Elf64_Section #define ELF_ST_BIND ELF64_ST_BIND #define ELF_ST_TYPE ELF64_ST_TYPE +#define Elf_Rela Elf64_Rela +#define ELF_R_SYM ELF64_R_SYM +#define ELF_R_TYPE ELF64_R_TYPE #endif #if KERNEL_ELFDATA != HOST_ELFDATA -- cgit v1.1 From 20a468b51325b3636785a8ca0047ae514b39cbd5 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 22 Jan 2006 13:34:15 +0100 Subject: kbuild: make cc-version available in kbuild files Move $(CC) support functions to Kbuild.include so they are available in the kbuild files. In addition the following was done: o as-option documented in Documentation/kbuild/makefiles.txt o Moved documentation to new section to match new scope of functions o added cc-ifversion used to conditionally select a text string dependent on actual $(CC) version o documented cc-ifversion o change so Kbuild.include is read before the kbuild file Signed-off-by: Sam Ravnborg --- scripts/Kbuild.include | 37 +++++++++++++++++++++++++++++++++++++ scripts/Makefile.build | 3 ++- 2 files changed, 39 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 0168d6c..92ce94b 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -44,6 +44,43 @@ define filechk fi endef +###### +# cc support functions to be used (only) in arch/$(ARCH)/Makefile +# See documentation in Documentation/kbuild/makefiles.txt + +# as-option +# Usage: cflags-y += $(call as-option, -Wa$(comma)-isa=foo,) + +as-option = $(shell if $(CC) $(CFLAGS) $(1) -Wa,-Z -c -o /dev/null \ + -xassembler /dev/null > /dev/null 2>&1; then echo "$(1)"; \ + else echo "$(2)"; fi ;) + +# cc-option +# Usage: cflags-y += $(call cc-option, -march=winchip-c6, -march=i586) + +cc-option = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ + > /dev/null 2>&1; then echo "$(1)"; else echo "$(2)"; fi ;) + +# cc-option-yn +# Usage: flag := $(call cc-option-yn, -march=winchip-c6) +cc-option-yn = $(shell if $(CC) $(CFLAGS) $(1) -S -o /dev/null -xc /dev/null \ + > /dev/null 2>&1; then echo "y"; else echo "n"; fi;) + +# cc-option-align +# Prefix align with either -falign or -malign +cc-option-align = $(subst -functions=0,,\ + $(call cc-option,-falign-functions=0,-malign-functions=0)) + +# cc-version +# Usage gcc-ver := $(call cc-version, $(CC)) +cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh \ + $(if $(1), $(1), $(CC))) + +# cc-ifversion +# Usage: EXTRA_CFLAGS += $(call cc-ifversion, -lt, 0402, -O1) +cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \ + echo $(3); fi;) + ### # Shorthand for $(Q)$(MAKE) -f scripts/Makefile.build obj= # Usage: diff --git a/scripts/Makefile.build b/scripts/Makefile.build index c33e62b..2737765 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -10,11 +10,12 @@ __build: # Read .config if it exist, otherwise ignore -include .config +include scripts/Kbuild.include + # The filename Kbuild has precedence over Makefile kbuild-dir := $(if $(filter /%,$(src)),$(src),$(srctree)/$(src)) include $(if $(wildcard $(kbuild-dir)/Kbuild), $(kbuild-dir)/Kbuild, $(kbuild-dir)/Makefile) -include scripts/Kbuild.include include scripts/Makefile.lib ifdef host-progs -- cgit v1.1 From 6176aa9ae4b83e1957d3031774f8a8e59ff97420 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 30 Jan 2006 10:04:27 +0100 Subject: kbuild: consolidate command line escaping While the recent change to also escape # symbols when storing C-file compilation command lines was helpful, it should be in effect for all command lines, as much as the dollar escaping should be in effect for C-source compilation commands. Additionally, for better readability and maintenance, consolidating all the escaping (single quotes, dollars, and now sharps) was also desirable. Signed-Off-By: Jan Beulich Signed-off-by: Sam Ravnborg --- scripts/Kbuild.include | 15 +++++++-------- scripts/Makefile.build | 8 +++----- scripts/basic/fixdep.c | 14 ++------------ 3 files changed, 12 insertions(+), 25 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 92ce94b..3e7e0b2 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -88,8 +88,7 @@ cc-ifversion = $(shell if [ $(call cc-version, $(CC)) $(1) $(2) ]; then \ build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj # If quiet is set, only print short version of command -cmd = @$(if $($(quiet)cmd_$(1)),\ - echo ' $(call escsq,$($(quiet)cmd_$(1)))' &&) $(cmd_$(1)) +cmd = @$(echo-cmd) $(cmd_$(1)) # Add $(obj)/ for paths that is not absolute objectify = $(foreach o,$(1),$(if $(filter /%,$(o)),$(o),$(obj)/$(o))) @@ -112,24 +111,24 @@ endif echo-cmd = $(if $($(quiet)cmd_$(1)), \ echo ' $(call escsq,$($(quiet)cmd_$(1)))';) +make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))) + # function to only execute the passed command if necessary # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars # if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ @set -e; \ - $(echo-cmd) \ - $(cmd_$(1)); \ - echo 'cmd_$@ := $(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).cmd) + $(echo-cmd) $(cmd_$(1)); \ + echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd) # execute the command and also postprocess generated .d dependencies # file if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ @set -e; \ - $(echo-cmd) \ - $(cmd_$(1)); \ - scripts/basic/fixdep $(depfile) $@ '$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))' > $(@D)/.$(@F).tmp; \ + $(echo-cmd) $(cmd_$(1)); \ + scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ rm -f $(depfile); \ mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 2737765..6ac96ea 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -178,12 +178,10 @@ cmd_modversions = \ endif define rule_cc_o_c - $(if $($(quiet)cmd_checksrc),echo ' $($(quiet)cmd_checksrc)';) \ - $(cmd_checksrc) \ - $(if $($(quiet)cmd_cc_o_c),echo ' $(call escsq,$($(quiet)cmd_cc_o_c))';) \ - $(cmd_cc_o_c); \ + $(call echo-cmd,checksrc) $(cmd_checksrc) \ + $(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \ $(cmd_modversions) \ - scripts/basic/fixdep $(depfile) $@ '$(call escsq,$(cmd_cc_o_c))' > $(@D)/.$(@F).tmp; \ + scripts/basic/fixdep $(depfile) $@ '$(call make-cmd,cc_o_c)' > $(@D)/.$(@F).tmp; \ rm -f $(depfile); \ mv -f $(@D)/.$(@F).tmp $(@D)/.$(@F).cmd endef diff --git a/scripts/basic/fixdep.c b/scripts/basic/fixdep.c index 679124b..668a11a 100644 --- a/scripts/basic/fixdep.c +++ b/scripts/basic/fixdep.c @@ -132,20 +132,10 @@ void usage(void) /* * Print out the commandline prefixed with cmd_ := - * If commandline contains '#' escape with '\' so make to not see - * the '#' as a start-of-comment symbol - **/ + */ void print_cmdline(void) { - char *p = cmdline; - - printf("cmd_%s := ", target); - for (; *p; p++) { - if (*p == '#') - printf("\\"); - printf("%c", *p); - } - printf("\n\n"); + printf("cmd_%s := %s\n\n", target, cmdline); } char * str_config = NULL; -- cgit v1.1 From 96678281bfaa5f04752a98f9b93454041169fd3b Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Mon, 30 Jan 2006 10:05:09 +0100 Subject: kbuild: fix mkmakefile With the current way of generating the Makefile in the output directory for builds outside of the source tree, specifying real targets (rather than phony ones) doesn't work in an already (partially) built tree, as the stub Makefile doesn't have any dependency information available. Thus, all targets where files may actually exist must be listed explicitly and, due to what I'd call a make misbehavior, directory targets must then also be special cased. Signed-Off-By: Jan Beulich Signed-off-by: Sam Ravnborg --- scripts/mkmakefile | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/mkmakefile b/scripts/mkmakefile index c4d621b..a22cbed 100644 --- a/scripts/mkmakefile +++ b/scripts/mkmakefile @@ -21,11 +21,13 @@ KERNELOUTPUT := $2 MAKEFLAGS += --no-print-directory +.PHONY: all \$(MAKECMDGOALS) + all: \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) -%:: - \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@ +Makefile:; +\$(filter-out all Makefile,\$(MAKECMDGOALS)) %/: + \$(MAKE) -C \$(KERNELSRC) O=\$(KERNELOUTPUT) \$@ EOF - -- cgit v1.1 From 18a43ba26dcbe2a7a51011c9daae37adc7fc5c93 Mon Sep 17 00:00:00 2001 From: Brian Gerst Date: Wed, 15 Feb 2006 01:01:58 -0500 Subject: kbuild: remove checkconfig.pl checkconfig.pl is no longer needed now that autoconf.h is automatically included. Remove it and all references to it. Signed-off-by: Brian Gerst Signed-off-by: Sam Ravnborg --- scripts/checkconfig.pl | 65 -------------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100755 scripts/checkconfig.pl (limited to 'scripts') diff --git a/scripts/checkconfig.pl b/scripts/checkconfig.pl deleted file mode 100755 index ca1f231..0000000 --- a/scripts/checkconfig.pl +++ /dev/null @@ -1,65 +0,0 @@ -#! /usr/bin/perl -# -# checkconfig: find uses of CONFIG_* names without matching definitions. -# Copyright abandoned, 1998, Michael Elizabeth Chastain . - -use integer; - -$| = 1; - -foreach $file (@ARGV) -{ - # Open this file. - open(FILE, $file) || die "Can't open $file: $!\n"; - - # Initialize variables. - my $fInComment = 0; - my $fInString = 0; - my $fUseConfig = 0; - my $iLinuxConfig = 0; - my %configList = (); - - LINE: while ( ) - { - # Strip comments. - $fInComment && (s+^.*?\*/+ +o ? ($fInComment = 0) : next); - m+/\*+o && (s+/\*.*?\*/+ +go, (s+/\*.*$+ +o && ($fInComment = 1))); - - # Pick up definitions. - if ( m/^\s*#/o ) - { - $iLinuxConfig = $. if m/^\s*#\s*include\s*"linux\/config\.h"/o; - $configList{uc $1} = 1 if m/^\s*#\s*include\s*"config\/(\S*)\.h"/o; - } - - # Strip strings. - $fInString && (s+^.*?"+ +o ? ($fInString = 0) : next); - m+"+o && (s+".*?"+ +go, (s+".*$+ +o && ($fInString = 1))); - - # Pick up definitions. - if ( m/^\s*#/o ) - { - $iLinuxConfig = $. if m/^\s*#\s*include\s*/o; - $configList{uc $1} = 1 if m/^\s*#\s*include\s*/o; - $configList{$1} = 1 if m/^\s*#\s*define\s+CONFIG_(\w*)/o; - $configList{$1} = 1 if m/^\s*#\s*undef\s+CONFIG_(\w*)/o; - } - - # Look for usages. - next unless m/CONFIG_/o; - WORD: while ( m/\bCONFIG_(\w+)/og ) - { - $fUseConfig = 1; - last LINE if $iLinuxConfig; - next WORD if exists $configList{$1}; - print "$file: $.: need CONFIG_$1.\n"; - $configList{$1} = 0; - } - } - - # Report superfluous includes. - if ( $iLinuxConfig && ! $fUseConfig ) - { print "$file: $iLinuxConfig: linux/config.h not needed.\n"; } - - close(FILE); -} -- cgit v1.1 From 9d6e7a709cdb8f43d9a9ac5532b54a3e70415b9b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sat, 18 Feb 2006 10:03:40 +0100 Subject: kbuild: fix comment in Kbuild.include Noted by Olaf Hering Signed-off-by: Sam Ravnborg --- scripts/Kbuild.include | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index 3e7e0b2..c3d2e4e 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -45,7 +45,7 @@ define filechk endef ###### -# cc support functions to be used (only) in arch/$(ARCH)/Makefile +# gcc support functions # See documentation in Documentation/kbuild/makefiles.txt # as-option -- cgit v1.1 From 41370d3b5ec6401c5cf0df82297ed989c03a64bd Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 19 Feb 2006 00:49:37 +0100 Subject: kbuild: do not segfault in modpost if MODVERDIR is not defined A combination of calling modpost with option -a and MODVERDIR undefined caused segmentation fault. So provide a default value and accept the error messages it generates instead. Signed-off-by: Sam Ravnborg --- scripts/mod/sumversion.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index 5c07545..8a28756 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -381,8 +381,11 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) struct md4_ctx md; char *sources, *end, *fname; const char *basename; - char filelist[strlen(getenv("MODVERDIR")) + strlen("/") + - strlen(modname) - strlen(".o") + strlen(".mod") + 1 ]; + char filelist[PATH_MAX + 1]; + char *modverdir = getenv("MODVERDIR"); + + if (!modverdir) + modverdir = "."; /* Source files for module are in .tmp_versions/modname.mod, after the first line. */ @@ -390,7 +393,7 @@ void get_src_version(const char *modname, char sum[], unsigned sumlen) basename = strrchr(modname, '/') + 1; else basename = modname; - sprintf(filelist, "%s/%.*s.mod", getenv("MODVERDIR"), + sprintf(filelist, "%s/%.*s.mod", modverdir, (int) strlen(basename) - 2, basename); file = grab_file(filelist, &len); -- cgit v1.1 From 8ea80ca4f583e377c902811d42626ccfce16913f Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 19 Feb 2006 09:56:18 +0100 Subject: kbuild: fix segfault in modpost Do not try to look up section name until we know it is not a special section. Otherwise we will address outside legal space and segfault. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index a7360c3..eeaf574 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -576,11 +576,11 @@ static void check_sec_ref(struct module *mod, const char *modname, r.r_offset = TO_NATIVE(rela->r_offset); r.r_info = TO_NATIVE(rela->r_info); sym = elf->symtab_start + ELF_R_SYM(r.r_info); - secname = secstrings + sechdrs[sym->st_shndx].sh_name; /* Skip special sections */ if (sym->st_shndx >= SHN_LORESERVE) continue; + secname = secstrings + sechdrs[sym->st_shndx].sh_name; if (section(secname)) warn_sec_mismatch(modname, name, elf, sym, r); } -- cgit v1.1 From 93684d3b8062d1cebdeaed398ec6d1f354cb41a9 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 19 Feb 2006 11:53:35 +0100 Subject: kbuild: include symbol names in section mismatch warnings Try to look up the symbol that is referenced. Include the symbol name in the warning message. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 64 +++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 47 insertions(+), 17 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index eeaf574..844f84b 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -451,6 +451,29 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len, return NULL; } +/** + * Find symbol based on relocation record info. + * In some cases the symbol supplied is a valid symbol so + * return refsym. If st_name != 0 we assume this is a valid symbol. + * In other cases the symbol needs to be looked up in the symbol table + * based on section and address. + * **/ +static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, + Elf_Sym *relsym) +{ + Elf_Sym *sym; + + if (relsym->st_name != 0) + return relsym; + for (sym = elf->symtab_start; sym < elf->symtab_stop; sym++) { + if (sym->st_shndx != relsym->st_shndx) + continue; + if (sym->st_value == addr) + return sym; + } + return NULL; +} + /* * Find symbols before or equal addr and after addr - in the section sec **/ @@ -499,8 +522,9 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, static void warn_sec_mismatch(const char *modname, const char *fromsec, struct elf_info *elf, Elf_Sym *sym, Elf_Rela r) { - Elf_Sym *before; - Elf_Sym *after; + const char *refsymname = ""; + Elf_Sym *before, *after; + Elf_Sym *refsym; Elf_Ehdr *hdr = elf->hdr; Elf_Shdr *sechdrs = elf->sechdrs; const char *secstrings = (void *)hdr + @@ -509,29 +533,34 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, find_symbols_between(elf, r.r_offset, fromsec, &before, &after); + refsym = find_elf_symbol(elf, r.r_addend, sym); + if (refsym && strlen(elf->strtab + refsym->st_name)) + refsymname = elf->strtab + refsym->st_name; + if (before && after) { - warn("%s - Section mismatch: reference to %s from %s " - "between '%s' (at offset 0x%lx) and '%s'\n", - modname, secname, fromsec, + warn("%s - Section mismatch: reference to %s:%s from %s " + "between '%s' (at offset 0x%llx) and '%s'\n", + modname, secname, refsymname, fromsec, elf->strtab + before->st_name, - (long)(r.r_offset - before->st_value), + (long long)r.r_offset, elf->strtab + after->st_name); } else if (before) { - warn("%s - Section mismatch: reference to %s from %s " - "after '%s' (at offset 0x%lx)\n", - modname, secname, fromsec, + warn("%s - Section mismatch: reference to %s:%s from %s " + "after '%s' (at offset 0x%llx)\n", + modname, secname, refsymname, fromsec, elf->strtab + before->st_name, - (long)(r.r_offset - before->st_value)); + (long long)r.r_offset); } else if (after) { - warn("%s - Section mismatch: reference to %s from %s " - "before '%s' (at offset -0x%lx)\n", - modname, secname, fromsec, + warn("%s - Section mismatch: reference to %s:%s from %s " + "before '%s' (at offset -0x%llx)\n", + modname, secname, refsymname, fromsec, elf->strtab + before->st_name, - (long)(before->st_value - r.r_offset)); + (long long)r.r_offset); } else { - warn("%s - Section mismatch: reference to %s from %s " - "(offset 0x%lx)\n", - modname, secname, fromsec, (long)r.r_offset); + warn("%s - Section mismatch: reference to %s:%s from %s " + "(offset 0x%llx)\n", + modname, secname, fromsec, refsymname, + (long long)r.r_offset); } } @@ -575,6 +604,7 @@ static void check_sec_ref(struct module *mod, const char *modname, const char *secname; r.r_offset = TO_NATIVE(rela->r_offset); r.r_info = TO_NATIVE(rela->r_info); + r.r_addend = TO_NATIVE(rela->r_addend); sym = elf->symtab_start + ELF_R_SYM(r.r_info); /* Skip special sections */ if (sym->st_shndx >= SHN_LORESERVE) -- cgit v1.1 From fededcd2af6219de69b252b7d3ea4b4ec2f33c7a Mon Sep 17 00:00:00 2001 From: "akpm@osdl.org" Date: Wed, 22 Feb 2006 03:19:54 -0800 Subject: kbuild: fix modpost compile with older gcc The kernel now requires that CC be 3.1.0 or higher. But we shouldn't place that requirement upon HOSTCC unless we really need to. Fixes my ia64 problem. Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 844f84b..5b076ef 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -590,14 +590,14 @@ static void check_sec_ref(struct module *mod, const char *modname, /* Walk through all sections */ for (i = 0; i < hdr->e_shnum; i++) { + Elf_Rela *rela; + Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset; + Elf_Rela *stop = (void*)start + sechdrs[i].sh_size; const char *name = secstrings + sechdrs[i].sh_name + strlen(".rela"); /* We want to process only relocation sections and not .init */ if (section_ref_ok(name) || (sechdrs[i].sh_type != SHT_RELA)) continue; - Elf_Rela *rela; - Elf_Rela *start = (void *)hdr + sechdrs[i].sh_offset; - Elf_Rela *stop = (void*)start + sechdrs[i].sh_size; for (rela = start; rela < stop; rela++) { Elf_Rela r; -- cgit v1.1 From 6e10133fa4b2366e8ef18bc2ce34afe727b1c4ba Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 22 Feb 2006 21:24:50 +0100 Subject: kbuild: do not warn when unwind sections references .init/.exit sections Andrew Morton reported a number of false positives for ia64 - like these: WARNING: drivers/acpi/button.o - Section mismatch: reference to .init.text: from .IA_64.unwind.init.text after '' (at offset 0x0) WARNING: drivers/acpi/button.o - Section mismatch: reference to .exit.text: from .IA_64.unwind.exit.text after '' (at offset 0x0) WARNING: drivers/acpi/processor.o - Section mismatch: reference to .init.text: from .IA_64.unwind after '' (at offset 0x1e8) They are all false positives - or at least the .c code looks OK. It is not known why sometimes a section name is appended and sometimes not. Fix is to accept references from all sections that includes "unwind." in the name. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5b076ef..7f25354 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -671,13 +671,21 @@ static int init_section_ref_ok(const char *name) ".debug", NULL }; - + /* part of section name */ + const char *namelist3 [] = { + ".unwind", /* sample: IA_64.unwind.init.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(*s, name) != NULL) + return 1; return 0; } @@ -727,6 +735,11 @@ static int exit_section_ref_ok(const char *name) ".debug", 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) @@ -734,6 +747,9 @@ static int exit_section_ref_ok(const char *name) for (s = namelist2; *s; s++) if (strncmp(*s, name, strlen(*s)) == 0) return 1; + for (s = namelist3; *s; s++) + if (strstr(*s, name) != NULL) + return 1; return 0; } -- cgit v1.1 From 382168f4791822de7d44d9c634fbfdf8bc08c91b Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 26 Feb 2006 20:11:17 +0100 Subject: kbuild: Add copyright to modpost.c It seems popular to protect your work with copyright, so I decided to do so for modpost which I patch a great deal atm. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 7f25354..de0a9ee 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -2,7 +2,7 @@ * * Copyright 2003 Kai Germaschewski * Copyright 2002-2004 Rusty Russell, IBM Corporation - * + * Copyright 2006 Sam Ravnborg * Based in part on module-init-tools/depmod.c,file2alias * * This software may be used and distributed according to the terms -- cgit v1.1 From 4c8fbca5836aaafd165aa8732d92ab5d4f3a6841 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 26 Feb 2006 22:18:11 +0100 Subject: kbuild: whitelist false section mismatch warnings In several cases the section mismatch check triggered false warnings. Following patch introduce a whitelist to 'false positives' are not warned of. Two types of patterns are recognised: 1) Typical case when a module parameter is _initdata 2) When a function pointer is assigned to a driver structure In both patterns we rely on the actual name of the variable assigned Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index de0a9ee..663b1ef 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -452,6 +452,89 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len, } /** + * Test if string s ends in string sub + * return 0 if match + **/ +static int strrcmp(const char *s, const char *sub) +{ + int slen, sublen; + + if (!s || !sub) + return 1; + + slen = strlen(s); + sublen = strlen(sub); + + if ((slen == 0) || (sublen == 0)) + return 1; + + if (sublen > slen) + return 1; + + return memcmp(s + slen - sublen, sub, sublen); +} + +/** + * Whitelist to allow certain references to pass with no warning. + * Pattern 1: + * If a module parameter is declared __initdata and permissions=0 + * then this is legal despite the warning generated. + * We cannot see value of permissions here, so just ignore + * this pattern. + * The pattern is identified by: + * tosec = .init.data + * fromsec = .data + * atsym =__param* + * + * Pattern 2: + * Many drivers utilise a *_driver container with references to + * add, remove, probe functions etc. + * These functions may often be marked __init and we do not want to + * warn here. + * the pattern is identified by: + * tosec = .init.text | .exit.text + * fromsec = .data + * atsym = *_driver, *_ops, *_probe, *probe_one + **/ +static int secref_whitelist(const char *tosec, const char *fromsec, + const char *atsym) +{ + int f1 = 1, f2 = 1; + const char **s; + const char *pat2sym[] = { + "_driver", + "_ops", + "_probe", + "_probe_one", + NULL + }; + + /* Check for pattern 1 */ + if (strcmp(tosec, ".init.data") != 0) + f1 = 0; + if (strcmp(fromsec, ".data") != 0) + f1 = 0; + if (strncmp(atsym, "__param", strlen("__param")) != 0) + f1 = 0; + + if (f1) + return f1; + + /* Check for pattern 2 */ + if ((strcmp(tosec, ".init.text") != 0) && + (strcmp(tosec, ".exit.text") != 0)) + f2 = 0; + if (strcmp(fromsec, ".data") != 0) + f2 = 0; + + for (s = pat2sym; *s; s++) + if (strrcmp(atsym, *s) == 0) + f1 = 1; + + return f1 && f2; +} + +/** * Find symbol based on relocation record info. * In some cases the symbol supplied is a valid symbol so * return refsym. If st_name != 0 we assume this is a valid symbol. @@ -518,6 +601,7 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, /** * Print a warning about a section mismatch. * Try to find symbols near it so user can find it. + * Check whitelist before warning - it may be a false positive. **/ static void warn_sec_mismatch(const char *modname, const char *fromsec, struct elf_info *elf, Elf_Sym *sym, Elf_Rela r) @@ -536,6 +620,11 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, refsym = find_elf_symbol(elf, r.r_addend, sym); if (refsym && strlen(elf->strtab + refsym->st_name)) refsymname = elf->strtab + refsym->st_name; + + /* check whitelist - we may ignore it */ + if (before && + secref_whitelist(secname, fromsec, elf->strtab + before->st_name)) + return; if (before && after) { warn("%s - Section mismatch: reference to %s:%s from %s " -- cgit v1.1 From 3a25f0b19f2eefd158955ab809c8947ed8feadf1 Mon Sep 17 00:00:00 2001 From: Aaron Brooks Date: Sun, 26 Feb 2006 22:25:46 -0500 Subject: kbuild: make namespace.pl CROSS_COMPILE happy Using the fixed path to /usr/bin/{nm,objdump} does not allow CROSS_COMPILE environments to use namespace.pl. This patch causes namespace.pl to use $NM and $OBJDUMP if defined or fall back to the nm and objdump found in the path. Signed-off-by: Aaron Brooks Signed-off-by: Sam Ravnborg --- scripts/namespace.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/namespace.pl b/scripts/namespace.pl index 88e30e8..f343738 100644 --- a/scripts/namespace.pl +++ b/scripts/namespace.pl @@ -66,8 +66,8 @@ require 5; # at least perl 5 use strict; use File::Find; -my $nm = "/usr/bin/nm -p"; -my $objdump = "/usr/bin/objdump -s -j .comment"; +my $nm = ($ENV{'NM'} || "nm") . " -p"; +my $objdump = ($ENV{'OBJDUMP'} || "objdump") . " -s -j .comment"; my $srctree = ""; my $objtree = ""; $srctree = "$ENV{'srctree'}/" if (exists($ENV{'srctree'})); -- cgit v1.1 From e11f04962cee8f7fb0dc14983a7a461ade8f71c3 Mon Sep 17 00:00:00 2001 From: Jesper Juhl Date: Sat, 25 Feb 2006 21:52:50 +0100 Subject: kbuild: small update of allnoconfig description 'allnoconfig' is described by 'make help' as a "minimal config", that's not strictly correct. To be pedantic, a minimal config would be one where EMBEDDED was set to Y and most things therein disabled etc. Simply answering 'no' to all options does not give a minimal config. A better description of allnoconfig is that it answers all options with 'no'. This patch updates the description. Signed-off-by: Jesper Juhl Signed-off-by: Sam Ravnborg --- scripts/kconfig/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 5760e05..5280945 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -78,7 +78,7 @@ help: @echo ' defconfig - New config with default answer to all options' @echo ' allmodconfig - New config selecting modules when possible' @echo ' allyesconfig - New config where all options are accepted with yes' - @echo ' allnoconfig - New minimal config' + @echo ' allnoconfig - New config where all options are answered with no' # =========================================================================== # Shared Makefile for the various kconfig executables: -- cgit v1.1 From 62070fa42c4ac23d1d71146a4c14702302b80245 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Fri, 3 Mar 2006 16:46:04 +0100 Subject: kbuild: kill trailing whitespace in modpost & friends Signed-off-by: Sam Ravnborg --- scripts/mod/file2alias.c | 4 +-- scripts/mod/mk_elfconfig.c | 4 +-- scripts/mod/modpost.c | 70 +++++++++++++++++++++++----------------------- scripts/mod/modpost.h | 8 +++--- 4 files changed, 43 insertions(+), 43 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 1346223..e7b5350 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -34,7 +34,7 @@ typedef uint16_t __u16; typedef unsigned char __u8; /* Big exception to the "don't include kernel headers into userspace, which - * even potentially has different endianness and word sizes, since + * 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" @@ -228,7 +228,7 @@ static int do_pci_entry(const char *filename, return 1; } -/* looks like: "ccw:tNmNdtNdmN" */ +/* looks like: "ccw:tNmNdtNdmN" */ static int do_ccw_entry(const char *filename, struct ccw_device_id *id, char *alias) { diff --git a/scripts/mod/mk_elfconfig.c b/scripts/mod/mk_elfconfig.c index de2aabf..3c92c83 100644 --- a/scripts/mod/mk_elfconfig.c +++ b/scripts/mod/mk_elfconfig.c @@ -6,7 +6,7 @@ int main(int argc, char **argv) { - unsigned char ei[EI_NIDENT]; + unsigned char ei[EI_NIDENT]; union { short s; char c[2]; } endian_test; if (argc != 2) { @@ -57,7 +57,7 @@ main(int argc, char **argv) if ((strcmp(argv[1], "v850") == 0) || (strcmp(argv[1], "h8300") == 0)) printf("#define MODULE_SYMBOL_PREFIX \"_\"\n"); - else + else printf("#define MODULE_SYMBOL_PREFIX \"\"\n"); return 0; diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 663b1ef..5de3c63 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -85,7 +85,7 @@ static struct module *new_module(char *modname) { struct module *mod; char *p, *s; - + mod = NOFAIL(malloc(sizeof(*mod))); memset(mod, 0, sizeof(*mod)); p = NOFAIL(strdup(modname)); @@ -320,9 +320,9 @@ static void parse_elf(struct elf_info *info, const char *filename) continue; info->symtab_start = (void *)hdr + sechdrs[i].sh_offset; - info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset + info->symtab_stop = (void *)hdr + sechdrs[i].sh_offset + sechdrs[i].sh_size; - info->strtab = (void *)hdr + + info->strtab = (void *)hdr + sechdrs[sechdrs[i].sh_link].sh_offset; } if (!info->symtab_start) { @@ -387,15 +387,15 @@ static void handle_modversions(struct module *mod, struct elf_info *info, /* Ignore register directives. */ if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER) break; - if (symname[0] == '.') { - char *munged = strdup(symname); - munged[0] = '_'; - munged[1] = toupper(munged[1]); - symname = munged; - } + if (symname[0] == '.') { + char *munged = strdup(symname); + munged[0] = '_'; + munged[1] = toupper(munged[1]); + symname = munged; + } } #endif - + if (memcmp(symname, MODULE_SYMBOL_PREFIX, strlen(MODULE_SYMBOL_PREFIX)) == 0) mod->unres = alloc_symbol(symname + @@ -458,13 +458,13 @@ static char *get_modinfo(void *modinfo, unsigned long modinfo_len, static int strrcmp(const char *s, const char *sub) { int slen, sublen; - + if (!s || !sub) return 1; - + slen = strlen(s); sublen = strlen(sub); - + if ((slen == 0) || (sublen == 0)) return 1; @@ -485,7 +485,7 @@ static int strrcmp(const char *s, const char *sub) * tosec = .init.data * fromsec = .data * atsym =__param* - * + * * Pattern 2: * Many drivers utilise a *_driver container with references to * add, remove, probe functions etc. @@ -508,7 +508,7 @@ static int secref_whitelist(const char *tosec, const char *fromsec, "_probe_one", NULL }; - + /* Check for pattern 1 */ if (strcmp(tosec, ".init.data") != 0) f1 = 0; @@ -521,7 +521,7 @@ static int secref_whitelist(const char *tosec, const char *fromsec, return f1; /* Check for pattern 2 */ - if ((strcmp(tosec, ".init.text") != 0) && + if ((strcmp(tosec, ".init.text") != 0) && (strcmp(tosec, ".exit.text") != 0)) f2 = 0; if (strcmp(fromsec, ".data") != 0) @@ -570,7 +570,7 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, Elf_Addr afterdiff = ~0; const char *secstrings = (void *)hdr + elf->sechdrs[hdr->e_shstrndx].sh_offset; - + *before = NULL; *after = NULL; @@ -614,7 +614,7 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, const char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; const char *secname = secstrings + sechdrs[sym->st_shndx].sh_name; - + find_symbols_between(elf, r.r_offset, fromsec, &before, &after); refsym = find_elf_symbol(elf, r.r_addend, sym); @@ -622,10 +622,10 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, refsymname = elf->strtab + refsym->st_name; /* check whitelist - we may ignore it */ - if (before && + if (before && secref_whitelist(secname, fromsec, elf->strtab + before->st_name)) return; - + if (before && after) { warn("%s - Section mismatch: reference to %s:%s from %s " "between '%s' (at offset 0x%llx) and '%s'\n", @@ -636,13 +636,13 @@ static void warn_sec_mismatch(const char *modname, const char *fromsec, } else if (before) { warn("%s - Section mismatch: reference to %s:%s from %s " "after '%s' (at offset 0x%llx)\n", - modname, secname, refsymname, fromsec, + modname, secname, refsymname, fromsec, elf->strtab + before->st_name, (long long)r.r_offset); } else if (after) { warn("%s - Section mismatch: reference to %s:%s from %s " "before '%s' (at offset -0x%llx)\n", - modname, secname, refsymname, fromsec, + modname, secname, refsymname, fromsec, elf->strtab + before->st_name, (long long)r.r_offset); } else { @@ -676,7 +676,7 @@ static void check_sec_ref(struct module *mod, const char *modname, Elf_Shdr *sechdrs = elf->sechdrs; const char *secstrings = (void *)hdr + sechdrs[hdr->e_shstrndx].sh_offset; - + /* Walk through all sections */ for (i = 0; i < hdr->e_shnum; i++) { Elf_Rela *rela; @@ -724,13 +724,13 @@ static int init_section(const char *name) /** * Identify sections from which references to a .init section is OK. - * + * * Unfortunately references to read only data that referenced .init * sections had to be excluded. Almost all of these are false * positives, they are created by gcc. The downside of excluding rodata * is that there really are some user references from rodata to * init code, e.g. drivers/video/vgacon.c: - * + * * const struct consw vga_con = { * con_startup: vgacon_startup, * @@ -769,10 +769,10 @@ static int init_section_ref_ok(const char *name) for (s = namelist1; *s; s++) if (strcmp(*s, name) == 0) return 1; - for (s = namelist2; *s; s++) + for (s = namelist2; *s; s++) if (strncmp(*s, name, strlen(*s)) == 0) return 1; - for (s = namelist3; *s; s++) + for (s = namelist3; *s; s++) if (strstr(*s, name) != NULL) return 1; return 0; @@ -792,12 +792,12 @@ static int exit_section(const char *name) if (strcmp(name, ".exit.data") == 0) return 1; return 0; - + } /* * 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. @@ -829,14 +829,14 @@ static int exit_section_ref_ok(const char *name) ".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++) + for (s = namelist2; *s; s++) if (strncmp(*s, name, strlen(*s)) == 0) return 1; - for (s = namelist3; *s; s++) + for (s = namelist3; *s; s++) if (strstr(*s, name) != NULL) return 1; return 0; @@ -900,7 +900,7 @@ void __attribute__((format(printf, 2, 3))) buf_printf(struct buffer *buf, char tmp[SZ]; int len; va_list ap; - + va_start(ap, fmt); len = vsnprintf(tmp, SZ, fmt, ap); if (buf->size - buf->pos < len + 1) { @@ -1129,7 +1129,7 @@ static int dump_sym(struct symbol *sym) return 0; return 1; } - + static void write_dump(const char *fname) { struct buffer buf = { }; @@ -1141,7 +1141,7 @@ static void write_dump(const char *fname) while (symbol) { if (dump_sym(symbol)) buf_printf(&buf, "0x%08x\t%s\t%s\n", - symbol->crc, symbol->name, + symbol->crc, symbol->name, symbol->module->name); symbol = symbol->next; } diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 3b5319d..b14255c 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -13,8 +13,8 @@ #if KERNEL_ELFCLASS == ELFCLASS32 -#define Elf_Ehdr Elf32_Ehdr -#define Elf_Shdr Elf32_Shdr +#define Elf_Ehdr Elf32_Ehdr +#define Elf_Shdr Elf32_Shdr #define Elf_Sym Elf32_Sym #define Elf_Addr Elf32_Addr #define Elf_Section Elf32_Section @@ -26,8 +26,8 @@ #define ELF_R_TYPE ELF32_R_TYPE #else -#define Elf_Ehdr Elf64_Ehdr -#define Elf_Shdr Elf64_Shdr +#define Elf_Ehdr Elf64_Ehdr +#define Elf_Shdr Elf64_Shdr #define Elf_Sym Elf64_Sym #define Elf_Addr Elf64_Addr #define Elf_Section Elf64_Section -- cgit v1.1 From 9209aed0726c77ad13b8d83e73a3cf9f59a8c2b2 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 5 Mar 2006 00:16:26 +0100 Subject: kbuild: kill false positives from section mismatch warnings for powerpc Building an allmodconfig kernel for ppc64 revealed a number of false positives - originally reported by Andrew Morton. This patch removes most if not all false positives for ppc64: Section .opd The .opd section contains function descriptors at least for ppc64. So ignore it for .init.text (was ignored for .exit.text). See description of function descriptors here: http://www.linuxbase.org/spec/ELF/ppc64/PPC-elf64abi-1.7.html Section .toc1 ppc64 places some static variables in .toc1 - ignore the. Section __bug_tabe BUG() and friends uses __bug_table. Ignore warnings from that section. Module parameters are placed in .data.rel for ppc64, for adjust pattern to match on section named .data* Tested with gcc: 3.4.0 and binutils 2.15.90.0.3 Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 5de3c63..c4dc1d7 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -483,7 +483,7 @@ static int strrcmp(const char *s, const char *sub) * this pattern. * The pattern is identified by: * tosec = .init.data - * fromsec = .data + * fromsec = .data* * atsym =__param* * * Pattern 2: @@ -512,7 +512,7 @@ static int secref_whitelist(const char *tosec, const char *fromsec, /* Check for pattern 1 */ if (strcmp(tosec, ".init.data") != 0) f1 = 0; - if (strcmp(fromsec, ".data") != 0) + if (strncmp(fromsec, ".data", strlen(".data")) != 0) f1 = 0; if (strncmp(atsym, "__param", strlen("__param")) != 0) f1 = 0; @@ -743,9 +743,12 @@ static int init_section_ref_ok(const char *name) /* Absolute section names */ const char *namelist1[] = { ".init", + ".opd", /* see comment [OPD] at exit_section_ref_ok() */ + ".toc1", /* used by ppc64 */ ".stab", ".rodata", ".text.lock", + "__bug_table", /* used by powerpc for BUG() */ ".pci_fixup_header", ".pci_fixup_final", ".pdr", @@ -812,8 +815,10 @@ static int exit_section_ref_ok(const char *name) ".exit.data", ".init.text", ".opd", /* See comment [OPD] */ + ".toc1", /* used by ppc64 */ ".altinstructions", ".pdr", + "__bug_table", /* used by powerpc for BUG() */ ".exitcall.exit", ".eh_frame", ".stab", -- cgit v1.1 From e835a39c1c1f023ef443f735b0e98b08660ae0e4 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 5 Mar 2006 11:34:15 +0100 Subject: kbuild: fix section mismatch check for unwind on IA64 Parameters to strstr() was reversed. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index c4dc1d7..3b570b1 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -776,7 +776,7 @@ static int init_section_ref_ok(const char *name) if (strncmp(*s, name, strlen(*s)) == 0) return 1; for (s = namelist3; *s; s++) - if (strstr(*s, name) != NULL) + if (strstr(name, *s) != NULL) return 1; return 0; } @@ -842,7 +842,7 @@ static int exit_section_ref_ok(const char *name) if (strncmp(*s, name, strlen(*s)) == 0) return 1; for (s = namelist3; *s; s++) - if (strstr(*s, name) != NULL) + if (strstr(name, *s) != NULL) return 1; return 0; } -- cgit v1.1 From 43c74d179596ba1f8eceb8c6a5c7e11afe233662 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 5 Mar 2006 12:02:46 +0100 Subject: kbuild: in the section mismatch check try harder to find symbols When searching for symbols the only check performed was if offset equals st_value. Adding an additional check to see if st_name points t a valid name made us sort out a few more false positives and let us report more correct names in warnings. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3b570b1..3648683 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -558,7 +558,10 @@ static Elf_Sym *find_elf_symbol(struct elf_info *elf, Elf_Addr addr, } /* - * Find symbols before or equal addr and after addr - in the section sec + * Find symbols before or equal addr and after addr - in the section sec. + * If we find two symbols with equal offset prefer one with a valid name. + * The ELF format may have a better way to detect what type of symbol + * it is, but this works for now. **/ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, const char *sec, @@ -587,6 +590,12 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, beforediff = addr - sym->st_value; *before = sym; } + else if ((addr - sym->st_value) == beforediff) { + /* equal offset, valid name? */ + const char *name = elf->strtab + sym->st_name; + if (name && strlen(name)) + *before = sym; + } } else { @@ -594,6 +603,12 @@ static void find_symbols_between(struct elf_info *elf, Elf_Addr addr, afterdiff = sym->st_value - addr; *after = sym; } + else if ((sym->st_value - addr) == afterdiff) { + /* equal offset, valid name? */ + const char *name = elf->strtab + sym->st_name; + if (name && strlen(name)) + *after = sym; + } } } } -- cgit v1.1 From 7b75b13cda8bd21e8636ea985f76e1ce5bd1a470 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 5 Mar 2006 13:48:58 +0100 Subject: kbuild: when warning symbols exported twice now tell user this is the problem Warning now looks like this: WARNING: vmlinux: 'strcpy' exported twice. Previous export was in vmlinux Which gives much better hint how to fix it. Signed-off-by: Sam Ravnborg --- scripts/mod/modpost.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 3648683..e2bf4c9 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -191,7 +191,7 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod) s = new_symbol(name, mod); } else { if (!s->preloaded) { - warn("%s: duplicate symbol '%s' previous definition " + warn("%s: '%s' exported twice. Previous export " "was in %s%s\n", mod->name, name, s->module->name, is_vmlinux(s->module->name) ?"":".ko"); -- cgit v1.1 From 4f1933620f57145212cdbb1ac6ce099eeeb21c5a Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 5 Mar 2006 17:14:10 -0500 Subject: kbuild: change kbuild to not rely on incorrect GNU make behavior The kbuild system takes advantage of an incorrect behavior in GNU make. Once this behavior is fixed, all files in the kernel rebuild every time, even if nothing has changed. This patch ensures kbuild works with both the incorrect and correct behaviors of GNU make. For more details on the incorrect behavior, see: http://lists.gnu.org/archive/html/bug-make/2006-03/msg00003.html Changes in this patch: - Keep all targets that are to be marked .PHONY in a variable, PHONY. - Add .PHONY: $(PHONY) to mark them properly. - Remove any $(PHONY) files from the $? list when determining whether targets are up-to-date or not. Signed-off-by: Paul Smith Signed-off-by: Sam Ravnborg --- scripts/Kbuild.include | 13 ++++++++----- scripts/Makefile.build | 12 +++++++++--- scripts/Makefile.clean | 10 ++++++++-- scripts/Makefile.modinst | 10 ++++++++-- scripts/Makefile.modpost | 12 +++++++++--- scripts/kconfig/Makefile | 4 ++-- scripts/kconfig/lxdialog/Makefile | 6 +++--- scripts/package/Makefile | 10 +++++----- 8 files changed, 52 insertions(+), 25 deletions(-) (limited to 'scripts') diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include index c3d2e4e..59620b1 100644 --- a/scripts/Kbuild.include +++ b/scripts/Kbuild.include @@ -116,16 +116,18 @@ make-cmd = $(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))) # function to only execute the passed command if necessary # >'< substitution is for echo to work, >$< substitution to preserve $ when reloading .cmd file # note: when using inline perl scripts [perl -e '...$$t=1;...'] in $(cmd_xxx) double $$ your perl vars -# -if_changed = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ +# +if_changed = $(if $(strip $(filter-out $(PHONY),$?) \ + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ echo 'cmd_$@ := $(make-cmd)' > $(@D)/.$(@F).cmd) # execute the command and also postprocess generated .d dependencies # file -if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ - $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ +if_changed_dep = $(if $(strip $(filter-out $(PHONY),$?) \ + $(filter-out FORCE $(wildcard $^),$^) \ + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ), \ @set -e; \ $(echo-cmd) $(cmd_$(1)); \ scripts/basic/fixdep $(depfile) $@ '$(make-cmd)' > $(@D)/.$(@F).tmp; \ @@ -135,6 +137,7 @@ if_changed_dep = $(if $(strip $? $(filter-out FORCE $(wildcard $^),$^)\ # Usage: $(call if_changed_rule,foo) # will check if $(cmd_foo) changed, or any of the prequisites changed, # and if so will execute $(rule_foo) -if_changed_rule = $(if $(strip $? $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ +if_changed_rule = $(if $(strip $(filter-out $(PHONY),$?) \ + $(call arg-check, $(cmd_$(1)), $(cmd_$@)) ),\ @set -e; \ $(rule_$(1))) diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 6ac96ea..7afe3e7 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -4,7 +4,7 @@ src := $(obj) -.PHONY: __build +PHONY := __build __build: # Read .config if it exist, otherwise ignore @@ -308,14 +308,14 @@ targets += $(multi-used-y) $(multi-used-m) # Descending # --------------------------------------------------------------------------- -.PHONY: $(subdir-ym) +PHONY += $(subdir-ym) $(subdir-ym): $(Q)$(MAKE) $(build)=$@ # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- -.PHONY: FORCE +PHONY += FORCE FORCE: @@ -330,3 +330,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/scripts/Makefile.clean b/scripts/Makefile.clean index 8974ea5..cff3349 100644 --- a/scripts/Makefile.clean +++ b/scripts/Makefile.clean @@ -4,7 +4,7 @@ src := $(obj) -.PHONY: __clean +PHONY := __clean __clean: # Shorthand for $(Q)$(MAKE) scripts/Makefile.clean obj=dir @@ -87,10 +87,16 @@ endif # Descending # --------------------------------------------------------------------------- -.PHONY: $(subdir-ymn) +PHONY += $(subdir-ymn) $(subdir-ymn): $(Q)$(MAKE) $(clean)=$@ # If quiet is set, only print short version of command cmd = @$(if $($(quiet)cmd_$(1)),echo ' $($(quiet)cmd_$(1))' &&) $(cmd_$(1)) + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index 23fd1bd..2686dd5 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst @@ -2,7 +2,7 @@ # Installing modules # ========================================================================== -.PHONY: __modinst +PHONY := __modinst __modinst: include scripts/Kbuild.include @@ -12,7 +12,7 @@ include scripts/Kbuild.include __modules := $(sort $(shell grep -h '\.ko' /dev/null $(wildcard $(MODVERDIR)/*.mod))) modules := $(patsubst %.o,%.ko,$(wildcard $(__modules:.ko=.o))) -.PHONY: $(modules) +PHONY += $(modules) __modinst: $(modules) @: @@ -27,3 +27,9 @@ modinst_dir = $(if $(KBUILD_EXTMOD),$(ext-mod-dir),kernel/$(@D)) $(modules): $(call cmd,modules_install,$(MODLIB)/$(modinst_dir)) + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index 563e3c5..0cfbe1c 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -32,7 +32,7 @@ # Step 4 is solely used to allow module versioning in external modules, # where the CRC of each module is retrieved from the Module.symers file. -.PHONY: _modpost +PHONY := _modpost _modpost: __modpost include .config @@ -60,7 +60,7 @@ quiet_cmd_modpost = MODPOST $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ $(filter-out FORCE,$^) -.PHONY: __modpost +PHONY += __modpost __modpost: $(wildcard vmlinux) $(modules:.ko=.o) FORCE $(call cmd,modpost) @@ -97,7 +97,7 @@ targets += $(modules) # Add FORCE to the prequisites of a target to force it to be always rebuilt. # --------------------------------------------------------------------------- -.PHONY: FORCE +PHONY += FORCE FORCE: @@ -112,3 +112,9 @@ cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd)) ifneq ($(cmd_files),) include $(cmd_files) endif + + +# Declare the contents of the .PHONY variable as phony. We keep that +# information in a variable se we can use it in if_changed and friends. + +.PHONY: $(PHONY) diff --git a/scripts/kconfig/Makefile b/scripts/kconfig/Makefile index 5280945..e6499db 100644 --- a/scripts/kconfig/Makefile +++ b/scripts/kconfig/Makefile @@ -2,7 +2,7 @@ # Kernel configuration targets # These targets are used from top-level makefile -.PHONY: oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config +PHONY += oldconfig xconfig gconfig menuconfig config silentoldconfig update-po-config xconfig: $(obj)/qconf $< arch/$(ARCH)/Kconfig @@ -42,7 +42,7 @@ update-po-config: $(obj)/kxgettext $(Q)rm -f arch/um/Kconfig_arch $(Q)rm -f scripts/kconfig/linux_*.pot scripts/kconfig/config.pot -.PHONY: randconfig allyesconfig allnoconfig allmodconfig defconfig +PHONY += randconfig allyesconfig allnoconfig allmodconfig defconfig randconfig: $(obj)/conf $< -r arch/$(ARCH)/Kconfig diff --git a/scripts/kconfig/lxdialog/Makefile b/scripts/kconfig/lxdialog/Makefile index bbf4887..a8b0263 100644 --- a/scripts/kconfig/lxdialog/Makefile +++ b/scripts/kconfig/lxdialog/Makefile @@ -7,10 +7,10 @@ check-lxdialog := $(srctree)/$(src)/check-lxdialog.sh # we really need to do so. (Do not call gcc as part of make mrproper) HOST_EXTRACFLAGS = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ccflags) HOST_LOADLIBES = $(shell $(CONFIG_SHELL) $(check-lxdialog) -ldflags $(HOSTCC)) - -HOST_EXTRACFLAGS += -DLOCALE -.PHONY: dochecklxdialog +HOST_EXTRACFLAGS += -DLOCALE + +PHONY += dochecklxdialog $(obj)/dochecklxdialog: $(Q)$(CONFIG_SHELL) $(check-lxdialog) -check $(HOSTCC) $(HOST_LOADLIBES) diff --git a/scripts/package/Makefile b/scripts/package/Makefile index c201ef00..d3038b7 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -32,7 +32,7 @@ MKSPEC := $(srctree)/scripts/package/mkspec PREV := set -e; cd ..; # rpm-pkg -.PHONY: rpm-pkg rpm +PHONY += rpm-pkg rpm $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) > $@ @@ -54,10 +54,10 @@ rpm-pkg rpm: $(objtree)/kernel.spec clean-files := $(objtree)/kernel.spec # binrpm-pkg -.PHONY: binrpm-pkg +PHONY += binrpm-pkg $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ - + binrpm-pkg: $(objtree)/binkernel.spec $(MAKE) KBUILD_SRC= set -e; \ @@ -72,7 +72,7 @@ clean-files += $(objtree)/binkernel.spec # Deb target # --------------------------------------------------------------------------- # -.PHONY: deb-pkg +PHONY += deb-pkg deb-pkg: $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb @@ -82,7 +82,7 @@ clean-dirs += $(objtree)/debian/ # tarball targets # --------------------------------------------------------------------------- -.PHONY: tar%pkg +PHONY += tar%pkg tar%pkg: $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ -- cgit v1.1 From f7b05e64bdb2fcc4b2dc94a4bd9426adc70c9599 Mon Sep 17 00:00:00 2001 From: Luke Yang Date: Thu, 2 Mar 2006 18:35:31 +0800 Subject: kbuild: Fix bug in crc symbol generating of kernel and modules The scripts/genksyms/genksyms.c uses hardcoded "__crc_" prefix for crc symbols in kernel and modules. The prefix should be replaced by "MODULE_SYMBOL_PREFIX##__crc_" otherwise there will be warnings when MODULE_SYMBOL_PREFIX is not NULL. I am sorry my last patch for this issue is actually wrong. I revert it in this patch. Signed-off-by: Luke Yang Signed-off-by: Sam Ravnborg --- scripts/genksyms/genksyms.c | 4 ++-- scripts/mod/modpost.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts') diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index 416a694..ef8822e 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -32,7 +32,7 @@ #endif /* __GNU_LIBRARY__ */ #include "genksyms.h" - +#include "../mod/elfconfig.h" /*----------------------------------------------------------------------*/ #define HASH_BUCKETS 4096 @@ -458,7 +458,7 @@ export_symbol(const char *name) fputs(">\n", debugfile); /* Used as a linker script. */ - printf("__crc_%s = 0x%08lx ;\n", name, crc); + printf("%s__crc_%s = 0x%08lx ;\n", MODULE_SYMBOL_PREFIX, name, crc); } } diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index e2bf4c9..30f3ac8 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -346,8 +346,8 @@ static void parse_elf_finish(struct elf_info *info) release_file(info->hdr, info->size); } -#define CRC_PFX "__crc_" -#define KSYMTAB_PFX "__ksymtab_" +#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" +#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" static void handle_modversions(struct module *mod, struct elf_info *info, Elf_Sym *sym, const char *symname) -- cgit v1.1 From 0131705d589e2341dbc5e8946a60f83d8c1773dc Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Wed, 8 Mar 2006 18:39:05 +0100 Subject: kbuild: replace PHONY with FORCE .PHONY: does not take patterns so use FORCE to achive same effect. Thanks to "Paul D. Smith" for noticing this. Signed-off-by: Sam Ravnborg --- scripts/package/Makefile | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) (limited to 'scripts') diff --git a/scripts/package/Makefile b/scripts/package/Makefile index d3038b7..7c434e0 100644 --- a/scripts/package/Makefile +++ b/scripts/package/Makefile @@ -32,12 +32,11 @@ MKSPEC := $(srctree)/scripts/package/mkspec PREV := set -e; cd ..; # rpm-pkg -PHONY += rpm-pkg rpm - +# --------------------------------------------------------------------------- $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) > $@ -rpm-pkg rpm: $(objtree)/kernel.spec +rpm-pkg rpm: $(objtree)/kernel.spec FORCE $(MAKE) clean $(PREV) ln -sf $(srctree) $(KERNELPATH) $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/. @@ -54,11 +53,11 @@ rpm-pkg rpm: $(objtree)/kernel.spec clean-files := $(objtree)/kernel.spec # binrpm-pkg -PHONY += binrpm-pkg +# --------------------------------------------------------------------------- $(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@ -binrpm-pkg: $(objtree)/binkernel.spec +binrpm-pkg: $(objtree)/binkernel.spec FORCE $(MAKE) KBUILD_SRC= set -e; \ $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version @@ -71,9 +70,7 @@ clean-files += $(objtree)/binkernel.spec # Deb target # --------------------------------------------------------------------------- -# -PHONY += deb-pkg -deb-pkg: +deb-pkg: FORCE $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb @@ -82,8 +79,7 @@ clean-dirs += $(objtree)/debian/ # tarball targets # --------------------------------------------------------------------------- -PHONY += tar%pkg -tar%pkg: +tar%pkg: FORCE $(MAKE) KBUILD_SRC= $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@ @@ -92,7 +88,7 @@ clean-dirs += $(objtree)/tar-install/ # Help text displayed when executing 'make help' # --------------------------------------------------------------------------- -help: +help: FORCE @echo ' rpm-pkg - Build the kernel as an RPM package' @echo ' binrpm-pkg - Build an rpm package containing the compiled kernel' @echo ' and modules' -- cgit v1.1 From c79c7b0923ff353d12194e83628bcca5a8606564 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 12 Mar 2006 22:54:34 +0100 Subject: kbuild: fix genksyms build error genksyms needs to know when a symbol must have a "_" prefex as is true for a few architectures. Pass $(ARCH) as commandline argument and hardcode what architectures that needs this info. Previous attemt to take it from elfconfig.h was br0ken since elfconfig.h is a generated file. Signed-off-by: Sam Ravnborg --- scripts/Makefile.build | 2 +- scripts/genksyms/genksyms.c | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 7afe3e7..19ef2bc 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -166,7 +166,7 @@ cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $< cmd_modversions = \ if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \ $(CPP) -D__GENKSYMS__ $(c_flags) $< \ - | $(GENKSYMS) \ + | $(GENKSYMS) -a $(ARCH) \ > $(@D)/.tmp_$(@F:.o=.ver); \ \ $(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \ diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index ef8822e..da8ff4f 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -32,7 +32,6 @@ #endif /* __GNU_LIBRARY__ */ #include "genksyms.h" -#include "../mod/elfconfig.h" /*----------------------------------------------------------------------*/ #define HASH_BUCKETS 4096 @@ -44,6 +43,8 @@ int cur_line = 1; char *cur_filename, *output_directory; int flag_debug, flag_dump_defs, flag_warnings; +const char *arch = ""; +const char *mod_prefix = ""; static int errors; static int nsyms; @@ -458,7 +459,7 @@ export_symbol(const char *name) fputs(">\n", debugfile); /* Used as a linker script. */ - printf("%s__crc_%s = 0x%08lx ;\n", MODULE_SYMBOL_PREFIX, name, crc); + printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc); } } @@ -529,6 +530,7 @@ main(int argc, char **argv) #ifdef __GNU_LIBRARY__ struct option long_opts[] = { + {"arch", 1, 0, 'a'}, {"debug", 0, 0, 'd'}, {"warnings", 0, 0, 'w'}, {"quiet", 0, 0, 'q'}, @@ -538,13 +540,16 @@ main(int argc, char **argv) {0, 0, 0, 0} }; - while ((o = getopt_long(argc, argv, "dwqVDk:p:", + while ((o = getopt_long(argc, argv, "a:dwqVDk:p:", &long_opts[0], NULL)) != EOF) #else /* __GNU_LIBRARY__ */ - while ((o = getopt(argc, argv, "dwqVDk:p:")) != EOF) + while ((o = getopt(argc, argv, "a:dwqVDk:p:")) != EOF) #endif /* __GNU_LIBRARY__ */ switch (o) { + case 'a': + arch = optarg; + break; case 'd': flag_debug++; break; @@ -567,7 +572,9 @@ main(int argc, char **argv) genksyms_usage(); return 1; } - + if ((strcmp(arch, "v850") == 0) || + (strcmp(arch, "h8300") == 0)) + mod_prefix = "_"; { extern int yydebug; extern int yy_flex_debug; -- cgit v1.1 From 78c041530ac2e65c9290137bfe3004340e0840d2 Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 12 Mar 2006 22:59:36 +0100 Subject: kbuild: Lindent genksyms.c No fix-ups applied yet. Just the raw Lindent output. Signed-off-by: Sam Ravnborg --- scripts/genksyms/genksyms.c | 840 +++++++++++++++++++++----------------------- 1 file changed, 402 insertions(+), 438 deletions(-) (limited to 'scripts') diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index da8ff4f..b798e28 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -29,7 +29,7 @@ #include #ifdef __GNU_LIBRARY__ #include -#endif /* __GNU_LIBRARY__ */ +#endif /* __GNU_LIBRARY__ */ #include "genksyms.h" /*----------------------------------------------------------------------*/ @@ -51,460 +51,427 @@ static int nsyms; static struct symbol *expansion_trail; -static const char * const symbol_type_name[] = { - "normal", "typedef", "enum", "struct", "union" +static const char *const symbol_type_name[] = { + "normal", "typedef", "enum", "struct", "union" }; /*----------------------------------------------------------------------*/ -static const unsigned int crctab32[] = -{ - 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, - 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, - 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, - 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, - 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, - 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, - 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, - 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, - 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, - 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, - 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, - 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, - 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, - 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, - 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, - 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, - 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, - 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, - 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, - 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, - 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, - 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, - 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, - 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, - 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, - 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, - 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, - 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, - 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, - 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, - 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, - 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, - 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, - 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, - 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, - 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, - 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, - 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, - 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, - 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, - 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, - 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, - 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, - 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, - 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, - 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, - 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, - 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, - 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, - 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, - 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, - 0x2d02ef8dU +static const unsigned int crctab32[] = { + 0x00000000U, 0x77073096U, 0xee0e612cU, 0x990951baU, 0x076dc419U, + 0x706af48fU, 0xe963a535U, 0x9e6495a3U, 0x0edb8832U, 0x79dcb8a4U, + 0xe0d5e91eU, 0x97d2d988U, 0x09b64c2bU, 0x7eb17cbdU, 0xe7b82d07U, + 0x90bf1d91U, 0x1db71064U, 0x6ab020f2U, 0xf3b97148U, 0x84be41deU, + 0x1adad47dU, 0x6ddde4ebU, 0xf4d4b551U, 0x83d385c7U, 0x136c9856U, + 0x646ba8c0U, 0xfd62f97aU, 0x8a65c9ecU, 0x14015c4fU, 0x63066cd9U, + 0xfa0f3d63U, 0x8d080df5U, 0x3b6e20c8U, 0x4c69105eU, 0xd56041e4U, + 0xa2677172U, 0x3c03e4d1U, 0x4b04d447U, 0xd20d85fdU, 0xa50ab56bU, + 0x35b5a8faU, 0x42b2986cU, 0xdbbbc9d6U, 0xacbcf940U, 0x32d86ce3U, + 0x45df5c75U, 0xdcd60dcfU, 0xabd13d59U, 0x26d930acU, 0x51de003aU, + 0xc8d75180U, 0xbfd06116U, 0x21b4f4b5U, 0x56b3c423U, 0xcfba9599U, + 0xb8bda50fU, 0x2802b89eU, 0x5f058808U, 0xc60cd9b2U, 0xb10be924U, + 0x2f6f7c87U, 0x58684c11U, 0xc1611dabU, 0xb6662d3dU, 0x76dc4190U, + 0x01db7106U, 0x98d220bcU, 0xefd5102aU, 0x71b18589U, 0x06b6b51fU, + 0x9fbfe4a5U, 0xe8b8d433U, 0x7807c9a2U, 0x0f00f934U, 0x9609a88eU, + 0xe10e9818U, 0x7f6a0dbbU, 0x086d3d2dU, 0x91646c97U, 0xe6635c01U, + 0x6b6b51f4U, 0x1c6c6162U, 0x856530d8U, 0xf262004eU, 0x6c0695edU, + 0x1b01a57bU, 0x8208f4c1U, 0xf50fc457U, 0x65b0d9c6U, 0x12b7e950U, + 0x8bbeb8eaU, 0xfcb9887cU, 0x62dd1ddfU, 0x15da2d49U, 0x8cd37cf3U, + 0xfbd44c65U, 0x4db26158U, 0x3ab551ceU, 0xa3bc0074U, 0xd4bb30e2U, + 0x4adfa541U, 0x3dd895d7U, 0xa4d1c46dU, 0xd3d6f4fbU, 0x4369e96aU, + 0x346ed9fcU, 0xad678846U, 0xda60b8d0U, 0x44042d73U, 0x33031de5U, + 0xaa0a4c5fU, 0xdd0d7cc9U, 0x5005713cU, 0x270241aaU, 0xbe0b1010U, + 0xc90c2086U, 0x5768b525U, 0x206f85b3U, 0xb966d409U, 0xce61e49fU, + 0x5edef90eU, 0x29d9c998U, 0xb0d09822U, 0xc7d7a8b4U, 0x59b33d17U, + 0x2eb40d81U, 0xb7bd5c3bU, 0xc0ba6cadU, 0xedb88320U, 0x9abfb3b6U, + 0x03b6e20cU, 0x74b1d29aU, 0xead54739U, 0x9dd277afU, 0x04db2615U, + 0x73dc1683U, 0xe3630b12U, 0x94643b84U, 0x0d6d6a3eU, 0x7a6a5aa8U, + 0xe40ecf0bU, 0x9309ff9dU, 0x0a00ae27U, 0x7d079eb1U, 0xf00f9344U, + 0x8708a3d2U, 0x1e01f268U, 0x6906c2feU, 0xf762575dU, 0x806567cbU, + 0x196c3671U, 0x6e6b06e7U, 0xfed41b76U, 0x89d32be0U, 0x10da7a5aU, + 0x67dd4accU, 0xf9b9df6fU, 0x8ebeeff9U, 0x17b7be43U, 0x60b08ed5U, + 0xd6d6a3e8U, 0xa1d1937eU, 0x38d8c2c4U, 0x4fdff252U, 0xd1bb67f1U, + 0xa6bc5767U, 0x3fb506ddU, 0x48b2364bU, 0xd80d2bdaU, 0xaf0a1b4cU, + 0x36034af6U, 0x41047a60U, 0xdf60efc3U, 0xa867df55U, 0x316e8eefU, + 0x4669be79U, 0xcb61b38cU, 0xbc66831aU, 0x256fd2a0U, 0x5268e236U, + 0xcc0c7795U, 0xbb0b4703U, 0x220216b9U, 0x5505262fU, 0xc5ba3bbeU, + 0xb2bd0b28U, 0x2bb45a92U, 0x5cb36a04U, 0xc2d7ffa7U, 0xb5d0cf31U, + 0x2cd99e8bU, 0x5bdeae1dU, 0x9b64c2b0U, 0xec63f226U, 0x756aa39cU, + 0x026d930aU, 0x9c0906a9U, 0xeb0e363fU, 0x72076785U, 0x05005713U, + 0x95bf4a82U, 0xe2b87a14U, 0x7bb12baeU, 0x0cb61b38U, 0x92d28e9bU, + 0xe5d5be0dU, 0x7cdcefb7U, 0x0bdbdf21U, 0x86d3d2d4U, 0xf1d4e242U, + 0x68ddb3f8U, 0x1fda836eU, 0x81be16cdU, 0xf6b9265bU, 0x6fb077e1U, + 0x18b74777U, 0x88085ae6U, 0xff0f6a70U, 0x66063bcaU, 0x11010b5cU, + 0x8f659effU, 0xf862ae69U, 0x616bffd3U, 0x166ccf45U, 0xa00ae278U, + 0xd70dd2eeU, 0x4e048354U, 0x3903b3c2U, 0xa7672661U, 0xd06016f7U, + 0x4969474dU, 0x3e6e77dbU, 0xaed16a4aU, 0xd9d65adcU, 0x40df0b66U, + 0x37d83bf0U, 0xa9bcae53U, 0xdebb9ec5U, 0x47b2cf7fU, 0x30b5ffe9U, + 0xbdbdf21cU, 0xcabac28aU, 0x53b39330U, 0x24b4a3a6U, 0xbad03605U, + 0xcdd70693U, 0x54de5729U, 0x23d967bfU, 0xb3667a2eU, 0xc4614ab8U, + 0x5d681b02U, 0x2a6f2b94U, 0xb40bbe37U, 0xc30c8ea1U, 0x5a05df1bU, + 0x2d02ef8dU }; static inline unsigned long partial_crc32_one(unsigned char c, unsigned long crc) { - return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8); + return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8); } -static inline unsigned long -partial_crc32(const char *s, unsigned long crc) +static inline unsigned long partial_crc32(const char *s, unsigned long crc) { - while (*s) - crc = partial_crc32_one(*s++, crc); - return crc; + while (*s) + crc = partial_crc32_one(*s++, crc); + return crc; } -static inline unsigned long -crc32(const char *s) +static inline unsigned long crc32(const char *s) { - return partial_crc32(s, 0xffffffff) ^ 0xffffffff; + return partial_crc32(s, 0xffffffff) ^ 0xffffffff; } - /*----------------------------------------------------------------------*/ -static inline enum symbol_type -map_to_ns(enum symbol_type t) +static inline enum symbol_type map_to_ns(enum symbol_type t) { - if (t == SYM_TYPEDEF) - t = SYM_NORMAL; - else if (t == SYM_UNION) - t = SYM_STRUCT; - return t; + if (t == SYM_TYPEDEF) + t = SYM_NORMAL; + else if (t == SYM_UNION) + t = SYM_STRUCT; + return t; } -struct symbol * -find_symbol(const char *name, enum symbol_type ns) +struct symbol *find_symbol(const char *name, enum symbol_type ns) { - unsigned long h = crc32(name) % HASH_BUCKETS; - struct symbol *sym; + unsigned long h = crc32(name) % HASH_BUCKETS; + struct symbol *sym; - for (sym = symtab[h]; sym ; sym = sym->hash_next) - if (map_to_ns(sym->type) == map_to_ns(ns) && strcmp(name, sym->name) == 0) - break; + for (sym = symtab[h]; sym; sym = sym->hash_next) + if (map_to_ns(sym->type) == map_to_ns(ns) + && strcmp(name, sym->name) == 0) + break; - return sym; + return sym; } -struct symbol * -add_symbol(const char *name, enum symbol_type type, struct string_list *defn, int is_extern) +struct symbol *add_symbol(const char *name, enum symbol_type type, + struct string_list *defn, int is_extern) { - unsigned long h = crc32(name) % HASH_BUCKETS; - struct symbol *sym; - - for (sym = symtab[h]; sym ; sym = sym->hash_next) - if (map_to_ns(sym->type) == map_to_ns(type) - && strcmp(name, sym->name) == 0) - { - if (!equal_list(sym->defn, defn)) - error_with_pos("redefinition of %s", name); + unsigned long h = crc32(name) % HASH_BUCKETS; + struct symbol *sym; + + for (sym = symtab[h]; sym; sym = sym->hash_next) + if (map_to_ns(sym->type) == map_to_ns(type) + && strcmp(name, sym->name) == 0) { + if (!equal_list(sym->defn, defn)) + error_with_pos("redefinition of %s", name); + return sym; + } + + sym = xmalloc(sizeof(*sym)); + sym->name = name; + sym->type = type; + sym->defn = defn; + sym->expansion_trail = NULL; + sym->is_extern = is_extern; + + sym->hash_next = symtab[h]; + symtab[h] = sym; + + if (flag_debug) { + fprintf(debugfile, "Defn for %s %s == <", + symbol_type_name[type], name); + if (is_extern) + fputs("extern ", debugfile); + print_list(debugfile, defn); + fputs(">\n", debugfile); + } + + ++nsyms; return sym; - } - - sym = xmalloc(sizeof(*sym)); - sym->name = name; - sym->type = type; - sym->defn = defn; - sym->expansion_trail = NULL; - sym->is_extern = is_extern; - - sym->hash_next = symtab[h]; - symtab[h] = sym; - - if (flag_debug) - { - fprintf(debugfile, "Defn for %s %s == <", symbol_type_name[type], name); - if (is_extern) - fputs("extern ", debugfile); - print_list(debugfile, defn); - fputs(">\n", debugfile); - } - - ++nsyms; - return sym; } - /*----------------------------------------------------------------------*/ -inline void -free_node(struct string_list *node) +inline void free_node(struct string_list *node) { - free(node->string); - free(node); + free(node->string); + free(node); } -void -free_list(struct string_list *s, struct string_list *e) +void free_list(struct string_list *s, struct string_list *e) { - while (s != e) - { - struct string_list *next = s->next; - free_node(s); - s = next; - } + while (s != e) { + struct string_list *next = s->next; + free_node(s); + s = next; + } } -inline struct string_list * -copy_node(struct string_list *node) +inline struct string_list *copy_node(struct string_list *node) { - struct string_list *newnode; + struct string_list *newnode; - newnode = xmalloc(sizeof(*newnode)); - newnode->string = xstrdup(node->string); - newnode->tag = node->tag; + newnode = xmalloc(sizeof(*newnode)); + newnode->string = xstrdup(node->string); + newnode->tag = node->tag; - return newnode; + return newnode; } -struct string_list * -copy_list(struct string_list *s, struct string_list *e) +struct string_list *copy_list(struct string_list *s, struct string_list *e) { - struct string_list *h, *p; + struct string_list *h, *p; - if (s == e) - return NULL; + if (s == e) + return NULL; - p = h = copy_node(s); - while ((s = s->next) != e) - p = p->next = copy_node(s); - p->next = NULL; + p = h = copy_node(s); + while ((s = s->next) != e) + p = p->next = copy_node(s); + p->next = NULL; - return h; + return h; } -int -equal_list(struct string_list *a, struct string_list *b) +int equal_list(struct string_list *a, struct string_list *b) { - while (a && b) - { - if (a->tag != b->tag || strcmp(a->string, b->string)) - return 0; - a = a->next; - b = b->next; - } - - return !a && !b; -} + while (a && b) { + if (a->tag != b->tag || strcmp(a->string, b->string)) + return 0; + a = a->next; + b = b->next; + } -static inline void -print_node(FILE *f, struct string_list *list) -{ - switch (list->tag) - { - case SYM_STRUCT: - putc('s', f); - goto printit; - case SYM_UNION: - putc('u', f); - goto printit; - case SYM_ENUM: - putc('e', f); - goto printit; - case SYM_TYPEDEF: - putc('t', f); - goto printit; - - printit: - putc('#', f); - case SYM_NORMAL: - fputs(list->string, f); - break; - } + return !a && !b; } -void -print_list(FILE *f, struct string_list *list) +static inline void print_node(FILE * f, struct string_list *list) { - struct string_list **e, **b; - struct string_list *tmp, **tmp2; - int elem = 1; - - if (list == NULL) - { - fputs("(nil)", f); - return; - } - - tmp = list; - while((tmp = tmp->next) != NULL) - elem++; - - b = alloca(elem * sizeof(*e)); - e = b + elem; - tmp2 = e - 1; - - (*tmp2--) = list; - while((list = list->next) != NULL) - *(tmp2--) = list; - - while (b != e) - { - print_node(f, *b++); - putc(' ', f); - } + switch (list->tag) { + case SYM_STRUCT: + putc('s', f); + goto printit; + case SYM_UNION: + putc('u', f); + goto printit; + case SYM_ENUM: + putc('e', f); + goto printit; + case SYM_TYPEDEF: + putc('t', f); + goto printit; + + printit: + putc('#', f); + case SYM_NORMAL: + fputs(list->string, f); + break; + } } -static unsigned long -expand_and_crc_list(struct string_list *list, unsigned long crc) +void print_list(FILE * f, struct string_list *list) { - struct string_list **e, **b; - struct string_list *tmp, **tmp2; - int elem = 1; - - if (!list) - return crc; + struct string_list **e, **b; + struct string_list *tmp, **tmp2; + int elem = 1; - tmp = list; - while((tmp = tmp->next) != NULL) - elem++; - - b = alloca(elem * sizeof(*e)); - e = b + elem; - tmp2 = e - 1; + if (list == NULL) { + fputs("(nil)", f); + return; + } - *(tmp2--) = list; - while ((list = list->next) != NULL) - *(tmp2--) = list; + tmp = list; + while ((tmp = tmp->next) != NULL) + elem++; - while (b != e) - { - struct string_list *cur; - struct symbol *subsym; + b = alloca(elem * sizeof(*e)); + e = b + elem; + tmp2 = e - 1; - cur = *(b++); - switch (cur->tag) - { - case SYM_NORMAL: - if (flag_dump_defs) - fprintf(debugfile, "%s ", cur->string); - crc = partial_crc32(cur->string, crc); - crc = partial_crc32_one(' ', crc); - break; + (*tmp2--) = list; + while ((list = list->next) != NULL) + *(tmp2--) = list; - case SYM_TYPEDEF: - subsym = find_symbol(cur->string, cur->tag); - if (subsym->expansion_trail) - { - if (flag_dump_defs) - fprintf(debugfile, "%s ", cur->string); - crc = partial_crc32(cur->string, crc); - crc = partial_crc32_one(' ', crc); - } - else - { - subsym->expansion_trail = expansion_trail; - expansion_trail = subsym; - crc = expand_and_crc_list(subsym->defn, crc); - } - break; + while (b != e) { + print_node(f, *b++); + putc(' ', f); + } +} - case SYM_STRUCT: - case SYM_UNION: - case SYM_ENUM: - subsym = find_symbol(cur->string, cur->tag); - if (!subsym) - { - struct string_list *n, *t = NULL; - - error_with_pos("expand undefined %s %s", - symbol_type_name[cur->tag], cur->string); - - n = xmalloc(sizeof(*n)); - n->string = xstrdup(symbol_type_name[cur->tag]); - n->tag = SYM_NORMAL; - n->next = t; - t = n; - - n = xmalloc(sizeof(*n)); - n->string = xstrdup(cur->string); - n->tag = SYM_NORMAL; - n->next = t; - t = n; - - n = xmalloc(sizeof(*n)); - n->string = xstrdup("{ UNKNOWN }"); - n->tag = SYM_NORMAL; - n->next = t; - - subsym = add_symbol(cur->string, cur->tag, n, 0); - } - if (subsym->expansion_trail) - { - if (flag_dump_defs) - { - fprintf(debugfile, "%s %s ", symbol_type_name[cur->tag], - cur->string); +static unsigned long +expand_and_crc_list(struct string_list *list, unsigned long crc) +{ + struct string_list **e, **b; + struct string_list *tmp, **tmp2; + int elem = 1; + + if (!list) + return crc; + + tmp = list; + while ((tmp = tmp->next) != NULL) + elem++; + + b = alloca(elem * sizeof(*e)); + e = b + elem; + tmp2 = e - 1; + + *(tmp2--) = list; + while ((list = list->next) != NULL) + *(tmp2--) = list; + + while (b != e) { + struct string_list *cur; + struct symbol *subsym; + + cur = *(b++); + switch (cur->tag) { + case SYM_NORMAL: + if (flag_dump_defs) + fprintf(debugfile, "%s ", cur->string); + crc = partial_crc32(cur->string, crc); + crc = partial_crc32_one(' ', crc); + break; + + case SYM_TYPEDEF: + subsym = find_symbol(cur->string, cur->tag); + if (subsym->expansion_trail) { + if (flag_dump_defs) + fprintf(debugfile, "%s ", cur->string); + crc = partial_crc32(cur->string, crc); + crc = partial_crc32_one(' ', crc); + } else { + subsym->expansion_trail = expansion_trail; + expansion_trail = subsym; + crc = expand_and_crc_list(subsym->defn, crc); + } + break; + + case SYM_STRUCT: + case SYM_UNION: + case SYM_ENUM: + subsym = find_symbol(cur->string, cur->tag); + if (!subsym) { + struct string_list *n, *t = NULL; + + error_with_pos("expand undefined %s %s", + symbol_type_name[cur->tag], + cur->string); + + n = xmalloc(sizeof(*n)); + n->string = xstrdup(symbol_type_name[cur->tag]); + n->tag = SYM_NORMAL; + n->next = t; + t = n; + + n = xmalloc(sizeof(*n)); + n->string = xstrdup(cur->string); + n->tag = SYM_NORMAL; + n->next = t; + t = n; + + n = xmalloc(sizeof(*n)); + n->string = xstrdup("{ UNKNOWN }"); + n->tag = SYM_NORMAL; + n->next = t; + + subsym = + add_symbol(cur->string, cur->tag, n, 0); + } + if (subsym->expansion_trail) { + if (flag_dump_defs) { + fprintf(debugfile, "%s %s ", + symbol_type_name[cur->tag], + cur->string); + } + + crc = + partial_crc32(symbol_type_name[cur->tag], + crc); + crc = partial_crc32_one(' ', crc); + crc = partial_crc32(cur->string, crc); + crc = partial_crc32_one(' ', crc); + } else { + subsym->expansion_trail = expansion_trail; + expansion_trail = subsym; + crc = expand_and_crc_list(subsym->defn, crc); + } + break; } - - crc = partial_crc32(symbol_type_name[cur->tag], crc); - crc = partial_crc32_one(' ', crc); - crc = partial_crc32(cur->string, crc); - crc = partial_crc32_one(' ', crc); - } - else - { - subsym->expansion_trail = expansion_trail; - expansion_trail = subsym; - crc = expand_and_crc_list(subsym->defn, crc); - } - break; } - } - return crc; + return crc; } -void -export_symbol(const char *name) +void export_symbol(const char *name) { - struct symbol *sym; + struct symbol *sym; - sym = find_symbol(name, SYM_NORMAL); - if (!sym) - error_with_pos("export undefined symbol %s", name); - else - { - unsigned long crc; + sym = find_symbol(name, SYM_NORMAL); + if (!sym) + error_with_pos("export undefined symbol %s", name); + else { + unsigned long crc; - if (flag_dump_defs) - fprintf(debugfile, "Export %s == <", name); + if (flag_dump_defs) + fprintf(debugfile, "Export %s == <", name); - expansion_trail = (struct symbol *)-1L; + expansion_trail = (struct symbol *)-1L; - crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff; + crc = expand_and_crc_list(sym->defn, 0xffffffff) ^ 0xffffffff; - sym = expansion_trail; - while (sym != (struct symbol *)-1L) - { - struct symbol *n = sym->expansion_trail; - sym->expansion_trail = 0; - sym = n; - } + sym = expansion_trail; + while (sym != (struct symbol *)-1L) { + struct symbol *n = sym->expansion_trail; + sym->expansion_trail = 0; + sym = n; + } - if (flag_dump_defs) - fputs(">\n", debugfile); + if (flag_dump_defs) + fputs(">\n", debugfile); - /* Used as a linker script. */ - printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc); - } + /* Used as a linker script. */ + printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc); + } } /*----------------------------------------------------------------------*/ -void -error(const char *fmt, ...) +void error(const char *fmt, ...) { - va_list args; + va_list args; - if (flag_warnings) - { - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - putc('\n', stderr); + if (flag_warnings) { + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + putc('\n', stderr); - errors++; - } + errors++; + } } -void -error_with_pos(const char *fmt, ...) +void error_with_pos(const char *fmt, ...) { - va_list args; + va_list args; - if (flag_warnings) - { - fprintf(stderr, "%s:%d: ", cur_filename ? : "", cur_line); + if (flag_warnings) { + fprintf(stderr, "%s:%d: ", cur_filename ? : "", + cur_line); - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - putc('\n', stderr); + va_start(args, fmt); + vfprintf(stderr, fmt, args); + va_end(args); + putc('\n', stderr); - errors++; - } + errors++; + } } - void genksyms_usage(void) { - fputs("Usage:\n" - "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" - "\n" + fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n" #ifdef __GNU_LIBRARY__ " -d, --debug Increment the debug level (repeatable)\n" " -D, --dump Dump expanded symbol defs (for debugging only)\n" @@ -512,87 +479,84 @@ void genksyms_usage(void) " -q, --quiet Disable warnings (default)\n" " -h, --help Print this message\n" " -V, --version Print the release version\n" -#else /* __GNU_LIBRARY__ */ - " -d Increment the debug level (repeatable)\n" - " -D Dump expanded symbol defs (for debugging only)\n" - " -w Enable warnings\n" - " -q Disable warnings (default)\n" - " -h Print this message\n" - " -V Print the release version\n" -#endif /* __GNU_LIBRARY__ */ +#else /* __GNU_LIBRARY__ */ + " -d Increment the debug level (repeatable)\n" + " -D Dump expanded symbol defs (for debugging only)\n" + " -w Enable warnings\n" + " -q Disable warnings (default)\n" + " -h Print this message\n" + " -V Print the release version\n" +#endif /* __GNU_LIBRARY__ */ , stderr); } -int -main(int argc, char **argv) +int main(int argc, char **argv) { - int o; + int o; #ifdef __GNU_LIBRARY__ - struct option long_opts[] = { - {"arch", 1, 0, 'a'}, - {"debug", 0, 0, 'd'}, - {"warnings", 0, 0, 'w'}, - {"quiet", 0, 0, 'q'}, - {"dump", 0, 0, 'D'}, - {"version", 0, 0, 'V'}, - {"help", 0, 0, 'h'}, - {0, 0, 0, 0} - }; - - while ((o = getopt_long(argc, argv, "a:dwqVDk:p:", - &long_opts[0], NULL)) != EOF) -#else /* __GNU_LIBRARY__ */ - while ((o = getopt(argc, argv, "a:dwqVDk:p:")) != EOF) -#endif /* __GNU_LIBRARY__ */ - switch (o) - { - case 'a': - arch = optarg; - break; - case 'd': - flag_debug++; - break; - case 'w': - flag_warnings = 1; - break; - case 'q': - flag_warnings = 0; - break; - case 'V': - fputs("genksyms version 2.5.60\n", stderr); - break; - case 'D': - flag_dump_defs = 1; - break; - case 'h': - genksyms_usage(); - return 0; - default: - genksyms_usage(); - return 1; - } - if ((strcmp(arch, "v850") == 0) || - (strcmp(arch, "h8300") == 0)) - mod_prefix = "_"; - { - extern int yydebug; - extern int yy_flex_debug; - - yydebug = (flag_debug > 1); - yy_flex_debug = (flag_debug > 2); - - debugfile = stderr; - /* setlinebuf(debugfile); */ - } - - yyparse(); - - if (flag_debug) - { - fprintf(debugfile, "Hash table occupancy %d/%d = %g\n", - nsyms, HASH_BUCKETS, (double)nsyms / (double)HASH_BUCKETS); - } - - return errors != 0; + struct option long_opts[] = { + {"arch", 1, 0, 'a'}, + {"debug", 0, 0, 'd'}, + {"warnings", 0, 0, 'w'}, + {"quiet", 0, 0, 'q'}, + {"dump", 0, 0, 'D'}, + {"version", 0, 0, 'V'}, + {"help", 0, 0, 'h'}, + {0, 0, 0, 0} + }; + + while ((o = getopt_long(argc, argv, "a:dwqVDk:p:", + &long_opts[0], NULL)) != EOF) +#else /* __GNU_LIBRARY__ */ + while ((o = getopt(argc, argv, "a:dwqVDk:p:")) != EOF) +#endif /* __GNU_LIBRARY__ */ + switch (o) { + case 'a': + arch = optarg; + break; + case 'd': + flag_debug++; + break; + case 'w': + flag_warnings = 1; + break; + case 'q': + flag_warnings = 0; + break; + case 'V': + fputs("genksyms version 2.5.60\n", stderr); + break; + case 'D': + flag_dump_defs = 1; + break; + case 'h': + genksyms_usage(); + return 0; + default: + genksyms_usage(); + return 1; + } + if ((strcmp(arch, "v850") == 0) || (strcmp(arch, "h8300") == 0)) + mod_prefix = "_"; + { + extern int yydebug; + extern int yy_flex_debug; + + yydebug = (flag_debug > 1); + yy_flex_debug = (flag_debug > 2); + + debugfile = stderr; + /* setlinebuf(debugfile); */ + } + + yyparse(); + + if (flag_debug) { + fprintf(debugfile, "Hash table occupancy %d/%d = %g\n", + nsyms, HASH_BUCKETS, + (double)nsyms / (double)HASH_BUCKETS); + } + + return errors != 0; } -- cgit v1.1 From ce560686947fd50b30eaf42045554797f53949dd Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Sun, 12 Mar 2006 23:26:29 +0100 Subject: kbuild: clean-up genksyms o remove all inlines o declare everything static which is only used by genksyms.c o delete unused functions o delete unused variables o delete unused stuff in genksyms.h o properly ident genksyms.h Signed-off-by: Sam Ravnborg --- scripts/genksyms/genksyms.c | 80 +++++++++++++++------------------------------ scripts/genksyms/genksyms.h | 57 ++++++++++---------------------- 2 files changed, 43 insertions(+), 94 deletions(-) (limited to 'scripts') diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c index b798e28..5b0344e 100644 --- a/scripts/genksyms/genksyms.c +++ b/scripts/genksyms/genksyms.c @@ -37,14 +37,14 @@ #define HASH_BUCKETS 4096 static struct symbol *symtab[HASH_BUCKETS]; -FILE *debugfile; +static FILE *debugfile; int cur_line = 1; -char *cur_filename, *output_directory; +char *cur_filename; -int flag_debug, flag_dump_defs, flag_warnings; -const char *arch = ""; -const char *mod_prefix = ""; +static int flag_debug, flag_dump_defs, flag_warnings; +static const char *arch = ""; +static const char *mod_prefix = ""; static int errors; static int nsyms; @@ -55,6 +55,9 @@ static const char *const symbol_type_name[] = { "normal", "typedef", "enum", "struct", "union" }; +static int equal_list(struct string_list *a, struct string_list *b); +static void print_list(FILE * f, struct string_list *list); + /*----------------------------------------------------------------------*/ static const unsigned int crctab32[] = { @@ -112,27 +115,26 @@ static const unsigned int crctab32[] = { 0x2d02ef8dU }; -static inline unsigned long -partial_crc32_one(unsigned char c, unsigned long crc) +static unsigned long partial_crc32_one(unsigned char c, unsigned long crc) { return crctab32[(crc ^ c) & 0xff] ^ (crc >> 8); } -static inline unsigned long partial_crc32(const char *s, unsigned long crc) +static unsigned long partial_crc32(const char *s, unsigned long crc) { while (*s) crc = partial_crc32_one(*s++, crc); return crc; } -static inline unsigned long crc32(const char *s) +static unsigned long crc32(const char *s) { return partial_crc32(s, 0xffffffff) ^ 0xffffffff; } /*----------------------------------------------------------------------*/ -static inline enum symbol_type map_to_ns(enum symbol_type t) +static enum symbol_type map_to_ns(enum symbol_type t) { if (t == SYM_TYPEDEF) t = SYM_NORMAL; @@ -147,8 +149,8 @@ struct symbol *find_symbol(const char *name, enum symbol_type ns) struct symbol *sym; for (sym = symtab[h]; sym; sym = sym->hash_next) - if (map_to_ns(sym->type) == map_to_ns(ns) - && strcmp(name, sym->name) == 0) + if (map_to_ns(sym->type) == map_to_ns(ns) && + strcmp(name, sym->name) == 0) break; return sym; @@ -160,13 +162,14 @@ struct symbol *add_symbol(const char *name, enum symbol_type type, unsigned long h = crc32(name) % HASH_BUCKETS; struct symbol *sym; - for (sym = symtab[h]; sym; sym = sym->hash_next) + for (sym = symtab[h]; sym; sym = sym->hash_next) { if (map_to_ns(sym->type) == map_to_ns(type) && strcmp(name, sym->name) == 0) { if (!equal_list(sym->defn, defn)) error_with_pos("redefinition of %s", name); return sym; } + } sym = xmalloc(sizeof(*sym)); sym->name = name; @@ -193,7 +196,7 @@ struct symbol *add_symbol(const char *name, enum symbol_type type, /*----------------------------------------------------------------------*/ -inline void free_node(struct string_list *node) +void free_node(struct string_list *node) { free(node->string); free(node); @@ -208,7 +211,7 @@ void free_list(struct string_list *s, struct string_list *e) } } -inline struct string_list *copy_node(struct string_list *node) +struct string_list *copy_node(struct string_list *node) { struct string_list *newnode; @@ -219,22 +222,7 @@ inline struct string_list *copy_node(struct string_list *node) return newnode; } -struct string_list *copy_list(struct string_list *s, struct string_list *e) -{ - struct string_list *h, *p; - - if (s == e) - return NULL; - - p = h = copy_node(s); - while ((s = s->next) != e) - p = p->next = copy_node(s); - p->next = NULL; - - return h; -} - -int equal_list(struct string_list *a, struct string_list *b) +static int equal_list(struct string_list *a, struct string_list *b) { while (a && b) { if (a->tag != b->tag || strcmp(a->string, b->string)) @@ -246,7 +234,7 @@ int equal_list(struct string_list *a, struct string_list *b) return !a && !b; } -static inline void print_node(FILE * f, struct string_list *list) +static void print_node(FILE * f, struct string_list *list) { switch (list->tag) { case SYM_STRUCT: @@ -270,7 +258,7 @@ static inline void print_node(FILE * f, struct string_list *list) } } -void print_list(FILE * f, struct string_list *list) +static void print_list(FILE * f, struct string_list *list) { struct string_list **e, **b; struct string_list *tmp, **tmp2; @@ -299,8 +287,8 @@ void print_list(FILE * f, struct string_list *list) } } -static unsigned long -expand_and_crc_list(struct string_list *list, unsigned long crc) +static unsigned long expand_and_crc_list(struct string_list *list, + unsigned long crc) { struct string_list **e, **b; struct string_list *tmp, **tmp2; @@ -386,9 +374,8 @@ expand_and_crc_list(struct string_list *list, unsigned long crc) cur->string); } - crc = - partial_crc32(symbol_type_name[cur->tag], - crc); + crc = partial_crc32(symbol_type_name[cur->tag], + crc); crc = partial_crc32_one(' ', crc); crc = partial_crc32(cur->string, crc); crc = partial_crc32_one(' ', crc); @@ -437,21 +424,6 @@ void export_symbol(const char *name) } /*----------------------------------------------------------------------*/ - -void error(const char *fmt, ...) -{ - va_list args; - - if (flag_warnings) { - va_start(args, fmt); - vfprintf(stderr, fmt, args); - va_end(args); - putc('\n', stderr); - - errors++; - } -} - void error_with_pos(const char *fmt, ...) { va_list args; @@ -469,7 +441,7 @@ void error_with_pos(const char *fmt, ...) } } -void genksyms_usage(void) +static void genksyms_usage(void) { fputs("Usage:\n" "genksyms [-dDwqhV] > /path/to/.tmp_obj.ver\n" "\n" #ifdef __GNU_LIBRARY__ diff --git a/scripts/genksyms/genksyms.h b/scripts/genksyms/genksyms.h index f09af47..ab6f34f 100644 --- a/scripts/genksyms/genksyms.h +++ b/scripts/genksyms/genksyms.h @@ -20,74 +20,51 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - #ifndef MODUTILS_GENKSYMS_H #define MODUTILS_GENKSYMS_H 1 #include - -enum symbol_type -{ - SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION +enum symbol_type { + SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION }; -struct string_list -{ - struct string_list *next; - enum symbol_type tag; - char *string; +struct string_list { + struct string_list *next; + enum symbol_type tag; + char *string; }; -struct symbol -{ - struct symbol *hash_next; - const char *name; - enum symbol_type type; - struct string_list *defn; - struct symbol *expansion_trail; - int is_extern; +struct symbol { + struct symbol *hash_next; + const char *name; + enum symbol_type type; + struct string_list *defn; + struct symbol *expansion_trail; + int is_extern; }; typedef struct string_list **yystype; #define YYSTYPE yystype -extern FILE *outfile, *debugfile; - extern int cur_line; -extern char *cur_filename, *output_directory; - -extern int flag_debug, flag_dump_defs, flag_warnings; -extern int checksum_version, kernel_version; - -extern int want_brace_phrase, want_exp_phrase, discard_phrase_contents; -extern struct string_list *current_list, *next_list; - +extern char *cur_filename; struct symbol *find_symbol(const char *name, enum symbol_type ns); struct symbol *add_symbol(const char *name, enum symbol_type type, - struct string_list *defn, int is_extern); + struct string_list *defn, int is_extern); void export_symbol(const char *); -struct string_list *reset_list(void); -void free_list(struct string_list *s, struct string_list *e); void free_node(struct string_list *list); +void free_list(struct string_list *s, struct string_list *e); struct string_list *copy_node(struct string_list *); -struct string_list *copy_list(struct string_list *s, struct string_list *e); -int equal_list(struct string_list *a, struct string_list *b); -void print_list(FILE *, struct string_list *list); int yylex(void); int yyparse(void); void error_with_pos(const char *, ...); -#define version(a,b,c) ((a << 16) | (b << 8) | (c)) - /*----------------------------------------------------------------------*/ - -#define MODUTILS_VERSION "" - #define xmalloc(size) ({ void *__ptr = malloc(size); \ if(!__ptr && size != 0) { \ fprintf(stderr, "out of memory\n"); \ @@ -101,4 +78,4 @@ void error_with_pos(const char *, ...); } \ __str; }) -#endif /* genksyms.h */ +#endif /* genksyms.h */ -- cgit v1.1 From 7d1859835cd6c0afd1773d249300da82b1b868a5 Mon Sep 17 00:00:00 2001 From: Chuck Ebbert <76306.1226@compuserve.com> Date: Tue, 7 Mar 2006 23:58:33 -0800 Subject: kbuild: add -fverbose-asm to i386 Makefile Add -fverbose-asm to i386 Makefile rule for building .s files. This makes the assembler output much more readable for humans. Suggested by Der Herr Hofrat Signed-off-by: Chuck Ebbert <76306.1226@compuserve.com> Signed-off-by: Andrew Morton Signed-off-by: Sam Ravnborg --- scripts/Makefile.build | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/Makefile.build b/scripts/Makefile.build index 19ef2bc..e48e60d 100644 --- a/scripts/Makefile.build +++ b/scripts/Makefile.build @@ -129,7 +129,7 @@ $(multi-objs-y:.o=.s) : modname = $(modname-multi) $(multi-objs-y:.o=.lst) : modname = $(modname-multi) quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ -cmd_cc_s_c = $(CC) $(c_flags) -S -o $@ $< +cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< %.s: %.c FORCE $(call if_changed_dep,cc_s_c) -- cgit v1.1 From dc9a49a4af9cdbe3d79183eefb12372b4dbc09c2 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Thu, 9 Mar 2006 14:47:46 +0100 Subject: kconfig: fix time ordering of writes to .kconfig.d and include/linux/autoconf.h Since .kconfig.d is used as a make dependency of include/linux/autoconf.h, it should be written earlier than the header file, to avoid a subsequent rebuild to consider the header outdated. Signed-Off-By: Jan Beulich Signed-off-by: Sam Ravnborg --- scripts/kconfig/confdata.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/kconfig/confdata.c b/scripts/kconfig/confdata.c index b0cbbe2..1b8882d 100644 --- a/scripts/kconfig/confdata.c +++ b/scripts/kconfig/confdata.c @@ -374,6 +374,7 @@ int conf_write(const char *name) out_h = fopen(".tmpconfig.h", "w"); if (!out_h) return 1; + file_write_dep(NULL); } sym = sym_lookup("KERNELVERSION", 0); sym_calc_value(sym); @@ -512,7 +513,6 @@ int conf_write(const char *name) if (out_h) { fclose(out_h); rename(".tmpconfig.h", "include/linux/autoconf.h"); - file_write_dep(NULL); } if (!name || basename != conf_def_filename) { if (!name) -- cgit v1.1 From eae0f536f640bb95f2ad437a57c40c7d5683d1ac Mon Sep 17 00:00:00 2001 From: Sam Ravnborg Date: Tue, 21 Mar 2006 07:28:24 +0100 Subject: kbuild: remove obsoleted scripts/reference_* files The checks performed by scripts/reference_* has been moved to modpost. Remove the files and their reference in top-level Makefile. Signed-off-by: Sam Ravnborg --- scripts/reference_discarded.pl | 112 ----------------------------------------- scripts/reference_init.pl | 108 --------------------------------------- 2 files changed, 220 deletions(-) delete mode 100644 scripts/reference_discarded.pl delete mode 100644 scripts/reference_init.pl (limited to 'scripts') diff --git a/scripts/reference_discarded.pl b/scripts/reference_discarded.pl deleted file mode 100644 index 4ee6ab2..0000000 --- a/scripts/reference_discarded.pl +++ /dev/null @@ -1,112 +0,0 @@ -#!/usr/bin/perl -w -# -# reference_discarded.pl (C) Keith Owens 2001 -# -# Released under GPL V2. -# -# List dangling references to vmlinux discarded sections. - -use strict; -die($0 . " takes no arguments\n") if($#ARGV >= 0); - -my %object; -my $object; -my $line; -my $ignore; -my $errorcount; - -$| = 1; - -# printf("Finding objects, "); -open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed"; -while (defined($line = )) { - chomp($line); - if ($line =~ /:\s+file format/) { - ($object = $line) =~ s/:.*//; - $object{$object}->{'module'} = 0; - $object{$object}->{'size'} = 0; - $object{$object}->{'off'} = 0; - } - if ($line =~ /^\s*\d+\s+\.modinfo\s+/) { - $object{$object}->{'module'} = 1; - } - if ($line =~ /^\s*\d+\s+\.comment\s+/) { - ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5]; - } -} -close(OBJDUMP_LIST); -# printf("%d objects, ", scalar keys(%object)); -$ignore = 0; -foreach $object (keys(%object)) { - if ($object{$object}->{'module'}) { - ++$ignore; - delete($object{$object}); - } -} -# printf("ignoring %d module(s)\n", $ignore); - -# Ignore conglomerate objects, they have been built from multiple objects and we -# only care about the individual objects. If an object has more than one GCC: -# string in the comment section then it is conglomerate. This does not filter -# out conglomerates that consist of exactly one object, can't be helped. - -# printf("Finding conglomerates, "); -$ignore = 0; -foreach $object (keys(%object)) { - if (exists($object{$object}->{'off'})) { - my ($off, $size, $comment, $l); - $off = hex($object{$object}->{'off'}); - $size = hex($object{$object}->{'size'}); - open(OBJECT, "<$object") || die "cannot read $object"; - seek(OBJECT, $off, 0) || die "seek to $off in $object failed"; - $l = read(OBJECT, $comment, $size); - die "read $size bytes from $object .comment failed" if ($l != $size); - close(OBJECT); - if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) { - ++$ignore; - delete($object{$object}); - } - } -} -# printf("ignoring %d conglomerate(s)\n", $ignore); - -# printf("Scanning objects\n"); - -# 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. -$errorcount = 0; -foreach $object (keys(%object)) { - my $from; - open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object"; - while (defined($line = )) { - chomp($line); - if ($line =~ /RELOCATION RECORDS FOR /) { - ($from = $line) =~ s/.*\[([^]]*).*/$1/; - } - if (($line =~ /\.text\.exit$/ || - $line =~ /\.exit\.text$/ || - $line =~ /\.data\.exit$/ || - $line =~ /\.exit\.data$/ || - $line =~ /\.exitcall\.exit$/) && - ($from !~ /\.text\.exit$/ && - $from !~ /\.exit\.text$/ && - $from !~ /\.data\.exit$/ && - $from !~ /\.opd$/ && - $from !~ /\.exit\.data$/ && - $from !~ /\.altinstructions$/ && - $from !~ /\.pdr$/ && - $from !~ /\.debug_.*$/ && - $from !~ /\.exitcall\.exit$/ && - $from !~ /\.eh_frame$/ && - $from !~ /\.stab$/)) { - printf("Error: %s %s refers to %s\n", $object, $from, $line); - $errorcount = $errorcount + 1; - } - } - close(OBJDUMP); -} -# printf("Done\n"); - -exit(0); diff --git a/scripts/reference_init.pl b/scripts/reference_init.pl deleted file mode 100644 index 7f6960b..0000000 --- a/scripts/reference_init.pl +++ /dev/null @@ -1,108 +0,0 @@ -#!/usr/bin/perl -w -# -# reference_init.pl (C) Keith Owens 2002 -# -# List references to vmlinux init sections from non-init sections. - -# Unfortunately I had to exclude references from read only data to .init -# sections, almost all of these are false positives, they are created by -# gcc. The downside of excluding rodata is that there really are some -# user references from rodata to init code, e.g. drivers/video/vgacon.c -# -# const struct consw vga_con = { -# con_startup: vgacon_startup, -# -# where vgacon_startup is __init. If you want to wade through the false -# positives, take out the check for rodata. - -use strict; -die($0 . " takes no arguments\n") if($#ARGV >= 0); - -my %object; -my $object; -my $line; -my $ignore; - -$| = 1; - -printf("Finding objects, "); -open(OBJDUMP_LIST, "find . -name '*.o' | xargs objdump -h |") || die "getting objdump list failed"; -while (defined($line = )) { - chomp($line); - if ($line =~ /:\s+file format/) { - ($object = $line) =~ s/:.*//; - $object{$object}->{'module'} = 0; - $object{$object}->{'size'} = 0; - $object{$object}->{'off'} = 0; - } - if ($line =~ /^\s*\d+\s+\.modinfo\s+/) { - $object{$object}->{'module'} = 1; - } - if ($line =~ /^\s*\d+\s+\.comment\s+/) { - ($object{$object}->{'size'}, $object{$object}->{'off'}) = (split(' ', $line))[2,5]; - } -} -close(OBJDUMP_LIST); -printf("%d objects, ", scalar keys(%object)); -$ignore = 0; -foreach $object (keys(%object)) { - if ($object{$object}->{'module'}) { - ++$ignore; - delete($object{$object}); - } -} -printf("ignoring %d module(s)\n", $ignore); - -# Ignore conglomerate objects, they have been built from multiple objects and we -# only care about the individual objects. If an object has more than one GCC: -# string in the comment section then it is conglomerate. This does not filter -# out conglomerates that consist of exactly one object, can't be helped. - -printf("Finding conglomerates, "); -$ignore = 0; -foreach $object (keys(%object)) { - if (exists($object{$object}->{'off'})) { - my ($off, $size, $comment, $l); - $off = hex($object{$object}->{'off'}); - $size = hex($object{$object}->{'size'}); - open(OBJECT, "<$object") || die "cannot read $object"; - seek(OBJECT, $off, 0) || die "seek to $off in $object failed"; - $l = read(OBJECT, $comment, $size); - die "read $size bytes from $object .comment failed" if ($l != $size); - close(OBJECT); - if ($comment =~ /GCC\:.*GCC\:/m || $object =~ /built-in\.o/) { - ++$ignore; - delete($object{$object}); - } - } -} -printf("ignoring %d conglomerate(s)\n", $ignore); - -printf("Scanning objects\n"); -foreach $object (sort(keys(%object))) { - my $from; - open(OBJDUMP, "objdump -r $object|") || die "cannot objdump -r $object"; - while (defined($line = )) { - chomp($line); - if ($line =~ /RELOCATION RECORDS FOR /) { - ($from = $line) =~ s/.*\[([^]]*).*/$1/; - } - if (($line =~ /\.init$/ || $line =~ /\.init\./) && - ($from !~ /\.init$/ && - $from !~ /\.init\./ && - $from !~ /\.stab$/ && - $from !~ /\.rodata$/ && - $from !~ /\.text\.lock$/ && - $from !~ /\.pci_fixup_header$/ && - $from !~ /\.pci_fixup_final$/ && - $from !~ /\.pdr$/ && - $from !~ /\__param$/ && - $from !~ /\.altinstructions/ && - $from !~ /\.eh_frame/ && - $from !~ /\.debug_/)) { - printf("Error: %s %s refers to %s\n", $object, $from, $line); - } - } - close(OBJDUMP); -} -printf("Done\n"); -- cgit v1.1