Skip to contentSkip to conversation

kbuild updates

PATCH New Sam Ravnborg 1 participant 21 messages Mar 21, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild updates

Hi Linus.

Here follows kbuild updates for 2.6.17.
Most noteworthy changes:
o Introduced section consistency checks during modpost.
This generates a number of warnings for an allmodconfig build but it looks sane for most normal configs.
There may be false positives around but they are getting less.
o Removed scripts/reference_* - they are replaced by the check for inconsistent section usage
o Introduced check for duplicated exported symbols
o Make kbuild compatible with a future gnu make change
o Improved support for external modules (depmod, exported symbols)
o Lindent a few files (modpost.c, genksyms.c) addidng to size of diff.

Almost all patches have been in -mm for a shorter or longer period. Shortlog contains more details.
Patches (all 48) will follow as separate mails.

Please pull from:

ssh://master.kernel.org/pub/scm/linux/kernel/git/sam/kbuild.git

Sam

Diffstat:

 Documentation/DocBook/Makefile          |    8 
 Documentation/kbuild/makefiles.txt      |  173 +++--
 Documentation/kbuild/modules.txt        |   98 +++
 Documentation/smart-config.txt          |    4 
 Makefile                                |  234 +++-----
 arch/arm/Makefile                       |    5 
 arch/arm/boot/Makefile                  |    5 
 arch/arm/boot/bootp/Makefile            |    5 
 arch/arm26/Makefile                     |    7 
 arch/arm26/boot/Makefile                |    5 
 arch/i386/Makefile                      |    4 
 arch/i386/kernel/vmlinux.lds.S          |    4 
 arch/ia64/Makefile                      |    5 
 arch/m32r/Makefile                      |    5 
 arch/powerpc/Makefile                   |    2 
 arch/ppc/Makefile                       |    2 
 arch/ppc/boot/Makefile                  |    5 
 arch/ppc/boot/openfirmware/Makefile     |    7 
 arch/sh/Makefile                        |    2 
 arch/um/Makefile                        |    7 
 arch/x86_64/Makefile                    |    4 
 drivers/atm/.gitignore                  |    5 
 drivers/video/matrox/matroxfb_DAC1064.c |    1 
 drivers/video/matrox/matroxfb_DAC1064.h |    1 
 drivers/video/matrox/matroxfb_Ti3026.c  |    1 
 drivers/video/matrox/matroxfb_Ti3026.h  |    1 
 drivers/video/matrox/matroxfb_base.c    |    1 
 drivers/video/matrox/matroxfb_misc.c    |    1 
 init/Kconfig                            |   38 -
 scripts/Kbuild.include                  |   68 +-
 scripts/Makefile.build                  |   29 
 scripts/Makefile.clean                  |   10 
 scripts/Makefile.modinst                |   10 
 scripts/Makefile.modpost                |   19 
 scripts/basic/fixdep.c                  |   15 
 scripts/checkconfig.pl                  |   66 --
 scripts/genksyms/genksyms.c             |  935 ++++++++++++++------------------
 scripts/genksyms/genksyms.h             |   58 -
 scripts/kconfig/Makefile                |    7 
 scripts/kconfig/confdata.c              |    3 
 scripts/kconfig/lxdialog/Makefile       |    6 
 scripts/mkmakefile                      |    9 
 scripts/mod/file2alias.c                |   17 
 scripts/mod/mk_elfconfig.c              |    4 
 scripts/mod/modpost.c                   |  838 +++++++++++++++++++++-------
 scripts/mod/modpost.h                   |   27 
 scripts/mod/sumversion.c                |   34 -
 scripts/namespace.pl                    |    5 
 scripts/package/Makefile                |   30 -
 scripts/reference_discarded.pl          |  112 ---
 scripts/reference_init.pl               |  109 ---
 sound/oss/.gitignore                    |    5 
 52 files changed, 1624 insertions(+), 1432 deletions(-)

Shortlog:
Aaron Brooks:
kbuild: make namespace.pl CROSS_COMPILE happy

Adrian Bunk:
kbuild: remove a tab from an empty line
Kconfig: remove the CONFIG_CC_ALIGN_* options

Andrew Morton:
kbuild: fix modpost compile with older gcc

Brian Gerst:
kbuild: remove checkconfig.pl

Chuck Ebbert:
kbuild: add -fverbose-asm to i386 Makefile

Jan Beulich:
kbuild: consolidate command line escaping
kbuild: fix mkmakefile
kbuild: version.h should depend on .kernelrelease
kconfig: fix time ordering of writes to .kconfig.d and include/linux/autoconf.h

Jesper Juhl:
kbuild: small update of allnoconfig description

Luke Yang:
kbuild: Fix bug in crc symbol generating of kernel and modules

Martin Michlmayr:
kbuild: Accept various mips sub-types in SUBARCH

