Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

modpost: improve the section mismatch warning format

This commit improves the section mismatch warning format when there is
no suitable symbol name to print.

The section mismatch warning prints the reference source in the form
of <symbol_name>+<offset> and the reference destination in the form
of <symbol_name>.

However, there are some corner cases where <symbol_name> becomes
"(unknown)", as reported in commit 23dfd914d2bf ("modpost: fix null
pointer dereference").

In such cases, it is better to print the symbol address.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

+13 -8
+13 -8
scripts/mod/modpost.c
··· 697 697 698 698 static const char *sym_name(struct elf_info *elf, Elf_Sym *sym) 699 699 { 700 - if (sym) 701 - return elf->strtab + sym->st_name; 702 - else 703 - return "(unknown)"; 700 + return sym ? elf->strtab + sym->st_name : ""; 704 701 } 705 702 706 703 /* ··· 1010 1013 Elf_Sym *from; 1011 1014 const char *tosym; 1012 1015 const char *fromsym; 1016 + char taddr_str[16]; 1013 1017 1014 1018 from = find_fromsym(elf, faddr, fsecndx); 1015 1019 fromsym = sym_name(elf, from); ··· 1024 1026 1025 1027 sec_mismatch_count++; 1026 1028 1027 - warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n", 1028 - modname, fromsym, 1029 - (unsigned int)(faddr - (from ? from->st_value : 0)), 1030 - fromsec, tosym, tosec); 1029 + if (!tosym[0]) 1030 + snprintf(taddr_str, sizeof(taddr_str), "0x%x", (unsigned int)taddr); 1031 + 1032 + /* 1033 + * The format for the reference source: <symbol_name>+<offset> or <address> 1034 + * The format for the reference destination: <symbol_name> or <address> 1035 + */ 1036 + warn("%s: section mismatch in reference: %s%s0x%x (section: %s) -> %s (section: %s)\n", 1037 + modname, fromsym, fromsym[0] ? "+" : "", 1038 + (unsigned int)(faddr - (fromsym[0] ? from->st_value : 0)), 1039 + fromsec, tosym[0] ? tosym : taddr_str, tosec); 1031 1040 1032 1041 if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) { 1033 1042 if (match(tosec, mismatch->bad_tosec))