<html><head><meta http-equiv="content-type" content="text/html; charset=UTF-8"><style>body { line-height: 1.5; }blockquote { margin-top: 0px; margin-bottom: 0px; margin-left: 0.5em; }body { font-size: 10.5pt; font-family: 微软雅黑; color: rgb(0, 0, 0); line-height: 1.5; }</style></head><body>
<div><span style="font-size: 10.5pt; line-height: 1.5; background-color: transparent;">Build file drivers/net/ethernet/intel/e1000e/e1000e.ko size about 920KB for old PATCH.</span><span></span></div><div><span style="font-size: 10.5pt; line-height: 1.5; background-color: transparent;">After the new patch is about 177KB</span></div><div><span style="font-size: 10.5pt; line-height: 1.5; background-color: transparent;"><br></span></div><blockquote style="margin-Top: 0px; margin-Bottom: 0px; margin-Left: 0.5em"><div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm"><div style="PADDING-RIGHT: 8px; PADDING-LEFT: 8px; FONT-SIZE: 12px;FONT-FAMILY:tahoma;COLOR:#000000; BACKGROUND: #efefef; PADDING-BOTTOM: 8px; PADDING-TOP: 8px"><div><b>From:</b> <a href="mailto:hauke@hauke-m.de">Hauke Mehrtens</a></div><div><b>Date:</b> 2019-10-30 23:47</div><div><b>To:</b> <a href="mailto:lxliu@ikuai8.com">daxiong</a>; <a href="mailto:openwrt-devel@lists.openwrt.org">openwrt-devel</a></div><div><b>Subject:</b> Re: [OpenWrt-Devel] [PATCH-19.07] build: fix module strip invalid</div></div></div><div><div>On 10/30/19 11:14 AM, daxiong wrote:</div>
<div>> Current modpost cannot reduce the module size.</div>
<div>> </div>
<div>> Use $(STRIP) command to replace the modpost patch,</div>
<div>> I think to be compatibility will be better.</div>
<div>> </div>
<div>> Signed-off-by: daxiong <lxliu@ikuai8.com></div>
<div> </div>
<div>Please base this against master, then we can backport it to 19.07.</div>
<div> </div>
<div>Could you please elaborate a little bit more how module-strip provides</div>
<div>better results than the previous patch? It would be nice if you could</div>
<div>also provide some numbers to compare the previous size and the current size.</div>
<div> </div>
<div>Would it make sense to do both together, what was done in this patch</div>
<div>before and after your change?</div>
<div> </div>
<div>Hauke</div>
<div> </div>
<div>> ---</div>
<div>>  .../linux/generic/hack-4.14/204-module_strip.patch | 216 +++------------------</div>
<div>>  1 file changed, 24 insertions(+), 192 deletions(-)</div>
<div>> </div>
<div>> diff --git a/target/linux/generic/hack-4.14/204-module_strip.patch b/target/linux/generic/hack-4.14/204-module_strip.patch</div>
<div>> index d847adf..c22a507 100644</div>
<div>> --- a/target/linux/generic/hack-4.14/204-module_strip.patch</div>
<div>> +++ b/target/linux/generic/hack-4.14/204-module_strip.patch</div>
<div>> @@ -1,104 +1,8 @@</div>
<div>> -From a779a482fb9b9f8fcdf8b2519c789b4b9bb5dd05 Mon Sep 17 00:00:00 2001</div>
<div>> -From: Felix Fietkau <nbd@nbd.name></div>
<div>> -Date: Fri, 7 Jul 2017 16:56:48 +0200</div>
<div>> -Subject: build: add a hack for removing non-essential module info</div>
<div>> -</div>
<div>> -Signed-off-by: Felix Fietkau <nbd@nbd.name></div>
<div>> ----</div>
<div>> - include/linux/module.h      | 13 ++++++++-----</div>
<div>> - include/linux/moduleparam.h | 15 ++++++++++++---</div>
<div>> - init/Kconfig                |  7 +++++++</div>
<div>> - kernel/module.c             |  5 ++++-</div>
<div>> - scripts/mod/modpost.c       | 12 ++++++++++++</div>
<div>> - 5 files changed, 43 insertions(+), 9 deletions(-)</div>
<div>> -</div>
<div>> ---- a/include/linux/module.h</div>
<div>> -+++ b/include/linux/module.h</div>
<div>> -@@ -158,6 +158,7 @@ extern void cleanup_module(void);</div>
<div>> - </div>
<div>> - /* Generic info of form tag = "info" */</div>
<div>> - #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)</div>
<div>> -+#define MODULE_INFO_STRIP(tag, info) __MODULE_INFO_STRIP(tag, tag, info)</div>
<div>> - </div>
<div>> - /* For userspace: you can also call me... */</div>
<div>> - #define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias)</div>
<div>> -@@ -201,12 +202,12 @@ extern void cleanup_module(void);</div>
<div>> -  * Author(s), use "Name <email>" or just "Name", for multiple</div>
<div>> -  * authors use multiple MODULE_AUTHOR() statements/lines.</div>
<div>> -  */</div>
<div>> --#define MODULE_AUTHOR(_author) MODULE_INFO(author, _author)</div>
<div>> -+#define MODULE_AUTHOR(_author) MODULE_INFO_STRIP(author, _author)</div>
<div>> - </div>
<div>> - /* What your module does. */</div>
<div>> --#define MODULE_DESCRIPTION(_description) MODULE_INFO(description, _description)</div>
<div>> -+#define MODULE_DESCRIPTION(_description) MODULE_INFO_STRIP(description, _description)</div>
<div>> - </div>
<div>> --#ifdef MODULE</div>
<div>> -+#if defined(MODULE) && !defined(CONFIG_MODULE_STRIPPED)</div>
<div>> - /* Creates an alias so file2alias.c can find device table. */</div>
<div>> - #define MODULE_DEVICE_TABLE(type, name)                                       \</div>
<div>> - extern typeof(name) __mod_##type##__##name##_device_table             \</div>
<div>> -@@ -233,7 +234,9 @@ extern typeof(name) __mod_##type##__##na</div>
<div>> -  */</div>
<div>> - </div>
<div>> - #if defined(MODULE) || !defined(CONFIG_SYSFS)</div>
<div>> --#define MODULE_VERSION(_version) MODULE_INFO(version, _version)</div>
<div>> -+#define MODULE_VERSION(_version) MODULE_INFO_STRIP(version, _version)</div>
<div>> -+#elif defined(CONFIG_MODULE_STRIPPED)</div>
<div>> -+#define MODULE_VERSION(_version) __MODULE_INFO_DISABLED(version)</div>
<div>> - #else</div>
<div>> - #define MODULE_VERSION(_version)                                      \</div>
<div>> -       static struct module_version_attribute ___modver_attr = {       \</div>
<div>> -@@ -255,7 +258,7 @@ extern typeof(name) __mod_##type##__##na</div>
<div>> - /* Optional firmware file (or files) needed by the module</div>
<div>> -  * format is simply firmware file name.  Multiple firmware</div>
<div>> -  * files require multiple MODULE_FIRMWARE() specifiers */</div>
<div>> --#define MODULE_FIRMWARE(_firmware) MODULE_INFO(firmware, _firmware)</div>
<div>> -+#define MODULE_FIRMWARE(_firmware) MODULE_INFO_STRIP(firmware, _firmware)</div>
<div>> - </div>
<div>> - struct notifier_block;</div>
<div>> - </div>
<div>> ---- a/include/linux/moduleparam.h</div>
<div>> -+++ b/include/linux/moduleparam.h</div>
<div>> -@@ -17,6 +17,16 @@</div>
<div>> - /* Chosen so that structs with an unsigned long line up. */</div>
<div>> - #define MAX_PARAM_PREFIX_LEN (64 - sizeof(unsigned long))</div>
<div>> - </div>
<div>> -+/* This struct is here for syntactic coherency, it is not used */</div>
<div>> -+#define __MODULE_INFO_DISABLED(name)                                    \</div>
<div>> -+  struct __UNIQUE_ID(name) {}</div>
<div>> -+</div>
<div>> -+#ifdef CONFIG_MODULE_STRIPPED</div>
<div>> -+#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO_DISABLED(name)</div>
<div>> -+#else</div>
<div>> -+#define __MODULE_INFO_STRIP(tag, name, info) __MODULE_INFO(tag, name, info)</div>
<div>> -+#endif</div>
<div>> -+</div>
<div>> - #ifdef MODULE</div>
<div>> - #define __MODULE_INFO(tag, name, info)                                          \</div>
<div>> - static const char __UNIQUE_ID(name)[]                                   \</div>
<div>> -@@ -24,8 +34,7 @@ static const char __UNIQUE_ID(name)[]</div>
<div>> -   = __stringify(tag) "=" info</div>
<div>> - #else  /* !MODULE */</div>
<div>> - /* This struct is here for syntactic coherency, it is not used */</div>
<div>> --#define __MODULE_INFO(tag, name, info)                                          \</div>
<div>> --  struct __UNIQUE_ID(name) {}</div>
<div>> -+#define __MODULE_INFO(tag, name, info) __MODULE_INFO_DISABLED(name)</div>
<div>> - #endif</div>
<div>> - #define __MODULE_PARM_TYPE(name, _type)                                         \</div>
<div>> -   __MODULE_INFO(parmtype, name##type, #name ":" _type)</div>
<div>> -@@ -33,7 +42,7 @@ static const char __UNIQUE_ID(name)[]</div>
<div>> - /* One for each parameter, describing how to use it.  Some files do</div>
<div>> -    multiple of these per line, so can't just use MODULE_INFO. */</div>
<div>> - #define MODULE_PARM_DESC(_parm, desc) \</div>
<div>> --      __MODULE_INFO(parm, _parm, #_parm ":" desc)</div>
<div>> -+      __MODULE_INFO_STRIP(parm, _parm, #_parm ":" desc)</div>
<div>> - </div>
<div>> - struct kernel_param;</div>
<div>> - </div>
<div>> +diff --git a/init/Kconfig b/init/Kconfig</div>
<div>> +index 4607532..cba0f81 100644</div>
<div>>  --- a/init/Kconfig</div>
<div>>  +++ b/init/Kconfig</div>
<div>> -@@ -1903,6 +1903,13 @@ config TRIM_UNUSED_KSYMS</div>
<div>> +@@ -1883,6 +1883,13 @@ config TRIM_UNUSED_KSYMS</div>
<div>>   </div>
<div>>         If unsure, or if you need to build out-of-tree modules, say N.</div>
<div>>   </div>
<div>> @@ -112,97 +16,25 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name></div>
<div>>   endif # MODULES</div>
<div>>   </div>
<div>>   config MODULES_TREE_LOOKUP</div>
<div>> ---- a/kernel/module.c</div>
<div>> -+++ b/kernel/module.c</div>
<div>> -@@ -3020,9 +3020,11 @@ static struct module *setup_load_info(st</div>
<div>> - </div>
<div>> - static int check_modinfo(struct module *mod, struct load_info *info, int flags)</div>
<div>> - {</div>
<div>> --      const char *modmagic = get_modinfo(info, "vermagic");</div>
<div>> -       int err;</div>
<div>> - </div>
<div>> -+#ifndef CONFIG_MODULE_STRIPPED</div>
<div>> -+      const char *modmagic = get_modinfo(info, "vermagic");</div>
<div>> +diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include</div>
<div>> +index a33fa1a..34b34e0 100644</div>
<div>> +--- a/scripts/Kbuild.include</div>
<div>> ++++ b/scripts/Kbuild.include</div>
<div>> +@@ -260,11 +260,16 @@ make-cmd = $(call escsq,$(subst $(pound),$$(pound),$(subst $$,$$$$,$(cmd_$(1))))</div>
<div>> + # PHONY targets skipped in both cases.</div>
<div>> + any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)</div>
<div>> + </div>
<div>> ++ifeq ($(CONFIG_MODULE_STRIPPED),y)</div>
<div>> ++      module-strip = s=$@; if [ "$${s//*.}" = "ko" ];then $(STRIP) -g -S -d --strip-unneeded $@ ;fi</div>
<div>> ++endif</div>
<div>>  +</div>
<div>> -       if (flags & MODULE_INIT_IGNORE_VERMAGIC)</div>
<div>> -               modmagic = NULL;</div>
<div>> - </div>
<div>> -@@ -3043,6 +3045,7 @@ static int check_modinfo(struct module *</div>
<div>> -                               mod->name);</div>
<div>> -               add_taint_module(mod, TAINT_OOT_MODULE, LOCKDEP_STILL_OK);</div>
<div>> -       }</div>
<div>> -+#endif</div>
<div>> - </div>
<div>> -       check_modinfo_retpoline(mod, info);</div>
<div>> - </div>
<div>> ---- a/scripts/mod/modpost.c</div>
<div>> -+++ b/scripts/mod/modpost.c</div>
<div>> -@@ -1984,7 +1984,9 @@ static void read_symbols(char *modname)</div>
<div>> -               symname = remove_dot(info.strtab + sym->st_name);</div>
<div>> - </div>
<div>> -               handle_modversions(mod, &info, sym, symname);</div>
<div>> -+#ifndef CONFIG_MODULE_STRIPPED</div>
<div>> -               handle_moddevtable(mod, &info, sym, symname);</div>
<div>> -+#endif</div>
<div>> -       }</div>
<div>> -       if (!is_vmlinux(modname) ||</div>
<div>> -            (is_vmlinux(modname) && vmlinux_section_warnings))</div>
<div>> -@@ -2145,8 +2147,10 @@ static void add_header(struct buffer *b,</div>
<div>> -       buf_printf(b, "#include <linux/vermagic.h>\n");</div>
<div>> -       buf_printf(b, "#include <linux/compiler.h>\n");</div>
<div>> -       buf_printf(b, "\n");</div>
<div>> -+#ifndef CONFIG_MODULE_STRIPPED</div>
<div>> -       buf_printf(b, "MODULE_INFO(vermagic, VERMAGIC_STRING);\n");</div>
<div>> -       buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");</div>
<div>> -+#endif</div>
<div>> -       buf_printf(b, "\n");</div>
<div>> -       buf_printf(b, "__visible struct module __this_module\n");</div>
<div>> -       buf_printf(b, "__attribute__((section(\".gnu.linkonce.this_module\"))) = {\n");</div>
<div>> -@@ -2163,8 +2167,10 @@ static void add_header(struct buffer *b,</div>
<div>> - </div>
<div>> - static void add_intree_flag(struct buffer *b, int is_intree)</div>
<div>> - {</div>
<div>> -+#ifndef CONFIG_MODULE_STRIPPED</div>
<div>> -       if (is_intree)</div>
<div>> -               buf_printf(b, "\nMODULE_INFO(intree, \"Y\");\n");</div>
<div>> -+#endif</div>
<div>> - }</div>
<div>> - </div>
<div>> - /* Cannot check for assembler */</div>
<div>> -@@ -2177,10 +2183,12 @@ static void add_retpoline(struct buffer</div>
<div>> - </div>
<div>> - static void add_staging_flag(struct buffer *b, const char *name)</div>
<div>> - {</div>
<div>> -+#ifndef CONFIG_MODULE_STRIPPED</div>
<div>> -       static const char *staging_dir = "drivers/staging";</div>
<div>> - </div>
<div>> -       if (strncmp(staging_dir, name, strlen(staging_dir)) == 0)</div>
<div>> -               buf_printf(b, "\nMODULE_INFO(staging, \"Y\");\n");</div>
<div>> -+#endif</div>
<div>> - }</div>
<div>> - </div>
<div>> - /**</div>
<div>> -@@ -2279,11 +2287,13 @@ static void add_depends(struct buffer *b</div>
<div>> - </div>
<div>> - static void add_srcversion(struct buffer *b, struct module *mod)</div>
<div>> - {</div>
<div>> -+#ifndef CONFIG_MODULE_STRIPPED</div>
<div>> -       if (mod->srcversion[0]) {</div>
<div>> -               buf_printf(b, "\n");</div>
<div>> -               buf_printf(b, "MODULE_INFO(srcversion, \"%s\");\n",</div>
<div>> -                          mod->srcversion);</div>
<div>> -       }</div>
<div>> -+#endif</div>
<div>> - }</div>
<div>> - </div>
<div>> - static void write_if_changed(struct buffer *b, const char *fname)</div>
<div>> -@@ -2520,7 +2530,9 @@ int main(int argc, char **argv)</div>
<div>> -               add_staging_flag(&buf, mod->name);</div>
<div>> -               err |= add_versions(&buf, mod);</div>
<div>> -               add_depends(&buf, mod, modules);</div>
<div>> -+#ifndef CONFIG_MODULE_STRIPPED</div>
<div>> -               add_moddevtable(&buf, mod);</div>
<div>> -+#endif</div>
<div>> -               add_srcversion(&buf, mod);</div>
<div>> - </div>
<div>> -               sprintf(fname, "%s.mod.c", mod->name);</div>
<div>> + # Execute command if command has changed or prerequisite(s) are updated.</div>
<div>> + if_changed = $(if $(strip $(any-prereq) $(arg-check)),                       \</div>
<div>> +       @set -e;                                                             \</div>
<div>> +       $(echo-cmd) $(cmd_$(1));                                             \</div>
<div>> +-      printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:)</div>
<div>> ++      printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd, @:);      \</div>
<div>> ++      $(module-strip)</div>
<div>> + </div>
<div>> + # Execute the command and also postprocess generated .d dependencies file.</div>
<div>> + if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ),                  \</div>
<div>> </div>
<div> </div>
<div> </div>
</div></blockquote>
</body></html>