History

modpost: fix removing numeric suffixes

With the `-z unique-symbol` linker flag or any similar mechanism, it is possible to trigger the following: ERROR: modpost: "param_set_uint.0" [vmlinux] is a static EXPORT_SYMBOL The reason is that for now the condition from remove_dot(): if (m && (s[n + m] == '.' || s[n + m] == 0)) which was designed to test if it's a dot or a '\0' after the suffix is never satisfied. This is due to that `s[n + m]` always points to the last digit of a numeric suffix, not on the symbol next to it (from a custom debug print added to modpost): param_set_uint.0, s[n + m] is '0', s[n + m + 1] is '\0' So it's off-by-one and was like that since 2014. Fix this for the sake of any potential upcoming features, but don't bother stable-backporting, as it's well hidden -- apart from that LD flag, it can be triggered only with GCC LTO which never landed upstream.

Alexander Lobakin committed 4 years ago

Commit b5beffa1 parent 8d3a7501 file · +1 −1Browse files

Unified · Split

scripts/mod/modpost.c+1−1
@@ -1906,7 +1906,7 @@ static char *remove_dot(char *s) · 1905 unmodified lines
1906 1906
1907 if (n && s[n]) {1907 if (n && s[n]) {
1908 size_t m = strspn(s + n + 1, "0123456789");1908 size_t m = strspn(s + n + 1, "0123456789");
1909 if (m && (s[n + m] == '.' || s[n + m] == 0))1909 if (m && (s[n + m + 1] == '.' || s[n + m + 1] == 0))
1910 s[n] = 0;1910 s[n] = 0;
1911 1911
1912 /* strip trailing .prelink */1912 /* strip trailing .prelink */