kernel: bump 6.1 to 6.1.35
[openwrt/openwrt.git] / target / linux / generic / hack-6.1 / 204-module_strip.patch
index dd5d93e22673e710e0966798802c2a2096639fe2..f0949d32fddd197a2cfd3b0636793e6fa5b134cd 100644 (file)
@@ -14,7 +14,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 
 --- a/include/linux/module.h
 +++ b/include/linux/module.h
-@@ -164,6 +164,7 @@ extern void cleanup_module(void);
+@@ -163,6 +163,7 @@ extern void cleanup_module(void);
  
  /* Generic info of form tag = "info" */
  #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
@@ -22,7 +22,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
  /* For userspace: you can also call me... */
  #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)
-@@ -233,12 +234,12 @@ extern void cleanup_module(void);
+@@ -232,12 +233,12 @@ extern void cleanup_module(void);
   * Author(s), use "Name <email>" or just "Name", for multiple
   * authors use multiple MODULE_AUTHOR() statements/lines.
   */
@@ -38,7 +38,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  /* Creates an alias so file2alias.c can find device table. */
  #define MODULE_DEVICE_TABLE(type, name)                                       \
  extern typeof(name) __mod_##type##__##name##_device_table             \
-@@ -265,7 +266,9 @@ extern typeof(name) __mod_##type##__##na
+@@ -264,7 +265,9 @@ extern typeof(name) __mod_##type##__##na
   */
  
  #if defined(MODULE) || !defined(CONFIG_SYSFS)
@@ -49,14 +49,14 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  #else
  #define MODULE_VERSION(_version)                                      \
        MODULE_INFO(version, _version);                                 \
-@@ -288,7 +291,7 @@ extern typeof(name) __mod_##type##__##na
+@@ -287,7 +290,7 @@ extern typeof(name) __mod_##type##__##na
  /* Optional firmware file (or files) needed by the module
   * format is simply firmware file name.  Multiple firmware
   * files require multiple MODULE_FIRMWARE() specifiers */
 -#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)
 +#define MODULE_FIRMWARE(_firmware) MODULE_INFO_STRIP(firmware, _firmware)
  
- #define MODULE_IMPORT_NS(ns) MODULE_INFO(import_ns, #ns)
+ #define MODULE_IMPORT_NS(ns)  MODULE_INFO(import_ns, __stringify(ns))
  
 --- a/include/linux/moduleparam.h
 +++ b/include/linux/moduleparam.h
@@ -86,11 +86,11 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
  struct kernel_param;
  
---- a/init/Kconfig
-+++ b/init/Kconfig
-@@ -2356,6 +2356,13 @@ config UNUSED_KSYMS_WHITELIST
-         one per line. The path can be absolute, or relative to the kernel
-         source tree.
+--- a/kernel/module/Kconfig
++++ b/kernel/module/Kconfig
+@@ -290,4 +290,11 @@ config MODULES_TREE_LOOKUP
+       def_bool y
+       depends on PERF_EVENTS || TRACING || CFI_CLANG
  
 +config MODULE_STRIPPED
 +      bool "Reduce module size"
@@ -100,27 +100,25 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
 +        device tables, etc.
 +
  endif # MODULES
