History

modpost: reduce visibility of symbols and constify r/o arrays

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

Mathias Krause committed 12 years ago

Commit 7a3ee751 parent 7a486d31 file · +12 −11Browse files

Showing the changes to scripts/mod (1 of 1 file). Show all

Unified · Split

scripts/mod/modpost.c+12−11
@@ -24,9 +24,9 @@ · 23 unmodified lines
2424 #include "../../include/linux/export.h"
2525
2626 /* Are we using CONFIG_MODVERSIONS? */
27−int modversions = 0;
27+static int modversions = 0;
2828 /* Warn about undefined symbols? (do so if we have vmlinux) */
29−int have_vmlinux = 0;
29+static int have_vmlinux = 0;
3030 /* Is CONFIG_MODULE_SRCVERSION_ALL set? */
3131 static int all_versions = 0;
3232 /* If we are modposting external module set to 1 */
@@ -229,7 +229,7 @@ static struct symbol *find_symbol(const char *name) · 196 unmodified lines
229229 return NULL;
230230 }
231231
232−static struct {
232+static const struct {
233233 const char *str;
234234 enum export export;
235235 } export_list[] = {
@@ -805,7 +805,7 @@ static int match(const char *sym, const char * const pat[]) · 569 unmodified lines
805805 }
806806
807807 /* 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[] =
809809 {
810810 ".comment*",
811811 ".debug*",
@@ -882,17 +882,18 @@ static void check_section(const char *modname, struct elf_info *elf, · 70 unmodified lines
882882 #define MEM_EXIT_SECTIONS ".memexit.*"
883883
884884 /* 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 };
886887
887888 /* all init sections */
888−static const char *init_sections[] = { ALL_INIT_SECTIONS, NULL };
889+static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL };
889890
890891 /* All init and exit sections (code + data) */
891−static const char *init_exit_sections[] =
892+static const char *const init_exit_sections[] =
892893 {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
893894
894895 /* data section */
895−static const char *data_sections[] = { DATA_SECTIONS, NULL };
896+static const char *const data_sections[] = { DATA_SECTIONS, NULL };
896897
897898
898899 /* 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
906907 "*_probe_one", \
907908 "*_console"
908909
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[] =
911912 { "__init_begin", "_sinittext", "_einittext", NULL };
912913
913914 enum mismatch {
@@ -929,7 +930,7 @@ struct sectioncheck { · 15 unmodified lines
929930 const char *symbol_white_list[20];
930931 };
931932
932−const struct sectioncheck sectioncheck[] = {
933+static const struct sectioncheck sectioncheck[] = {
933934 /* Do not reference init/exit code/data from
934935 * normal code and data
935936 */