diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Kconfig.debug | 14 | ||||
-rw-r--r-- | lib/Makefile | 1 | ||||
-rw-r--r-- | lib/test_module.c | 33 |
3 files changed, 48 insertions, 0 deletions
diff --git a/lib/Kconfig.debug b/lib/Kconfig.debug index 900b63c1e899..7e37a36b6913 100644 --- a/lib/Kconfig.debug +++ b/lib/Kconfig.debug | |||
@@ -1595,6 +1595,20 @@ config DMA_API_DEBUG | |||
1595 | 1595 | ||
1596 | If unsure, say N. | 1596 | If unsure, say N. |
1597 | 1597 | ||
1598 | config TEST_MODULE | ||
1599 | tristate "Test module loading with 'hello world' module" | ||
1600 | default n | ||
1601 | depends on m | ||
1602 | help | ||
1603 | This builds the "test_module" module that emits "Hello, world" | ||
1604 | on printk when loaded. It is designed to be used for basic | ||
1605 | evaluation of the module loading subsystem (for example when | ||
1606 | validating module verification). It lacks any extra dependencies, | ||
1607 | and will not normally be loaded by the system unless explicitly | ||
1608 | requested by name. | ||
1609 | |||
1610 | If unsure, say N. | ||
1611 | |||
1598 | source "samples/Kconfig" | 1612 | source "samples/Kconfig" |
1599 | 1613 | ||
1600 | source "lib/Kconfig.kgdb" | 1614 | source "lib/Kconfig.kgdb" |
diff --git a/lib/Makefile b/lib/Makefile index a459c31e8c6b..b494b9af631c 100644 --- a/lib/Makefile +++ b/lib/Makefile | |||
@@ -31,6 +31,7 @@ obj-y += string_helpers.o | |||
31 | obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o | 31 | obj-$(CONFIG_TEST_STRING_HELPERS) += test-string_helpers.o |
32 | obj-y += kstrtox.o | 32 | obj-y += kstrtox.o |
33 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o | 33 | obj-$(CONFIG_TEST_KSTRTOX) += test-kstrtox.o |
34 | obj-$(CONFIG_TEST_MODULE) += test_module.o | ||
34 | 35 | ||
35 | ifeq ($(CONFIG_DEBUG_KOBJECT),y) | 36 | ifeq ($(CONFIG_DEBUG_KOBJECT),y) |
36 | CFLAGS_kobject.o += -DDEBUG | 37 | CFLAGS_kobject.o += -DDEBUG |
diff --git a/lib/test_module.c b/lib/test_module.c new file mode 100644 index 000000000000..319b66f1ff61 --- /dev/null +++ b/lib/test_module.c | |||
@@ -0,0 +1,33 @@ | |||
1 | /* | ||
2 | * This module emits "Hello, world" on printk when loaded. | ||
3 | * | ||
4 | * It is designed to be used for basic evaluation of the module loading | ||
5 | * subsystem (for example when validating module signing/verification). It | ||
6 | * lacks any extra dependencies, and will not normally be loaded by the | ||
7 | * system unless explicitly requested by name. | ||
8 | */ | ||
9 | |||
10 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | ||
11 | |||
12 | #include <linux/init.h> | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/printk.h> | ||
15 | |||
16 | static int __init test_module_init(void) | ||
17 | { | ||
18 | pr_warn("Hello, world\n"); | ||
19 | |||
20 | return 0; | ||
21 | } | ||
22 | |||
23 | module_init(test_module_init); | ||
24 | |||
25 | static void __exit test_module_exit(void) | ||
26 | { | ||
27 | pr_warn("Goodbye\n"); | ||
28 | } | ||
29 | |||
30 | module_exit(test_module_exit); | ||
31 | |||
32 | MODULE_AUTHOR("Kees Cook <keescook@chromium.org>"); | ||
33 | MODULE_LICENSE("GPL"); | ||