- config MODULES_TREE_LOOKUP
---- a/kernel/module.c
-+++ b/kernel/module.c
-@@ -1218,6 +1218,7 @@ static struct module_attribute *modinfo_
+--- a/kernel/module/main.c
++++ b/kernel/module/main.c
+@@ -988,6 +988,7 @@ size_t modinfo_attrs_count = ARRAY_SIZE(
  
  static const char vermagic[] = VERMAGIC_STRING;
  
 +#if defined(CONFIG_MODVERSIONS) || !defined(CONFIG_MODULE_STRIPPED)
static int try_to_force_load(struct module *mod, const char *reason)
+ int try_to_force_load(struct module *mod, const char *reason)
  {
  #ifdef CONFIG_MODULE_FORCE_LOAD
-@@ -1229,6 +1230,7 @@ static int try_to_force_load(struct modu
+@@ -999,6 +1000,7 @@ int try_to_force_load(struct module *mod
        return -ENOEXEC;
  #endif
  }
 +#endif
  
- #ifdef CONFIG_MODVERSIONS
-@@ -3266,9 +3268,11 @@ static int setup_load_info(struct load_i
+ static char *get_modinfo(const struct load_info *info, const char *tag);
+ static char *get_next_modinfo(const struct load_info *info, const char *tag,
+@@ -1950,9 +1952,11 @@ static int setup_load_info(struct load_i
  
  static int check_modinfo(struct module *mod, struct load_info *info, int flags)
  {
@@ -133,7 +131,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        if (flags & MODULE_INIT_IGNORE_VERMAGIC)
                modmagic = NULL;
  
-@@ -3289,6 +3293,7 @@ static int check_modinfo(struct module *
+@@ -1973,6 +1977,7 @@ static int check_modinfo(struct module *
                                mod->name);
                add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);
        }
@@ -143,7 +141,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  
 --- a/scripts/mod/modpost.c
 +++ b/scripts/mod/modpost.c
-@@ -2036,7 +2036,9 @@ static void read_symbols(const char *mod
+@@ -1817,7 +1817,9 @@ static void read_symbols(const char *mod
                symname = remove_dot(info.strtab + sym->st_name);
  
                handle_symbol(mod, &info, sym, symname);
@@ -153,7 +151,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        }
  
        for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
-@@ -2215,8 +2217,10 @@ static void add_header(struct buffer *b,
+@@ -1980,8 +1982,10 @@ static void add_header(struct buffer *b,
        buf_printf(b, "BUILD_SALT;\n");
        buf_printf(b, "BUILD_LTO_INFO;\n");
        buf_printf(b, "\n");
@@ -164,29 +162,29 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
        buf_printf(b, "\n");
        buf_printf(b, "__visible struct module __this_module\n");
        buf_printf(b, "__section(\".gnu.linkonce.this_module\") = {\n");
-@@ -2233,8 +2237,10 @@ static void add_header(struct buffer *b,
+@@ -1995,8 +1999,10 @@ static void add_header(struct buffer *b,
+       buf_printf(b, "\t.arch = MODULE_ARCH_INIT,\n");
+       buf_printf(b, "};\n");
  
- static void add_intree_flag(struct buffer *b, int is_intree)
- {
 +#ifndef CONFIG_MODULE_STRIPPED
-       if (is_intree)
+       if (!external_module)
                buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");
 +#endif
- }
  
- /* Cannot check for assembler */
-@@ -2247,8 +2253,10 @@ static void add_retpoline(struct buffer
+       buf_printf(b,
+                  "\n"
+@@ -2004,8 +2010,10 @@ static void add_header(struct buffer *b,
+                  "MODULE_INFO(retpoline, \"Y\");\n"
+                  "#endif\n");
  
- static void add_staging_flag(struct buffer *b, const char *name)
- {
 +#ifndef CONFIG_MODULE_STRIPPED
-       if (strstarts(name, "drivers/staging"))
+       if (strstarts(mod->name, "drivers/staging"))
                buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");
 +#endif
- }
  
- /**
-@@ -2328,11 +2336,13 @@ static void add_depends(struct buffer *b
+       if (strstarts(mod->name, "tools/testing"))
+               buf_printf(b, "\nMODULE_INFO(test, \"Y\");\n");
+@@ -2101,11 +2109,13 @@ static void add_depends(struct buffer *b
  
  static void add_srcversion(struct buffer *b, struct module *mod)
  {
@@ -200,13 +198,13 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
  }
  
  static void write_buf(struct buffer *b, const char *fname)
-@@ -2581,7 +2591,9 @@ int main(int argc, char **argv)
-               add_staging_flag(&buf, mod->name);
-               add_versions(&buf, mod);
-               add_depends(&buf, mod);
+@@ -2191,7 +2201,9 @@ static void write_mod_c_file(struct modu
+       add_exported_symbols(&buf, mod);
+       add_versions(&buf, mod);
+       add_depends(&buf, mod);
 +#ifndef CONFIG_MODULE_STRIPPED
-               add_moddevtable(&buf, mod);
+       add_moddevtable(&buf, mod);
 +#endif
-               add_srcversion(&buf, mod);
+       add_srcversion(&buf, mod);
  
-               sprintf(fname, "%s.mod.c", mod->name);
+       ret = snprintf(fname, sizeof(fname), "%s.mod.c", mod->name);