Mattia Dongili:
kbuild: fix a cscope bug (make cscope segfaults)

Paul Smith:
kbuild: change kbuild to not rely on incorrect GNU make behavior

Sam Ravnborg:
kbuild: support building individual files for external modules
kbuild: use warn()/fatal() consistent in modpost
kbuild: apply CodingStyle to modpost.c
kbuild: improved modversioning support for external modules
kbuild: warn about duplicate exported symbols
kbuild: avoid stale modules in $(MODVERDIR) for external modules
kbuild: run depmod when installing external modules
kbuild: check for section mismatch during modpost stage
kbuild: make cc-version available in kbuild files
kbuild: fix comment in Kbuild.include
kbuild: do not segfault in modpost if MODVERDIR is not defined
kbuild: fix segfault in modpost
kbuild: include symbol names in section mismatch warnings
kbuild: do not warn when unwind sections references .init/.exit sections
kbuild: Add copyright to modpost.c
kbuild: ignore all generated files for make allmodconfig (x86_64)
kbuild: whitelist false section mismatch warnings
kbuild: kill trailing whitespace in modpost & friends
kbuild: kill false positives from section mismatch warnings for powerpc
kbuild: fix section mismatch check for unwind on IA64
kbuild: in the section mismatch check try harder to find symbols
kbuild: fix make dir/file.xx when asm symlink is missing
kbuild: when warning symbols exported twice now tell user this is the problem
kbuild: replace PHONY with FORCE
kbuild: in makefile.txt note that Makefile is preferred name for kbuild files
kbuild: fix genksyms build error
kbuild: Lindent genksyms.c
kbuild: clean-up genksyms
kbuild: fix make help & make *pkg
kbuild: remove obsoleted scripts/reference_* files

Zach Brown:
x86: align per-cpu section to configured cache bytes

#1 lore raw

PATCH 1/46 kbuild: support building individual files for external modules

Support building individual files when dealing with separate modules. So say you have a module named "foo" which consist of two .o files bar.o and fun.o.

You can then do:
make -C $KERNELSRC M=pwd bar.o
make -C $KERNELSRC M=pwd bar.lst
make -C $KERNELSRC M=pwd bar.i
make -C $KERNELSRC M=pwd / <= will build all .o files
and link foo.o
make -C $KERNELSRC M=pwd foo.ko <= will build the module
and do the modpost step to create foo.ko

The above will also work if the external module is placed in a subdirectory using a hirachy of kbuild files.
Thanks to Andreas Gruenbacher <[email protected]> for initial feature request / bug report.

---

 Documentation/kbuild/modules.txt |   11 ++++++
 Makefile                         |   66 +++++++++++++++++++++++++-------------
 2 files changed, 55 insertions(+), 22 deletions(-)

06300b21f4c79fd1578f4b7ca4b314fbab61a383

Documentation/kbuild/modules.txt +11 -0
index 7e77f93..87d858d 100644
@@ -13,6 +13,7 @@ In this document you will find informati
 	   --- 2.2 Available targets
 	   --- 2.3 Available options
 	   --- 2.4 Preparing the kernel tree for module build
+	   --- 2.5 Building separate files for a module
 	=== 3. Example commands
 	=== 4. Creating a kbuild file for an external module
 	=== 5. Include files
@@ -131,6 +132,16 @@ when building an external module.
 	      Therefore a full kernel build needs to be executed to make
 	      module versioning work.
 
+--- 2.5 Building separate files for a module
+	It is possible to build single files which is part of a module.
+	This works equal for the kernel, a module and even for external
+	modules.
+	Examples (module foo.ko, consist of bar.o, baz.o):
+		make -C $KDIR M=`pwd` bar.lst
+		make -C $KDIR M=`pwd` bar.o
+		make -C $KDIR M=`pwd` foo.ko
+		make -C $KDIR M=`pwd` /
+	
 
 === 3. Example commands
 
Makefile +44 -22

90 lines not on this page · raw message

Signature · 1 line
1.0.GIT
#2 lore raw

PATCH 2/46 kbuild: use warn()/fatal() consistent in modpost

modpost.c provides warn() and fatal() - so use them all over the place.

---

 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(-)

cb80514d9c517cc1d101ef304529a0e9b76b4468

