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()
613 static void handle_symbol(struct module *mod, struct elf_info *info, in handle_symbol() argument
621 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); in handle_symbol()
643 sym_add_unresolved(symname, mod, in handle_symbol()
648 mod->has_init = true; in handle_symbol()
650 mod->has_cleanup = true; in handle_symbol()
1066 static void check_export_symbol(struct module *mod, struct elf_info *elf, in check_export_symbol() argument
1081 mod->name, label_name); in check_export_symbol()
1087 error("%s: local symbol '%s' was exported\n", mod->name, in check_export_symbol()
1095 mod->name, name); in check_export_symbol()
1106 mod->name, data, name); in check_export_symbol()
1111 s = sym_add_exported(name, mod, is_gpl, data); in check_export_symbol()
1130 mod->name, name); in check_export_symbol()
1133 mod->name, name); in check_export_symbol()
1136 static void check_section_mismatch(struct module *mod, struct elf_info *elf, in check_section_mismatch() argument
1145 check_export_symbol(mod, elf, faddr, tosec, sym); in check_section_mismatch()
1153 default_mismatch_handler(mod->name, elf, mismatch, sym, in check_section_mismatch()
1331 static void section_rela(struct module *mod, struct elf_info *elf, in section_rela() argument
1368 check_section_mismatch(mod, elf, tsym, in section_rela()
1373 static void section_rel(struct module *mod, struct elf_info *elf, in section_rel() argument
1405 check_section_mismatch(mod, elf, tsym, in section_rel()
1422 static void check_sec_ref(struct module *mod, struct elf_info *elf) in check_sec_ref() argument
1430 check_section(mod->name, elf, sechdr); in check_sec_ref()
1446 section_rela(mod, elf, secndx, secname, in check_sec_ref()
1449 section_rel(mod, elf, secndx, secname, in check_sec_ref()
1471 static void extract_crcs_for_object(const char *object, struct module *mod) in extract_crcs_for_object() argument
1521 sym = sym_find_with_module(name, mod); in extract_crcs_for_object()
1533 static void mod_set_crcs(struct module *mod) in mod_set_crcs() argument
1539 if (mod->is_vmlinux) { in mod_set_crcs()
1543 ret = snprintf(objlist, sizeof(objlist), "%s.mod", mod->name); in mod_set_crcs()
1554 extract_crcs_for_object(obj, mod); in mod_set_crcs()
1565 struct module *mod; in read_symbols() local
1578 mod = new_module(modname, strlen(modname) - strlen(".o")); in read_symbols()
1582 mod->no_trim_symbol = xmalloc(info.no_trim_symbol_len); in read_symbols()
1583 memcpy(mod->no_trim_symbol, info.no_trim_symbol, in read_symbols()
1585 mod->no_trim_symbol_len = info.no_trim_symbol_len; in read_symbols()
1588 if (!mod->is_vmlinux) { in read_symbols()
1594 mod->is_gpl_compatible = false; in read_symbols()
1605 mod->name, namespace); in read_symbols()
1607 add_namespace(&mod->imported_namespaces, namespace); in read_symbols()
1617 handle_symbol(mod, &info, sym, symname); in read_symbols()
1618 handle_moddevtable(mod, &info, sym, symname); in read_symbols()
1621 check_sec_ref(mod, &info); in read_symbols()
1623 if (!mod->is_vmlinux) { in read_symbols()
1626 get_src_version(mod->name, mod->srcversion, in read_symbols()
1627 sizeof(mod->srcversion) - 1); in read_symbols()
1639 sym_add_unresolved("module_layout", mod, false); in read_symbols()
1641 mod_set_crcs(mod); in read_symbols()
1732 static void check_exports(struct module *mod) in check_exports() argument
1736 list_for_each_entry(s, &mod->unresolved_symbols, list) { in check_exports()
1743 s->name, mod->name); in check_exports()
1746 if (exp->module == mod) { in check_exports()
1748 s->name, mod->name); in check_exports()
1757 basename = get_basename(mod->name); in check_exports()
1760 !contains_namespace(&mod->imported_namespaces, exp->namespace)) { in check_exports()
1764 add_namespace(&mod->missing_namespaces, exp->namespace); in check_exports()
1767 if (!mod->is_gpl_compatible && exp->is_gpl_only) in check_exports()
1795 static void keep_no_trim_symbols(struct module *mod) in keep_no_trim_symbols() argument
1797 unsigned long size = mod->no_trim_symbol_len; in keep_no_trim_symbols()
1799 for (char *s = mod->no_trim_symbol; s; s = next_string(s , &size)) { in keep_no_trim_symbols()
1812 static void check_modname_len(struct module *mod) in check_modname_len() argument
1816 mod_name = get_basename(mod->name); in check_modname_len()
1819 error("module name is too long [%s.ko]\n", mod->name); in check_modname_len()
1825 static void add_header(struct buffer *b, struct module *mod) in add_header() argument
1836 if (mod->has_init) in add_header()
1838 if (mod->has_cleanup) in add_header()
1848 if (strstarts(mod->name, "drivers/staging")) in add_header()
1851 if (strstarts(mod->name, "tools/testing")) in add_header()
1855 static void add_exported_symbols(struct buffer *buf, struct module *mod) in add_exported_symbols() argument
1861 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1875 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1882 sym->name, mod->name, mod->is_vmlinux ? "" : ".ko", in add_exported_symbols()
1893 static void add_extended_versions(struct buffer *b, struct module *mod) in add_extended_versions() argument
1903 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_extended_versions()
1908 s->name, mod->name); in add_extended_versions()
1917 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_extended_versions()
1936 static void add_versions(struct buffer *b, struct module *mod) in add_versions() argument
1947 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_versions()
1952 s->name, mod->name); in add_versions()
1961 s->name, mod->name); in add_versions()
1972 static void add_depends(struct buffer *b, struct module *mod) in add_depends() argument
1978 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
1985 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
2001 static void add_srcversion(struct buffer *b, struct module *mod) in add_srcversion() argument
2003 if (mod->srcversion[0]) { in add_srcversion()
2006 mod->srcversion); in add_srcversion()
2067 static void write_vmlinux_export_c_file(struct module *mod) in write_vmlinux_export_c_file() argument
2074 add_exported_symbols(&buf, mod); in write_vmlinux_export_c_file()
2080 static void write_mod_c_file(struct module *mod) in write_mod_c_file() argument
2087 add_header(&buf, mod); in write_mod_c_file()
2088 add_exported_symbols(&buf, mod); in write_mod_c_file()
2089 add_versions(&buf, mod); in write_mod_c_file()
2090 add_extended_versions(&buf, mod); in write_mod_c_file()
2091 add_depends(&buf, mod); in write_mod_c_file()
2094 list_for_each_entry_safe(alias, next, &mod->aliases, node) { in write_mod_c_file()
2100 add_srcversion(&buf, mod); in write_mod_c_file()
2102 ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name); in write_mod_c_file()
2131 struct module *mod; in read_dump() local
2161 mod = find_module(fname, modname); in read_dump()
2162 if (!mod) { in read_dump()
2163 mod = new_module(modname, strlen(modname)); in read_dump()
2164 mod->dump_file = fname; in read_dump()
2166 s = sym_add_exported(symname, mod, gpl_only, namespace); in read_dump()
2179 struct module *mod; in write_dump() local
2182 list_for_each_entry(mod, &modules, list) { in write_dump()
2183 if (mod->dump_file) in write_dump()
2185 list_for_each_entry(sym, &mod->exported_symbols, list) { in write_dump()
2190 sym->crc, sym->name, mod->name, in write_dump()
2201 struct module *mod; in write_namespace_deps_files() local
2205 list_for_each_entry(mod, &modules, list) { in write_namespace_deps_files()
2207 if (mod->dump_file || list_empty(&mod->missing_namespaces)) in write_namespace_deps_files()
2210 buf_printf(&ns_deps_buf, "%s.ko:", mod->name); in write_namespace_deps_files()
2212 list_for_each_entry(ns, &mod->missing_namespaces, list) in write_namespace_deps_files()
2248 struct module *mod; in main() local
2330 list_for_each_entry(mod, &modules, list) { in main()
2331 keep_no_trim_symbols(mod); in main()
2333 if (mod->dump_file || mod->is_vmlinux) in main()
2336 check_modname_len(mod); in main()
2337 check_exports(mod); in main()
2343 list_for_each_entry(mod, &modules, list) { in main()
2344 if (mod->dump_file) in main()
2347 if (mod->is_vmlinux) in main()
2348 write_vmlinux_export_c_file(mod); in main()
2350 write_mod_c_file(mod); in main()