diff options
| author | Andreas Schwab <schwab@linux-m68k.org> | 2013-01-20 11:58:47 -0500 |
|---|---|---|
| committer | Michal Marek <mmarek@suse.cz> | 2013-01-24 16:48:04 -0500 |
| commit | 6543becf26fff612cdadeed7250ccc8d49f67f27 (patch) | |
| tree | bcba277bb0c03a81aae46965f3ddc76e582b51f1 /scripts | |
| parent | a49f0d1ea3ec94fc7cf33a7c36a16343b74bd565 (diff) | |
mod/file2alias: make modalias generation safe for cross compiling
Use the target compiler to compute the offsets for the fields of the
device_id structures, so that it won't be broken by different alignments
between the host and target ABIs.
This also fixes missing endian corrections for some modaliases.
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/Makefile.modpost | 7 | ||||
| -rw-r--r-- | scripts/mod/.gitignore | 1 | ||||
| -rw-r--r-- | scripts/mod/Makefile | 35 | ||||
| -rw-r--r-- | scripts/mod/devicetable-offsets.c | 178 | ||||
| -rw-r--r-- | scripts/mod/file2alias.c | 674 | ||||
| -rw-r--r-- | scripts/mod/modpost.c | 5 |
6 files changed, 582 insertions, 318 deletions
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost index a1cb0222ebe6..cf82c832458f 100644 --- a/scripts/Makefile.modpost +++ b/scripts/Makefile.modpost | |||
| @@ -66,10 +66,6 @@ modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) | |||
| 66 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker | 66 | # Stop after building .o files if NOFINAL is set. Makes compile tests quicker |
| 67 | _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) | 67 | _modpost: $(if $(KBUILD_MODPOST_NOFINAL), $(modules:.ko:.o),$(modules)) |
| 68 | 68 | ||
| 69 | ifneq ($(KBUILD_BUILDHOST),$(ARCH)) | ||
| 70 | cross_build := 1 | ||
| 71 | endif | ||
| 72 | |||
| 73 | # Step 2), invoke modpost | 69 | # Step 2), invoke modpost |
| 74 | # Includes step 3,4 | 70 | # Includes step 3,4 |
| 75 | modpost = scripts/mod/modpost \ | 71 | modpost = scripts/mod/modpost \ |
| @@ -80,8 +76,7 @@ modpost = scripts/mod/modpost \ | |||
| 80 | $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ | 76 | $(if $(KBUILD_EXTRA_SYMBOLS), $(patsubst %, -e %,$(KBUILD_EXTRA_SYMBOLS))) \ |
| 81 | $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ | 77 | $(if $(KBUILD_EXTMOD),-o $(modulesymfile)) \ |
| 82 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ | 78 | $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ |
| 83 | $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) \ | 79 | $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) |
| 84 | $(if $(cross_build),-c) | ||
| 85 | 80 | ||
| 86 | quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules | 81 | quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules |
| 87 | cmd_modpost = $(modpost) -s | 82 | cmd_modpost = $(modpost) -s |
diff --git a/scripts/mod/.gitignore b/scripts/mod/.gitignore index e9b7abe7b95b..33bae0df4de5 100644 --- a/scripts/mod/.gitignore +++ b/scripts/mod/.gitignore | |||
| @@ -1,4 +1,5 @@ | |||
| 1 | elfconfig.h | 1 | elfconfig.h |
| 2 | mk_elfconfig | 2 | mk_elfconfig |
| 3 | modpost | 3 | modpost |
| 4 | devicetable-offsets.h | ||
| 4 | 5 | ||
diff --git a/scripts/mod/Makefile b/scripts/mod/Makefile index ff954f8168c1..9415b5663364 100644 --- a/scripts/mod/Makefile +++ b/scripts/mod/Makefile | |||
| @@ -3,9 +3,44 @@ always := $(hostprogs-y) empty.o | |||
| 3 | 3 | ||
| 4 | modpost-objs := modpost.o file2alias.o sumversion.o | 4 | modpost-objs := modpost.o file2alias.o sumversion.o |
| 5 | 5 | ||
| 6 | devicetable-offsets-file := devicetable-offsets.h | ||
| 7 | |||
| 8 | define sed-y | ||
| 9 | "/^->/{s:->#\(.*\):/* \1 */:; \ | ||
| 10 | s:^->\([^ ]*\) [\$$#]*\([-0-9]*\) \(.*\):#define \1 \2 /* \3 */:; \ | ||
| 11 | s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; \ | ||
| 12 | s:->::; p;}" | ||
| 13 | endef | ||
| 14 | |||
| 15 | quiet_cmd_offsets = GEN $@ | ||
| 16 | define cmd_offsets | ||
| 17 | (set -e; \ | ||
| 18 | echo "#ifndef __DEVICEVTABLE_OFFSETS_H__"; \ | ||
| 19 | echo "#define __DEVICEVTABLE_OFFSETS_H__"; \ | ||
| 20 | echo "/*"; \ | ||
| 21 | echo " * DO NOT MODIFY."; \ | ||
| 22 | echo " *"; \ | ||
| 23 | echo " * This file was generated by Kbuild"; \ | ||
| 24 | echo " *"; \ | ||
| 25 | echo " */"; \ | ||
| 26 | echo ""; \ | ||
| 27 | sed -ne $(sed-y) $<; \ | ||
| 28 | echo ""; \ | ||
| 29 | echo "#endif" ) > $@ | ||
| 30 | endef | ||
| 31 | |||
| 32 | # We use internal kbuild rules to avoid the "is up to date" message from make | ||
| 33 | scripts/mod/devicetable-offsets.s: scripts/mod/devicetable-offsets.c FORCE | ||
| 34 | $(Q)mkdir -p $(dir $@) | ||
| 35 | $(call if_changed_dep,cc_s_c) | ||
| 36 | |||
| 37 | $(obj)/$(devicetable-offsets-file): scripts/mod/devicetable-offsets.s | ||
| 38 | $(call cmd,offsets) | ||
| 39 | |||
| 6 | # dependencies on generated files need to be listed explicitly | 40 | # dependencies on generated files need to be listed explicitly |
| 7 | 41 | ||
| 8 | $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h | 42 | $(obj)/modpost.o $(obj)/file2alias.o $(obj)/sumversion.o: $(obj)/elfconfig.h |
| 43 | $(obj)/file2alias.o: $(obj)/$(devicetable-offsets-file) | ||
| 9 | 44 | ||
| 10 | quiet_cmd_elfconfig = MKELF $@ | 45 | quiet_cmd_elfconfig = MKELF $@ |
| 11 | cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@ | 46 | cmd_elfconfig = $(obj)/mk_elfconfig < $< > $@ |
diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c new file mode 100644 index 000000000000..b45260bfeaa0 --- /dev/null +++ b/scripts/mod/devicetable-offsets.c | |||
| @@ -0,0 +1,178 @@ | |||
| 1 | #include <linux/kbuild.h> | ||
| 2 | #include <linux/mod_devicetable.h> | ||
| 3 | |||
| 4 | #define DEVID(devid) DEFINE(SIZE_##devid, sizeof(struct devid)) | ||
| 5 | #define DEVID_FIELD(devid, field) \ | ||
| 6 | DEFINE(OFF_##devid##_##field, offsetof(struct devid, field)) | ||
| 7 | |||
| 8 | int main(void) | ||
| 9 | { | ||
| 10 | DEVID(usb_device_id); | ||
| 11 | DEVID_FIELD(usb_device_id, match_flags); | ||
| 12 | DEVID_FIELD(usb_device_id, idVendor); | ||
| 13 | DEVID_FIELD(usb_device_id, idProduct); | ||
| 14 | DEVID_FIELD(usb_device_id, bcdDevice_lo); | ||
| 15 | DEVID_FIELD(usb_device_id, bcdDevice_hi); | ||
| 16 | DEVID_FIELD(usb_device_id, bDeviceClass); | ||
| 17 | DEVID_FIELD(usb_device_id, bDeviceSubClass); | ||
| 18 | DEVID_FIELD(usb_device_id, bDeviceProtocol); | ||
| 19 | DEVID_FIELD(usb_device_id, bInterfaceClass); | ||
| 20 | DEVID_FIELD(usb_device_id, bInterfaceSubClass); | ||
| 21 | DEVID_FIELD(usb_device_id, bInterfaceProtocol); | ||
| 22 | DEVID_FIELD(usb_device_id, bInterfaceNumber); | ||
| 23 | |||
| 24 | DEVID(hid_device_id); | ||
| 25 | DEVID_FIELD(hid_device_id, bus); | ||
| 26 | DEVID_FIELD(hid_device_id, group); | ||
| 27 | DEVID_FIELD(hid_device_id, vendor); | ||
| 28 | DEVID_FIELD(hid_device_id, product); | ||
| 29 | |||
| 30 | DEVID(ieee1394_device_id); | ||
| 31 | DEVID_FIELD(ieee1394_device_id, match_flags); | ||
| 32 | DEVID_FIELD(ieee1394_device_id, vendor_id); | ||
| 33 | DEVID_FIELD(ieee1394_device_id, model_id); | ||
| 34 | DEVID_FIELD(ieee1394_device_id, specifier_id); | ||
| 35 | DEVID_FIELD(ieee1394_device_id, version); | ||
| 36 | |||
| 37 | DEVID(pci_device_id); | ||
| 38 | DEVID_FIELD(pci_device_id, vendor); | ||
| 39 | DEVID_FIELD(pci_device_id, device); | ||
| 40 | DEVID_FIELD(pci_device_id, subvendor); | ||
| 41 | DEVID_FIELD(pci_device_id, subdevice); | ||
| 42 | DEVID_FIELD(pci_device_id, class); | ||
| 43 | DEVID_FIELD(pci_device_id, class_mask); | ||
| 44 | |||
| 45 | DEVID(ccw_device_id); | ||
| 46 | DEVID_FIELD(ccw_device_id, match_flags); | ||
| 47 | DEVID_FIELD(ccw_device_id, cu_type); | ||
| 48 | DEVID_FIELD(ccw_device_id, cu_model); | ||
| 49 | DEVID_FIELD(ccw_device_id, dev_type); | ||
| 50 | DEVID_FIELD(ccw_device_id, dev_model); | ||
| 51 | |||
| 52 | DEVID(ap_device_id); | ||
| 53 | DEVID_FIELD(ap_device_id, dev_type); | ||
| 54 | |||
| 55 | DEVID(css_device_id); | ||
| 56 | DEVID_FIELD(css_device_id, type); | ||
| 57 | |||
| 58 | DEVID(serio_device_id); | ||
| 59 | DEVID_FIELD(serio_device_id, type); | ||
| 60 | DEVID_FIELD(serio_device_id, proto); | ||
| 61 | DEVID_FIELD(serio_device_id, id); | ||
| 62 | DEVID_FIELD(serio_device_id, extra); | ||
| 63 | |||
| 64 | DEVID(acpi_device_id); | ||
| 65 | DEVID_FIELD(acpi_device_id, id); | ||
| 66 | |||
| 67 | DEVID(pnp_device_id); | ||
| 68 | DEVID_FIELD(pnp_device_id, id); | ||
| 69 | |||
| 70 | DEVID(pnp_card_device_id); | ||
| 71 | DEVID_FIELD(pnp_card_device_id, devs); | ||
| 72 | |||
| 73 | DEVID(pcmcia_device_id); | ||
| 74 | DEVID_FIELD(pcmcia_device_id, match_flags); | ||
| 75 | DEVID_FIELD(pcmcia_device_id, manf_id); | ||
| 76 | DEVID_FIELD(pcmcia_device_id, card_id); | ||
| 77 | DEVID_FIELD(pcmcia_device_id, func_id); | ||
| 78 | DEVID_FIELD(pcmcia_device_id, function); | ||
| 79 | DEVID_FIELD(pcmcia_device_id, device_no); | ||
| 80 | DEVID_FIELD(pcmcia_device_id, prod_id_hash); | ||
| 81 | |||
| 82 | DEVID(of_device_id); | ||
| 83 | DEVID_FIELD(of_device_id, name); | ||
| 84 | DEVID_FIELD(of_device_id, type); | ||
| 85 | DEVID_FIELD(of_device_id, compatible); | ||
| 86 | |||
| 87 | DEVID(vio_device_id); | ||
| 88 | DEVID_FIELD(vio_device_id, type); | ||
| 89 | DEVID_FIELD(vio_device_id, compat); | ||
| 90 | |||
| 91 | DEVID(input_device_id); | ||
| 92 | DEVID_FIELD(input_device_id, flags); | ||
| 93 | DEVID_FIELD(input_device_id, bustype); | ||
| 94 | DEVID_FIELD(input_device_id, vendor); | ||
| 95 | |||
