[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <0e582a7f5144a33f465978d97701f9b3dcc377f3.camel@perches.com>
Date: Wed, 30 Sep 2020 11:33:59 -0700
From: Joe Perches <joe@...ches.com>
To: Nick Desaulniers <ndesaulniers@...gle.com>,
Arvind Sankar <nivedita@...m.mit.edu>
Cc: Andrew Morton <akpm@...ux-foundation.org>,
Miguel Ojeda <miguel.ojeda.sandonis@...il.com>,
Luc Van Oostenryck <luc.vanoostenryck@...il.com>,
Nathan Chancellor <natechancellor@...il.com>,
linux-sparse@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
clang-built-linux <clang-built-linux@...glegroups.com>,
Linus Torvalds <torvalds@...ux-foundation.org>
Subject: Re: [PATCH] compiler.h: avoid escaped section names
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__ */
Download attachment "convert_section.pl" of type "application/x-perl" (5945 bytes)
Powered by blists - more mailing lists