scripts/mod/file2alias.c +6 -7
index be97caf..1346223 100644
@@ -153,8 +153,8 @@ static void do_usb_table(void *symval, u
 	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 *file
 	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, unsig
 	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;
scripts/mod/modpost.c +6 -10
index f70ff13..a3c57ec 100644
@@ -303,8 +303,7 @@ parse_elf(struct elf_info *info, const c
 			             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 c
 	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, s
 
 	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 mo
 		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 mo
 			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;
 		}
scripts/mod/modpost.h +6 -1
index 7334d83..c0de7b9 100644
@@ -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, ...);
scripts/mod/sumversion.c +9 -14
index 43271a1..5c07545 100644
@@ -316,8 +316,7 @@ static int parse_source_files(const char
 
 	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
 		/* 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
 
 	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 *fi
 
 	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;
 	}
Signature · 1 line
1.0.GIT
#3 lore raw

PATCH 3/46 kbuild: apply CodingStyle to modpost.c

Just some light CodingStyle updates - no functional changes.

---

 scripts/mod/modpost.c |  124 +++++++++++++++++++++----------------------------
 1 files changed, 54 insertions(+), 70 deletions(-)

5c3ead8c72788d36d34c9f1689fb529d1339b405

scripts/mod/modpost.c +54 -70
index a3c57ec..4a2f2e3 100644
@@ -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 *e
 
 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(cons
 	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 
 }
 
 /* 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 modu
 	}
 }
 
-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, st
 	}
 }
 
-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
 	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 *
 	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 c
 	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, s
 	}
 }
 
-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, 
 	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 cha
 	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
 	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 <linux/module.h>\n");
 	buf_printf(b, "#include <linux/vermagic.h>\n");
@@ -548,10 +538,10 @@ add_header(struct buffer *b, struct modu
 	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 mo
 	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 mod
 	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 
 	}
 }
 
-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
 	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;
 }
-
Signature · 1 line
1.0.GIT
#4 lore raw

PATCH 4/46 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

---

 Documentation/kbuild/modules.txt |   87 +++++++++++++++++++++++++--
 scripts/Makefile.modpost         |    7 ++
 scripts/mod/modpost.c            |  123 +++++++++++++++++++++++---------------
 3 files changed, 158 insertions(+), 59 deletions(-)

040fcc819a2e7783a570f4bdcdd1f2a7f5f06837

Documentation/kbuild/modules.txt +80 -7
index 87d858d..fcccf24 100644
@@ -23,7 +23,10 @@ In this document you will find informati
 	=== 6. Module installation
 	   --- 6.1 INSTALL_MOD_PATH
 	   --- 6.2 INSTALL_MOD_DIR
-	=== 7. Module versioning
+	=== 7. Module versioning & Module.symvers
+	   --- 7.1 Symbols fron the kernel (vmlinux + modules)
+	   --- 7.2 Symbols and external modules
+	   --- 7.3 Symbols from another external module
 	=== 8. Tips & Tricks
 	   --- 8.1 Testing for CONFIG_FOO_BAR
 
@@ -89,7 +92,8 @@ when building an external module.
 	make -C $KDIR M=$PWD modules_install
 		Install the external module(s).
 		Installation default is in /lib/modules/<kernel-version>/extra,
-		but may be prefixed with INSTALL_MOD_PATH - see separate chapter.
+		but may be prefixed with INSTALL_MOD_PATH - see separate
+		chapter.
 
 	make -C $KDIR M=$PWD clean
 		Remove all generated files for the module - the kernel
@@ -433,7 +437,7 @@ External modules are installed in the di
 		=> Install dir: /lib/modules/$(KERNELRELEASE)/gandalf
 
 
-=== 7. Module versioning
+=== 7. Module versioning & Module.symvers
 
 Module versioning is enabled by the CONFIG_MODVERSIONS tag.
 
@@ -443,11 +447,80 @@ when a module is loaded/used then the CR
 compared with similar values in the module. If they are not equal then the
 kernel refuses to load the module.
 
-During a kernel build a file named Module.symvers will be generated. This
-file includes the symbol version of all symbols within the kernel. If the 
-Module.symvers file is saved from the last full kernel compile one does not
-have to do a full kernel compile to build a module version's compatible module.
+Module.symvers contains a list of all exported symbols from a kernel build.
 
+--- 7.1 Symbols fron the kernel (vmlinux + modules)
+
+	During a kernel build a file named Module.symvers will be generated.
+	Module.symvers contains all exported symbols from the kernel and
+	compiled modules. For each symbols the corresponding CRC value
+	is stored too.
+
+	The syntax of the Module.symvers file is:
+		<CRC>       <Symbol>           <module>
+	Sample:
+		0x2d036834  scsi_remove_host   drivers/scsi/scsi_mod
+
+	For a kernel build without CONFIG_MODVERSIONING enabled the crc
+	would read: 0x00000000
+
+	Module.symvers serve two purposes.
+	1) It list all exported symbols both from vmlinux and all modules
+	2) It list CRC if CONFIG_MODVERSION is enabled
+
+--- 7.2 Symbols and external modules
+
+	When building an external module the build system needs access to
+	the symbols from the kernel to check if all external symbols are
+	defined. This is done in the MODPOST step and to obtain all
+	symbols modpost reads Module.symvers from the kernel.
+	If a Module.symvers file is present in the directory where
+	the external module is being build this file will be read too.
+	During the MODPOST step a new Module.symvers file will be written
+	containing all exported symbols that was not defined in the kernel.
+	
+--- 7.3 Symbols from another external module
+
+	Sometimes one external module uses exported symbols from another
+	external module. Kbuild needs to have full knowledge on all symbols
+	to avoid spitting out warnings about undefined symbols.
+	Two solutions exist to let kbuild know all symbols of more than
+	one external module.
+	The method with a top-level kbuild file is recommended but may be
+	impractical in certain situations.
+
+	Use a top-level Kbuild file
+		If you have two modules: 'foo', 'bar' and 'foo' needs symbols
+		from 'bar' then one can use a common top-level kbuild file so
+		both modules are compiled in same build.
+
+		Consider following directory layout:
+		./foo/ <= contains the foo module
+		./bar/ <= contains the bar module
+		The top-level Kbuild file would then look like:
+		
+		#./Kbuild: (this file may also be named Makefile)
+			obj-y := foo/ bar/
+
+		Executing:
+			make -C $KDIR M=`pwd`
+
+		will then do the expected and compile both modules with full
+		knowledge on symbols from both modules.
+
+	Use an extra Module.symvers file
+		When an external module is build a Module.symvers file is
+		generated containing all exported symbols which are not
+		defined in the kernel.
+		To get access to symbols from module 'bar' one can copy the
+		Module.symvers file from the compilation of the 'bar' module
+		to the directory where the 'foo' module is build.
+		During the module build kbuild will read the Module.symvers
+		file in the directory of the external module and when the
+		build is finished a new Module.symvers file is created
+		containing the sum of all symbols defined and not part of the
+		kernel.
+		
 === 8. Tips & Tricks
 
 --- 8.1 Testing for CONFIG_FOO_BAR
scripts/Makefile.modpost +5 -2
index bf96a61..563e3c5 100644
@@ -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
scripts/mod/modpost.c +73 -50

233 lines not on this page · raw message

Signature · 1 line
1.0.GIT
#5 lore raw

PATCH 5/46 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.

---

 scripts/mod/modpost.c |   16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

8e70c45887a6bbe40393342ea5b426b0dd836dff

scripts/mod/modpost.c +13 -3
index 976adf1..d901095 100644
@@ -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(c
 {
 	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,
 			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;
Signature · 1 line
1.0.GIT
#6 lore raw

PATCH 6/46 x86: align per-cpu section to configured cache bytes

This matches the fix for a bug seen on x86-64. Test booted on old hardware that had 32 byte cachelines to begin with.

---

 arch/i386/kernel/vmlinux.lds.S |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

379b5441aeb895fe55b877a8a9c187e8728f774c

arch/i386/kernel/vmlinux.lds.S +2 -1
index 4710195..18f99cc 100644
@@ -7,6 +7,7 @@
 #include <asm-generic/vmlinux.lds.h>
 #include <asm/thread_info.h>
 #include <asm/page.h>
+#include <asm/cache.h>
 
 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
 OUTPUT_ARCH(i386)
@@ -115,7 +116,7 @@ SECTIONS
   __initramfs_start = .;
   .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { *(.init.ramfs) }
   __initramfs_end = .;
-  . = ALIGN(32);
+  . = ALIGN(L1_CACHE_BYTES);
   __per_cpu_start = .;
   .data.percpu  : AT(ADDR(.data.percpu) - LOAD_OFFSET) { *(.data.percpu) }
   __per_cpu_end = .;
Signature · 1 line
1.0.GIT
#7 lore raw

PATCH 7/46 kbuild: Accept various mips sub-types in SUBARCH

uname -m on MIPS can give a number of results, such as mips64. We need to add another substitution to the sed call for SUBARCH in the main Makefile.

---

 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

8999257c292cb757828ae3def9f5e9d894a24741

Makefile +1 -1
index 639d8a4..1db819e 100644
@@ -151,7 +151,7 @@ export srctree objtree VPATH TOPDIR
 SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
 				  -e s/arm.*/arm/ -e s/sa110/arm/ \
 				  -e s/s390x/s390/ -e s/parisc64/parisc/ \
-				  -e s/ppc.*/powerpc/ )
+				  -e s/ppc.*/powerpc/ -e s/mips.*/mips/ )
 
 # Cross compiling and selecting different set of gcc/bin-utils
 # ---------------------------------------------------------------------------
