modpost: show offset from symbol for section mismatch warnings
authorMasahiro Yamada <masahiroy@kernel.org>
Sun, 11 Jun 2023 15:50:59 +0000 (00:50 +0900)
committerMasahiro Yamada <masahiroy@kernel.org>
Thu, 22 Jun 2023 12:21:06 +0000 (21:21 +0900)
Currently, modpost only shows the symbol names and section names, so it
repeats the same message if there are multiple relocations in the same
symbol. It is common the relocation spans across multiple instructions.

It is better to show the offset from the symbol.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>
scripts/mod/modpost.c

index c7faa455f97857d13eecc8875c139cfde50ad9f0..39cf43d61d518a918cb504a9febd634c71c3084c 100644 (file)
@@ -1147,8 +1147,8 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 
        sec_mismatch_count++;
 
-       warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
-            modname, fromsym, fromsec, tosym, tosec);
+       warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n",
+            modname, fromsym, (unsigned int)(faddr - from->st_value), fromsec, tosym, tosec);
 
        if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
                if (match(tosec, mismatch->bad_tosec))