Lines Matching refs:mod
178 struct module *mod; in find_module() local
180 list_for_each_entry(mod, &modules, list) { in find_module()
181 if (!strcmp(mod->dump_file, filename) && in find_module()
182 !strcmp(mod->name, modname)) in find_module()
183 return mod; in find_module()
190 struct module *mod; in new_module() local
192 mod = xmalloc(sizeof(*mod) + namelen + 1); in new_module()
193 memset(mod, 0, sizeof(*mod)); in new_module()
195 INIT_LIST_HEAD(&mod->exported_symbols); in new_module()
196 INIT_LIST_HEAD(&mod->unresolved_symbols); in new_module()
197 INIT_LIST_HEAD(&mod->missing_namespaces); in new_module()
198 INIT_LIST_HEAD(&mod->imported_namespaces); in new_module()
199 INIT_LIST_HEAD(&mod->aliases); in new_module()
201 memcpy(mod->name, name, namelen); in new_module()
202 mod->name[namelen] = '\0'; in new_module()
203 mod->is_vmlinux = (strcmp(mod->name, "vmlinux") == 0); in new_module()
210 mod->is_gpl_compatible = true; in new_module()
212 list_add_tail(&mod->list, &modules); in new_module()
214 return mod; in new_module()
253 static void sym_add_unresolved(const char *name, struct module *mod, bool weak) in sym_add_unresolved() argument
260 list_add_tail(&sym->list, &mod->unresolved_symbols); in sym_add_unresolved()
263 static struct symbol *sym_find_with_module(const char *name, struct module *mod) in sym_find_with_module() argument
272 if (strcmp(s->name, name) == 0 && (!mod || s->module == mod)) in sym_find_with_module()
351 static struct symbol *sym_add_exported(const char *name, struct module *mod, in sym_add_exported() argument
356 if (s && (!external_module || s->module->is_vmlinux || s->module == mod)) { in sym_add_exported()
358 mod->name, name, s->module->name, in sym_add_exported()
363 s->module = mod; in sym_add_exported()
366 list_add_tail(&s->list, &mod->exported_symbols); 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()
1075 static void check_export_symbol(struct module *mod, struct elf_info *elf, in check_export_symbol() argument
1090 mod->name, label_name); in check_export_symbol()
1096 error("%s: local symbol '%s' was exported\n", mod->name, in check_export_symbol()
1104 mod->name, name); in check_export_symbol()
1115 mod->name, data, name); in check_export_symbol()
1120 s = sym_add_exported(name, mod, is_gpl, data); in check_export_symbol()
1139 mod->name, name); in check_export_symbol()
1142 mod->name, name); in check_export_symbol()
1145 static void check_section_mismatch(struct module *mod, struct elf_info *elf, in check_section_mismatch() argument
1154 check_export_symbol(mod, elf, faddr, tosec, sym); in check_section_mismatch()
1162 default_mismatch_handler(mod->name, elf, mismatch, sym, in check_section_mismatch()
1340 static void section_rela(struct module *mod, struct elf_info *elf, in section_rela() argument
1377 check_section_mismatch(mod, elf, tsym, in section_rela()
1382 static void section_rel(struct module *mod, struct elf_info *elf, in section_rel() argument
1414 check_section_mismatch(mod, elf, tsym, in section_rel()
1431 static void check_sec_ref(struct module *mod, struct elf_info *elf) in check_sec_ref() argument
1439 check_section(mod->name, elf, sechdr); in check_sec_ref()
1455 section_rela(mod, elf, secndx, secname, in check_sec_ref()
1458 section_rel(mod, elf, secndx, secname, in check_sec_ref()
1480 static void extract_crcs_for_object(const char *object, struct module *mod) in extract_crcs_for_object() argument
1530 sym = sym_find_with_module(name, mod); in extract_crcs_for_object()
1542 static void mod_set_crcs(struct module *mod) in mod_set_crcs() argument
1548 if (mod->is_vmlinux) { in mod_set_crcs()
1552 ret = snprintf(objlist, sizeof(objlist), "%s.mod", mod->name); in mod_set_crcs()
1563 extract_crcs_for_object(obj, mod); in mod_set_crcs()
1574 struct module *mod; in read_symbols() local
1587 mod = new_module(modname, strlen(modname) - strlen(".o")); in read_symbols()
1591 mod->no_trim_symbol = xmalloc(info.no_trim_symbol_len); in read_symbols()
1592 memcpy(mod->no_trim_symbol, info.no_trim_symbol, in read_symbols()
1594 mod->no_trim_symbol_len = info.no_trim_symbol_len; in read_symbols()
1597 if (!mod->is_vmlinux) { in read_symbols()
1603 mod->is_gpl_compatible = false; in read_symbols()
1614 mod->name, namespace); in read_symbols()
1616 add_namespace(&mod->imported_namespaces, namespace); in read_symbols()
1626 handle_symbol(mod, &info, sym, symname); in read_symbols()
1627 handle_moddevtable(mod, &info, sym, symname); in read_symbols()
1630 check_sec_ref(mod, &info); in read_symbols()
1632 if (!mod->is_vmlinux) { in read_symbols()
1635 get_src_version(mod->name, mod->srcversion, in read_symbols()
1636 sizeof(mod->srcversion) - 1); in read_symbols()
1648 sym_add_unresolved("module_layout", mod, false); in read_symbols()
1650 mod_set_crcs(mod); in read_symbols()
1741 static void check_exports(struct module *mod) in check_exports() argument
1745 list_for_each_entry(s, &mod->unresolved_symbols, list) { in check_exports()
1752 s->name, mod->name); in check_exports()
1755 if (exp->module == mod) { in check_exports()
1757 s->name, mod->name); in check_exports()
1766 basename = get_basename(mod->name); in check_exports()
1769 !contains_namespace(&mod->imported_namespaces, exp->namespace)) { in check_exports()
1773 add_namespace(&mod->missing_namespaces, exp->namespace); in check_exports()
1776 if (!mod->is_gpl_compatible && exp->is_gpl_only) in check_exports()
1804 static void keep_no_trim_symbols(struct module *mod) in keep_no_trim_symbols() argument
1806 unsigned long size = mod->no_trim_symbol_len; in keep_no_trim_symbols()
1808 for (char *s = mod->no_trim_symbol; s; s = next_string(s , &size)) { in keep_no_trim_symbols()
1821 static void check_modname_len(struct module *mod) in check_modname_len() argument
1825 mod_name = get_basename(mod->name); in check_modname_len()
1828 error("module name is too long [%s.ko]\n", mod->name); in check_modname_len()
1834 static void add_header(struct buffer *b, struct module *mod) in add_header() argument
1845 if (mod->has_init) in add_header()
1847 if (mod->has_cleanup) in add_header()
1857 if (strstarts(mod->name, "drivers/staging")) in add_header()
1860 if (strstarts(mod->name, "tools/testing")) in add_header()
1864 static void add_exported_symbols(struct buffer *buf, struct module *mod) in add_exported_symbols() argument
1870 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1884 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1891 sym->name, mod->name, mod->is_vmlinux ? "" : ".ko", in add_exported_symbols()
1902 static void add_extended_versions(struct buffer *b, struct module *mod) in add_extended_versions() argument
1912 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_extended_versions()
1917 s->name, mod->name); in add_extended_versions()
1926 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_extended_versions()
1945 static void add_versions(struct buffer *b, struct module *mod) in add_versions() argument
1956 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_versions()
1961 s->name, mod->name); in add_versions()
1970 s->name, mod->name); in add_versions()
1981 static void add_depends(struct buffer *b, struct module *mod) in add_depends() argument
1987 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
1994 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
2010 static void add_srcversion(struct buffer *b, struct module *mod) in add_srcversion() argument
2012 if (mod->srcversion[0]) { in add_srcversion()
2015 mod->srcversion); in add_srcversion()
2076 static void write_vmlinux_export_c_file(struct module *mod) in write_vmlinux_export_c_file() argument
2084 add_exported_symbols(&buf, mod); in write_vmlinux_export_c_file()
2091 list_for_each_entry_safe(alias, next, &mod->aliases, node) { in write_vmlinux_export_c_file()
2104 static void write_mod_c_file(struct module *mod) in write_mod_c_file() argument
2111 add_header(&buf, mod); in write_mod_c_file()
2112 add_exported_symbols(&buf, mod); in write_mod_c_file()
2113 add_versions(&buf, mod); in write_mod_c_file()
2114 add_extended_versions(&buf, mod); in write_mod_c_file()
2115 add_depends(&buf, mod); in write_mod_c_file()
2118 list_for_each_entry_safe(alias, next, &mod->aliases, node) { in write_mod_c_file()
2124 add_srcversion(&buf, mod); in write_mod_c_file()
2126 ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name); in write_mod_c_file()
2155 struct module *mod; in read_dump() local
2185 mod = find_module(fname, modname); in read_dump()
2186 if (!mod) { in read_dump()
2187 mod = new_module(modname, strlen(modname)); in read_dump()
2188 mod->dump_file = fname; in read_dump()
2190 s = sym_add_exported(symname, mod, gpl_only, namespace); in read_dump()
2203 struct module *mod; in write_dump() local
2206 list_for_each_entry(mod, &modules, list) { in write_dump()
2207 if (mod->dump_file) in write_dump()
2209 list_for_each_entry(sym, &mod->exported_symbols, list) { in write_dump()
2214 sym->crc, sym->name, mod->name, in write_dump()
2225 struct module *mod; in write_namespace_deps_files() local
2229 list_for_each_entry(mod, &modules, list) { in write_namespace_deps_files()
2231 if (mod->dump_file || list_empty(&mod->missing_namespaces)) in write_namespace_deps_files()
2234 buf_printf(&ns_deps_buf, "%s.ko:", mod->name); in write_namespace_deps_files()
2236 list_for_each_entry(ns, &mod->missing_namespaces, list) in write_namespace_deps_files()
2272 struct module *mod; in main() local
2354 list_for_each_entry(mod, &modules, list) { in main()
2355 keep_no_trim_symbols(mod); in main()
2357 if (mod->dump_file || mod->is_vmlinux) in main()
2360 check_modname_len(mod); in main()
2361 check_exports(mod); in main()
2367 list_for_each_entry(mod, &modules, list) { in main()
2368 if (mod->dump_file) in main()
2371 if (mod->is_vmlinux) in main()
2372 write_vmlinux_export_c_file(mod); in main()
2374 write_mod_c_file(mod); in main()