Commit 2d04b5ae authored by Richard Hacker's avatar Richard Hacker Committed by Sam Ravnborg

kbuild: support loading extra symbols in modpost

This patch adds a new command line option -E to modpost, expecting a symbol
file as an argument which is read prior to symbol processing. -E can be
supplied multiple times for as many files as is needed.

When building kernel modules that depend on other modules not in the main
kernel tree, modpost complains about undefined symbols:
# make -C /path/to/linux/kernel M=/path/to/my/module
...
Building modules, stage 2.
....
WARNING: "rt_copy_buf" [/home/rich/osc_etl_rtw/osc_kmod.ko] undefined!
...etc

This situation occurs when modpost processes the new module's symbols. When
it finds symbols not exported by the mainline kernel, it issues this warning.

The patch adds a new command line option -e to modpost which expects a symbol
file as an argument. The symbols listed in this file are added to modpost's
symbol tables during startup. -e can be supplied as often as required.

This patch works together with the second patch. It introduces a new make
variable, KBUILD_EXTRA_SYMBOLS, which is used when calling modpost.
Signed-off-by: default avatarRichard Hacker <lerichi@gmx.net>
Signed-off-by: default avatarSam Ravnborg <sam@ravnborg.org>
parent 35bb5b1e
...@@ -2019,6 +2019,11 @@ static void write_markers(const char *fname) ...@@ -2019,6 +2019,11 @@ static void write_markers(const char *fname)
write_if_changed(&buf, fname); write_if_changed(&buf, fname);
} }
struct ext_sym_list {
struct ext_sym_list *next;
const char *file;
};
int main(int argc, char **argv) int main(int argc, char **argv)
{ {
struct module *mod; struct module *mod;
...@@ -2029,8 +2034,10 @@ int main(int argc, char **argv) ...@@ -2029,8 +2034,10 @@ int main(int argc, char **argv)
char *markers_write = NULL; char *markers_write = NULL;
int opt; int opt;
int err; int err;
struct ext_sym_list *extsym_iter;
struct ext_sym_list *extsym_start = NULL;
while ((opt = getopt(argc, argv, "i:I:cmsSo:awM:K:")) != -1) { while ((opt = getopt(argc, argv, "i:I:e:cmsSo:awM:K:")) != -1) {
switch (opt) { switch (opt) {
case 'i': case 'i':
kernel_read = optarg; kernel_read = optarg;
...@@ -2042,6 +2049,14 @@ int main(int argc, char **argv) ...@@ -2042,6 +2049,14 @@ int main(int argc, char **argv)
case 'c': case 'c':
cross_build = 1; cross_build = 1;
break; break;
case 'e':
external_module = 1;
extsym_iter =
NOFAIL(malloc(sizeof(*extsym_iter)));
extsym_iter->next = extsym_start;
extsym_iter->file = optarg;
extsym_start = extsym_iter;
break;
case 'm': case 'm':
modversions = 1; modversions = 1;
break; break;
...@@ -2075,6 +2090,12 @@ int main(int argc, char **argv) ...@@ -2075,6 +2090,12 @@ int main(int argc, char **argv)
read_dump(kernel_read, 1); read_dump(kernel_read, 1);
if (module_read) if (module_read)
read_dump(module_read, 0); read_dump(module_read, 0);
while (extsym_start) {
read_dump(extsym_start->file, 0);
extsym_iter = extsym_start->next;
free(extsym_start);
extsym_start = extsym_iter;
}
while (optind < argc) while (optind < argc)
read_symbols(argv[optind++]); read_symbols(argv[optind++]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment