Lines Matching defs:mod
174 struct module *mod;
176 list_for_each_entry(mod, &modules, list) {
177 if (strcmp(mod->name, modname) == 0)
178 return mod;
185 struct module *mod;
187 mod = NOFAIL(malloc(sizeof(*mod) + namelen + 1));
188 memset(mod, 0, sizeof(*mod));
190 INIT_LIST_HEAD(&mod->exported_symbols);
191 INIT_LIST_HEAD(&mod->unresolved_symbols);
192 INIT_LIST_HEAD(&mod->missing_namespaces);
193 INIT_LIST_HEAD(&mod->imported_namespaces);
195 memcpy(mod->name, name, namelen);
196 mod->name[namelen] = '\0';
197 mod->is_vmlinux = (strcmp(mod->name, "vmlinux") == 0);
200 * Set mod->is_gpl_compatible to true by default. If MODULE_LICENSE()
204 mod->is_gpl_compatible = true;
206 list_add_tail(&mod->list, &modules);
208 return mod;
269 static void sym_add_unresolved(const char *name, struct module *mod, bool weak)
276 list_add_tail(&sym->list, &mod->unresolved_symbols);
279 static struct symbol *sym_find_with_module(const char *name, struct module *mod)
288 if (strcmp(s->name, name) == 0 && (!mod || s->module == mod))
370 static struct symbol *sym_add_exported(const char *name, struct module *mod,
375 if (s && (!external_module || s->module->is_vmlinux || s->module == mod)) {
377 mod->name, name, s->module->name,
382 s->module = mod;
385 list_add_tail(&s->list, &mod->exported_symbols);
622 static void handle_symbol(struct module *mod, struct elf_info *info,
630 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
652 sym_add_unresolved(symname, mod,
657 mod->has_init = true;
659 mod->has_cleanup = true;
1173 "OTHER_TEXT_SECTIONS in scripts/mod/modpost.c.\n",
1181 static void check_export_symbol(struct module *mod, struct elf_info *elf,
1196 mod->name, label_name);
1202 error("%s: local symbol '%s' was exported\n", mod->name,
1210 mod->name, name);
1221 mod->name, data, name);
1226 s = sym_add_exported(name, mod, is_gpl, data);
1245 mod->name, name);
1248 mod->name, name);
1251 static void check_section_mismatch(struct module *mod, struct elf_info *elf,
1260 check_export_symbol(mod, elf, faddr, tosec, sym);
1268 default_mismatch_handler(mod->name, elf, mismatch, sym,
1477 static void section_rela(struct module *mod, struct elf_info *elf,
1514 check_section_mismatch(mod, elf, tsym,
1519 static void section_rel(struct module *mod, struct elf_info *elf,
1558 check_section_mismatch(mod, elf, tsym,
1575 static void check_sec_ref(struct module *mod, struct elf_info *elf)
1582 check_section(mod->name, elf, &elf->sechdrs[i]);
1585 section_rela(mod, elf, &elf->sechdrs[i]);
1587 section_rel(mod, elf, &elf->sechdrs[i]);
1607 static void extract_crcs_for_object(const char *object, struct module *mod)
1663 sym = sym_find_with_module(name, mod);
1675 static void mod_set_crcs(struct module *mod)
1681 if (mod->is_vmlinux) {
1684 /* objects for a module are listed in the *.mod file. */
1685 ret = snprintf(objlist, sizeof(objlist), "%s.mod", mod->name);
1696 extract_crcs_for_object(obj, mod);
1707 struct module *mod;
1720 mod = new_module(modname, strlen(modname) - strlen(".o"));
1722 if (!mod->is_vmlinux) {
1728 mod->is_gpl_compatible = false;
1736 add_namespace(&mod->imported_namespaces, namespace);
1747 handle_symbol(mod, &info, sym, symname);
1748 handle_moddevtable(mod, &info, sym, symname);
1751 check_sec_ref(mod, &info);
1753 if (!mod->is_vmlinux) {
1756 get_src_version(mod->name, mod->srcversion,
1757 sizeof(mod->srcversion) - 1);
1769 sym_add_unresolved("module_layout", mod, false);
1771 mod_set_crcs(mod);
1822 static void check_exports(struct module *mod)
1826 list_for_each_entry(s, &mod->unresolved_symbols, list) {
1833 s->name, mod->name);
1836 if (exp->module == mod) {
1838 s->name, mod->name);
1847 basename = strrchr(mod->name, '/');
1851 basename = mod->name;
1853 if (!contains_namespace(&mod->imported_namespaces, exp->namespace)) {
1857 add_namespace(&mod->missing_namespaces, exp->namespace);
1860 if (!mod->is_gpl_compatible && exp->is_gpl_only)
1883 static void check_modname_len(struct module *mod)
1887 mod_name = strrchr(mod->name, '/');
1889 mod_name = mod->name;
1893 error("module name is too long [%s.ko]\n", mod->name);
1899 static void add_header(struct buffer *b, struct module *mod)
1927 if (mod->has_init)
1929 if (mod->has_cleanup)
1945 if (strstarts(mod->name, "drivers/staging"))
1948 if (strstarts(mod->name, "tools/testing"))
1952 static void add_exported_symbols(struct buffer *buf, struct module *mod)
1958 list_for_each_entry(sym, &mod->exported_symbols, list) {
1972 list_for_each_entry(sym, &mod->exported_symbols, list) {
1979 sym->name, mod->name, mod->is_vmlinux ? "" : ".ko",
1990 static void add_versions(struct buffer *b, struct module *mod)
2001 list_for_each_entry(s, &mod->unresolved_symbols, list) {
2006 s->name, mod->name);
2011 s->name, mod->name);
2021 static void add_depends(struct buffer *b, struct module *mod)
2027 list_for_each_entry(s, &mod->unresolved_symbols, list) {
2034 list_for_each_entry(s, &mod->unresolved_symbols, list) {
2054 static void add_srcversion(struct buffer *b, struct module *mod)
2056 if (mod->srcversion[0]) {
2059 mod->srcversion);
2120 static void write_vmlinux_export_c_file(struct module *mod)
2127 add_exported_symbols(&buf, mod);
2132 /* do sanity checks, and generate *.mod.c file */
2133 static void write_mod_c_file(struct module *mod)
2139 add_header(&buf, mod);
2140 add_exported_symbols(&buf, mod);
2141 add_versions(&buf, mod);
2142 add_depends(&buf, mod);
2143 add_moddevtable(&buf, mod);
2144 add_srcversion(&buf, mod);
2146 ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name);
2175 struct module *mod;
2205 mod = find_module(modname);
2206 if (!mod) {
2207 mod = new_module(modname, strlen(modname));
2208 mod->from_dump = true;
2210 s = sym_add_exported(symname, mod, gpl_only, namespace);
2223 struct module *mod;
2226 list_for_each_entry(mod, &modules, list) {
2227 if (mod->from_dump)
2229 list_for_each_entry(sym, &mod->exported_symbols, list) {
2234 sym->crc, sym->name, mod->name,
2245 struct module *mod;
2249 list_for_each_entry(mod, &modules, list) {
2251 if (mod->from_dump || list_empty(&mod->missing_namespaces))
2254 buf_printf(&ns_deps_buf, "%s.ko:", mod->name);
2256 list_for_each_entry(ns, &mod->missing_namespaces, list)
2273 struct module *mod;
2347 list_for_each_entry(mod, &modules, list) {
2348 if (mod->from_dump || mod->is_vmlinux)
2351 check_modname_len(mod);
2352 check_exports(mod);
2358 list_for_each_entry(mod, &modules, list) {
2359 if (mod->from_dump)
2362 if (mod->is_vmlinux)
2363 write_vmlinux_export_c_file(mod);
2365 write_mod_c_file(mod);