diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2004-10-21 15:58:05 -0400 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2004-10-21 15:58:05 -0400 |
| commit | f5b8a851511cbbc1d9354258fc1840ff2c9eadc5 (patch) | |
| tree | 5400038e3a535107a8e20496d85afee696d8ce28 /scripts | |
| parent | 0d554d392aa7adce368f13d6068679c18b0fa50e (diff) | |
| parent | 77752839e8a15553eda7f2396f894eae80409a8d (diff) | |
Merge pobox.com:/garz/repo/libata-dev/export-simulator
into pobox.com:/garz/repo/libata-2.6
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Makefile.modpost | 1 | ||||
| -rw-r--r-- | scripts/gen_initramfs_list.sh | 84 | ||||
| -rw-r--r-- | scripts/mod/modpost.c | 65 | ||||
| -rw-r--r-- | scripts/mod/modpost.h | 10 | ||||
| -rw-r--r-- | scripts/mod/sumversion.c | 80 | ||||
| -rw-r--r-- | scripts/reference_init.pl | 2 |
6 files changed, 168 insertions, 74 deletions
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index b3d31b559ad8..94b550e21be8 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost @@ -52,6 +52,7 @@ _modpost: $(modules) 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) \ $(filter-out FORCE,$^) diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh new file mode 100644 index 000000000000..59b810396c7b --- /dev/null +++ b/scripts/gen_initramfs_list.sh @@ -0,0 +1,84 @@ +#!/bin/bash +# Copyright (C) Martin Schlemmer <azarah@nosferatu.za.org> +# Released under the terms of the GNU GPL +# +# A script to generate newline separated entries (to stdout) from a directory's +# contents suitable for use as a cpio_list for gen_init_cpio. +# +# Arguements: $1 -- the source directory +# +# TODO: Add support for symlinks, sockets and pipes when gen_init_cpio +# supports them. + +usage() { + echo "Usage: $0 initramfs-source-dir" + exit 1 +} + +srcdir=$(echo "$1" | sed -e 's://*:/:g') + +if [ "$#" -gt 1 -o ! -d "${srcdir}" ]; then + usage +fi + +filetype() { + local argv1="$1" + + if [ -f "${argv1}" ]; then + echo "file" + elif [ -d "${argv1}" ]; then + echo "dir" + elif [ -b "${argv1}" -o -c "${argv1}" ]; then + echo "nod" + else + echo "invalid" + fi + return 0 +} + +parse() { + local location="$1" + local name="${location/${srcdir}//}" + local mode="$2" + local uid="$3" + local gid="$4" + local ftype=$(filetype "${location}") + local str="${mode} ${uid} ${gid}" + + [ "${ftype}" == "invalid" ] && return 0 + [ "${location}" == "${srcdir}" ] && return 0 + + case "${ftype}" in + "file") + str="${ftype} ${name} ${location} ${str}" + ;; + "nod") + local dev_type= + local maj=$(LC_ALL=C ls -l "${location}" | \ + gawk '{sub(/,/, "", $5); print $5}') + local min=$(LC_ALL=C ls -l "${location}" | \ + gawk '{print $6}') + + if [ -b "${location}" ]; then + dev_type="b" + else + dev_type="c" + fi + str="${ftype} ${name} ${str} ${dev_type} ${maj} ${min}" + ;; + *) + str="${ftype} ${name} ${str}" + ;; + esac + + echo "${str}" + + return 0 +} + +find "${srcdir}" -printf "%p %m %U %G\n" | \ +while read x; do + parse ${x} +done + +exit 0 diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 2a174e504c22..db094659fb1e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1,7 +1,7 @@ /* Postprocess module symbol versions * * Copyright 2003 Kai Germaschewski - * 2002-2003 Rusty Russell, IBM Corporation + * Copyright 2002-2004 Rusty Russell, IBM Corporation * * Based in part on module-init-tools/depmod.c,file2alias * @@ -18,6 +18,8 @@ int modversions = 0; /* Warn about undefined symbols? (do so if we have vmlinux) */ int have_vmlinux = 0; +/* Is CONFIG_MODULE_SRCVERSION_ALL set? */ +static int all_versions = 0; void fatal(const char *fmt, ...) @@ -397,10 +399,44 @@ is_vmlinux(const char *modname) return strcmp(myname, "vmlinux") == 0; } +/* Parse tag=value strings from .modinfo section */ +static char *next_string(char *string, unsigned long *secsize) +{ + /* Skip non-zero chars */ + while (string[0]) { + string++; + if ((*secsize)-- <= 1) + return NULL; + } + + /* Skip any zero padding. */ + while (!string[0]) { + string++; + if ((*secsize)-- <= 1) + return NULL; + } + return string; +} + +static char *get_modinfo(void *modinfo, unsigned long modinfo_len, + const char *tag) +{ + char *p; + unsigned int taglen = strlen(tag); + unsigned long size = modinfo_len; + + for (p = modinfo; p; p = next_string(p, &size)) { + if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=') + return p + taglen + 1; + } + return NULL; +} + void read_symbols(char *modname) { const char *symname; + char *version; struct module *mod; struct elf_info info = { }; Elf_Sym *sym; @@ -424,8 +460,15 @@ read_symbols(char *modname) handle_modversions(mod, &info, sym, symname); handle_moddevtable(mod, &info, sym, symname); } - maybe_frob_version(modname, info.modinfo, info.modinfo_len, - (void *)info.modinfo - (void *)info.hdr); + + version = get_modinfo(info.modinfo, info.modinfo_len, "version"); + if (version) + maybe_frob_rcs_version(modname, version, info.modinfo, + version - (char *)info.hdr); + if (version || (all_versions && !is_vmlinux(modname))) + get_src_version(modname, mod->srcversion, + sizeof(mod->srcversion)-1); + parse_elf_finish(&info); /* Our trick to get versioning for struct_module - it's @@ -571,6 +614,16 @@ add_depends(struct buffer *b, struct module *mod, struct module *modules) } void +add_srcversion(struct buffer *b, struct module *mod) +{ + if (mod->srcversion[0]) { + buf_printf(b, "\n"); + buf_printf(b, "MODULE_INFO(srcversion, \"%s\");\n", + mod->srcversion); + } +} + +void write_if_changed(struct buffer *b, const char *fname) { char *tmp; @@ -691,7 +744,7 @@ main(int argc, char **argv) char *dump_read = NULL, *dump_write = NULL; int opt; - while ((opt = getopt(argc, argv, "i:mo:")) != -1) { + while ((opt = getopt(argc, argv, "i:mo:a")) != -1) { switch(opt) { case 'i': dump_read = optarg; @@ -702,6 +755,9 @@ main(int argc, char **argv) case 'o': dump_write = optarg; break; + case 'a': + all_versions = 1; + break; default: exit(1); } @@ -724,6 +780,7 @@ main(int argc, char **argv) add_versions(&buf, mod); add_depends(&buf, mod, modules); add_moddevtable(&buf, mod); + add_srcversion(&buf, mod); sprintf(fname, "%s.mod.c", mod->name); write_if_changed(&buf, fname); diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 4871343e192a..eb8815ae209e 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h @@ -77,6 +77,7 @@ struct module { int has_init; int has_cleanup; struct buffer dev_table_buf; + char srcversion[25]; }; struct elf_info { @@ -95,10 +96,11 @@ void handle_moddevtable(struct module *mod, struct elf_info *info, void add_moddevtable(struct buffer *buf, struct module *mod); -void maybe_frob_version(const char *modfilename, - void *modinfo, - unsigned long modinfo_len, - unsigned long modinfo_offset); +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); void *grab_file(const char *filename, unsigned long *size); char* get_next_line(unsigned long *pos, void *file, unsigned long size); diff --git a/scripts/mod/sumversion.c b/scripts/mod/sumversion.c index bf07479c8630..6ece36794c0d 100644 --- a/scripts/mod/sumversion.c +++ b/scripts/mod/sumversion.c @@ -9,39 +9,6 @@ #include <string.h> #include "modpost.h" -/* Parse tag=value strings from .modinfo section */ -static char *next_string(char *string, unsigned long *secsize) -{ - /* Skip non-zero chars */ - while (string[0]) { - string++; - if ((*secsize)-- <= 1) - return NULL; - } - - /* Skip any zero padding. */ - while (!string[0]) { - string++; - if ((*secsize)-- <= 1) - return NULL; - } - return string; -} - -static char *get_modinfo(void *modinfo, unsigned long modinfo_len, - const char *tag) -{ - char *p; - unsigned int taglen = strlen(tag); - unsigned long size = modinfo_len; - - for (p = modinfo; p; p = next_string(p, &size)) { - if (strncmp(p, tag, taglen) == 0 && p[taglen] == '=') - return p + taglen + 1; - } - return NULL; -} - /* * Stolen form Cryptographic API. * @@ -408,11 +375,11 @@ out: return ret; } -static int get_version(const char *modname, char sum[]) +/* Calc and record src checksum. */ +void get_src_version(const char *modname, char sum[], unsigned sumlen) { void *file; unsigned long len; - int ret = 0; struct md4_ctx md; char *sources, *end, *fname; const char *basename; @@ -432,7 +399,7 @@ static int get_version(const char *modname, char sum[]) if (!file) { fprintf(stderr, "Warning: could not find versions for %s\n", filelist); - return 0; + return; } sources = strchr(file, '\n'); @@ -457,12 +424,9 @@ static int get_version(const char *modname, char sum[]) goto release; } - /* sum is of form \0<padding>. */ - md4_final_ascii(&md, sum, 1 + strlen(sum+1)); - ret = 1; + md4_final_ascii(&md, sum, sumlen); release: release_file(file, len); - return ret; } static void write_version(const char *filename, const char *sum, @@ -492,12 +456,12 @@ out: close(fd); } -void strip_rcs_crap(char *version) +static int strip_rcs_crap(char *version) { unsigned int len, full_len; if (strncmp(version, "$Revision", strlen("$Revision")) != 0) - return; + return 0; /* Space for version string follows. */ full_len = strlen(version) + strlen(version + strlen(version) + 1) + 2; @@ -518,31 +482,15 @@ void strip_rcs_crap(char *version) len++; memmove(version + len, version + strlen(version), full_len - strlen(version)); + return 1; } -/* If the modinfo contains a "version" value, then set this. */ -void maybe_frob_version(const char *modfilename, - void *modinfo, - unsigned long modinfo_len, - unsigned long modinfo_offset) +/* Clean up RCS-style version numbers. */ +void maybe_frob_rcs_version(const char *modfilename, + char *version, + void *modinfo, + unsigned long version_offset) { - char *version, *csum; - - version = get_modinfo(modinfo, modinfo_len, "version"); - if (!version) - return; - - /* RCS $Revision gets stripped out. */ - strip_rcs_crap(version); - - /* Check against double sumversion */ - if (strchr(version, ' ')) - return; - - /* Version contains embedded NUL: second half has space for checksum */ - csum = version + strlen(version); - *(csum++) = ' '; - if (get_version(modfilename, csum)) - write_version(modfilename, version, - modinfo_offset + (version - (char *)modinfo)); + if (strip_rcs_crap(version)) + write_version(modfilename, version, version_offset); } diff --git a/scripts/reference_init.pl b/scripts/reference_init.pl index b4e37dc3a944..23cea187a857 100644 --- a/scripts/reference_init.pl +++ b/scripts/reference_init.pl @@ -93,6 +93,8 @@ foreach $object (sort(keys(%object))) { $from !~ /\.stab$/ && $from !~ /\.rodata$/ && $from !~ /\.text\.lock$/ && + $from !~ /\.pci_fixup_header$/ && + $from !~ /\.pci_fixup_final$/ && $from !~ /\.debug_/)) { printf("Error: %s %s refers to %s\n", $object, $from, $line); } |
