[1/2] modpost: add switch to skip symbol exclusions likely to generate false positives
diff mbox series

Message ID 20181020131911.22443-2-paul.walmsley@sifive.com
State Superseded
Headers show
  • modpost: skip section mismatch warnings on ELF local symbols by default
Related show

Commit Message

Paul Walmsley Oct. 20, 2018, 1:19 p.m. UTC
modpost uses symbol name whitelist patterns to determine whether
symbols should be excluded from section mismatch tests.  Since ELF
local symbols, empty symbol names, and ARM toolchain "magic" symbols
have autogenerated symbol names, they can trigger false positive
warnings for section mismatches, and are thus excluded from the
modpost section mismatch scan.  However, it seems useful to have the
option to include these autogenerated symbols in some section mismatch
scans, as an indicator that a patch set could require more attention
during review.  To that end, this patch adds a '-P' flag to modpost
that disables the filters that exclude autogenerated and empty symbol

Cc: Masahiro Yamada <yamada.masahiro@socionext.com>
Cc: Michal Marek <michal.lkml@markovi.net>
Cc: Jim Wilson <jimw@sifive.com>
Cc: linux-kbuild@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Paul Walmsley <paul.walmsley@sifive.com>
Signed-off-by: Paul Walmsley <paul@pwsan.com>
 scripts/mod/modpost.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff mbox series

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 0d998c54564d..38fc1bd47926 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -39,6 +39,8 @@  static int sec_mismatch_verbose = 1;
 static int sec_mismatch_fatal = 0;
 /* ignore missing files */
 static int ignore_missing_files;
+/* accept checks which are more likely to generate false positives if set to 1 */
+static int accept_falsepos_risk;
 enum export {
 	export_plain,      export_unused,     export_gpl,
@@ -1292,7 +1294,7 @@  static Elf_Sym *find_elf_symbol2(struct elf_info *elf, Elf_Addr addr,
 		symsec = sec_name(elf, get_secindex(elf, sym));
 		if (strcmp(symsec, sec) != 0)
-		if (!is_valid_name(elf, sym))
+		if (!accept_falsepos_risk && !is_valid_name(elf, sym))
 		if (sym->st_value <= addr) {
 			if ((addr - sym->st_value) < distance) {
@@ -2416,7 +2418,7 @@  int main(int argc, char **argv)
 	struct ext_sym_list *extsym_iter;
 	struct ext_sym_list *extsym_start = NULL;
-	while ((opt = getopt(argc, argv, "i:I:e:mnsST:o:awM:K:E")) != -1) {
+	while ((opt = getopt(argc, argv, "i:I:e:mnPsST:o:awM:K:E")) != -1) {
 		switch (opt) {
 		case 'i':
 			kernel_read = optarg;
@@ -2442,6 +2444,9 @@  int main(int argc, char **argv)
 		case 'o':
 			dump_write = optarg;
+		case 'P':
+			accept_falsepos_risk = 1;
+			break;
 		case 'a':
 			all_versions = 1;