aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorMathias Krause <minipli@googlemail.com>2014-08-27 06:58:53 -0400
committerRusty Russell <rusty@rustcorp.com.au>2014-08-27 08:24:10 -0400
commit7a3ee7538598e0d60e6aa87dcf34a4e8a0adebc2 (patch)
treef8cace0f731f4066b3670c79bca2b4a7a2005825 /scripts
parent7a486d3781295b5298cbf9556928a76d26896863 (diff)
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 Signed-off-by: Mathias Krause <minipli@googlemail.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'scripts')
-rw-r--r--scripts/mod/modpost.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 091d90573b63..c2ebdc788f4c 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -24,9 +24,9 @@
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)
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[])
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,
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 };
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 {
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 from 934/* Do not reference init/exit code/data from
934 * normal code and data 935 * normal code and data
935 */ 936 */