Internally used symbols of modpost don't need to be externally visible; make them static. Also constify the string arrays so they resist in the r/o section instead of being runtime writable. Those changes lead to a small size reduction as can be seen below: text data bss dec hex filename 51381 2640 12416 66437 10385 scripts/mod/modpost.old 51765 2224 12416 66405 10365 scripts/mod/modpost.new
Showing the changes to scripts/mod (1 of 1 file). Show all
Unified · Split
| @@ -24,9 +24,9 @@ · 23 unmodified lines | ||
| 24 | 24 | #include "../../include/linux/export.h" |
| 25 | 25 | |
| 26 | 26 | /* Are we using CONFIG_MODVERSIONS? */ |
| 27 | −int modversions = 0; | |
| 27 | +static int modversions = 0; | |
| 28 | 28 | /* Warn about undefined symbols? (do so if we have vmlinux) */ |
| 29 | −int have_vmlinux = 0; | |
| 29 | +static int have_vmlinux = 0; | |
| 30 | 30 | /* Is CONFIG_MODULE_SRCVERSION_ALL set? */ |
| 31 | 31 | static int all_versions = 0; |
| 32 | 32 | /* If we are modposting external module set to 1 */ |
| @@ -229,7 +229,7 @@ static struct symbol *find_symbol(const char *name) · 196 unmodified lines | ||
| 229 | 229 | return NULL; |
| 230 | 230 | } |
| 231 | 231 | |
| 232 | −static struct { | |
| 232 | +static const struct { | |
| 233 | 233 | const char *str; |
| 234 | 234 | enum export export; |
| 235 | 235 | } export_list[] = { |
| @@ -805,7 +805,7 @@ static int match(const char *sym, const char * const pat[]) · 569 unmodified lines | ||
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | /* sections that we do not want to do full section mismatch check on */ |
| 808 | −static const char *section_white_list[] = | |
| 808 | +static const char *const section_white_list[] = | |
| 809 | 809 | { |
| 810 | 810 | ".comment*", |
| 811 | 811 | ".debug*", |
| @@ -882,17 +882,18 @@ static void check_section(const char *modname, struct elf_info *elf, · 70 unmodified lines | ||
| 882 | 882 | #define MEM_EXIT_SECTIONS ".memexit.*" |
| 883 | 883 | |
| 884 | 884 | /* init data sections */ |
| 885 | −static const char *init_data_sections[] = { ALL_INIT_DATA_SECTIONS, NULL }; | |
| 885 | +static const char *const init_data_sections[] = | |
| 886 | + { ALL_INIT_DATA_SECTIONS, NULL }; | |
| 886 | 887 | |
| 887 | 888 | /* all init sections */ |
| 888 | −static const char *init_sections[] = { ALL_INIT_SECTIONS, NULL }; | |
| 889 | +static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL }; | |
| 889 | 890 | |
| 890 | 891 | /* All init and exit sections (code + data) */ |
| 891 | −static const char *init_exit_sections[] = | |
| 892 | +static const char *const init_exit_sections[] = | |
| 892 | 893 | {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }; |
| 893 | 894 | |
| 894 | 895 | /* data section */ |
| 895 | −static const char *data_sections[] = { DATA_SECTIONS, NULL }; | |
| 896 | +static const char *const data_sections[] = { DATA_SECTIONS, NULL }; | |
| 896 | 897 | |
| 897 | 898 | |
| 898 | 899 | /* symbols in .data that may refer to init/exit sections */ |
| @@ -906,8 +907,8 @@ static const char *data_sections[] = { DATA_SECTIONS, NULL }; · 7 unmodified lines | ||
| 906 | 907 | "*_probe_one", \ |
| 907 | 908 | "*_console" |
| 908 | 909 | |
| 909 | −static const char *head_sections[] = { ".head.text*", NULL }; | |
| 910 | −static const char *linker_symbols[] = | |
| 910 | +static const char *const head_sections[] = { ".head.text*", NULL }; | |
| 911 | +static const char *const linker_symbols[] = | |
| 911 | 912 | { "__init_begin", "_sinittext", "_einittext", NULL }; |
| 912 | 913 | |
| 913 | 914 | enum mismatch { |
| @@ -929,7 +930,7 @@ struct sectioncheck { · 15 unmodified lines | ||
| 929 | 930 | const char *symbol_white_list[20]; |
| 930 | 931 | }; |
| 931 | 932 | |
| 932 | −const struct sectioncheck sectioncheck[] = { | |
| 933 | +static const struct sectioncheck sectioncheck[] = { | |
| 933 | 934 | /* Do not reference init/exit code/data from |
| 934 | 935 | * normal code and data |
| 935 | 936 | */ |