Commit 4ce6efed authored by Sam Ravnborg's avatar Sam Ravnborg

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: default avatarMichael Buesch <mb@bu3sch.de>
Tested-by: default avatarGordon Farquharson <gordonfarquharson@gmail.com>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
Cc: stable@kernel.org
parent d2532dd2
...@@ -189,7 +189,7 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \ ...@@ -189,7 +189,7 @@ SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
# Alternatively CROSS_COMPILE can be set in the environment. # Alternatively CROSS_COMPILE can be set in the environment.
# Default value for CROSS_COMPILE is not to prefix executables # Default value for CROSS_COMPILE is not to prefix executables
# Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile # Note: Some architectures assign CROSS_COMPILE in their arch/*/Makefile
export KBUILD_BUILDHOST := $(SUBARCH)
ARCH ?= $(SUBARCH) ARCH ?= $(SUBARCH)
CROSS_COMPILE ?= CROSS_COMPILE ?=
......
...@@ -58,6 +58,9 @@ modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) ...@@ -58,6 +58,9 @@ modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
# Stop after building .o files if NOFINAL is set. Makes compile tests quicker # Stop after building .o files if NOFINAL is set. Makes compile tests quicker
_modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules))
ifneq ($(KBUILD_BUILDHOST),$(ARCH))
cross_build := 1
endif
# Step 2), invoke modpost # Step 2), invoke modpost
# Includes step 3,4 # Includes step 3,4
...@@ -70,7 +73,8 @@ modpost = scripts/mod/modpost \ ...@@ -70,7 +73,8 @@ modpost = scripts/mod/modpost \
$(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
$(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \ $(if $(CONFIG_MARKERS),-K $(kernelmarkersfile)) \
$(if $(CONFIG_MARKERS),-M $(markersfile)) \ $(if $(CONFIG_MARKERS),-M $(markersfile)) \
$(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \
$(if $(cross_build),-c)
quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
cmd_modpost = $(modpost) -s cmd_modpost = $(modpost) -s
......
...@@ -51,11 +51,13 @@ do { \ ...@@ -51,11 +51,13 @@ do { \
sprintf(str + strlen(str), "*"); \ sprintf(str + strlen(str), "*"); \
} while(0) } while(0)
unsigned int cross_build = 0;
/** /**
* Check that sizeof(device_id type) are consistent with size of section * Check that sizeof(device_id type) are consistent with size of section
* in .o file. If in-consistent then userspace and kernel does not agree * in .o file. If in-consistent then userspace and kernel does not agree
* on actual size which is a bug. * on actual size which is a bug.
* Also verify that the final entry in the table is all zeros. * Also verify that the final entry in the table is all zeros.
* Ignore both checks if build host differ from target host and size differs.
**/ **/
static void device_id_check(const char *modname, const char *device_id, static void device_id_check(const char *modname, const char *device_id,
unsigned long size, unsigned long id_size, unsigned long size, unsigned long id_size,
...@@ -64,6 +66,8 @@ static void device_id_check(const char *modname, const char *device_id, ...@@ -64,6 +66,8 @@ static void device_id_check(const char *modname, const char *device_id,
int i; int i;
if (size % id_size || size < id_size) { if (size % id_size || size < id_size) {
if (cross_build != 0)
return;
fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
"of the size of section __mod_%s_device_table=%lu.\n" "of the size of section __mod_%s_device_table=%lu.\n"
"Fix definition of struct %s_device_id " "Fix definition of struct %s_device_id "
......
...@@ -2026,7 +2026,7 @@ int main(int argc, char **argv) ...@@ -2026,7 +2026,7 @@ int main(int argc, char **argv)
int opt; int opt;
int err; int err;
while ((opt = getopt(argc, argv, "i:I:msSo:awM:K:")) != -1) { while ((opt = getopt(argc, argv, "i:I:cmsSo:awM:K:")) != -1) {
switch (opt) { switch (opt) {
case 'i': case 'i':
kernel_read = optarg; kernel_read = optarg;
...@@ -2035,6 +2035,9 @@ int main(int argc, char **argv) ...@@ -2035,6 +2035,9 @@ int main(int argc, char **argv)
module_read = optarg; module_read = optarg;
external_module = 1; external_module = 1;
break; break;
case 'c':
cross_build = 1;
break;
case 'm': case 'm':
modversions = 1; modversions = 1;
break; break;
......
...@@ -135,6 +135,7 @@ struct elf_info { ...@@ -135,6 +135,7 @@ struct elf_info {
}; };
/* file2alias.c */ /* file2alias.c */
extern unsigned int cross_build;
void handle_moddevtable(struct module *mod, struct elf_info *info, void handle_moddevtable(struct module *mod, struct elf_info *info,
Elf_Sym *sym, const char *symname); Elf_Sym *sym, const char *symname);
void add_moddevtable(struct buffer *buf, struct module *mod); void add_moddevtable(struct buffer *buf, struct module *mod);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment