From: Mathias Krause <minipli@googlemail.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Cc: Joe Perches <joe@perches.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
linux-kernel@vger.kernel.org,
Mathias Krause <minipli@googlemail.com>
Subject: [PATCHv3 4/9] modpost: provide better diagnostics for __init / __exit strings
Date: Thu, 21 Aug 2014 14:23:07 +0200 [thread overview]
Message-ID: <1408623792-7973-5-git-send-email-minipli@googlemail.com> (raw)
In-Reply-To: <1408623792-7973-1-git-send-email-minipli@googlemail.com>
Modpost will detect wrong usage of the pe_*() / pi_*() macros or the
__init_str() / __exit_str() annotations in general. But it'll print
cryptic diagnoses in this case that don't really help fixing the issue
in the code. Detect __init / __exit string section mismatches by there
unique symbol name pattern and provide better help texts in this case.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
This patch generates quite a few checkpatch warnings related to strings
split across lines. But I choose to do so anyway to not make the code
differ from other fprintf()s in this file.
scripts/mod/modpost.c | 94 +++++++++++++++++++++++++++++++++++++++----------
1 file changed, 75 insertions(+), 19 deletions(-)
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 091d90573b..7b462d5d01 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -1150,6 +1150,16 @@ static inline int is_arm_mapping_symbol(const char *str)
&& (str[2] == '\0' || str[2] == '.');
}
+static inline int is_init_str(const char *str)
+{
+ return !strncmp(str, "__UNIQUE_ID__init_str_", 22);
+}
+
+static inline int is_exit_str(const char *str)
+{
+ return !strncmp(str, "__UNIQUE_ID__exit_str_", 22);
+}
+
/*
* If there's no name there, ignore it; likewise, ignore it if it's
* one of the magic symbols emitted used by current ARM tools.
@@ -1305,12 +1315,24 @@ static void report_sec_mismatch(const char *modname,
prl_to = sec2annotation(tosec);
fprintf(stderr,
"The function %s%s() references\n"
- "the %s %s%s%s.\n"
- "This is often because %s lacks a %s\n"
- "annotation or the annotation of %s is wrong.\n",
+ "the %s %s%s%s.\n",
prl_from, fromsym,
- to, prl_to, tosym, to_p,
- fromsym, prl_to, tosym);
+ to, prl_to, tosym, to_p);
+ if (!to_is_func && is_init_str(tosym)) {
+ fprintf(stderr,
+ "This is probably due to a wrong use of the "
+ "pi_<level>() macro\n"
+ "or a wrongly __init_str() annotated string literal.\n"
+ "The fix is to either change the pi_<level>() to its "
+ "pr_<level>()\n"
+ "counterpart or to remove the __init_str() annotation "
+ "of the string literal\n");
+ } else {
+ fprintf(stderr,
+ "This is often because %s lacks a %s\n"
+ "annotation or the annotation of %s is wrong.\n",
+ fromsym, prl_to, tosym);
+ }
free(prl_from);
free(prl_to);
break;
@@ -1330,10 +1352,24 @@ static void report_sec_mismatch(const char *modname,
case TEXT_TO_ANY_EXIT:
prl_to = sec2annotation(tosec);
fprintf(stderr,
- "The function %s() references a %s in an exit section.\n"
- "Often the %s %s%s has valid usage outside the exit section\n"
- "and the fix is to remove the %sannotation of %s.\n",
- fromsym, to, to, tosym, to_p, prl_to, tosym);
+ "The function %s() references a %s in an exit section.\n",
+ fromsym, to);
+ if (!to_is_func && is_exit_str(tosym)) {
+ fprintf(stderr,
+ "This is probably due to a wrong use of the "
+ "pe_<level>() macro\n"
+ "or a wrongly __exit_str() annotated string literal.\n"
+ "The fix is to either change the pe_<level>() to its "
+ "pr_<level>()\n"
+ "counterpart or to remove the __exit_str() annotation "
+ "of the string literal\n");
+ } else {
+ fprintf(stderr,
+ "Often the %s %s%s has valid usage outside the exit "
+ "section\n"
+ "and the fix is to remove the %sannotation of %s.\n",
+ to, tosym, to_p, prl_to, tosym);
+ }
free(prl_to);
break;
case DATA_TO_ANY_EXIT: {
@@ -1372,12 +1408,22 @@ static void report_sec_mismatch(const char *modname,
"a %s %s%s%s.\n"
"This is often seen when error handling "
"in the init function\n"
- "uses functionality in the exit path.\n"
- "The fix is often to remove the %sannotation of\n"
- "%s%s so it may be used outside an exit section.\n",
+ "uses functionality of the exit path.\n",
from, prl_from, fromsym, from_p,
- to, prl_to, tosym, to_p,
- prl_to, tosym, to_p);
+ to, prl_to, tosym, to_p);
+ if (!to_is_func && is_exit_str(tosym)) {
+ fprintf(stderr,
+ "The fix is often to either change the pe_<level>() to "
+ "its pr_<level>()\n"
+ "counterpart or to remove the __exit_str() annotation "
+ "of the string literal\n"
+ "so it may be used outside an exit section.\n");
+ } else {
+ fprintf(stderr,
+ "The fix is often to remove the %sannotation of\n"
+ "%s%s so it may be used outside an exit section.\n",
+ prl_to, tosym, to_p);
+ }
free(prl_from);
free(prl_to);
break;
@@ -1389,12 +1435,22 @@ static void report_sec_mismatch(const char *modname,
"a %s %s%s%s.\n"
"This is often seen when error handling "
"in the exit function\n"
- "uses functionality in the init path.\n"
- "The fix is often to remove the %sannotation of\n"
- "%s%s so it may be used outside an init section.\n",
+ "uses functionality of the init path.\n",
from, prl_from, fromsym, from_p,
- to, prl_to, tosym, to_p,
- prl_to, tosym, to_p);
+ to, prl_to, tosym, to_p);
+ if (!to_is_func && is_init_str(tosym)) {
+ fprintf(stderr,
+ "The fix is often to either change the pi_<level>() to "
+ "its pr_<level>()\n"
+ "counterpart or to remove the __init_str() annotation "
+ "of the string literal\n"
+ "so it may be used outside an init section.\n");
+ } else {
+ fprintf(stderr,
+ "The fix is often to remove the %sannotation of\n"
+ "%s%s so it may be used outside an init section.\n",
+ prl_to, tosym, to_p);
+ }
free(prl_from);
free(prl_to);
break;
--
1.7.10.4
next prev parent reply other threads:[~2014-08-21 12:26 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-08-21 12:23 [PATCHv3 0/9] Mark literal strings in __init / __exit code Mathias Krause
2014-08-21 12:23 ` [PATCHv3 1/9] init.h: Add __init_str / __exit_str macros Mathias Krause
2014-08-21 12:23 ` [PATCHv3 2/9] printk: Provide pi_<level> / pe_<level> macros for __init / __exit code Mathias Krause
2014-08-21 12:23 ` [PATCHv3 3/9] kallsyms: exclude pseudo symbols for __init / __exit strings Mathias Krause
2014-08-21 12:23 ` Mathias Krause [this message]
2014-08-21 12:23 ` [PATCHv3 5/9] x86, acpi: Mark __init strings as such Mathias Krause
2014-08-21 12:23 ` [PATCHv3 6/9] x86, mm: Make x86_init.memory_setup() return a const char * Mathias Krause
2014-08-21 12:23 ` [PATCHv3 7/9] x86, mm: early_panic() - pass on the message as string Mathias Krause
2014-08-21 12:23 ` [PATCHv3 8/9] x86, mm: e820 - mark __init strings as such Mathias Krause
2014-08-21 12:23 ` [PATCHv3 9/9] x86: setup " Mathias Krause
2014-08-21 12:57 ` [PATCHv3 0/9] Mark literal strings in __init / __exit code Ingo Molnar
2014-08-21 14:29 ` Mathias Krause
2014-08-22 8:24 ` Ingo Molnar
2014-08-30 15:28 ` Mathias Krause
2014-09-16 8:57 ` Ingo Molnar
2014-08-21 16:25 ` Sam Ravnborg
2014-08-24 16:04 ` Mathias Krause
2014-08-24 16:28 ` Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1408623792-7973-5-git-send-email-minipli@googlemail.com \
--to=minipli@googlemail.com \
--cc=akpm@linux-foundation.org \
--cc=hpa@zytor.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).