History

modpost: Don't let "driver"s reference .exit.*

Drivers must not reference functions marked with __exit as these likely are not available when the code is built-in. There are few creative offenders uncovered for example in ARCH=amd64 allmodconfig builds. So only trigger the section mismatch warning for W=1 builds. The dual rule that drivers must not reference .init.* is implemented since commit 0db252452378 ("modpost: don't allow *driver to reference .init.*") which however missed that .exit.* should be handled in the same way. Thanks to Masahiro Yamada and Arnd Bergmann who gave valuable hints to find this improvement.

Uwe Kleine-König committed 3 years ago

Commit f177cd01 parent 15e86641 file · +13 −2Browse files

Unified · Split

scripts/mod/modpost.c+13−2
@@ -1015,9 +1015,20 @@ static int secref_whitelist(const char *fromsec, const char *fromsym, · 1014 unmodified lines
10151015 "*_console")))
10161016 return 0;
10171017
1018− /* symbols in data sections that may refer to meminit/exit sections */
1018+ /* symbols in data sections that may refer to meminit sections */
10191019 if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
1020− match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
1020+ match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_XXXEXIT_SECTIONS)) &&
1021+ match(fromsym, PATTERNS("*driver")))
1022+ return 0;
1023+
1024+ /*
1025+ * symbols in data sections must not refer to .exit.*, but there are
1026+ * quite a few offenders, so hide these unless for W=1 builds until
1027+ * these are fixed.
1028+ */
1029+ if (!extra_warn &&
1030+ match(fromsec, PATTERNS(DATA_SECTIONS)) &&
1031+ match(tosec, PATTERNS(EXIT_SECTIONS)) &&
10211032 match(fromsym, PATTERNS("*driver")))
10221033 return 0;
10231034