aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/file2alias.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 14:23:06 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-16 14:23:06 -0400
commit821f3eff7cdb9d6c7076effabd46c96c322daed1 (patch)
tree60f13155196fd6c84424c8aebc133ca4a5f56749 /scripts/mod/file2alias.c
parentebc283118ee448dcb6e6cae74a8a43f17a1ccc3f (diff)
parentf77bf01425b11947eeb3b5b54685212c302741b8 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild
* git://git.kernel.org/pub/scm/linux/kernel/git/sam/kbuild: (40 commits) kbuild: introduce ccflags-y, asflags-y and ldflags-y kbuild: enable 'make CPPFLAGS=...' to add additional options to CPP kbuild: enable use of AFLAGS and CFLAGS on commandline kbuild: enable 'make AFLAGS=...' to add additional options to AS kbuild: fix AFLAGS use in h8300 and m68knommu kbuild: check for wrong use of CFLAGS kbuild: enable 'make CFLAGS=...' to add additional options to CC kbuild: fix up CFLAGS usage kbuild: make modpost detect unterminated device id lists kbuild: call export_report from the Makefile kbuild: move Kai Germaschewski to CREDITS kconfig/menuconfig: distinguish between selected-by-another options and comments kconfig: tristate choices with mixed tristate and boolean values include/linux/Kbuild: remove duplicate entries kbuild: kill backward compatibility checks kbuild: kill EXTRA_ARFLAGS kbuild: fix documentation in makefiles.txt kbuild: call make once for all targets when O=.. is used kbuild: pass -g to assembler under CONFIG_DEBUG_INFO kbuild: update _shipped files for kconfig syntax cleanup ... Fix up conflicts in arch/um/sys-{x86_64,i386}/Makefile manually.
Diffstat (limited to 'scripts/mod/file2alias.c')
-rw-r--r--scripts/mod/file2alias.c40
1 files changed, 33 insertions, 7 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index 494435ca88fa..91c15da2680b 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -55,10 +55,14 @@ do { \
55 * Check that sizeof(device_id type) are consistent with size of section 55 * 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 56 * in .o file. If in-consistent then userspace and kernel does not agree
57 * on actual size which is a bug. 57 * on actual size which is a bug.
58 * Also verify that the final entry in the table is all zeros.
58 **/ 59 **/
59static void device_id_size_check(const char *modname, const char *device_id, 60static void device_id_check(const char *modname, const char *device_id,
60 unsigned long size, unsigned long id_size) 61 unsigned long size, unsigned long id_size,
62 void *symval)
61{ 63{
64 int i;
65
62 if (size % id_size || size < id_size) { 66 if (size % id_size || size < id_size) {
63 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo " 67 fatal("%s: sizeof(struct %s_device_id)=%lu is not a modulo "
64 "of the size of section __mod_%s_device_table=%lu.\n" 68 "of the size of section __mod_%s_device_table=%lu.\n"
@@ -66,6 +70,20 @@ static void device_id_size_check(const char *modname, const char *device_id,
66 "in mod_devicetable.h\n", 70 "in mod_devicetable.h\n",
67 modname, device_id, id_size, device_id, size, device_id); 71 modname, device_id, id_size, device_id, size, device_id);
68 } 72 }
73 /* Verify last one is a terminator */
74 for (i = 0; i < id_size; i++ ) {
75 if (*(uint8_t*)(symval+size-id_size+i)) {
76 fprintf(stderr,"%s: struct %s_device_id is %lu bytes. "
77 "The last of %lu is:\n",
78 modname, device_id, id_size, size / id_size);
79 for (i = 0; i < id_size; i++ )
80 fprintf(stderr,"0x%02x ",
81 *(uint8_t*)(symval+size-id_size+i) );
82 fprintf(stderr,"\n");
83 fatal("%s: struct %s_device_id is not terminated "
84 "with a NULL entry!\n", modname, device_id);
85 }
86 }
69} 87}
70 88
71/* USB is special because the bcdDevice can be matched against a numeric range */ 89/* USB is special because the bcdDevice can be matched against a numeric range */
@@ -168,7 +186,7 @@ static void do_usb_table(void *symval, unsigned long size,
168 unsigned int i; 186 unsigned int i;
169 const unsigned long id_size = sizeof(struct usb_device_id); 187 const unsigned long id_size = sizeof(struct usb_device_id);
170 188
171 device_id_size_check(mod->name, "usb", size, id_size); 189 device_id_check(mod->name, "usb", size, id_size, symval);
172 190
173 /* Leave last one: it's the terminator. */ 191 /* Leave last one: it's the terminator. */
174 size -= id_size; 192 size -= id_size;
@@ -528,7 +546,7 @@ static void do_table(void *symval, unsigned long size,
528 char alias[500]; 546 char alias[500];
529 int (*do_entry)(const char *, void *entry, char *alias) = function; 547 int (*do_entry)(const char *, void *entry, char *alias) = function;
530 548
531 device_id_size_check(mod->name, device_id, size, id_size); 549 device_id_check(mod->name, device_id, size, id_size, symval);
532 /* Leave last one: it's the terminator. */ 550 /* Leave last one: it's the terminator. */
533 size -= id_size; 551 size -= id_size;
534 552
@@ -550,14 +568,21 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
550 Elf_Sym *sym, const char *symname) 568 Elf_Sym *sym, const char *symname)
551{ 569{
552 void *symval; 570 void *symval;
571 char *zeros = NULL;
553 572
554 /* We're looking for a section relative symbol */ 573 /* We're looking for a section relative symbol */
555 if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum) 574 if (!sym->st_shndx || sym->st_shndx >= info->hdr->e_shnum)
556 return; 575 return;
557 576
558 symval = (void *)info->hdr 577 /* Handle all-NULL symbols allocated into .bss */
559 + info->sechdrs[sym->st_shndx].sh_offset 578 if (info->sechdrs[sym->st_shndx].sh_type & SHT_NOBITS) {
560 + sym->st_value; 579 zeros = calloc(1, sym->st_size);
580 symval = zeros;
581 } else {
582 symval = (void *)info->hdr
583 + info->sechdrs[sym->st_shndx].sh_offset
584 + sym->st_value;
585 }
561 586
562 if (sym_is(symname, "__mod_pci_device_table")) 587 if (sym_is(symname, "__mod_pci_device_table"))
563 do_table(symval, sym->st_size, 588 do_table(symval, sym->st_size,
@@ -626,6 +651,7 @@ void handle_moddevtable(struct module *mod, struct elf_info *info,
626 do_table(symval, sym->st_size, 651 do_table(symval, sym->st_size,
627 sizeof(struct ssb_device_id), "ssb", 652 sizeof(struct ssb_device_id), "ssb",
628 do_ssb_entry, mod); 653 do_ssb_entry, mod);
654 free(zeros);
629} 655}
630 656
631/* Now add out buffered information to the generated C source */ 657/* Now add out buffered information to the generated C source */