Lines Matching refs:mod
176 struct module *mod; in find_module() local
178 list_for_each_entry(mod, &modules, list) { in find_module()
179 if (!strcmp(mod->dump_file, filename) && in find_module()
180 !strcmp(mod->name, modname)) in find_module()
181 return mod; in find_module()
188 struct module *mod; in new_module() local
190 mod = xmalloc(sizeof(*mod) + namelen + 1); in new_module()
191 memset(mod, 0, sizeof(*mod)); in new_module()
193 INIT_LIST_HEAD(&mod->exported_symbols); in new_module()
194 INIT_LIST_HEAD(&mod->unresolved_symbols); in new_module()
195 INIT_LIST_HEAD(&mod->missing_namespaces); in new_module()
196 INIT_LIST_HEAD(&mod->imported_namespaces); in new_module()
197 INIT_LIST_HEAD(&mod->aliases); in new_module()
199 memcpy(mod->name, name, namelen); in new_module()
200 mod->name[namelen] = '\0'; in new_module()
201 mod->is_vmlinux = (strcmp(mod->name, "vmlinux") == 0); in new_module()
208 mod->is_gpl_compatible = true; in new_module()
210 list_add_tail(&mod->list, &modules); in new_module()
212 return mod; in new_module()
251 static void sym_add_unresolved(const char *name, struct module *mod, bool weak) in sym_add_unresolved() argument
258 list_add_tail(&sym->list, &mod->unresolved_symbols); in sym_add_unresolved()
261 static struct symbol *sym_find_with_module(const char *name, struct module *mod) in sym_find_with_module() argument
270 if (strcmp(s->name, name) == 0 && (!mod || s->module == mod)) in sym_find_with_module()
349 static struct symbol *sym_add_exported(const char *name, struct module *mod, in sym_add_exported() argument
354 if (s && (!external_module || s->module->is_vmlinux || s->module == mod)) { in sym_add_exported()
356 mod->name, name, s->module->name, in sym_add_exported()
361 s->module = mod; in sym_add_exported()
364 list_add_tail(&s->list, &mod->exported_symbols); in sym_add_exported()
611 static void handle_symbol(struct module *mod, struct elf_info *info, in handle_symbol() argument
619 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); in handle_symbol()
641 sym_add_unresolved(symname, mod, in handle_symbol()
646 mod->has_init = true; in handle_symbol()
648 mod->has_cleanup = true; in handle_symbol()
1064 static void check_export_symbol(struct module *mod, struct elf_info *elf, in check_export_symbol() argument
1079 mod->name, label_name); in check_export_symbol()
1085 error("%s: local symbol '%s' was exported\n", mod->name, in check_export_symbol()
1093 mod->name, name); in check_export_symbol()
1104 mod->name, data, name); in check_export_symbol()
1109 s = sym_add_exported(name, mod, is_gpl, data); in check_export_symbol()
1128 mod->name, name); in check_export_symbol()
1131 mod->name, name); in check_export_symbol()
1134 static void check_section_mismatch(struct module *mod, struct elf_info *elf, in check_section_mismatch() argument
1143 check_export_symbol(mod, elf, faddr, tosec, sym); in check_section_mismatch()
1151 default_mismatch_handler(mod->name, elf, mismatch, sym, in check_section_mismatch()
1329 static void section_rela(struct module *mod, struct elf_info *elf, in section_rela() argument
1366 check_section_mismatch(mod, elf, tsym, in section_rela()
1371 static void section_rel(struct module *mod, struct elf_info *elf, in section_rel() argument
1403 check_section_mismatch(mod, elf, tsym, in section_rel()
1420 static void check_sec_ref(struct module *mod, struct elf_info *elf) in check_sec_ref() argument
1428 check_section(mod->name, elf, sechdr); in check_sec_ref()
1444 section_rela(mod, elf, secndx, secname, in check_sec_ref()
1447 section_rel(mod, elf, secndx, secname, in check_sec_ref()
1469 static void extract_crcs_for_object(const char *object, struct module *mod) in extract_crcs_for_object() argument
1519 sym = sym_find_with_module(name, mod); in extract_crcs_for_object()
1531 static void mod_set_crcs(struct module *mod) in mod_set_crcs() argument
1537 if (mod->is_vmlinux) { in mod_set_crcs()
1541 ret = snprintf(objlist, sizeof(objlist), "%s.mod", mod->name); in mod_set_crcs()
1552 extract_crcs_for_object(obj, mod); in mod_set_crcs()
1563 struct module *mod; in read_symbols() local
1576 mod = new_module(modname, strlen(modname) - strlen(".o")); in read_symbols()
1580 mod->no_trim_symbol = xmalloc(info.no_trim_symbol_len); in read_symbols()
1581 memcpy(mod->no_trim_symbol, info.no_trim_symbol, in read_symbols()
1583 mod->no_trim_symbol_len = info.no_trim_symbol_len; in read_symbols()
1586 if (!mod->is_vmlinux) { in read_symbols()
1592 mod->is_gpl_compatible = false; in read_symbols()
1600 add_namespace(&mod->imported_namespaces, namespace); in read_symbols()
1612 handle_symbol(mod, &info, sym, symname); in read_symbols()
1613 handle_moddevtable(mod, &info, sym, symname); in read_symbols()
1616 check_sec_ref(mod, &info); in read_symbols()
1618 if (!mod->is_vmlinux) { in read_symbols()
1621 get_src_version(mod->name, mod->srcversion, in read_symbols()
1622 sizeof(mod->srcversion) - 1); in read_symbols()
1634 sym_add_unresolved("module_layout", mod, false); in read_symbols()
1636 mod_set_crcs(mod); in read_symbols()
1687 static void check_exports(struct module *mod) in check_exports() argument
1691 list_for_each_entry(s, &mod->unresolved_symbols, list) { in check_exports()
1698 s->name, mod->name); in check_exports()
1701 if (exp->module == mod) { in check_exports()
1703 s->name, mod->name); in check_exports()
1712 basename = get_basename(mod->name); in check_exports()
1714 if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) { in check_exports()
1718 add_namespace(&mod->missing_namespaces, exp->namespace); in check_exports()
1721 if (!mod->is_gpl_compatible && exp->is_gpl_only) in check_exports()
1749 static void keep_no_trim_symbols(struct module *mod) in keep_no_trim_symbols() argument
1751 unsigned long size = mod->no_trim_symbol_len; in keep_no_trim_symbols()
1753 for (char *s = mod->no_trim_symbol; s; s = next_string(s , &size)) { in keep_no_trim_symbols()
1766 static void check_modname_len(struct module *mod) in check_modname_len() argument
1770 mod_name = get_basename(mod->name); in check_modname_len()
1773 error("module name is too long [%s.ko]\n", mod->name); in check_modname_len()
1779 static void add_header(struct buffer *b, struct module *mod) in add_header() argument
1790 if (mod->has_init) in add_header()
1792 if (mod->has_cleanup) in add_header()
1802 if (strstarts(mod->name, "drivers/staging")) in add_header()
1805 if (strstarts(mod->name, "tools/testing")) in add_header()
1809 static void add_exported_symbols(struct buffer *buf, struct module *mod) in add_exported_symbols() argument
1815 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1829 list_for_each_entry(sym, &mod->exported_symbols, list) { in add_exported_symbols()
1836 sym->name, mod->name, mod->is_vmlinux ? "" : ".ko", in add_exported_symbols()
1847 static void add_extended_versions(struct buffer *b, struct module *mod) in add_extended_versions() argument
1857 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_extended_versions()
1862 s->name, mod->name); in add_extended_versions()
1871 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_extended_versions()
1890 static void add_versions(struct buffer *b, struct module *mod) in add_versions() argument
1901 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_versions()
1906 s->name, mod->name); in add_versions()
1915 s->name, mod->name); in add_versions()
1926 static void add_depends(struct buffer *b, struct module *mod) in add_depends() argument
1932 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
1939 list_for_each_entry(s, &mod->unresolved_symbols, list) { in add_depends()
1955 static void add_srcversion(struct buffer *b, struct module *mod) in add_srcversion() argument
1957 if (mod->srcversion[0]) { in add_srcversion()
1960 mod->srcversion); in add_srcversion()
2021 static void write_vmlinux_export_c_file(struct module *mod) in write_vmlinux_export_c_file() argument
2028 add_exported_symbols(&buf, mod); in write_vmlinux_export_c_file()
2034 static void write_mod_c_file(struct module *mod) in write_mod_c_file() argument
2041 add_header(&buf, mod); in write_mod_c_file()
2042 add_exported_symbols(&buf, mod); in write_mod_c_file()
2043 add_versions(&buf, mod); in write_mod_c_file()
2044 add_extended_versions(&buf, mod); in write_mod_c_file()
2045 add_depends(&buf, mod); in write_mod_c_file()
2048 list_for_each_entry_safe(alias, next, &mod->aliases, node) { in write_mod_c_file()
2054 add_srcversion(&buf, mod); in write_mod_c_file()
2056 ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name); in write_mod_c_file()
2085 struct module *mod; in read_dump() local
2115 mod = find_module(fname, modname); in read_dump()
2116 if (!mod) { in read_dump()
2117 mod = new_module(modname, strlen(modname)); in read_dump()
2118 mod->dump_file = fname; in read_dump()
2120 s = sym_add_exported(symname, mod, gpl_only, namespace); in read_dump()
2133 struct module *mod; in write_dump() local
2136 list_for_each_entry(mod, &modules, list) { in write_dump()
2137 if (mod->dump_file) in write_dump()
2139 list_for_each_entry(sym, &mod->exported_symbols, list) { in write_dump()
2144 sym->crc, sym->name, mod->name, in write_dump()
2155 struct module *mod; in write_namespace_deps_files() local
2159 list_for_each_entry(mod, &modules, list) { in write_namespace_deps_files()
2161 if (mod->dump_file || list_empty(&mod->missing_namespaces)) in write_namespace_deps_files()
2164 buf_printf(&ns_deps_buf, "%s.ko:", mod->name); in write_namespace_deps_files()
2166 list_for_each_entry(ns, &mod->missing_namespaces, list) in write_namespace_deps_files()
2202 struct module *mod; in main() local
2284 list_for_each_entry(mod, &modules, list) { in main()
2285 keep_no_trim_symbols(mod); in main()
2287 if (mod->dump_file || mod->is_vmlinux) in main()
2290 check_modname_len(mod); in main()
2291 check_exports(mod); in main()
2297 list_for_each_entry(mod, &modules, list) { in main()
2298 if (mod->dump_file) in main()
2301 if (mod->is_vmlinux) in main()
2302 write_vmlinux_export_c_file(mod); in main()
2304 write_mod_c_file(mod); in main()