Skip to content

Commit f177cd0

Browse files
Uwe Kleine-Königmasahir0y
Uwe Kleine-König
authored andcommitted
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 0db2524 ("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. Signed-off-by: Uwe Kleine-König <[email protected]> Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 15e8664 commit f177cd0

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

Diff for: scripts/mod/modpost.c

+13-2
Original file line numberDiff line numberDiff line change
@@ -1015,9 +1015,20 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
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

0 commit comments

Comments
 (0)