[PATCH v6 19/20] modpost: merge two similar section mismatch warnings

Masahiro Yamada posted 20 patches 2 years, 8 months ago
There is a newer version of this series
[PATCH v6 19/20] modpost: merge two similar section mismatch warnings
Posted by Masahiro Yamada 2 years, 8 months ago
In case of section mismatch, modpost shows slightly different messages.

For extable section mismatch:

 "%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n"

For the other cases:

 "%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n"

They are similar. Merge them.

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

 scripts/mod/modpost.c | 18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 852cc164c77e..e7561fa57478 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1135,21 +1135,10 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 
 	sec_mismatch_count++;
 
-	switch (mismatch->mismatch) {
-	case TEXT_TO_ANY_INIT:
-	case DATA_TO_ANY_INIT:
-	case TEXTDATA_TO_ANY_EXIT:
-	case XXXINIT_TO_SOME_INIT:
-	case XXXEXIT_TO_SOME_EXIT:
-	case ANY_INIT_TO_ANY_EXIT:
-	case ANY_EXIT_TO_ANY_INIT:
-		warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
-		     modname, fromsym, fromsec, tosym, tosec);
-		break;
-	case EXTABLE_TO_NON_TEXT:
-		warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n",
-		     modname, fromsec, (long)faddr, tosec, tosym);
+	warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
+	     modname, fromsym, fromsec, tosym, tosec);
 
+	if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
 		if (match(tosec, mismatch->bad_tosec))
 			fatal("The relocation at %s+0x%lx references\n"
 			      "section \"%s\" which is black-listed.\n"
@@ -1169,7 +1158,6 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
 		else
 			error("%s+0x%lx references non-executable section '%s'\n",
 			      fromsec, (long)faddr, tosec);
-		break;
 	}
 }
 
-- 
2.39.2
Re: [PATCH v6 19/20] modpost: merge two similar section mismatch warnings
Posted by Nick Desaulniers 2 years, 8 months ago
On Sun, May 21, 2023 at 9:05 AM Masahiro Yamada <masahiroy@kernel.org> wrote:
>
> In case of section mismatch, modpost shows slightly different messages.
>
> For extable section mismatch:
>
>  "%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n"
>
> For the other cases:
>
>  "%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n"
>
> They are similar. Merge them.
>
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>

Thanks for the patch!
Reviewed-by: Nick Desaulniers <ndesaulniers@google.com>

> ---
>
>  scripts/mod/modpost.c | 18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)
>
> diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
> index 852cc164c77e..e7561fa57478 100644
> --- a/scripts/mod/modpost.c
> +++ b/scripts/mod/modpost.c
> @@ -1135,21 +1135,10 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
>
>         sec_mismatch_count++;
>
> -       switch (mismatch->mismatch) {
> -       case TEXT_TO_ANY_INIT:
> -       case DATA_TO_ANY_INIT:
> -       case TEXTDATA_TO_ANY_EXIT:
> -       case XXXINIT_TO_SOME_INIT:
> -       case XXXEXIT_TO_SOME_EXIT:
> -       case ANY_INIT_TO_ANY_EXIT:
> -       case ANY_EXIT_TO_ANY_INIT:
> -               warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
> -                    modname, fromsym, fromsec, tosym, tosec);
> -               break;
> -       case EXTABLE_TO_NON_TEXT:
> -               warn("%s(%s+0x%lx): Section mismatch in reference to the %s:%s\n",
> -                    modname, fromsec, (long)faddr, tosec, tosym);
> +       warn("%s: section mismatch in reference: %s (section: %s) -> %s (section: %s)\n",
> +            modname, fromsym, fromsec, tosym, tosec);
>
> +       if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) {
>                 if (match(tosec, mismatch->bad_tosec))
>                         fatal("The relocation at %s+0x%lx references\n"
>                               "section \"%s\" which is black-listed.\n"
> @@ -1169,7 +1158,6 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf,
>                 else
>                         error("%s+0x%lx references non-executable section '%s'\n",
>                               fromsec, (long)faddr, tosec);
> -               break;
>         }
>  }
>
> --
> 2.39.2
>


-- 
Thanks,
~Nick Desaulniers