Lines Matching refs:mod
174 struct module *mod; in find_module() local
176 list_for_each_entry(mod, &modules, list) { in find_module()
177 if (strcmp(mod->name, modname) == 0) in find_module()
178 return mod; in find_module()
185 struct module *mod; in new_module() local
187 mod = xmalloc(sizeof(*mod) + namelen + 1); in new_module()
188 memset(mod, 0, sizeof(*mod)); in new_module()
190 INIT_LIST_HEAD(&mod->exported_symbols); in new_module()
191 INIT_LIST_HEAD(&mod->unresolved_symbols); in new_module()
192 INIT_LIST_HEAD(&mod->missing_namespaces); in new_module()
193 INIT_LIST_HEAD(&mod->imported_namespaces); in new_module()
195 memcpy(mod->name, name, namelen); in new_module()
196 mod->name[namelen] = '\0'; in new_module()
197 mod->is_vmlinux = (strcmp(mod->name, "vmlinux") == 0); in new_module()
204 mod->is_gpl_compatible = true; in new_module()
206 list_add_tail(&mod->list, &modules); in new_module()
208 return mod; in new_module()
260 static void sym_add_unresolved(const char *name, struct module *mod, bool weak) in sym_add_unresolved() argument
267 list_add_tail(&sym->list, &mod->unresolved_symbols); in sym_add_unresolved()
270 static struct symbol *sym_find_with_module(const char *name, struct module *mod) in sym_find_with_module() argument
279 if (strcmp(s->name, name) == 0 && (!mod || s->module == mod)) in sym_find_with_module()
360 static struct symbol *sym_add_exported(const char *name, struct module *mod, in sym_add_exported() argument
365 if (s && (!external_module || s->module->is_vmlinux || s->module == mod)) { in sym_add_exported()
367 mod->name, name, s->module->name, in sym_add_exported()
372 s->module = mod; in sym_add_exported()
375 list_add_tail(&s->list, &mod->exported_symbols); in sym_add_exported()
377 if (!mod->is_vmlinux && !mod->from_dump) { in sym_add_exported()
622 static void handle_symbol(struct module *mod, struct elf_info *info, in handle_symbol() argument
630 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); in handle_symbol()
652 sym_add_unresolved(symname, mod, in handle_symbol()
657 mod->has_init = true; in handle_symbol()
659 mod->has_cleanup = true; in handle_symbol()
1076 static void check_export_symbol(struct module *mod, struct elf_info *elf, in check_export_symbol() argument
1091 mod->name, label_name); in check_export_symbol()
1097 error("%s: local symbol '%s' was exported\n", mod->name, in check_export_symbol()
1105 mod->name, name); in check_export_symbol()
1116 mod->name, data, name); in check_export_symbol()
1121 s = sym_add_exported(name, mod, is_gpl, data); in check_export_symbol()
1140 mod->name, name); in check_export_symbol()
1143 mod->name, name); in check_export_symbol()
1146 static void check_section_mismatch(struct module *mod, struct elf_info *elf, in check_section_mismatch() argument
1155 check_export_symbol(mod, elf, faddr, tosec, sym); in check_section_mismatch()
1163 default_mismatch_handler(mod->name, elf, mismatch, sym, in check_section_mismatch()
1341 static void section_rela(struct module *mod, struct elf_info *elf, in section_rela() argument
1378 check_section_mismatch(mod, elf, tsym, in section_rela()
1383 static void section_rel(struct module *mod, struct elf_info *elf, in section_rel() argument
1415 check_section_mismatch(mod, elf, tsym, in section_rel()
1432 static void check_sec_ref(struct module *mod, struct elf_info *elf) in check_sec_ref() argument
1440 check_section(mod->name, elf, sechdr); in check_sec_ref()
1456 section_rela(mod, elf, secndx, secname, in check_sec_ref()
1459 section_rel(mod, elf, secndx, secname, in check_sec_ref()
1481 static void extract_crcs_for_object(const char *object, struct module *mod) in extract_crcs_for_object() argument
1537 sym = sym_find_with_module(name, mod); in extract_crcs_for_object()
1549 static void mod_set_crcs(struct module *mod) in mod_set_crcs() argument
1555 if (mod->is_vmlinux) { in mod_set_crcs()
1559 ret = snprintf(objlist, sizeof(objlist), "%s.mod", mod->name); in mod_set_crcs()
1570 extract_crcs_for_object(obj, mod); in mod_set_crcs()
1581 struct module *mod; in read_symbols() local
1594 mod = new_module(modname, strlen(modname) - strlen(".o")); in read_symbols()
1596 if (!mod->is_vmlinux) { in read_symbols()
1602 mod->is_gpl_compatible = false; in read_symbols()
1610 add_namespace(&mod->imported_namespaces, namespace); in read_symbols()
1622 handle_symbol(mod, &info, sym, symname); in read_symbols()
1623 handle_moddevtable(mod, &info, sym, symname); in read_symbols()
1626 check_sec_ref(mod, &info); in read_symbols()
1628 if (!mod->is_vmlinux) { in read_symbols()
1631 get_src_version(mod->name, mod->srcversion, in read_symbols()
1632 sizeof(mod->srcversion) - 1); in read_symbols()
1644 sym_add_unresolved("module_layout", mod, false); in read_symbols()
1646 mod_set_crcs(mod); in read_symbols()
1697 static void check_exports(struct module *mod) in check_exports() argument
1701 list_for_each_entry(s, &mod->unresolved_symbols, list) { in check_exports()
1708 s->name, mod->name); in check_exports()
1711 if (exp->module == mod) { in check_exports()
1713 s->name, mod->name); in check_exports()
1722 basename = strrchr(mod->name, '/'); in check_exports()
1726 basename = mod->name; in check_exports()
1728 if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) { in check_exports()
1732 add_namespace(&mod->missing_namespaces, exp->namespace); in check_exports()
1735 if (!mod->is_gpl_compatible && exp->is_gpl_only) in check_exports()
1769 static void check_modname_len(struct module *mod) in check_modname_len() argument
1773 mod_name = strrchr(mod->name, '/'); in check_modname_len()
1775 mod_name = mod->name; in check_modname_len()
1779 error("module name is too long [%s.ko]\n", mod->name); in check_modname_len()
1785 static void add_header(struct buffer *b, struct module *mod) in add_header() argument
1796 if (mod->has_init) in add_header()
1798 if (mod->has_cleanup) in add_header()
1811 if (strstarts(mod->name, "drivers/staging")) in add_header()
1814 if (strstarts(mod->name, "tools/testing")) in add_header()
1818 static void add_exported_symbols(struct buffer *buf, struct module *mod) in add_exported_symbols() argument
1824 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1838 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1845 sym->name, mod->name, mod->is_vmlinux ? "" : ".ko", in add_exported_symbols()
1856 static void add_extended_versions(struct buffer *b, struct module *mod) in add_extended_versions() argument
1866 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_extended_versions()
1871 s->name, mod->name); in add_extended_versions()
1880 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_extended_versions()
1899 static void add_versions(struct buffer *b, struct module *mod) in add_versions() argument
1910 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_versions()
1915 s->name, mod->name); in add_versions()
1924 s->name, mod->name); in add_versions()
1935 static void add_depends(struct buffer *b, struct module *mod) in add_depends() argument
1941 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
1948 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
1968 static void add_srcversion(struct buffer *b, struct module *mod) in add_srcversion() argument
1970 if (mod->srcversion[0]) { in add_srcversion()
1973 mod->srcversion); in add_srcversion()
2034 static void write_vmlinux_export_c_file(struct module *mod) in write_vmlinux_export_c_file() argument
2041 add_exported_symbols(&buf, mod); in write_vmlinux_export_c_file()
2047 static void write_mod_c_file(struct module *mod) in write_mod_c_file() argument
2053 add_header(&buf, mod); in write_mod_c_file()
2054 add_exported_symbols(&buf, mod); in write_mod_c_file()
2055 add_versions(&buf, mod); in write_mod_c_file()
2056 add_extended_versions(&buf, mod); in write_mod_c_file()
2057 add_depends(&buf, mod); in write_mod_c_file()
2058 add_moddevtable(&buf, mod); in write_mod_c_file()
2059 add_srcversion(&buf, mod); in write_mod_c_file()
2061 ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name); in write_mod_c_file()
2090 struct module *mod; in read_dump() local
2120 mod = find_module(modname); in read_dump()
2121 if (!mod) { in read_dump()
2122 mod = new_module(modname, strlen(modname)); in read_dump()
2123 mod->from_dump = true; in read_dump()
2125 s = sym_add_exported(symname, mod, gpl_only, namespace); in read_dump()
2138 struct module *mod; in write_dump() local
2141 list_for_each_entry(mod, &modules, list) { in write_dump()
2142 if (mod->from_dump) in write_dump()
2144 list_for_each_entry(sym, &mod->exported_symbols, list) { in write_dump()
2149 sym->crc, sym->name, mod->name, in write_dump()
2160 struct module *mod; in write_namespace_deps_files() local
2164 list_for_each_entry(mod, &modules, list) { in write_namespace_deps_files()
2166 if (mod->from_dump || list_empty(&mod->missing_namespaces)) in write_namespace_deps_files()
2169 buf_printf(&ns_deps_buf, "%s.ko:", mod->name); in write_namespace_deps_files()
2171 list_for_each_entry(ns, &mod->missing_namespaces, list) in write_namespace_deps_files()
2213 struct module *mod = find_module(name); in handle_protected_modules_list() local
2215 if (mod) in handle_protected_modules_list()
2216 mod->is_protected = true; in handle_protected_modules_list()
2227 struct module *mod; in write_protected_exports_c_file() local
2231 list_for_each_entry(mod, &modules, list) { in write_protected_exports_c_file()
2232 if (mod->is_vmlinux || mod->from_dump || !mod->is_protected) in write_protected_exports_c_file()
2235 list_for_each_entry(sym, &mod->exported_symbols, list) { in write_protected_exports_c_file()
2279 struct module *mod; in main() local
2368 list_for_each_entry(mod, &modules, list) { in main()
2369 if (mod->from_dump || mod->is_vmlinux) in main()
2372 check_modname_len(mod); in main()
2373 check_exports(mod); in main()
2384 list_for_each_entry(mod, &modules, list) { in main()
2385 if (mod->from_dump) in main()
2388 if (mod->is_vmlinux) in main()
2389 write_vmlinux_export_c_file(mod); in main()
2391 write_mod_c_file(mod); in main()