@@ -11,6 +11,10 @@ obj-m += mod-foo-b.o
obj-m += mod-foo-c.o
obj-m += mod-foo.o
+# predictable relocated/non-relocated symbols crc
+mod-foo-a-rel-y := mod-foo-a.o
+mod-foo-b-nonrel-y := mod-foo-b.o
+
# mod-loop: create loops in dependencies:
# 1) mod-loop-a -> mod-loop-b -> mod-loop-c -> mod-loop-a
# |-> mod-loop-f |-> mod-loop-f
@@ -63,8 +67,12 @@ mod-simple-%.ko: mod-simple-%.c Makefile.arch
$(MAKE) KDIR=$(KDIR_$(arch)) ARCH=$(arch) CROSS_COMPILE=$(CROSS_COMPILE_$(arch)) -f Makefile.arch
ifeq ($(FAKE_BUILD),0)
-modules:
+modules: rel-modules
$(MAKE) -C $(KDIR) M=$$PWD
+
+rel-modules:
+ $(MAKE) -C $(KDIR) M=$$PWD CONFIG_MODULE_REL_CRCS=y obj-m=mod-foo-a-rel.o
+ $(MAKE) -C $(KDIR) M=$$PWD CONFIG_MODULE_REL_CRCS=n obj-m=mod-foo-b-nonrel.o
else
modules:
@echo " CP cache/*.ko"
@@ -28,6 +28,10 @@ map=(
["test-depmod/search-order-external-last/lib/modules/4.4.4/foo/"]="mod-simple.ko"
["test-depmod/search-order-external-last/lib/modules/4.4.4/foobar/"]="mod-simple.ko"
["test-depmod/search-order-external-last/lib/modules/external/"]="mod-simple.ko"
+ ["test-depmod/relocated-crc/lib/modules/4.4.4/kernel/mod-foo-a-rel.ko"]="mod-foo-a-rel.ko"
+ ["test-depmod/relocated-crc/lib/modules/4.4.4/kernel/mod-foo-b-nonrel.ko"]="mod-foo-b-nonrel.ko"
+ ["test-depmod/relocated-crc/lib/modules/4.4.4/kernel/mod-foo-c.ko"]="mod-foo-c.ko"
+ ["test-depmod/relocated-crc/lib/modules/4.4.4/kernel/mod-foo.ko"]="mod-foo.ko"
["test-dependencies/lib/modules/4.0.20-kmod/kernel/fs/foo/"]="mod-foo-b.ko"
["test-dependencies/lib/modules/4.0.20-kmod/kernel/"]="mod-foo-c.ko"
["test-dependencies/lib/modules/4.0.20-kmod/kernel/lib/"]="mod-foo-a.ko"
new file mode 100644
new file mode 100644
@@ -0,0 +1,4 @@
+kernel/mod-foo-c.ko:
+kernel/mod-foo-b-nonrel.ko:
+kernel/mod-foo.ko: kernel/mod-foo-b-nonrel.ko kernel/mod-foo-a-rel.ko kernel/mod-foo-c.ko
+kernel/mod-foo-a-rel.ko:
new file mode 100644
new file mode 100644
new file mode 100644
@@ -0,0 +1,10 @@
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-c.ko needs unknown symbol __fentry__
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-c.ko needs unknown symbol printk
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-c.ko needs unknown symbol module_layout
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-b-nonrel.ko needs unknown symbol __fentry__
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-b-nonrel.ko needs unknown symbol printk
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-b-nonrel.ko needs unknown symbol module_layout
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo.ko needs unknown symbol module_layout
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-a-rel.ko needs unknown symbol __fentry__
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-a-rel.ko needs unknown symbol printk
+depmod: WARNING: /lib/modules/4.4.4/kernel/mod-foo-a-rel.ko needs unknown symbol module_layout
@@ -183,4 +183,34 @@ DEFINE_TEST(depmod_search_order_external_last,
},
});
+#define RELOCATED_CRC_ROOTFS TESTSUITE_ROOTFS "test-depmod/relocated-crc"
+static noreturn int relocated_crc(const struct test *t)
+{
+ const char *progname = ABS_TOP_BUILDDIR "/tools/depmod";
+ const char *const args[] = {
+ progname,
+ "-aeE",
+ "/boot/symvers",
+ NULL,
+ };
+
+ test_spawn_prog(progname, args);
+ exit(EXIT_FAILURE);
+}
+DEFINE_TEST(relocated_crc,
+ .description = "check if depmod understand both relocated and non-relocated crcs",
+ .print_outputs = true,
+ .config = {
+ [TC_UNAME_R] = "4.4.4",
+ [TC_ROOTFS] = RELOCATED_CRC_ROOTFS,
+ },
+ .output = {
+ .err = RELOCATED_CRC_ROOTFS "/output.err",
+ .files = (const struct keyval[]) {
+ { RELOCATED_CRC_ROOTFS "/lib/modules/4.4.4/correct-modules.dep",
+ RELOCATED_CRC_ROOTFS "/lib/modules/4.4.4/modules.dep" },
+ { }
+ },
+ });
+
TESTSUITE_MAIN();