Commit 70422e7
committed
x86: add module symbol import test
Symbol namespace imports end up as "import_ns=<value>" strings inside
the ELF .modinfo section. If a kpatch needs to import a namespace, it
may result in a modified .modinfo section that kpatch-build needs to
carefully handle: the string is extracted from the patched ELF object
and saved in the output ELF object .modinfo section.
Add a test that verifies that four namespaces are successfully
re-imported by create-diff-object. The following patch produced the
import-ns.{ORIG,PATCHED}.o files:
diff -Nupr src.orig/fs/proc/cmdline.c src/fs/proc/cmdline.c
--- src.orig/fs/proc/cmdline.c 2022-10-24 15:41:08.858760066 -0400
+++ src/fs/proc/cmdline.c 2022-10-24 15:41:11.698715352 -0400
@@ -4,10 +4,23 @@
#include <linux/proc_fs.h>
#include <linux/seq_file.h>
+#include <linux/module.h>
+
+MODULE_IMPORT_NS(DMA_BUF);
+MODULE_IMPORT_NS(DEVMEM);
+MODULE_IMPORT_NS(KPATCH_TEST); /* dummy import to inflate .modinfo */
+MODULE_IMPORT_NS(KPATCH_TEST2); /* dummy import to inflate .modinfo */
+extern void dma_buf_export(void *);
+extern int cpu_cache_invalidate_memregion(int);
+
static int cmdline_proc_show(struct seq_file *m, void *v)
{
- seq_puts(m, saved_command_line);
- seq_putc(m, '\n');
+ seq_printf(m, "%s kpatch=1\n", saved_command_line);
+
+ /* test namespace import */
+ pr_info("dma_buf_export=%pK", dma_buf_export);
+ pr_info("cpu_cache_invalidate_memregion=%pK", cpu_cache_invalidate_memregion);
+
return 0;
}
Signed-off-by: Joe Lawrence <[email protected]>1 parent a51c80a commit 70422e7
3 files changed
+15
-0
lines changedBinary file not shown.
Binary file not shown.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
0 commit comments