From: Joe Perches <joe@perches.com>
To: Nick Desaulniers <ndesaulniers@google.com>,
Arvind Sankar <nivedita@alum.mit.edu>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Miguel Ojeda <miguel.ojeda.sandonis@gmail.com>,
Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
Nathan Chancellor <natechancellor@gmail.com>,
linux-sparse@vger.kernel.org, LKML <linux-kernel@vger.kernel.org>,
clang-built-linux <clang-built-linux@googlegroups.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH] compiler.h: avoid escaped section names
Date: Wed, 30 Sep 2020 11:33:59 -0700 [thread overview]
Message-ID: <0e582a7f5144a33f465978d97701f9b3dcc377f3.camel@perches.com> (raw)
In-Reply-To: <ffe0224b2dc88e091d4d3bb32ee073ffc0585882.camel@perches.com>
[-- Attachment #1: Type: text/plain, Size: 3502 bytes --]
On Wed, 2020-09-30 at 08:40 -0700, Joe Perches wrote:
> On Tue, 2020-09-29 at 13:25 -0700, Nick Desaulniers wrote:
> > And I don't remember what ever happened to Joe's script for treewide
> > conversion of __section.
>
> Nor do I but here (attached) is the script.
>
> My recollection is there was some problem with mscros
> with ## concatenation in some converted uses.
I believe I have it sorted now and I've attached
a new version of the script.
It runs against -next (or any other tree) and
produces a single commit.
It converts all the various uses of
__attribute__((section(<foo>)))
to
__section("<foo>")
changes the various macros with token pasting uses
I believe appropriately as well.
Please give it a spin.
There were 4 problems as below.
With these 4 items fixed, the build works (seems to at least)
1: compiler_attributes.h needed to unquote the __section__(#S)
the old automated patch didn't apply as the file had changed
diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attri>
index ea7b756b1c8f..b6fef9033c0b 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -254,7 +254,7 @@
* gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#i>
* clang: https://clang.llvm.org/docs/AttributeReference.html#section-declspec>
*/
-#define __section(S) __attribute__((__section__(#S)))
+#define __section(section) __attribute__((__section__(section)))
2: The script needed to use different token pasting for
__section(foo##bar##baz)
The script converted this to
__section("foo" ## bar ## "baz")
instead this needed to be
__section("foo" #bar "baz")
3: scripts/mod/modpost.c needed quoting of its internal __section uses:
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 69341b36f271..f882ce0d9327 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -2254,7 +2254,7 @@ static void add_header(struct buffer *b, struct module *mod)
buf_printf(b, "MODULE_INFO(name, KBUILD_MODNAME);\n");
buf_printf(b, "\n");
buf_printf(b, "__visible struct module __this_module\n");
- buf_printf(b, "__section(.gnu.linkonce.this_module) = {\n");
+ buf_printf(b, "__section(\".gnu.linkonce.this_module\") = {\n");
buf_printf(b, "\t.name = KBUILD_MODNAME,\n");
if (mod->has_init)
buf_printf(b, "\t.init = init_module,\n");
@@ -2308,7 +2308,7 @@ static int add_versions(struct buffer *b, struct module *mod)
buf_printf(b, "\n");
buf_printf(b, "static const struct modversion_info ____versions[]\n");
- buf_printf(b, "__used __section(__versions) = {\n");
+ buf_printf(b, "__used __section(\"__versions\") = {\n");
4: tools/ was excluded, but now needs conversion
tools/include/linux/objtool.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/include/linux/objtool.h b/tools/include/linux/objtool.h
index ab82c793c897..577f51436cf9 100644
--- a/tools/include/linux/objtool.h
+++ b/tools/include/linux/objtool.h
@@ -60,7 +60,7 @@ struct unwind_hint {
* For more information, see tools/objtool/Documentation/stack-validation.txt.
*/
#define STACK_FRAME_NON_STANDARD(func) \
- static void __used __section(.discard.func_stack_frame_non_standard) \
+ static void __used __section(".discard.func_stack_frame_non_standard") \
*__func_stack_frame_non_standard_##func = func
#else /* __ASSEMBLY__ */
[-- Attachment #2: convert_section.pl --]
[-- Type: application/x-perl, Size: 5945 bytes --]
next prev parent reply other threads:[~2020-09-30 18:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-29 19:43 [PATCH] compiler.h: avoid escaped section names Nick Desaulniers
2020-09-29 20:08 ` Arvind Sankar
2020-09-29 20:13 ` Arvind Sankar
2020-09-29 20:25 ` Nick Desaulniers
2020-09-29 20:30 ` Nick Desaulniers
2020-09-29 20:47 ` Arvind Sankar
2020-09-29 20:59 ` Nick Desaulniers
2020-09-30 15:40 ` Joe Perches
2020-09-30 18:33 ` Joe Perches [this message]
2020-09-30 23:10 ` convert_section.pl attached Joe Perches
2020-09-29 21:33 ` [PATCH] compiler.h: avoid escaped section names Miguel Ojeda
2020-09-30 8:33 ` David Laight
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=0e582a7f5144a33f465978d97701f9b3dcc377f3.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=clang-built-linux@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-sparse@vger.kernel.org \
--cc=luc.vanoostenryck@gmail.com \
--cc=miguel.ojeda.sandonis@gmail.com \
--cc=natechancellor@gmail.com \
--cc=ndesaulniers@google.com \
--cc=nivedita@alum.mit.edu \
--cc=torvalds@linux-foundation.org \
/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).