Signature · 1 line
1.0.GIT
#8 lore raw

PATCH 8/46 kbuild: avoid stale modules in $(MODVERDIR) for external modules

To avoid stale modules located in $(MODVERDIR) aka .tmp_versions/ always delete the directory when building an external module.

---

 Makefile |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

fb3cbd2e575f9ac0700bfa1e7cb9f4119fbd0abd

Makefile +1 -0
index 1db819e..fdb3dac 100644
@@ -1126,6 +1126,7 @@ else # KBUILD_EXTMOD
 KBUILD_MODULES := 1
 .PHONY: crmodverdir
 crmodverdir:
+	$(Q)rm -rf $(MODVERDIR)
 	$(Q)mkdir -p $(MODVERDIR)
 
 .PHONY: $(objtree)/Module.symvers
Signature · 1 line
1.0.GIT
#9 lore raw

PATCH 9/46 kbuild: run depmod when installing external modules

Following patch enables depmod support when installing external modules.

---

 Makefile |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

a67dc21a38055ec2d8d85b2f64d98091748569b3

Makefile +20 -1
index fdb3dac..c55d0f1 100644
@@ -1147,9 +1147,28 @@ modules: $(module-dirs)
 	$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modpost
 
 .PHONY: modules_install
-modules_install:
+modules_install: _emodinst_ _emodinst_post
+	
+install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)	
+.PHONY: _emodinst_
+_emodinst_:
+	$(Q)rm -rf $(MODLIB)/$(install-dir)
+	$(Q)mkdir -p $(MODLIB)/$(install-dir)
 	$(Q)$(MAKE) -rR -f $(srctree)/scripts/Makefile.modinst
 
