diff options
author | Sam Ravnborg <sam@uranus.ravnborg.org> | 2008-03-23 16:38:54 -0400 |
---|---|---|
committer | Sam Ravnborg <sam@uranus.ravnborg.org> | 2008-03-23 16:38:54 -0400 |
commit | 4ce6efed48d736e3384c39ff87bda723e1f8e041 (patch) | |
tree | 961601d69caf571c5d3350d8d9f9075b844486b6 | |
parent | d2532dd20a126020de407c1c2476a75b53fce7ac (diff) |
kbuild: soften modpost checks when doing cross builds
The module alias support in the kernel have a consistency
check where it is checked that the size of a structure
in the kernel and on the build host are the same.
For cross builds this check does not make sense so detect
when we do cross builds and silently skip the check in these
situations.
This fixes a build bug for a wireless driver when cross building
for arm.
Acked-by: Michael Buesch <mb@bu3sch.de>
Tested-by: Gordon Farquharson <gordonfarquharson@gmail.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Cc: stable@kernel.org
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | scripts/Makefile.modpost | 6 | ||||
-rw-r--r-- | scripts/mod/file2alias.c | 4 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 5 | ||||
-rw-r--r-- | scripts/mod/modpost.h | 1 |
5 files changed, 15 insertions, 3 deletions
@@ -189,7 +189,7 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ | |||
189 | # Alternatively CROSS_COMPILE can be set in the environment. | 189 | # Alternatively CROSS_COMPILE can be set in the environment. |
190 | # Default value for CROSS_COMPILE is not to prefix executables | 190 | # Default value for CROSS_COMPILE is not to prefix executables |
191 | # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile | 191 | # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile |
192 | 192 | export KBUILD_BUILDHOST := $(SUBARCH) | |
193 | ARCH ?= $(SUBARCH) | 193 | ARCH ?= $(SUBARCH) |
194 | CROSS_COMPILE ?= | 194 | CROSS_COMPILE ?= |
195 | 195 | ||
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index cfc004e04417..2d20640854b7 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
@@ -58,6 +58,9 @@ modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) | |||
58 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker | 58 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker |
59 | _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) | 59 | _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) |
60 | 60 | ||
61 | ifneq ($(KBUILD_BUILDHOST),$(ARCH)) | ||
62 | cross_build := 1 | ||
63 | endif | ||
61 | 64 | ||
62 | # Step 2), invoke modpost | 65 | # Step 2), invoke modpost |
63 | # Includes step 3,4 | 66 | # Includes step 3,4 |
@@ -70,7 +73,8 @@ modpost = scripts/mod/modpost \ | |||
70 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ | 73 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ |
71 | $(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \ | 74 | $(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \ |
72 | $(if $(CONFIG_MARKERS),-M $(markersfile)) \ | 75 | $(if $(CONFIG_MARKERS),-M $(markersfile)) \ |
73 | $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) | 76 | $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ |
77 | $(if $(cross_build),-c) | ||
74 | 78 | ||
75 | quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules | 79 | quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules |
76 | cmd_modpost = $(modpost) -s | 80 | cmd_modpost = $(modpost) -s |
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 9ddf944cce29..348d8687b7c9 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c | |||
@@ -51,11 +51,13 @@ do { \ | |||
51 | sprintf(str + strlen(str), "*"); \ | 51 | sprintf(str + strlen(str), "*"); \ |
52 | } while(0) | 52 | } while(0) |
53 | 53 | ||
54 | unsigned int cross_build = 0; | ||
54 | /** | 55 | /** |
55 | * Check that sizeof(device_id type) are consistent with size of section | 56 | * Check that sizeof(device_id type) are consistent with size of section |
56 | * in .o file. If in-consistent then userspace and kernel does not agree | 57 | * in .o file. If in-consistent then userspace and kernel does not agree |
57 | * on actual size which is a bug. | 58 | * on actual size which is a bug. |
58 | * Also verify that the final entry in the table is all zeros. | 59 | * Also verify that the final entry in the table is all zeros. |
60 | * Ignore both checks if build host differ from target host and size differs. | ||
59 | **/ | 61 | **/ |
60 | static void device_id_check(const char *modname, const char *device_id, | 62 | static void device_id_check(const char *modname, const char *device_id, |
61 | unsigned long size, unsigned long id_size, | 63 | unsigned long size, unsigned long id_size, |
@@ -64,6 +66,8 @@ static void device_id_check(const char *modname, const char *device_id, | |||
64 | int i; | 66 | int i; |
65 | 67 | ||
66 | if (size % id_size || size < id_size) { | 68 | if (size % id_size || size < id_size) { |
69 | if (cross_build != 0) | ||
70 | return; | ||
67 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " | 71 | fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " |
68 | "of the size of section __mod_%s_device_table=%lu.\n" | 72 | "of the size of section __mod_%s_device_table=%lu.\n" |
69 | "Fix definition of struct %s_device_id " | 73 | "Fix definition of struct %s_device_id " |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 695b5d657cf5..110cf243fa4e 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -2026,7 +2026,7 @@ int main(int argc, char **argv) | |||
2026 | int opt; | 2026 | int opt; |
2027 | int err; | 2027 | int err; |
2028 | 2028 | ||
2029 | while ((opt = getopt(argc, argv, "i:I:msSo:awM:K:")) != -1) { | 2029 | while ((opt = getopt(argc, argv, "i:I:cmsSo:awM:K:")) != -1) { |
2030 | switch (opt) { | 2030 | switch (opt) { |
2031 | case 'i': | 2031 | case 'i': |
2032 | kernel_read = optarg; | 2032 | kernel_read = optarg; |
@@ -2035,6 +2035,9 @@ int main(int argc, char **argv) | |||
2035 | module_read = optarg; | 2035 | module_read = optarg; |
2036 | external_module = 1; | 2036 | external_module = 1; |
2037 | break; | 2037 | break; |
2038 | case 'c': | ||
2039 | cross_build = 1; | ||
2040 | break; | ||
2038 | case 'm': | 2041 | case 'm': |
2039 | modversions = 1; | 2042 | modversions = 1; |
2040 | break; | 2043 | break; |
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h index 565c5872407e..09f58e33d227 100644 --- a/scripts/mod/modpost.h +++ b/scripts/mod/modpost.h | |||
@@ -135,6 +135,7 @@ struct elf_info { | |||
135 | }; | 135 | }; |
136 | 136 | ||
137 | /* file2alias.c */ | 137 | /* file2alias.c */ |
138 | extern unsigned int cross_build; | ||
138 | void handle_moddevtable(struct module *mod, struct elf_info *info, | 139 | void handle_moddevtable(struct module *mod, struct elf_info *info, |
139 | Elf_Sym *sym, const char *symname); | 140 | Elf_Sym *sym, const char *symname); |
140 | void add_moddevtable(struct buffer *buf, struct module *mod); | 141 | void add_moddevtable(struct buffer *buf, struct module *mod); |