diff options
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r-- | scripts/mod/modpost.c | 48 |
1 files changed, 38 insertions, 10 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index f277e116e0eb..820eed87fb43 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -169,6 +169,7 @@ struct symbol { | |||
169 | unsigned int kernel:1; /* 1 if symbol is from kernel | 169 | unsigned int kernel:1; /* 1 if symbol is from kernel |
170 | * (only for external modules) **/ | 170 | * (only for external modules) **/ |
171 | unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */ | 171 | unsigned int preloaded:1; /* 1 if symbol from Module.symvers, or crc */ |
172 | unsigned int is_static:1; /* 1 if symbol is not global */ | ||
172 | enum export export; /* Type of export */ | 173 | enum export export; /* Type of export */ |
173 | char name[0]; | 174 | char name[0]; |
174 | }; | 175 | }; |
@@ -201,6 +202,7 @@ static struct symbol *alloc_symbol(const char *name, unsigned int weak, | |||
201 | strcpy(s->name, name); | 202 | strcpy(s->name, name); |
202 | s->weak = weak; | 203 | s->weak = weak; |
203 | s->next = next; | 204 | s->next = next; |
205 | s->is_static = 1; | ||
204 | return s; | 206 | return s; |
205 | } | 207 | } |
206 | 208 | ||
@@ -795,9 +797,9 @@ static int match(const char *sym, const char * const pat[]) | |||
795 | 797 | ||
796 | /* "*foo*" */ | 798 | /* "*foo*" */ |
797 | if (*p == '*' && *endp == '*') { | 799 | if (*p == '*' && *endp == '*') { |
798 | char *here, *bare = strndup(p + 1, strlen(p) - 2); | 800 | char *bare = NOFAIL(strndup(p + 1, strlen(p) - 2)); |
801 | char *here = strstr(sym, bare); | ||
799 | 802 | ||
800 | here = strstr(sym, bare); | ||
801 | free(bare); | 803 | free(bare); |
802 | if (here != NULL) | 804 | if (here != NULL) |
803 | return 1; | 805 | return 1; |
@@ -1980,6 +1982,21 @@ static void read_symbols(const char *modname) | |||
1980 | handle_modversions(mod, &info, sym, symname); | 1982 | handle_modversions(mod, &info, sym, symname); |
1981 | handle_moddevtable(mod, &info, sym, symname); | 1983 | handle_moddevtable(mod, &info, sym, symname); |
1982 | } | 1984 | } |
1985 | |||
1986 | // check for static EXPORT_SYMBOL_* functions && global vars | ||
1987 | for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { | ||
1988 | unsigned char bind = ELF_ST_BIND(sym->st_info); | ||
1989 | |||
1990 | if (bind == STB_GLOBAL || bind == STB_WEAK) { | ||
1991 | struct symbol *s = | ||
1992 | find_symbol(remove_dot(info.strtab + | ||
1993 | sym->st_name)); | ||
1994 | |||
1995 | if (s) | ||
1996 | s->is_static = 0; | ||
1997 | } | ||
1998 | } | ||
1999 | |||
1983 | if (!is_vmlinux(modname) || vmlinux_section_warnings) | 2000 | if (!is_vmlinux(modname) || vmlinux_section_warnings) |
1984 | check_sec_ref(mod, modname, &info); | 2001 | check_sec_ref(mod, modname, &info); |
1985 | 2002 | ||
@@ -2159,7 +2176,7 @@ static void add_header(struct buffer *b, struct module *mod) | |||
2159 | buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); | 2176 | buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n"); |
2160 | buf_printf(b, "\n"); | 2177 | buf_printf(b, "\n"); |
2161 | buf_printf(b, "__visible struct module __this_module\n"); | 2178 | buf_printf(b, "__visible struct module __this_module\n"); |
2162 | buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n"); | 2179 | buf_printf(b, "__section(.gnu.linkonce.this_module) = {\n"); |
2163 | buf_printf(b, "\t.name = KBUILD_MODNAME,\n"); | 2180 | buf_printf(b, "\t.name = KBUILD_MODNAME,\n"); |
2164 | if (mod->has_init) | 2181 | if (mod->has_init) |
2165 | buf_printf(b, "\t.init = init_module,\n"); | 2182 | buf_printf(b, "\t.init = init_module,\n"); |
@@ -2213,8 +2230,7 @@ static int add_versions(struct buffer *b, struct module *mod) | |||
2213 | 2230 | ||
2214 | buf_printf(b, "\n"); | 2231 | buf_printf(b, "\n"); |
2215 | buf_printf(b, "static const struct modversion_info ____versions[]\n"); | 2232 | buf_printf(b, "static const struct modversion_info ____versions[]\n"); |
2216 | buf_printf(b, "__used\n"); | 2233 | buf_printf(b, "__used __section(__versions) = {\n"); |
2217 | buf_printf(b, "__attribute__((section(\"__versions\"))) = {\n"); | ||
2218 | 2234 | ||
2219 | for (s = mod->unres; s; s = s->next) { | 2235 | for (s = mod->unres; s; s = s->next) { |
2220 | if (!s->module) | 2236 | if (!s->module) |
@@ -2250,10 +2266,7 @@ static void add_depends(struct buffer *b, struct module *mod) | |||
2250 | s->module->seen = is_vmlinux(s->module->name); | 2266 | s->module->seen = is_vmlinux(s->module->name); |
2251 | 2267 | ||
2252 | buf_printf(b, "\n"); | 2268 | buf_printf(b, "\n"); |
2253 | buf_printf(b, "static const char __module_depends[]\n"); | 2269 | buf_printf(b, "MODULE_INFO(depends, \""); |
2254 | buf_printf(b, "__used\n"); | ||
2255 | buf_printf(b, "__attribute__((section(\".modinfo\"))) =\n"); | ||
2256 | buf_printf(b, "\"depends="); | ||
2257 | for (s = mod->unres; s; s = s->next) { | 2270 | for (s = mod->unres; s; s = s->next) { |
2258 | const char *p; | 2271 | const char *p; |
2259 | if (!s->module) | 2272 | if (!s->module) |
@@ -2271,7 +2284,7 @@ static void add_depends(struct buffer *b, struct module *mod) | |||
2271 | buf_printf(b, "%s%s", first ? "" : ",", p); | 2284 | buf_printf(b, "%s%s", first ? "" : ",", p); |
2272 | first = 0; | 2285 | first = 0; |
2273 | } | 2286 | } |
2274 | buf_printf(b, "\";\n"); | 2287 | buf_printf(b, "\");\n"); |
2275 | } | 2288 | } |
2276 | 2289 | ||
2277 | static void add_srcversion(struct buffer *b, struct module *mod) | 2290 | static void add_srcversion(struct buffer *b, struct module *mod) |
@@ -2369,6 +2382,7 @@ static void read_dump(const char *fname, unsigned int kernel) | |||
2369 | s = sym_add_exported(symname, mod, export_no(export)); | 2382 | s = sym_add_exported(symname, mod, export_no(export)); |
2370 | s->kernel = kernel; | 2383 | s->kernel = kernel; |
2371 | s->preloaded = 1; | 2384 | s->preloaded = 1; |
2385 | s->is_static = 0; | ||
2372 | sym_update_crc(symname, mod, crc, export_no(export)); | 2386 | sym_update_crc(symname, mod, crc, export_no(export)); |
2373 | } | 2387 | } |
2374 | release_file(file, size); | 2388 | release_file(file, size); |
@@ -2425,6 +2439,7 @@ int main(int argc, char **argv) | |||
2425 | char *dump_write = NULL, *files_source = NULL; | 2439 | char *dump_write = NULL, *files_source = NULL; |
2426 | int opt; | 2440 | int opt; |
2427 | int err; | 2441 | int err; |
2442 | int n; | ||
2428 | struct ext_sym_list *extsym_iter; | 2443 | struct ext_sym_list *extsym_iter; |
2429 | struct ext_sym_list *extsym_start = NULL; | 2444 | struct ext_sym_list *extsym_start = NULL; |
2430 | 2445 | ||
@@ -2520,6 +2535,19 @@ int main(int argc, char **argv) | |||
2520 | if (sec_mismatch_count && sec_mismatch_fatal) | 2535 | if (sec_mismatch_count && sec_mismatch_fatal) |
2521 | fatal("modpost: Section mismatches detected.\n" | 2536 | fatal("modpost: Section mismatches detected.\n" |
2522 | "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n"); | 2537 | "Set CONFIG_SECTION_MISMATCH_WARN_ONLY=y to allow them.\n"); |
2538 | for (n = 0; n < SYMBOL_HASH_SIZE; n++) { | ||
2539 | struct symbol *s = symbolhash[n]; | ||
2540 | |||
2541 | while (s) { | ||
2542 | if (s->is_static) | ||
2543 | warn("\"%s\" [%s] is a static %s\n", | ||
2544 | s->name, s->module->name, | ||
2545 | export_str(s->export)); | ||
2546 | |||
2547 | s = s->next; | ||
2548 | } | ||
2549 | } | ||
2550 | |||
2523 | free(buf.p); | 2551 | free(buf.p); |
2524 | 2552 | ||
2525 | return err; | 2553 | return err; |