+# Run depmod only is we have System.map and depmod is executable
+quiet_cmd_depmod = DEPMOD  $(KERNELRELEASE)
+      cmd_depmod = if [ -r System.map -a -x $(DEPMOD) ]; then \
+                      $(DEPMOD) -ae -F System.map             \
+                      $(if $(strip $(INSTALL_MOD_PATH)),      \
+		      -b $(INSTALL_MOD_PATH) -r)              \
+		      $(KERNELRELEASE);                       \
+                   fi
+
+.PHONY: _emodinst_post
+_emodinst_post: _emodinst_
+	$(call cmd,depmod)
+
 clean-dirs := $(addprefix _clean_,$(KBUILD_EXTMOD))
 
 .PHONY: $(clean-dirs) clean
Signature · 1 line
1.0.GIT
#10 lore raw

PATCH 10/46 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.

---

 scripts/mod/modpost.c |  258 +++++++++++++++++++++++++++++++++++++++++++++++++
 scripts/mod/modpost.h |   10 ++
 2 files changed, 268 insertions(+), 0 deletions(-)

b39927cf4cc5a9123d2b157ffd396884cb8156eb

scripts/mod/modpost.c +258 -0
index d901095..a7360c3 100644
@@ -451,6 +451,262 @@ static char *get_modinfo(void *modinfo, 
 	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 <[email protected]> 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)
scripts/mod/modpost.h +10 -0
index c0de7b9..3b5319d 100644
@@ -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
Signature · 1 line
1.0.GIT
#11 lore raw

PATCH 11/46 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

---

 Documentation/kbuild/makefiles.txt |  166 +++++++++++++++++++++---------------
 Makefile                           |   32 -------
 scripts/Kbuild.include             |   37 ++++++++
 scripts/Makefile.build             |    3 -
 4 files changed, 136 insertions(+), 102 deletions(-)

20a468b51325b3636785a8ca0047ae514b39cbd5

Documentation/kbuild/makefiles.txt +97 -69
index 443230b..99d51a5 100644
@@ -17,6 +17,7 @@ This document describes the Linux kernel
 	   --- 3.8 Command line dependency
 	   --- 3.9 Dependency tracking
 	   --- 3.10 Special Rules
+	   --- 3.11 $(CC) support functions
 
 	=== 4 Host Program support
 	   --- 4.1 Simple Host Program
@@ -38,7 +39,6 @@ This document describes the Linux kernel
 	   --- 6.6 Commands useful for building a boot image
 	   --- 6.7 Custom kbuild commands
 	   --- 6.8 Preprocessing linker scripts
-	   --- 6.9 $(CC) support functions
 
 	=== 7 Kbuild Variables
 	=== 8 Makefile language
@@ -385,6 +385,102 @@ more details, with real examples.
 	to prerequisites are referenced with $(src) (because they are not
 	generated files).
 
