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
24#include "../../include/linux/export.h"24#include "../../include/linux/export.h"
25 25
26/* Are we using CONFIG_MODVERSIONS? */26/* Are we using CONFIG_MODVERSIONS? */
27int modversions = 0;27static int modversions = 0;
28/* Warn about undefined symbols? (do so if we have vmlinux) */28/* Warn about undefined symbols? (do so if we have vmlinux) */
29int have_vmlinux = 0;29static int have_vmlinux = 0;
30/* Is CONFIG_MODULE_SRCVERSION_ALL set? */30/* Is CONFIG_MODULE_SRCVERSION_ALL set? */
31static int all_versions = 0;31static int all_versions = 0;
32/* If we are modposting external module set to 1 */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 return NULL;229 return NULL;
230}230}
231 231
232static struct {232static const struct {
233 const char *str;233 const char *str;
234 enum export export;234 enum export export;
235} export_list[] = {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/* sections that we do not want to do full section mismatch check on */807/* sections that we do not want to do full section mismatch check on */
808static const char *section_white_list[] =808static const char *const section_white_list[] =
809{809{
810 ".comment*",810 ".comment*",
811 ".debug*",811 ".debug*",
@@ -882,17 +882,18 @@ static void check_section(const char *modname, struct elf_info *elf, · 70 unmodified lines
882#define MEM_EXIT_SECTIONS ".memexit.*"882#define MEM_EXIT_SECTIONS ".memexit.*"
883 883
884/* init data sections */884/* init data sections */
885static const char *init_data_sections[] = { ALL_INIT_DATA_SECTIONS, NULL };885static const char *const init_data_sections[] =
886 { ALL_INIT_DATA_SECTIONS, NULL };
886 887
887/* all init sections */888/* all init sections */
888static const char *init_sections[] = { ALL_INIT_SECTIONS, NULL };889static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL };
889 890
890/* All init and exit sections (code + data) */891/* All init and exit sections (code + data) */
891static const char *init_exit_sections[] =892static const char *const init_exit_sections[] =
892 {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };893 {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
893 894
894/* data section */895/* data section */
895static const char *data_sections[] = { DATA_SECTIONS, NULL };896static const char *const data_sections[] = { DATA_SECTIONS, NULL };
896 897
897 898
898/* symbols in .data that may refer to init/exit sections */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 "*_probe_one", \907 "*_probe_one", \
907 "*_console"908 "*_console"
908 909
909static const char *head_sections[] = { ".head.text*", NULL };910static const char *const head_sections[] = { ".head.text*", NULL };
910static const char *linker_symbols[] =911static const char *const linker_symbols[] =
911 { "__init_begin", "_sinittext", "_einittext", NULL };912 { "__init_begin", "_sinittext", "_einittext", NULL };
912 913
913enum mismatch {914enum mismatch {
@@ -929,7 +930,7 @@ struct sectioncheck { · 15 unmodified lines
929 const char *symbol_white_list[20];930 const char *symbol_white_list[20];
930};931};
931 932
932const struct sectioncheck sectioncheck[] = {933static const struct sectioncheck sectioncheck[] = {
933/* Do not reference init/exit code/data from934/* Do not reference init/exit code/data from
934 * normal code and data935 * normal code and data
935 */936 */