# make distclean Remove editor backup files, patch leftover files and the like
 
 # Directories & files removed with 'make clean'
-CLEAN_FILES += include/ksym vmlinux.symvers \
+CLEAN_FILES += include/ksym vmlinux.symvers modules-only.symvers \
               modules.builtin modules.builtin.modinfo modules.nsdeps \
               compile_commands.json .thinlto-cache
 
 
 ifeq ($(KBUILD_EXTMOD),)
 
 input-symdump := vmlinux.symvers
-output-symdump := Module.symvers
+output-symdump := modules-only.symvers
+
+quiet_cmd_cat = GEN     $@
+      cmd_cat = cat $(real-prereqs) > $@
+
+ifneq ($(wildcard vmlinux.symvers),)
+
+__modpost: Module.symvers
+Module.symvers: vmlinux.symvers modules-only.symvers FORCE
+       $(call if_changed,cat)
+
+targets += Module.symvers
+
+endif
 
 else
 
 
        fatal("parse error in symbol dump file\n");
 }
 
-/* For normal builds always dump all symbols.
- * For external modules only dump symbols
- * that are not read from kernel Module.symvers.
- **/
-static int dump_sym(struct symbol *sym)
-{
-       if (!external_module)
-               return 1;
-       if (sym->module->from_dump)
-               return 0;
-       return 1;
-}
-
 static void write_dump(const char *fname)
 {
        struct buffer buf = { };
        for (n = 0; n < SYMBOL_HASH_SIZE ; n++) {
                symbol = symbolhash[n];
                while (symbol) {
-                       if (dump_sym(symbol)) {
+                       if (!symbol->module->from_dump) {
                                namespace = symbol->namespace;
                                buf_printf(&buf, "0x%08x\t%s\t%s\t%s\t%s\n",
                                           symbol->crc, symbol->name,