Commit f177cd0c authored by Uwe Kleine-König's avatar Uwe Kleine-König Committed by Masahiro Yamada
Browse files

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 0db25245 ("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: default avatarUwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
parent 15e86643
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1015,9 +1015,20 @@ static int secref_whitelist(const char *fromsec, const char *fromsym,
				    "*_console")))
		return 0;

	/* symbols in data sections that may refer to meminit/exit sections */
	/* symbols in data sections that may refer to meminit sections */
	if (match(fromsec, PATTERNS(DATA_SECTIONS)) &&
	    match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_EXIT_SECTIONS)) &&
	    match(tosec, PATTERNS(ALL_XXXINIT_SECTIONS, ALL_XXXEXIT_SECTIONS)) &&
	    match(fromsym, PATTERNS("*driver")))
		return 0;

	/*
	 * symbols in data sections must not refer to .exit.*, but there are
	 * quite a few offenders, so hide these unless for W=1 builds until
	 * these are fixed.
	 */
	if (!extra_warn &&
	    match(fromsec, PATTERNS(DATA_SECTIONS)) &&
	    match(tosec, PATTERNS(EXIT_SECTIONS)) &&
	    match(fromsym, PATTERNS("*driver")))
		return 0;