+--- 3.11 $(CC) support functions
+
+	The kernel may be build with several different versions of
+	$(CC), each supporting a unique set of features and options.
+	kbuild provide basic support to check for valid options for $(CC).
+	$(CC) is useally the gcc compiler, but other alternatives are
+	available.
+
+    as-option
+    	as-option is used to check if $(CC) when used to compile
+	assembler (*.S) files supports the given option. An optional
+	second option may be specified if first option are not supported.
+
+	Example:
+		#arch/sh/Makefile
+		cflags-y += $(call as-option,-Wa$(comma)-isa=$(isa-y),)
+
+	In the above example cflags-y will be assinged the the option
+	-Wa$(comma)-isa=$(isa-y) if it is supported by $(CC).
+	The second argument is optional, and if supplied will be used
+	if first argument is not supported.
+
+    cc-option
+	cc-option is used to check if $(CC) support a given option, and not
+	supported to use an optional second option.
+
+	Example:
+		#arch/i386/Makefile
+		cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
+
+	In the above example cflags-y will be assigned the option
+	-march=pentium-mmx if supported by $(CC), otherwise -march-i586.
+	The second argument to cc-option is optional, and if omitted
+	cflags-y will be assigned no value if first option is not supported.
+
+   cc-option-yn
+   	cc-option-yn is used to check if gcc supports a given option
+	and return 'y' if supported, otherwise 'n'.
+
+	Example:
+		#arch/ppc/Makefile
+		biarch := $(call cc-option-yn, -m32)
+		aflags-$(biarch) += -a32
+		cflags-$(biarch) += -m32
+	
+	In the above example $(biarch) is set to y if $(CC) supports the -m32
+	option. When $(biarch) equals to y the expanded variables $(aflags-y)
+	and $(cflags-y) will be assigned the values -a32 and -m32.
+
+    cc-option-align
+	gcc version >= 3.0 shifted type of options used to speify
+	alignment of functions, loops etc. $(cc-option-align) whrn used
+	as prefix to the align options will select the right prefix:
+	gcc < 3.00
+		cc-option-align = -malign
+	gcc >= 3.00
+		cc-option-align = -falign
+	
+	Example:
+		CFLAGS += $(cc-option-align)-functions=4
+
+	In the above example the option -falign-functions=4 is used for
+	gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
+	
+    cc-version
+	cc-version return a numerical version of the $(CC) compiler version.
+	The format is <major><minor> where both are two digits. So for example
+	gcc 3.41 would return 0341.
+	cc-version is useful when a specific $(CC) version is faulty in one
+	area, for example the -mregparm=3 were broken in some gcc version
+	even though the option was accepted by gcc.
+
+	Example:
+		#arch/i386/Makefile
+		cflags-y += $(shell \
+		if [ $(call cc-version) -ge 0300 ] ; then \
+			echo "-mregparm=3"; fi ;)
+
+	In the above example -mregparm=3 is only used for gcc version greater
+	than or equal to gcc 3.0.
+
+    cc-ifversion
+	cc-ifversion test the version of $(CC) and equals last argument if
+	version expression is true.
+
+	Example:
+		#fs/reiserfs/Makefile
+		EXTRA_CFLAGS := $(call cc-ifversion, -lt, 0402, -O1)
+
+	In this example EXTRA_CFLAGS will be assigned the value -O1 if the
+	$(CC) version is less than 4.2.
+	cc-ifversion takes all the shell operators: 
+	-eq, -ne, -lt, -le, -gt, and -ge
+	The third parameter may be a text as in this example, but it may also
+	be an expanded variable or a macro.
+
 
 === 4 Host Program support
 
@@ -973,74 +1069,6 @@ When kbuild executes the following steps
 	architecture specific files.
 
 
---- 6.9 $(CC) support functions
-
-	The kernel may be build with several different versions of
-	$(CC), each supporting a unique set of features and options.
-	kbuild provide basic support to check for valid options for $(CC).
-	$(CC) is useally the gcc compiler, but other alternatives are
-	available.
-
-    cc-option
-	cc-option is used to check if $(CC) support a given option, and not
-	supported to use an optional second option.
-
-	Example:
-		#arch/i386/Makefile
-		cflags-y += $(call cc-option,-march=pentium-mmx,-march=i586)
-
-	In the above example cflags-y will be assigned the option
-	-march=pentium-mmx if supported by $(CC), otherwise -march-i586.
-	The second argument to cc-option is optional, and if omitted
-	cflags-y will be assigned no value if first option is not supported.
-
-   cc-option-yn
-   	cc-option-yn is used to check if gcc supports a given option
-	and return 'y' if supported, otherwise 'n'.
-
-	Example:
-		#arch/ppc/Makefile
-		biarch := $(call cc-option-yn, -m32)
-		aflags-$(biarch) += -a32
-		cflags-$(biarch) += -m32
-	
-	In the above example $(biarch) is set to y if $(CC) supports the -m32
-	option. When $(biarch) equals to y the expanded variables $(aflags-y)
-	and $(cflags-y) will be assigned the values -a32 and -m32.
-
-    cc-option-align
-	gcc version >= 3.0 shifted type of options used to speify
-	alignment of functions, loops etc. $(cc-option-align) whrn used
-	as prefix to the align options will select the right prefix:
-	gcc < 3.00
-		cc-option-align = -malign
-	gcc >= 3.00
-		cc-option-align = -falign
-	
-	Example:
-		CFLAGS += $(cc-option-align)-functions=4
-
-	In the above example the option -falign-functions=4 is used for
-	gcc >= 3.00. For gcc < 3.00 -malign-functions=4 is used.
-	
-    cc-version
-	cc-version return a numerical version of the $(CC) compiler version.
-	The format is <major><minor> where both are two digits. So for example
-	gcc 3.41 would return 0341.
-	cc-version is useful when a specific $(CC) version is faulty in one
-	area, for example the -mregparm=3 were broken in some gcc version
-	even though the option was accepted by gcc.
-
-	Example:
-		#arch/i386/Makefile
-		cflags-y += $(shell \
-		if [ $(call cc-version) -ge 0300 ] ; then \
-			echo "-mregparm=3"; fi ;)
-
-	In the above example -mregparm=3 is only used for gcc version greater
-	than or equal to gcc 3.0.
-	
-
 === 7 Kbuild Variables
 
 The top Makefile exports the following variables:
