aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod
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
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')
-rw-r--r--scripts/mod/file2alias.c40
-rw-r--r--scripts/mod/modpost.c6
-rw-r--r--scripts/mod/modpost.h4
3 files changed, 41 insertions, 9 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 */
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0a4051fbd34e..2ef9a193fcae 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -381,6 +381,12 @@ static int parse_elf(struct elf_info *info, const char *filename)
381 sechdrs = (void *)hdr + hdr->e_shoff; 381 sechdrs = (void *)hdr + hdr->e_shoff;
382 info->sechdrs = sechdrs; 382 info->sechdrs = sechdrs;
383 383
384 /* Check if file offset is correct */
385 if (hdr->e_shoff > info->size) {
386 fatal("section header offset=%u in file '%s' is bigger then filesize=%lu\n", hdr->e_shoff, filename, info->size);
387 return 0;
388 }
389
384 /* Fix endianness in section headers */ 390 /* Fix endianness in section headers */
385 for (i = 0; i < hdr->e_shnum; i++) { 391 for (i = 0; i < hdr->e_shnum; i++) {
386 sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type); 392 sechdrs[i].sh_type = TO_NATIVE(sechdrs[i].sh_type);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 4156dd34c5de..0ffed17ec20c 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -17,7 +17,7 @@
17#define Elf_Shdr Elf32_Shdr 17#define Elf_Shdr Elf32_Shdr
18#define Elf_Sym Elf32_Sym 18#define Elf_Sym Elf32_Sym
19#define Elf_Addr Elf32_Addr 19#define Elf_Addr Elf32_Addr
20#define Elf_Section Elf32_Section 20#define Elf_Section Elf32_Half
21#define ELF_ST_BIND ELF32_ST_BIND 21#define ELF_ST_BIND ELF32_ST_BIND
22#define ELF_ST_TYPE ELF32_ST_TYPE 22#define ELF_ST_TYPE ELF32_ST_TYPE
23 23
@@ -31,7 +31,7 @@
31#define Elf_Shdr Elf64_Shdr 31#define Elf_Shdr Elf64_Shdr
32#define Elf_Sym Elf64_Sym 32#define Elf_Sym Elf64_Sym
33#define Elf_Addr Elf64_Addr 33#define Elf_Addr Elf64_Addr
34#define Elf_Section Elf64_Section 34#define Elf_Section Elf64_Half
35#define ELF_ST_BIND ELF64_ST_BIND 35#define ELF_ST_BIND ELF64_ST_BIND
36#define ELF_ST_TYPE ELF64_ST_TYPE 36#define ELF_ST_TYPE ELF64_ST_TYPE
37 37