aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Makefile.build3
-rw-r--r--scripts/Makefile.lib7
-rw-r--r--scripts/Makefile.modpost8
-rw-r--r--scripts/genksyms/genksyms.c18
-rw-r--r--scripts/link-vmlinux.sh5
-rw-r--r--scripts/mod/modpost.c94
6 files changed, 78 insertions, 57 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 0e801c3cdaf8..d5d859c80729 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -211,7 +211,8 @@ $(obj)/%.i: $(src)/%.c FORCE
211 211
212cmd_gensymtypes = \ 212cmd_gensymtypes = \
213 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \ 213 $(CPP) -D__GENKSYMS__ $(c_flags) $< | \
214 $(GENKSYMS) $(if $(1), -T $(2)) -a $(ARCH) \ 214 $(GENKSYMS) $(if $(1), -T $(2)) \
215 $(patsubst y,-s _,$(CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX)) \
215 $(if $(KBUILD_PRESERVE),-p) \ 216 $(if $(KBUILD_PRESERVE),-p) \
216 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null)) 217 -r $(firstword $(wildcard $(2:.symtypes=.symref) /dev/null))
217 218
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3e73dfd838cd..51bb3de680b6 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -119,13 +119,6 @@ _c_flags += $(if $(patsubst n%,, \
119 $(CFLAGS_GCOV)) 119 $(CFLAGS_GCOV))
120endif 120endif
121 121
122ifdef CONFIG_SYMBOL_PREFIX
123_sym_flags = -DSYMBOL_PREFIX=$(patsubst "%",%,$(CONFIG_SYMBOL_PREFIX))
124_cpp_flags += $(_sym_flags)
125_a_flags += $(_sym_flags)
126endif
127
128
129# If building the kernel in a separate objtree expand all occurrences 122# If building the kernel in a separate objtree expand all occurrences
130# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). 123# of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/').
131 124
diff --git a/scripts/Makefile.modpost b/scripts/Makefile.modpost
index cf82c832458f..8dcdca27d836 100644
--- a/scripts/Makefile.modpost
+++ b/scripts/Makefile.modpost
@@ -60,7 +60,8 @@ kernelsymfile := $(objtree)/Module.symvers
60modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers 60modulesymfile := $(firstword $(KBUILD_EXTMOD))/Module.symvers
61 61
62# Step 1), find all modules listed in $(MODVERDIR)/ 62# Step 1), find all modules listed in $(MODVERDIR)/
63__modules := $(sort $(shell grep -h '\.ko$$' /dev/null $(wildcard $(MODVERDIR)/*.mod))) 63MODLISTCMD := find $(MODVERDIR) -name '*.mod' | xargs -r grep -h '\.ko$$' | sort -u
64__modules := $(shell $(MODLISTCMD))
64modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o))) 65modules := $(patsubst %.o,%.ko, $(wildcard $(__modules:.ko=.o)))
65 66
66# Stop after building .o files if NOFINAL is set. Makes compile tests quicker 67# Stop after building .o files if NOFINAL is set. Makes compile tests quicker
@@ -78,12 +79,13 @@ modpost = scripts/mod/modpost \
78 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \ 79 $(if $(CONFIG_DEBUG_SECTION_MISMATCH),,-S) \
79 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w) 80 $(if $(KBUILD_EXTMOD)$(KBUILD_MODPOST_WARN),-w)
80 81
82# We can go over command line length here, so be careful.
81quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules 83quiet_cmd_modpost = MODPOST $(words $(filter-out vmlinux FORCE, $^)) modules
82 cmd_modpost = $(modpost) -s 84 cmd_modpost = $(MODLISTCMD) | sed 's/\.ko$$/.o/' | $(modpost) -s -T -
83 85
84PHONY += __modpost 86PHONY += __modpost
85__modpost: $(modules:.ko=.o) FORCE 87__modpost: $(modules:.ko=.o) FORCE
86 $(call cmd,modpost) $(wildcard vmlinux) $(filter-out FORCE,$^) 88 $(call cmd,modpost) $(wildcard vmlinux)
87 89
88quiet_cmd_kernel-mod = MODPOST $@ 90quiet_cmd_kernel-mod = MODPOST $@
89 cmd_kernel-mod = $(modpost) $@ 91 cmd_kernel-mod = $(modpost) $@
diff --git a/scripts/genksyms/genksyms.c b/scripts/genksyms/genksyms.c
index d25e4a118d37..88632df4381b 100644
--- a/scripts/genksyms/genksyms.c
+++ b/scripts/genksyms/genksyms.c
@@ -45,7 +45,6 @@ int in_source_file;
45 45
46static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types, 46static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types,
47 flag_preserve, flag_warnings; 47 flag_preserve, flag_warnings;
48static const char *arch = "";
49static const char *mod_prefix = ""; 48static const char *mod_prefix = "";
50 49
51static int errors; 50static int errors;
@@ -731,7 +730,7 @@ static void genksyms_usage(void)
731{ 730{
732 fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n" 731 fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n"
733#ifdef __GNU_LIBRARY__ 732#ifdef __GNU_LIBRARY__
734 " -a, --arch Select architecture\n" 733 " -s, --symbol-prefix Select symbol prefix\n"
735 " -d, --debug Increment the debug level (repeatable)\n" 734 " -d, --debug Increment the debug level (repeatable)\n"
736 " -D, --dump Dump expanded symbol defs (for debugging only)\n" 735 " -D, --dump Dump expanded symbol defs (for debugging only)\n"
737 " -r, --reference file Read reference symbols from a file\n" 736 " -r, --reference file Read reference symbols from a file\n"
@@ -742,7 +741,7 @@ static void genksyms_usage(void)
742 " -h, --help Print this message\n" 741 " -h, --help Print this message\n"
743 " -V, --version Print the release version\n" 742 " -V, --version Print the release version\n"
744#else /* __GNU_LIBRARY__ */ 743#else /* __GNU_LIBRARY__ */
745 " -a Select architecture\n" 744 " -s Select symbol prefix\n"
746 " -d Increment the debug level (repeatable)\n" 745 " -d Increment the debug level (repeatable)\n"
747 " -D Dump expanded symbol defs (for debugging only)\n" 746 " -D Dump expanded symbol defs (for debugging only)\n"
748 " -r file Read reference symbols from a file\n" 747 " -r file Read reference symbols from a file\n"
@@ -763,7 +762,7 @@ int main(int argc, char **argv)
763 762
764#ifdef __GNU_LIBRARY__ 763#ifdef __GNU_LIBRARY__
765 struct option long_opts[] = { 764 struct option long_opts[] = {
766 {"arch", 1, 0, 'a'}, 765 {"symbol-prefix", 1, 0, 's'},
767 {"debug", 0, 0, 'd'}, 766 {"debug", 0, 0, 'd'},
768 {"warnings", 0, 0, 'w'}, 767 {"warnings", 0, 0, 'w'},
769 {"quiet", 0, 0, 'q'}, 768 {"quiet", 0, 0, 'q'},
@@ -776,14 +775,14 @@ int main(int argc, char **argv)
776 {0, 0, 0, 0} 775 {0, 0, 0, 0}
777 }; 776 };
778 777
779 while ((o = getopt_long(argc, argv, "a:dwqVDr:T:ph", 778 while ((o = getopt_long(argc, argv, "s:dwqVDr:T:ph",
780 &long_opts[0], NULL)) != EOF) 779 &long_opts[0], NULL)) != EOF)
781#else /* __GNU_LIBRARY__ */ 780#else /* __GNU_LIBRARY__ */
782 while ((o = getopt(argc, argv, "a:dwqVDr:T:ph")) != EOF) 781 while ((o = getopt(argc, argv, "s:dwqVDr:T:ph")) != EOF)
783#endif /* __GNU_LIBRARY__ */ 782#endif /* __GNU_LIBRARY__ */
784 switch (o) { 783 switch (o) {
785 case 'a': 784 case 's':
786 arch = optarg; 785 mod_prefix = optarg;
787 break; 786 break;
788 case 'd': 787 case 'd':
789 flag_debug++; 788 flag_debug++;
@@ -826,9 +825,6 @@ int main(int argc, char **argv)
826 genksyms_usage(); 825 genksyms_usage();
827 return 1; 826 return 1;
828 } 827 }
829 if ((strcmp(arch, "h8300") == 0) || (strcmp(arch, "blackfin") == 0) ||
830 (strcmp(arch, "metag") == 0))
831 mod_prefix = "_";
832 { 828 {
833 extern int yydebug; 829 extern int yydebug;
834 extern int yy_flex_debug; 830 extern int yy_flex_debug;
diff --git a/scripts/link-vmlinux.sh b/scripts/link-vmlinux.sh
index 3d569d6022c2..014994936b1c 100644
--- a/scripts/link-vmlinux.sh
+++ b/scripts/link-vmlinux.sh
@@ -74,9 +74,8 @@ kallsyms()
74 info KSYM ${2} 74 info KSYM ${2}
75 local kallsymopt; 75 local kallsymopt;
76 76
77 if [ -n "${CONFIG_SYMBOL_PREFIX}" ]; then 77 if [ -n "${CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX}" ]; then
78 kallsymopt="${kallsymopt} \ 78 kallsymopt="${kallsymopt} --symbol-prefix=_"
79 --symbol-prefix=${CONFIG_SYMBOL_PREFIX}"
80 fi 79 fi
81 80
82 if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then 81 if [ -n "${CONFIG_KALLSYMS_ALL}" ]; then
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 78b30c1548e9..a4be8e112bb6 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -15,17 +15,12 @@
15#include <stdio.h> 15#include <stdio.h>
16#include <ctype.h> 16#include <ctype.h>
17#include <string.h> 17#include <string.h>
18#include <limits.h>
19#include <stdbool.h>
18#include "modpost.h" 20#include "modpost.h"
19#include "../../include/generated/autoconf.h" 21#include "../../include/generated/autoconf.h"
20#include "../../include/linux/license.h" 22#include "../../include/linux/license.h"
21 23#include "../../include/linux/export.h"
22/* Some toolchains use a `_' prefix for all user symbols. */
23#ifdef CONFIG_SYMBOL_PREFIX
24#define MODULE_SYMBOL_PREFIX CONFIG_SYMBOL_PREFIX
25#else
26#define MODULE_SYMBOL_PREFIX ""
27#endif
28
29 24
30/* Are we using CONFIG_MODVERSIONS? */ 25/* Are we using CONFIG_MODVERSIONS? */
31int modversions = 0; 26int modversions = 0;
@@ -85,6 +80,14 @@ PRINTF void merror(const char *fmt, ...)
85 va_end(arglist); 80 va_end(arglist);
86} 81}
87 82
83static inline bool strends(const char *str, const char *postfix)
84{
85 if (strlen(str) < strlen(postfix))
86 return false;
87
88 return strcmp(str + strlen(str) - strlen(postfix), postfix) == 0;
89}
90
88static int is_vmlinux(const char *modname) 91static int is_vmlinux(const char *modname)
89{ 92{
90 const char *myname; 93 const char *myname;
@@ -120,22 +123,20 @@ static struct module *find_module(char *modname)
120 return mod; 123 return mod;
121} 124}
122 125
123static struct module *new_module(char *modname) 126static struct module *new_module(const char *modname)
124{ 127{
125 struct module *mod; 128 struct module *mod;
126 char *p, *s; 129 char *p;
127 130
128 mod = NOFAIL(malloc(sizeof(*mod))); 131 mod = NOFAIL(malloc(sizeof(*mod)));
129 memset(mod, 0, sizeof(*mod)); 132 memset(mod, 0, sizeof(*mod));
130 p = NOFAIL(strdup(modname)); 133 p = NOFAIL(strdup(modname));
131 134
132 /* strip trailing .o */ 135 /* strip trailing .o */
133 s = strrchr(p, '.'); 136 if (strends(p, ".o")) {
134 if (s != NULL) 137 p[strlen(p) - 2] = '\0';
135 if (strcmp(s, ".o") == 0) { 138 mod->is_dot_o = 1;
136 *s = '\0'; 139 }
137 mod->is_dot_o = 1;
138 }
139 140
140 /* add to list */ 141 /* add to list */
141 mod->name = p; 142 mod->name = p;
@@ -562,7 +563,7 @@ static void parse_elf_finish(struct elf_info *info)
562static int ignore_undef_symbol(struct elf_info *info, const char *symname) 563static int ignore_undef_symbol(struct elf_info *info, const char *symname)
563{ 564{
564 /* ignore __this_module, it will be resolved shortly */ 565 /* ignore __this_module, it will be resolved shortly */
565 if (strcmp(symname, MODULE_SYMBOL_PREFIX "__this_module") == 0) 566 if (strcmp(symname, VMLINUX_SYMBOL_STR(__this_module)) == 0)
566 return 1; 567 return 1;
567 /* ignore global offset table */ 568 /* ignore global offset table */
568 if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0) 569 if (strcmp(symname, "_GLOBAL_OFFSET_TABLE_") == 0)
@@ -583,8 +584,8 @@ static int ignore_undef_symbol(struct elf_info *info, const char *symname)
583 return 0; 584 return 0;
584} 585}
585 586
586#define CRC_PFX MODULE_SYMBOL_PREFIX "__crc_" 587#define CRC_PFX VMLINUX_SYMBOL_STR(__crc_)
587#define KSYMTAB_PFX MODULE_SYMBOL_PREFIX "__ksymtab_" 588#define KSYMTAB_PFX VMLINUX_SYMBOL_STR(__ksymtab_)
588 589
589static void handle_modversions(struct module *mod, struct elf_info *info, 590static void handle_modversions(struct module *mod, struct elf_info *info,
590 Elf_Sym *sym, const char *symname) 591 Elf_Sym *sym, const char *symname)
@@ -637,14 +638,15 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
637 } 638 }
638#endif 639#endif
639 640
640 if (memcmp(symname, MODULE_SYMBOL_PREFIX, 641#ifdef CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX
641 strlen(MODULE_SYMBOL_PREFIX)) == 0) { 642 if (symname[0] != '_')
642 mod->unres = 643 break;
643 alloc_symbol(symname + 644 else
644 strlen(MODULE_SYMBOL_PREFIX), 645 symname++;
645 ELF_ST_BIND(sym->st_info) == STB_WEAK, 646#endif
646 mod->unres); 647 mod->unres = alloc_symbol(symname,
647 } 648 ELF_ST_BIND(sym->st_info) == STB_WEAK,
649 mod->unres);
648 break; 650 break;
649 default: 651 default:
650 /* All exported symbols */ 652 /* All exported symbols */
@@ -652,9 +654,9 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
652 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod, 654 sym_add_exported(symname + strlen(KSYMTAB_PFX), mod,
653 export); 655 export);
654 } 656 }
655 if (strcmp(symname, MODULE_SYMBOL_PREFIX "init_module") == 0) 657 if (strcmp(symname, VMLINUX_SYMBOL_STR(init_module)) == 0)
656 mod->has_init = 1; 658 mod->has_init = 1;
657 if (strcmp(symname, MODULE_SYMBOL_PREFIX "cleanup_module") == 0) 659 if (strcmp(symname, VMLINUX_SYMBOL_STR(cleanup_module)) == 0)
658 mod->has_cleanup = 1; 660 mod->has_cleanup = 1;
659 break; 661 break;
660 } 662 }
@@ -1762,6 +1764,27 @@ static void read_symbols(char *modname)
1762 mod->unres = alloc_symbol("module_layout", 0, mod->unres); 1764 mod->unres = alloc_symbol("module_layout", 0, mod->unres);
1763} 1765}
1764 1766
1767static void read_symbols_from_files(const char *filename)
1768{
1769 FILE *in = stdin;
1770 char fname[PATH_MAX];
1771
1772 if (strcmp(filename, "-") != 0) {
1773 in = fopen(filename, "r");
1774 if (!in)
1775 fatal("Can't open filenames file %s: %m", filename);
1776 }
1777
1778 while (fgets(fname, PATH_MAX, in) != NULL) {
1779 if (strends(fname, "\n"))
1780 fname[strlen(fname)-1] = '\0';
1781 read_symbols(fname);
1782 }
1783
1784 if (in != stdin)
1785 fclose(in);
1786}
1787
1765#define SZ 500 1788#define SZ 500
1766 1789
1767/* We first write the generated file into memory using the 1790/* We first write the generated file into memory using the
@@ -1934,7 +1957,8 @@ static int add_versions(struct buffer *b, struct module *mod)
1934 s->name, mod->name); 1957 s->name, mod->name);
1935 continue; 1958 continue;
1936 } 1959 }
1937 buf_printf(b, "\t{ %#8x, \"%s\" },\n", s->crc, s->name); 1960 buf_printf(b, "\t{ %#8x, __VMLINUX_SYMBOL_STR(%s) },\n",
1961 s->crc, s->name);
1938 } 1962 }
1939 1963
1940 buf_printf(b, "};\n"); 1964 buf_printf(b, "};\n");
@@ -2122,13 +2146,13 @@ int main(int argc, char **argv)
2122 struct module *mod; 2146 struct module *mod;
2123 struct buffer buf = { }; 2147 struct buffer buf = { };
2124 char *kernel_read = NULL, *module_read = NULL; 2148 char *kernel_read = NULL, *module_read = NULL;
2125 char *dump_write = NULL; 2149 char *dump_write = NULL, *files_source = NULL;
2126 int opt; 2150 int opt;
2127 int err; 2151 int err;
2128 struct ext_sym_list *extsym_iter; 2152 struct ext_sym_list *extsym_iter;
2129 struct ext_sym_list *extsym_start = NULL; 2153 struct ext_sym_list *extsym_start = NULL;
2130 2154
2131 while ((opt = getopt(argc, argv, "i:I:e:msSo:awM:K:")) != -1) { 2155 while ((opt = getopt(argc, argv, "i:I:e:msST:o:awM:K:")) != -1) {
2132 switch (opt) { 2156 switch (opt) {
2133 case 'i': 2157 case 'i':
2134 kernel_read = optarg; 2158 kernel_read = optarg;
@@ -2160,6 +2184,9 @@ int main(int argc, char **argv)
2160 case 'S': 2184 case 'S':
2161 sec_mismatch_verbose = 0; 2185 sec_mismatch_verbose = 0;
2162 break; 2186 break;
2187 case 'T':
2188 files_source = optarg;
2189 break;
2163 case 'w': 2190 case 'w':
2164 warn_unresolved = 1; 2191 warn_unresolved = 1;
2165 break; 2192 break;
@@ -2182,6 +2209,9 @@ int main(int argc, char **argv)
2182 while (optind < argc) 2209 while (optind < argc)
2183 read_symbols(argv[optind++]); 2210 read_symbols(argv[optind++]);
2184 2211
2212 if (files_source)
2213 read_symbols_from_files(files_source);
2214
2185 for (mod = modules; mod; mod = mod->next) { 2215 for (mod = modules; mod; mod = mod->next) {
2186 if (mod->skip) 2216 if (mod->skip)
2187 continue; 2217 continue;