All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang
@ 2020-09-29 19:07 Nick Desaulniers
  2020-09-29 23:44 ` Kees Cook
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nick Desaulniers @ 2020-09-29 19:07 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Nick Desaulniers, kbuild test robot, Kees Cook,
	Nathan Chancellor, Masahiro Yamada, Matthias Maennich,
	Jessica Yu, Greg Kroah-Hartman, Will Deacon, linux-kernel,
	clang-built-linux

When enabling CONFIG_TRIM_UNUSED_KSYMS, the linker will warn about the
orphan sections:
(".discard.ksym") is being placed in '".discard.ksym"'
repeatedly when linking vmlinux. This is because the stringification
operator, `#`, in the preprocessor escapes strings.  GCC and Clang
differ in how they treat section names that contain \".

The portable solution is to not use a string literal with the
preprocessor stringification operator.

Link: https://bugs.llvm.org/show_bug.cgi?id=42950
Link: https://github.com/ClangBuiltLinux/linux/issues/1166
Fixes: commit bbda5ec671d3 ("kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS")
Reported-by: kbuild test robot <lkp@intel.com>
Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>
---
 include/linux/export.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/export.h b/include/linux/export.h
index fceb5e855717..8933ff6ad23a 100644
--- a/include/linux/export.h
+++ b/include/linux/export.h
@@ -130,7 +130,7 @@ struct kernel_symbol {
  * discarded in the final link stage.
  */
 #define __ksym_marker(sym)	\
-	static int __ksym_marker_##sym[0] __section(".discard.ksym") __used
+	static int __ksym_marker_##sym[0] __section(.discard.ksym) __used
 
 #define __EXPORT_SYMBOL(sym, sec, ns)					\
 	__ksym_marker(sym);						\
-- 
2.28.0.709.gb0816b6eb0-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang
  2020-09-29 19:07 [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang Nick Desaulniers
@ 2020-09-29 23:44 ` Kees Cook
  2020-09-30 16:26 ` Nathan Chancellor
  2020-09-30 16:43 ` Sedat Dilek
  2 siblings, 0 replies; 4+ messages in thread
From: Kees Cook @ 2020-09-29 23:44 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andrew Morton, kbuild test robot, Nathan Chancellor,
	Masahiro Yamada, Matthias Maennich, Jessica Yu,
	Greg Kroah-Hartman, Will Deacon, linux-kernel, clang-built-linux

On Tue, Sep 29, 2020 at 12:07:00PM -0700, Nick Desaulniers wrote:
> When enabling CONFIG_TRIM_UNUSED_KSYMS, the linker will warn about the
> orphan sections:
> (".discard.ksym") is being placed in '".discard.ksym"'
> repeatedly when linking vmlinux. This is because the stringification
> operator, `#`, in the preprocessor escapes strings.  GCC and Clang
> differ in how they treat section names that contain \".
> 
> The portable solution is to not use a string literal with the
> preprocessor stringification operator.
> 
> Link: https://bugs.llvm.org/show_bug.cgi?id=42950
> Link: https://github.com/ClangBuiltLinux/linux/issues/1166
> Fixes: commit bbda5ec671d3 ("kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS")
> Reported-by: kbuild test robot <lkp@intel.com>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Reviewed-by: Kees Cook <keescook@chromium.org>

Do these other cases need fixing too?

arch/arm64/mm/mmu.c:u64 __section(".mmuoff.data.write") vabits_actual;
include/linux/srcutree.h:               __section("___srcu_struct_ptrs") = &name

-Kees

> ---
>  include/linux/export.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/export.h b/include/linux/export.h
> index fceb5e855717..8933ff6ad23a 100644
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -130,7 +130,7 @@ struct kernel_symbol {
>   * discarded in the final link stage.
>   */
>  #define __ksym_marker(sym)	\
> -	static int __ksym_marker_##sym[0] __section(".discard.ksym") __used
> +	static int __ksym_marker_##sym[0] __section(.discard.ksym) __used
>  
>  #define __EXPORT_SYMBOL(sym, sec, ns)					\
>  	__ksym_marker(sym);						\
> -- 
> 2.28.0.709.gb0816b6eb0-goog
> 

-- 
Kees Cook

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang
  2020-09-29 19:07 [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang Nick Desaulniers
  2020-09-29 23:44 ` Kees Cook
@ 2020-09-30 16:26 ` Nathan Chancellor
  2020-09-30 16:43 ` Sedat Dilek
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2020-09-30 16:26 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andrew Morton, kbuild test robot, Kees Cook, Masahiro Yamada,
	Matthias Maennich, Jessica Yu, Greg Kroah-Hartman, Will Deacon,
	linux-kernel, clang-built-linux

On Tue, Sep 29, 2020 at 12:07:00PM -0700, Nick Desaulniers wrote:
> When enabling CONFIG_TRIM_UNUSED_KSYMS, the linker will warn about the
> orphan sections:
> (".discard.ksym") is being placed in '".discard.ksym"'
> repeatedly when linking vmlinux. This is because the stringification
> operator, `#`, in the preprocessor escapes strings.  GCC and Clang
> differ in how they treat section names that contain \".
> 
> The portable solution is to not use a string literal with the
> preprocessor stringification operator.
> 
> Link: https://bugs.llvm.org/show_bug.cgi?id=42950
> Link: https://github.com/ClangBuiltLinux/linux/issues/1166
> Fixes: commit bbda5ec671d3 ("kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS")
> Reported-by: kbuild test robot <lkp@intel.com>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>

> ---
>  include/linux/export.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/export.h b/include/linux/export.h
> index fceb5e855717..8933ff6ad23a 100644
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -130,7 +130,7 @@ struct kernel_symbol {
>   * discarded in the final link stage.
>   */
>  #define __ksym_marker(sym)	\
> -	static int __ksym_marker_##sym[0] __section(".discard.ksym") __used
> +	static int __ksym_marker_##sym[0] __section(.discard.ksym) __used
>  
>  #define __EXPORT_SYMBOL(sym, sec, ns)					\
>  	__ksym_marker(sym);						\
> -- 
> 2.28.0.709.gb0816b6eb0-goog
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang
  2020-09-29 19:07 [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang Nick Desaulniers
  2020-09-29 23:44 ` Kees Cook
  2020-09-30 16:26 ` Nathan Chancellor
@ 2020-09-30 16:43 ` Sedat Dilek
  2 siblings, 0 replies; 4+ messages in thread
From: Sedat Dilek @ 2020-09-30 16:43 UTC (permalink / raw)
  To: Nick Desaulniers
  Cc: Andrew Morton, kbuild test robot, Kees Cook, Nathan Chancellor,
	Masahiro Yamada, Matthias Maennich, Jessica Yu,
	Greg Kroah-Hartman, Will Deacon, linux-kernel,
	Clang-Built-Linux ML

On Tue, Sep 29, 2020 at 9:07 PM 'Nick Desaulniers' via Clang Built
Linux <clang-built-linux@googlegroups.com> wrote:
>
> When enabling CONFIG_TRIM_UNUSED_KSYMS, the linker will warn about the
> orphan sections:
> (".discard.ksym") is being placed in '".discard.ksym"'
> repeatedly when linking vmlinux. This is because the stringification
> operator, `#`, in the preprocessor escapes strings.  GCC and Clang
> differ in how they treat section names that contain \".
>
> The portable solution is to not use a string literal with the
> preprocessor stringification operator.
>
> Link: https://bugs.llvm.org/show_bug.cgi?id=42950
> Link: https://github.com/ClangBuiltLinux/linux/issues/1166
> Fixes: commit bbda5ec671d3 ("kbuild: simplify dependency generation for CONFIG_TRIM_UNUSED_KSYMS")
> Reported-by: kbuild test robot <lkp@intel.com>
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

"The return of escaped section names" - soon in your cinema?

Thanks Nick for catching this.

Reviewed-by: Sedat Dilek <sedat.dilek@gmail.com>

- Sedat -

> ---
>  include/linux/export.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/include/linux/export.h b/include/linux/export.h
> index fceb5e855717..8933ff6ad23a 100644
> --- a/include/linux/export.h
> +++ b/include/linux/export.h
> @@ -130,7 +130,7 @@ struct kernel_symbol {
>   * discarded in the final link stage.
>   */
>  #define __ksym_marker(sym)     \
> -       static int __ksym_marker_##sym[0] __section(".discard.ksym") __used
> +       static int __ksym_marker_##sym[0] __section(.discard.ksym) __used
>
>  #define __EXPORT_SYMBOL(sym, sec, ns)                                  \
>         __ksym_marker(sym);                                             \
> --
> 2.28.0.709.gb0816b6eb0-goog
>
> --
> You received this message because you are subscribed to the Google Groups "Clang Built Linux" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to clang-built-linux+unsubscribe@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/clang-built-linux/20200929190701.398762-1-ndesaulniers%40google.com.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-30 16:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-29 19:07 [PATCH] export.h: fix section name for CONFIG_TRIM_UNUSED_KSYMS for Clang Nick Desaulniers
2020-09-29 23:44 ` Kees Cook
2020-09-30 16:26 ` Nathan Chancellor
2020-09-30 16:43 ` Sedat Dilek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.