aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod/modpost.c
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2015-04-19 20:50:40 -0400
committerRusty Russell <rusty@rustcorp.com.au>2015-04-22 04:01:34 -0400
commit4a3893d069b788f3570c19c12d9e986e8e15870f (patch)
treef2b4c93e1239befe1acc257b683bbba6c1ef8ff1 /scripts/mod/modpost.c
parent09c20c032b0f753969ae778d9783d946f054d7fe (diff)
modpost: don't emit section mismatch warnings for compiler optimizations
Currently an allyesconfig build [gcc-4.9.1] can generate the following: WARNING: vmlinux.o(.text.unlikely+0x3864): Section mismatch in reference from the function cpumask_empty.constprop.3() to the variable .init.data:nmi_ipi_mask which comes from the cpumask_empty usage in arch/x86/kernel/nmi_selftest.c. Normally we would not see a symbol entry for cpumask_empty since it is: static inline bool cpumask_empty(const struct cpumask *srcp) however in this case, the variant of the symbol gets emitted when GCC does constant propagation optimization. Fix things up so that any locally optimized constprop variants don't warn when accessing variables that live in the __init sections. Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com> Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'scripts/mod/modpost.c')
-rw-r--r--scripts/mod/modpost.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 1c2101bf63d2..91ee1b2e0f9a 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -908,6 +908,9 @@ static const char *const init_sections[] = { ALL_INIT_SECTIONS, NULL };
908static const char *const init_exit_sections[] = 908static const char *const init_exit_sections[] =
909 {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL }; 909 {ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL };
910 910
911/* all text sections */
912static const char *const text_sections[] = { ALL_TEXT_SECTIONS, NULL };
913
911/* data section */ 914/* data section */
912static const char *const data_sections[] = { DATA_SECTIONS, NULL }; 915static const char *const data_sections[] = { DATA_SECTIONS, NULL };
913 916
@@ -926,6 +929,7 @@ static const char *const data_sections[] = { DATA_SECTIONS, NULL };
926static const char *const head_sections[] = { ".head.text*", NULL }; 929static const char *const head_sections[] = { ".head.text*", NULL };
927static const char *const linker_symbols[] = 930static const char *const linker_symbols[] =
928 { "__init_begin", "_sinittext", "_einittext", NULL }; 931 { "__init_begin", "_sinittext", "_einittext", NULL };
932static const char *const optim_symbols[] = { "*.constprop.*", NULL };
929 933
930enum mismatch { 934enum mismatch {
931 TEXT_TO_ANY_INIT, 935 TEXT_TO_ANY_INIT,
@@ -1136,6 +1140,17 @@ static const struct sectioncheck *section_mismatch(
1136 * This pattern is identified by 1140 * This pattern is identified by
1137 * refsymname = __init_begin, _sinittext, _einittext 1141 * refsymname = __init_begin, _sinittext, _einittext
1138 * 1142 *
1143 * Pattern 5:
1144 * GCC may optimize static inlines when fed constant arg(s) resulting
1145 * in functions like cpumask_empty() -- generating an associated symbol
1146 * cpumask_empty.constprop.3 that appears in the audit. If the const that
1147 * is passed in comes from __init, like say nmi_ipi_mask, we get a
1148 * meaningless section warning. May need to add isra symbols too...
1149 * This pattern is identified by
1150 * tosec = init section
1151 * fromsec = text section
1152 * refsymname = *.constprop.*
1153 *
1139 **/ 1154 **/
1140static int secref_whitelist(const struct sectioncheck *mismatch, 1155static int secref_whitelist(const struct sectioncheck *mismatch,
1141 const char *fromsec, const char *fromsym, 1156 const char *fromsec, const char *fromsym,
@@ -1168,6 +1183,12 @@ static int secref_whitelist(const struct sectioncheck *mismatch,
1168 if (match(tosym, linker_symbols)) 1183 if (match(tosym, linker_symbols))
1169 return 0; 1184 return 0;
1170 1185
1186 /* Check for pattern 5 */
1187 if (match(fromsec, text_sections) &&
1188 match(tosec, init_sections) &&
1189 match(fromsym, optim_symbols))
1190 return 0;
1191
1171 return 1; 1192 return 1;
1172} 1193}
1173 1194