Lines Matching +full:mod +full:- +full:12 +full:b

4  * Copyright 2002-2004  Rusty Russell, IBM Corporation
5 * Copyright 2006-2008 Sam Ravnborg
6 * Based in part on module-init-tools/depmod.c,file2alias
42 /* Trim EXPORT_SYMBOLs that are unused by in-tree modules */
65 * here we use Elf_Addr instead of long for covering cross-compile
68 #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr))
93 return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0; in strends()
127 nbytes -= bytes_read; in read_text_file()
159 struct module *mod; in find_module() local
161 list_for_each_entry(mod, &modules, list) { in find_module()
162 if (strcmp(mod->name, modname) == 0) in find_module()
163 return mod; in find_module()
170 struct module *mod; in new_module() local
172 mod = xmalloc(sizeof(*mod) + namelen + 1); in new_module()
173 memset(mod, 0, sizeof(*mod)); in new_module()
175 INIT_LIST_HEAD(&mod->exported_symbols); in new_module()
176 INIT_LIST_HEAD(&mod->unresolved_symbols); in new_module()
177 INIT_LIST_HEAD(&mod->missing_namespaces); in new_module()
178 INIT_LIST_HEAD(&mod->imported_namespaces); in new_module()
180 memcpy(mod->name, name, namelen); in new_module()
181 mod->name[namelen] = '\0'; in new_module()
182 mod->is_vmlinux = (strcmp(mod->name, "vmlinux") == 0); in new_module()
185 * Set mod->is_gpl_compatible to true by default. If MODULE_LICENSE() in new_module()
189 mod->is_gpl_compatible = true; in new_module()
191 list_add_tail(&mod->list, &modules); in new_module()
193 return mod; in new_module()
234 strcpy(s->name, name); in alloc_symbol()
242 hash_add(symbol_hashtable, &sym->hnode, tdb_hash(sym->name)); in hash_add_symbol()
245 static void sym_add_unresolved(const char *name, struct module *mod, bool weak) in sym_add_unresolved() argument
250 sym->weak = weak; in sym_add_unresolved()
252 list_add_tail(&sym->list, &mod->unresolved_symbols); in sym_add_unresolved()
255 static struct symbol *sym_find_with_module(const char *name, struct module *mod) in sym_find_with_module() argument
264 if (strcmp(s->name, name) == 0 && (!mod || s->module == mod)) in sym_find_with_module()
292 if (!strcmp(list->namespace, namespace)) in contains_namespace()
305 strcpy(ns_entry->namespace, namespace); in add_namespace()
306 list_add_tail(&ns_entry->list, head); in add_namespace()
313 Elf_Shdr *sechdr = &info->sechdrs[secindex]; in sym_get_data_by_offset()
315 return (void *)info->hdr + sechdr->sh_offset + offset; in sym_get_data_by_offset()
321 sym->st_value); in sym_get_data()
326 return sym_get_data_by_offset(info, info->secindex_strings, in sech_name()
327 sechdr->sh_name); in sech_name()
333 * If sym->st_shndx is a special section index, there is no in sec_name()
335 * Return "" if the index is out of range of info->sechdrs[] array. in sec_name()
337 if (secindex >= info->num_sections) in sec_name()
340 return sech_name(info, &info->sechdrs[secindex]); in sec_name()
345 static struct symbol *sym_add_exported(const char *name, struct module *mod, in sym_add_exported() argument
350 if (s && (!external_module || s->module->is_vmlinux || s->module == mod)) { in sym_add_exported()
352 mod->name, name, s->module->name, in sym_add_exported()
353 s->module->is_vmlinux ? "" : ".ko"); in sym_add_exported()
357 s->module = mod; in sym_add_exported()
358 s->is_gpl_only = gpl_only; in sym_add_exported()
359 s->namespace = xstrdup(namespace); in sym_add_exported()
360 list_add_tail(&s->list, &mod->exported_symbols); in sym_add_exported()
368 sym->crc = crc; in sym_set_crc()
369 sym->crc_valid = true; in sym_set_crc()
408 hdr = grab_file(filename, &info->size); in parse_elf()
418 info->hdr = hdr; in parse_elf()
419 if (info->size < sizeof(*hdr)) { in parse_elf()
424 if ((hdr->e_ident[EI_MAG0] != ELFMAG0) || in parse_elf()
425 (hdr->e_ident[EI_MAG1] != ELFMAG1) || in parse_elf()
426 (hdr->e_ident[EI_MAG2] != ELFMAG2) || in parse_elf()
427 (hdr->e_ident[EI_MAG3] != ELFMAG3)) { in parse_elf()
428 /* Not an ELF file - silently ignore it */ in parse_elf()
432 switch (hdr->e_ident[EI_DATA]) { in parse_elf()
444 hdr->e_type = TO_NATIVE(hdr->e_type); in parse_elf()
445 hdr->e_machine = TO_NATIVE(hdr->e_machine); in parse_elf()
446 hdr->e_version = TO_NATIVE(hdr->e_version); in parse_elf()
447 hdr->e_entry = TO_NATIVE(hdr->e_entry); in parse_elf()
448 hdr->e_phoff = TO_NATIVE(hdr->e_phoff); in parse_elf()
449 hdr->e_shoff = TO_NATIVE(hdr->e_shoff); in parse_elf()
450 hdr->e_flags = TO_NATIVE(hdr->e_flags); in parse_elf()
451 hdr->e_ehsize = TO_NATIVE(hdr->e_ehsize); in parse_elf()
452 hdr->e_phentsize = TO_NATIVE(hdr->e_phentsize); in parse_elf()
453 hdr->e_phnum = TO_NATIVE(hdr->e_phnum); in parse_elf()
454 hdr->e_shentsize = TO_NATIVE(hdr->e_shentsize); in parse_elf()
455 hdr->e_shnum = TO_NATIVE(hdr->e_shnum); in parse_elf()
456 hdr->e_shstrndx = TO_NATIVE(hdr->e_shstrndx); in parse_elf()
457 sechdrs = (void *)hdr + hdr->e_shoff; in parse_elf()
458 info->sechdrs = sechdrs; in parse_elf()
461 if (hdr->e_type != ET_REL) in parse_elf()
465 if (hdr->e_shoff > info->size) in parse_elf()
467 (unsigned long)hdr->e_shoff, filename, info->size); in parse_elf()
469 if (hdr->e_shnum == SHN_UNDEF) { in parse_elf()
474 info->num_sections = TO_NATIVE(sechdrs[0].sh_size); in parse_elf()
477 info->num_sections = hdr->e_shnum; in parse_elf()
479 if (hdr->e_shstrndx == SHN_XINDEX) { in parse_elf()
480 info->secindex_strings = TO_NATIVE(sechdrs[0].sh_link); in parse_elf()
483 info->secindex_strings = hdr->e_shstrndx; in parse_elf()
487 for (i = 0; i < info->num_sections; i++) { in parse_elf()
500 secstrings = (void *)hdr + sechdrs[info->secindex_strings].sh_offset; in parse_elf()
501 for (i = 1; i < info->num_sections; i++) { in parse_elf()
505 if (!nobits && sechdrs[i].sh_offset > info->size) in parse_elf()
514 info->modinfo = (void *)hdr + sechdrs[i].sh_offset; in parse_elf()
515 info->modinfo_len = sechdrs[i].sh_size; in parse_elf()
517 info->export_symbol_secndx = i; in parse_elf()
523 info->symtab_start = (void *)hdr + in parse_elf()
525 info->symtab_stop = (void *)hdr + in parse_elf()
528 info->strtab = (void *)hdr + in parse_elf()
535 info->symtab_shndx_start = (void *)hdr + in parse_elf()
537 info->symtab_shndx_stop = (void *)hdr + in parse_elf()
541 if (!info->symtab_start) in parse_elf()
545 for (sym = info->symtab_start; sym < info->symtab_stop; sym++) { in parse_elf()
546 sym->st_shndx = TO_NATIVE(sym->st_shndx); in parse_elf()
547 sym->st_name = TO_NATIVE(sym->st_name); in parse_elf()
548 sym->st_value = TO_NATIVE(sym->st_value); in parse_elf()
549 sym->st_size = TO_NATIVE(sym->st_size); in parse_elf()
559 for (p = info->symtab_shndx_start; p < info->symtab_shndx_stop; in parse_elf()
572 release_file(info->hdr, info->size); in parse_elf_finish()
583 if (info->hdr->e_machine == EM_PPC) in ignore_undef_symbol()
592 if (info->hdr->e_machine == EM_PPC64) in ignore_undef_symbol()
604 static void handle_symbol(struct module *mod, struct elf_info *info, in handle_symbol() argument
607 switch (sym->st_shndx) { in handle_symbol()
612 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); in handle_symbol()
616 if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL && in handle_symbol()
617 ELF_ST_BIND(sym->st_info) != STB_WEAK) in handle_symbol()
621 if (info->hdr->e_machine == EM_SPARC || in handle_symbol()
622 info->hdr->e_machine == EM_SPARCV9) { in handle_symbol()
624 if (ELF_ST_TYPE(sym->st_info) == STT_SPARC_REGISTER) in handle_symbol()
634 sym_add_unresolved(symname, mod, in handle_symbol()
635 ELF_ST_BIND(sym->st_info) == STB_WEAK); in handle_symbol()
639 mod->has_init = true; in handle_symbol()
641 mod->has_cleanup = true; in handle_symbol()
651 /* Skip non-zero chars */ in next_string()
654 if ((*secsize)-- <= 1) in next_string()
661 if ((*secsize)-- <= 1) in next_string()
672 char *modinfo = info->modinfo; in get_next_modinfo()
673 unsigned long size = info->modinfo_len; in get_next_modinfo()
676 size -= prev - modinfo; in get_next_modinfo()
695 return sym ? elf->strtab + sym->st_name : ""; in sym_name()
729 ".GCC.command.line", /* record-gcc-switches */
744 ".llvm.call-graph-profile", /* call graph */
758 if (sechdr->sh_type == SHT_PROGBITS && in check_section()
759 !(sechdr->sh_flags & SHF_ALLOC) && in check_section()
761 warn("%s (%s): unexpected non-allocatable section.\n" in check_section()
807 * this array is forbidden (black-list). Can be empty.
810 * targeting sections in this array (white-list). Can be empty.
849 /* If you're adding any new black-listed sections in here, consider
865 * handling relocations to un-resolved symbols, trying to match it in section_mismatch()
875 if (match(fromsec, check->fromsec)) { in section_mismatch()
876 if (check->bad_tosec[0] && match(tosec, check->bad_tosec)) in section_mismatch()
878 if (check->good_tosec[0] && !match(tosec, check->good_tosec)) in section_mismatch()
910 * these from non-init sections as these symbols don't have any memory
919 * in functions like cpumask_empty() -- generating an associated symbol
993 if (secndx >= elf->num_sections) in is_executable_section()
996 return (elf->sechdrs[secndx].sh_flags & SHF_EXECINSTR) != 0; in is_executable_section()
1016 /* check whitelist - we may ignore it */ in default_mismatch_handler()
1029 warn("%s: section mismatch in reference: %s%s0x%x (section: %s) -> %s (section: %s)\n", in default_mismatch_handler()
1031 (unsigned int)(faddr - (fromsym[0] ? from->st_value : 0)), in default_mismatch_handler()
1034 if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) { in default_mismatch_handler()
1035 if (match(tosec, mismatch->bad_tosec)) in default_mismatch_handler()
1037 "section \"%s\" which is black-listed.\n" in default_mismatch_handler()
1049 "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n", in default_mismatch_handler()
1052 error("%s+0x%lx references non-executable section '%s'\n", in default_mismatch_handler()
1057 static void check_export_symbol(struct module *mod, struct elf_info *elf, in check_export_symbol() argument
1067 label = find_fromsym(elf, faddr, elf->export_symbol_secndx); in check_export_symbol()
1072 mod->name, label_name); in check_export_symbol()
1076 if (ELF_ST_BIND(sym->st_info) != STB_GLOBAL && in check_export_symbol()
1077 ELF_ST_BIND(sym->st_info) != STB_WEAK) { in check_export_symbol()
1078 error("%s: local symbol '%s' was exported\n", mod->name, in check_export_symbol()
1086 mod->name, name); in check_export_symbol()
1097 mod->name, data, name); in check_export_symbol()
1102 s = sym_add_exported(name, mod, is_gpl, data); in check_export_symbol()
1108 s->is_func = (ELF_ST_TYPE(sym->st_info) == STT_FUNC); in check_export_symbol()
1114 if (elf->hdr->e_ident[EI_CLASS] == ELFCLASS64 && in check_export_symbol()
1115 elf->hdr->e_machine == EM_PARISC && in check_export_symbol()
1116 ELF_ST_TYPE(sym->st_info) == STT_LOPROC) in check_export_symbol()
1117 s->is_func = true; in check_export_symbol()
1121 mod->name, name); in check_export_symbol()
1124 mod->name, name); in check_export_symbol()
1127 static void check_section_mismatch(struct module *mod, struct elf_info *elf, in check_section_mismatch() argument
1135 if (module_enabled && elf->export_symbol_secndx == fsecndx) { in check_section_mismatch()
1136 check_export_symbol(mod, elf, faddr, tosec, sym); in check_section_mismatch()
1144 default_mismatch_handler(mod->name, elf, mismatch, sym, in check_section_mismatch()
1158 return (Elf_Addr)(-1); in addend_386_rel()
1163 uint8_t shift = 31 - index; in sign_extend32()
1177 return inst + sym->st_value; in addend_arm_rel()
1183 return offset + sym->st_value; in addend_arm_rel()
1189 return offset + sym->st_value + 8; in addend_arm_rel()
1194 offset = sign_extend32(((upper & 0x000f) << 12) | in addend_arm_rel()
1199 return offset + sym->st_value; in addend_arm_rel()
1217 ((upper & 0x03f) << 12) | in addend_arm_rel()
1220 return offset + sym->st_value + 4; in addend_arm_rel()
1243 ((upper & 0x03ff) << 12) | in addend_arm_rel()
1246 return offset + sym->st_value + 4; in addend_arm_rel()
1249 return (Elf_Addr)(-1); in addend_arm_rel()
1265 return (Elf_Addr)(-1); in addend_mips_rel()
1303 bool is_64bit = (elf->hdr->e_ident[EI_CLASS] == ELFCLASS64); in get_rel_type_and_sym()
1305 if (elf->hdr->e_machine == EM_MIPS && is_64bit) { in get_rel_type_and_sym()
1308 *r_type = mips64_r_info->r_type; in get_rel_type_and_sym()
1309 *r_sym = TO_NATIVE(mips64_r_info->r_sym); in get_rel_type_and_sym()
1322 static void section_rela(struct module *mod, struct elf_info *elf, in section_rela() argument
1333 r_offset = TO_NATIVE(rela->r_offset); in section_rela()
1334 get_rel_type_and_sym(elf, rela->r_info, &r_type, &r_sym); in section_rela()
1336 tsym = elf->symtab_start + r_sym; in section_rela()
1337 taddr = tsym->st_value + TO_NATIVE(rela->r_addend); in section_rela()
1339 switch (elf->hdr->e_machine) { in section_rela()
1359 check_section_mismatch(mod, elf, tsym, in section_rela()
1364 static void section_rel(struct module *mod, struct elf_info *elf, in section_rel() argument
1376 r_offset = TO_NATIVE(rel->r_offset); in section_rel()
1377 get_rel_type_and_sym(elf, rel->r_info, &r_type, &r_sym); in section_rel()
1380 tsym = elf->symtab_start + r_sym; in section_rel()
1382 switch (elf->hdr->e_machine) { in section_rel()
1396 check_section_mismatch(mod, elf, tsym, in section_rel()
1403 * either when loaded or when used as built-in.
1406 * Likewise for modules used built-in the sections marked __exit
1408 * only when a module is unloaded which never happens for built-in modules.
1413 static void check_sec_ref(struct module *mod, struct elf_info *elf) in check_sec_ref() argument
1418 for (i = 0; i < elf->num_sections; i++) { in check_sec_ref()
1419 Elf_Shdr *sechdr = &elf->sechdrs[i]; in check_sec_ref()
1421 check_section(mod->name, elf, sechdr); in check_sec_ref()
1423 if (sechdr->sh_type == SHT_REL || sechdr->sh_type == SHT_RELA) { in check_sec_ref()
1425 unsigned int secndx = sechdr->sh_info; in check_sec_ref()
1434 stop = start + sechdr->sh_size; in check_sec_ref()
1436 if (sechdr->sh_type == SHT_RELA) in check_sec_ref()
1437 section_rela(mod, elf, secndx, secname, in check_sec_ref()
1440 section_rel(mod, elf, secndx, secname, in check_sec_ref()
1462 static void extract_crcs_for_object(const char *object, struct module *mod) in extract_crcs_for_object() argument
1472 dirlen = base - object; in extract_crcs_for_object()
1500 namelen = p - name; in extract_crcs_for_object()
1518 sym = sym_find_with_module(name, mod); in extract_crcs_for_object()
1530 static void mod_set_crcs(struct module *mod) in mod_set_crcs() argument
1536 if (mod->is_vmlinux) { in mod_set_crcs()
1539 /* objects for a module are listed in the *.mod file. */ in mod_set_crcs()
1540 ret = snprintf(objlist, sizeof(objlist), "%s.mod", mod->name); in mod_set_crcs()
1551 extract_crcs_for_object(obj, mod); in mod_set_crcs()
1562 struct module *mod; in read_symbols() local
1575 mod = new_module(modname, strlen(modname) - strlen(".o")); in read_symbols()
1577 if (!mod->is_vmlinux) { in read_symbols()
1583 mod->is_gpl_compatible = false; in read_symbols()
1591 add_namespace(&mod->imported_namespaces, namespace); in read_symbols()
1601 symname = remove_dot(info.strtab + sym->st_name); in read_symbols()
1603 handle_symbol(mod, &info, sym, symname); in read_symbols()
1604 handle_moddevtable(mod, &info, sym, symname); in read_symbols()
1607 check_sec_ref(mod, &info); in read_symbols()
1609 if (!mod->is_vmlinux) { in read_symbols()
1612 get_src_version(mod->name, mod->srcversion, in read_symbols()
1613 sizeof(mod->srcversion) - 1); in read_symbols()
1620 * Our trick to get versioning for module struct etc. - it's in read_symbols()
1625 sym_add_unresolved("module_layout", mod, false); in read_symbols()
1627 mod_set_crcs(mod); in read_symbols()
1642 fname[strlen(fname)-1] = '\0'; in read_symbols_from_files()
1670 if (buf->size - buf->pos < len) { in buf_write()
1671 buf->size += len + SZ; in buf_write()
1672 buf->p = xrealloc(buf->p, buf->size); in buf_write()
1674 strncpy(buf->p + buf->pos, s, len); in buf_write()
1675 buf->pos += len; in buf_write()
1678 static void check_exports(struct module *mod) in check_exports() argument
1682 list_for_each_entry(s, &mod->unresolved_symbols, list) { in check_exports()
1684 exp = find_symbol(s->name); in check_exports()
1686 if (!s->weak && nr_unresolved++ < MAX_UNRESOLVED_REPORTS) in check_exports()
1689 s->name, mod->name); in check_exports()
1692 if (exp->module == mod) { in check_exports()
1694 s->name, mod->name); in check_exports()
1698 exp->used = true; in check_exports()
1699 s->module = exp->module; in check_exports()
1700 s->crc_valid = exp->crc_valid; in check_exports()
1701 s->crc = exp->crc; in check_exports()
1703 basename = strrchr(mod->name, '/'); in check_exports()
1707 basename = mod->name; in check_exports()
1709 if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) { in check_exports()
1712 basename, exp->name, exp->namespace); in check_exports()
1713 add_namespace(&mod->missing_namespaces, exp->namespace); in check_exports()
1716 if (!mod->is_gpl_compatible && exp->is_gpl_only) in check_exports()
1717 error("GPL-incompatible module %s.ko uses GPL-only symbol '%s'\n", in check_exports()
1718 basename, exp->name); in check_exports()
1733 sym->used = true; in handle_white_list_exports()
1739 static void check_modname_len(struct module *mod) in check_modname_len() argument
1743 mod_name = strrchr(mod->name, '/'); in check_modname_len()
1745 mod_name = mod->name; in check_modname_len()
1749 error("module name is too long [%s.ko]\n", mod->name); in check_modname_len()
1755 static void add_header(struct buffer *b, struct module *mod) in add_header() argument
1757 buf_printf(b, "#include <linux/module.h>\n"); in add_header()
1758 buf_printf(b, "#include <linux/export-internal.h>\n"); in add_header()
1759 buf_printf(b, "#include <linux/compiler.h>\n"); in add_header()
1760 buf_printf(b, "\n"); in add_header()
1761 buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); in add_header()
1762 buf_printf(b, "\n"); in add_header()
1763 buf_printf(b, "__visible struct module __this_module\n"); in add_header()
1764 buf_printf(b, "__section(\".gnu.linkonce.this_module\") = {\n"); in add_header()
1765 buf_printf(b, "\t.name = KBUILD_MODNAME,\n"); in add_header()
1766 if (mod->has_init) in add_header()
1767 buf_printf(b, "\t.init = init_module,\n"); in add_header()
1768 if (mod->has_cleanup) in add_header()
1769 buf_printf(b, "#ifdef CONFIG_MODULE_UNLOAD\n" in add_header()
1772 buf_printf(b, "\t.arch = MODULE_ARCH_INIT,\n"); in add_header()
1773 buf_printf(b, "};\n"); in add_header()
1776 buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n"); in add_header()
1778 if (strstarts(mod->name, "drivers/staging")) in add_header()
1779 buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n"); in add_header()
1781 if (strstarts(mod->name, "tools/testing")) in add_header()
1782 buf_printf(b, "\nMODULE_INFO(test, \"Y\");\n"); in add_header()
1785 static void add_exported_symbols(struct buffer *buf, struct module *mod) in add_exported_symbols() argument
1791 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1792 if (trim_unused_exports && !sym->used) in add_exported_symbols()
1796 sym->is_func ? "FUNC" : "DATA", sym->name, in add_exported_symbols()
1797 sym->is_gpl_only ? "_gpl" : "", sym->namespace); in add_exported_symbols()
1805 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1806 if (trim_unused_exports && !sym->used) in add_exported_symbols()
1809 if (!sym->crc_valid) in add_exported_symbols()
1811 "Is \"%s\" prototyped in <asm/asm-prototypes.h>?\n", in add_exported_symbols()
1812 sym->name, mod->name, mod->is_vmlinux ? "" : ".ko", in add_exported_symbols()
1813 sym->name); in add_exported_symbols()
1816 sym->name, sym->crc, sym->is_gpl_only ? "_gpl" : ""); in add_exported_symbols()
1823 static void add_versions(struct buffer *b, struct module *mod) in add_versions() argument
1830 buf_printf(b, "\n"); in add_versions()
1831 buf_printf(b, "static const struct modversion_info ____versions[]\n"); in add_versions()
1832 buf_printf(b, "__used __section(\"__versions\") = {\n"); in add_versions()
1834 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_versions()
1835 if (!s->module) in add_versions()
1837 if (!s->crc_valid) { in add_versions()
1839 s->name, mod->name); in add_versions()
1842 if (strlen(s->name) >= MODULE_NAME_LEN) { in add_versions()
1844 s->name, mod->name); in add_versions()
1847 buf_printf(b, "\t{ %#8x, \"%s\" },\n", in add_versions()
1848 s->crc, s->name); in add_versions()
1851 buf_printf(b, "};\n"); in add_versions()
1854 static void add_depends(struct buffer *b, struct module *mod) in add_depends() argument
1859 /* Clear ->seen flag of modules that own symbols needed by this. */ in add_depends()
1860 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
1861 if (s->module) in add_depends()
1862 s->module->seen = s->module->is_vmlinux; in add_depends()
1865 buf_printf(b, "\n"); in add_depends()
1866 buf_printf(b, "MODULE_INFO(depends, \""); in add_depends()
1867 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
1869 if (!s->module) in add_depends()
1872 if (s->module->seen) in add_depends()
1875 s->module->seen = true; in add_depends()
1876 p = strrchr(s->module->name, '/'); in add_depends()
1880 p = s->module->name; in add_depends()
1881 buf_printf(b, "%s%s", first ? "" : ",", p); in add_depends()
1884 buf_printf(b, "\");\n"); in add_depends()
1887 static void add_srcversion(struct buffer *b, struct module *mod) in add_srcversion() argument
1889 if (mod->srcversion[0]) { in add_srcversion()
1890 buf_printf(b, "\n"); in add_srcversion()
1891 buf_printf(b, "MODULE_INFO(srcversion, \"%s\");\n", in add_srcversion()
1892 mod->srcversion); in add_srcversion()
1896 static void write_buf(struct buffer *b, const char *fname) in write_buf() argument
1908 if (fwrite(b->p, 1, b->pos, file) != b->pos) { in write_buf()
1918 static void write_if_changed(struct buffer *b, const char *fname) in write_if_changed() argument
1931 if (st.st_size != b->pos) in write_if_changed()
1934 tmp = xmalloc(b->pos); in write_if_changed()
1935 if (fread(tmp, 1, b->pos, file) != b->pos) in write_if_changed()
1938 if (memcmp(tmp, b->p, b->pos) != 0) in write_if_changed()
1950 write_buf(b, fname); in write_if_changed()
1953 static void write_vmlinux_export_c_file(struct module *mod) in write_vmlinux_export_c_file() argument
1958 "#include <linux/export-internal.h>\n"); in write_vmlinux_export_c_file()
1960 add_exported_symbols(&buf, mod); in write_vmlinux_export_c_file()
1965 /* do sanity checks, and generate *.mod.c file */
1966 static void write_mod_c_file(struct module *mod) in write_mod_c_file() argument
1972 add_header(&buf, mod); in write_mod_c_file()
1973 add_exported_symbols(&buf, mod); in write_mod_c_file()
1974 add_versions(&buf, mod); in write_mod_c_file()
1975 add_depends(&buf, mod); in write_mod_c_file()
1976 add_moddevtable(&buf, mod); in write_mod_c_file()
1977 add_srcversion(&buf, mod); in write_mod_c_file()
1979 ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name); in write_mod_c_file()
2008 struct module *mod; in read_dump() local
2038 mod = find_module(modname); in read_dump()
2039 if (!mod) { in read_dump()
2040 mod = new_module(modname, strlen(modname)); in read_dump()
2041 mod->from_dump = true; in read_dump()
2043 s = sym_add_exported(symname, mod, gpl_only, namespace); in read_dump()
2056 struct module *mod; in write_dump() local
2059 list_for_each_entry(mod, &modules, list) { in write_dump()
2060 if (mod->from_dump) in write_dump()
2062 list_for_each_entry(sym, &mod->exported_symbols, list) { in write_dump()
2063 if (trim_unused_exports && !sym->used) in write_dump()
2067 sym->crc, sym->name, mod->name, in write_dump()
2068 sym->is_gpl_only ? "_GPL" : "", in write_dump()
2069 sym->namespace); in write_dump()
2078 struct module *mod; in write_namespace_deps_files() local
2082 list_for_each_entry(mod, &modules, list) { in write_namespace_deps_files()
2084 if (mod->from_dump || list_empty(&mod->missing_namespaces)) in write_namespace_deps_files()
2087 buf_printf(&ns_deps_buf, "%s.ko:", mod->name); in write_namespace_deps_files()
2089 list_for_each_entry(ns, &mod->missing_namespaces, list) in write_namespace_deps_files()
2090 buf_printf(&ns_deps_buf, " %s", ns->namespace); in write_namespace_deps_files()
2125 struct module *mod; in main() local
2133 while ((opt = getopt(argc, argv, "ei:MmnT:to:au:WwENd:")) != -1) { in main()
2140 dl->file = optarg; in main()
2141 list_add_tail(&dl->list, &dump_lists); in main()
2190 read_dump(dl->file); in main()
2191 list_del(&dl->list); in main()
2201 list_for_each_entry(mod, &modules, list) { in main()
2202 if (mod->from_dump || mod->is_vmlinux) in main()
2205 check_modname_len(mod); in main()
2206 check_exports(mod); in main()
2212 list_for_each_entry(mod, &modules, list) { in main()
2213 if (mod->from_dump) in main()
2216 if (mod->is_vmlinux) in main()
2217 write_vmlinux_export_c_file(mod); in main()
2219 write_mod_c_file(mod); in main()
2233 nr_unresolved - MAX_UNRESOLVED_REPORTS); in main()