Makefile +0 -32
index c55d0f1..05b451a 100644
@@ -258,38 +258,6 @@ endif
 
 export quiet Q KBUILD_VERBOSE
 
-######
-# 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)))
-
 
 # Look for make include files relative to root of kernel src
 MAKEFLAGS += --include-dir=$(srctree)
scripts/Kbuild.include +37 -0
index 0168d6c..92ce94b 100644
@@ -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:
scripts/Makefile.build +2 -1
index c33e62b..2737765 100644
@@ -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
Signature · 1 line
1.0.GIT
#12 lore raw

PATCH 12/46 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.

---

 scripts/Kbuild.include |   15 +++++++--------
 scripts/Makefile.build |    8 +++-----
 scripts/basic/fixdep.c |   14 ++------------
 3 files changed, 12 insertions(+), 25 deletions(-)

6176aa9ae4b83e1957d3031774f8a8e59ff97420

scripts/Kbuild.include +7 -8
index 92ce94b..3e7e0b2 100644
@@ -88,8 +88,7 @@ cc-ifversion = $(shell if [ $(call cc-ve
 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)
 
scripts/Makefile.build +3 -5
index 2737765..6ac96ea 100644
@@ -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
scripts/basic/fixdep.c +2 -12
index 679124b..668a11a 100644
@@ -132,20 +132,10 @@ void usage(void)
 
 /*
  * Print out the commandline prefixed with cmd_<target filename> :=
- * 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;
Signature · 1 line
1.0.GIT
#13 lore raw

PATCH 13/46 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.

---

 scripts/mkmakefile |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

96678281bfaa5f04752a98f9b93454041169fd3b

scripts/mkmakefile +5 -3
index c4d621b..a22cbed 100644
@@ -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
-
Signature · 1 line
1.0.GIT
#14 lore raw

PATCH 14/46 kbuild: remove a tab from an empty line

Emacs warns if an otherwise empty line starts with a tab.

---

 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

e63046630c8a73825896cef140fbf49af233fd2a

Makefile +1 -1
index 05b451a..a55a1e4 100644
@@ -1116,7 +1116,7 @@ modules: $(module-dirs)
 
 .PHONY: modules_install
 modules_install: _emodinst_ _emodinst_post
-	
+
 install-dir := $(if $(INSTALL_MOD_DIR),$(INSTALL_MOD_DIR),extra)	
 .PHONY: _emodinst_
 _emodinst_:
Signature · 1 line
1.0.GIT
#15 lore raw

PATCH 15/46 kbuild: remove checkconfig.pl

checkconfig.pl is no longer needed now that autoconf.h is automatically included. Remove it and all references to it.

---

 Documentation/smart-config.txt          |    4 --
 drivers/video/matrox/matroxfb_DAC1064.c |    1 
 drivers/video/matrox/matroxfb_DAC1064.h |    1 
 drivers/video/matrox/matroxfb_Ti3026.c  |    1 
 drivers/video/matrox/matroxfb_Ti3026.h  |    1 
 drivers/video/matrox/matroxfb_base.c    |    1 
 drivers/video/matrox/matroxfb_misc.c    |    1 
 scripts/checkconfig.pl                  |   65 -------------------------------
 8 files changed, 0 insertions(+), 75 deletions(-)
 delete mode 100755 scripts/checkconfig.pl

18a43ba26dcbe2a7a51011c9daae37adc7fc5c93

Documentation/smart-config.txt +0 -4
index c9bed4c..8467447 100644
@@ -56,10 +56,6 @@ Here is the solution:
     writing one file per option.  It updates only the files for options
     that have changed.
 
-    mkdep.c no longer generates warning messages for missing or unneeded
-    <linux/config.h> lines.  The new top-level target 'make checkconfig'
-    checks for these problems.
-
 Flag Dependencies
 
     Martin Von Loewis contributed another feature to this patch:
drivers/video/matrox/matroxfb_DAC1064.c +0 -1
index 0fbd9b5..a456e67 100644
@@ -12,7 +12,6 @@
  *
  */
 
-/* make checkconfig does not walk through include tree :-( */
 #include <linux/config.h>
 
 #include "matroxfb_DAC1064.h"
drivers/video/matrox/matroxfb_DAC1064.h +0 -1
index a6a4701..2e7238a 100644
@@ -1,7 +1,6 @@
 #ifndef __MATROXFB_DAC1064_H__
 #define __MATROXFB_DAC1064_H__
 
-/* make checkconfig does not walk through include tree */
 #include <linux/config.h>
 
 #include "matroxfb_base.h"
drivers/video/matrox/matroxfb_Ti3026.c +0 -1
index 537ade5..23ebad0 100644
@@ -78,7 +78,6 @@
  *
  */
 
-/* make checkconfig does not verify included files... */
 #include <linux/config.h>
 
 #include "matroxfb_Ti3026.h"
drivers/video/matrox/matroxfb_Ti3026.h +0 -1
index 541933d..536e5f6 100644
@@ -1,7 +1,6 @@
 #ifndef __MATROXFB_TI3026_H__
 #define __MATROXFB_TI3026_H__
 
-/* make checkconfig does not walk through whole include tree */
 #include <linux/config.h>
 
 #include "matroxfb_base.h"
drivers/video/matrox/matroxfb_base.c +0 -1
index 4055ff6..951c997 100644
@@ -99,7 +99,6 @@
  *
  */
 
-/* make checkconfig does not check included files... */
 #include <linux/config.h>
 #include <linux/version.h>
 
drivers/video/matrox/matroxfb_misc.c +0 -1
index 455a46c..263d801 100644
@@ -84,7 +84,6 @@
  *
  */
 
-/* make checkconfig does not check includes for this... */
 #include <linux/config.h>
 
 #include "matroxfb_misc.h"
scripts/checkconfig.pl deleted +0 -65

65 lines not on this page · raw message

Signature · 1 line
1.0.GIT
#16 lore raw

PATCH 16/46 kbuild: fix comment in Kbuild.include

Noted by Olaf Hering <[email protected]>

---

 scripts/Kbuild.include |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

9d6e7a709cdb8f43d9a9ac5532b54a3e70415b9b

scripts/Kbuild.include +1 -1
index 3e7e0b2..c3d2e4e 100644
@@ -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
Signature · 1 line
1.0.GIT
#17 lore raw

PATCH 17/46 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.

---

 scripts/mod/sumversion.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

41370d3b5ec6401c5cf0df82297ed989c03a64bd

scripts/mod/sumversion.c +6 -3
index 5c07545..8a28756 100644
@@ -381,8 +381,11 @@ void get_src_version(const char *modname
 	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
 		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);
Signature · 1 line
1.0.GIT
#18 lore raw

PATCH 18/46 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.

---

 scripts/mod/modpost.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

8ea80ca4f583e377c902811d42626ccfce16913f

scripts/mod/modpost.c +1 -1
index a7360c3..eeaf574 100644
@@ -576,11 +576,11 @@ static void check_sec_ref(struct module 
 			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);
 		}
Signature · 1 line
1.0.GIT
#19 lore raw

PATCH 19/46 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.

---

 scripts/mod/modpost.c |   64 ++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 47 insertions(+), 17 deletions(-)

93684d3b8062d1cebdeaed398ec6d1f354cb41a9

scripts/mod/modpost.c +47 -17
index eeaf574..844f84b 100644
@@ -451,6 +451,29 @@ static char *get_modinfo(void *modinfo, 
 	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 
 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
 	
 	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 
 			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)
Signature · 1 line
1.0.GIT
#20 lore raw

PATCH 20/46 kbuild: fix a cscope bug (make cscope segfaults)

Workaround a cscope bug where a trailing ':' in VPATH makes it segfault and let it build the cross-reference succesfully.

VPATH=/home/mattia/devel/kernel/git/linux-2.6: cscope -b
[1] 17555 segmentation fault VPATH=/home/mattia/devel/kernel/git/linux-2.6: cscope -b

---

 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

0f558c333445a0181f33f9e6f996ce7cf008206a

Makefile +1 -1
index a55a1e4..7a95f4f 100644
@@ -137,7 +137,7 @@ objtree		:= $(CURDIR)
 src		:= $(srctree)
 obj		:= $(objtree)
 
-VPATH		:= $(srctree):$(KBUILD_EXTMOD)
+VPATH		:= $(srctree)$(if $(KBUILD_EXTMOD),:$(KBUILD_EXTMOD))
 
 export srctree objtree VPATH TOPDIR
 
Signature · 1 line
1.0.GIT