diff mbox series

[16/16] compiler_attributes.h: add note about __section

Message ID 20190812215052.71840-16-ndesaulniers@google.com
State Superseded
Headers show
Series [01/16] s390/boot: fix section name escaping | expand

Commit Message

Nick Desaulniers Aug. 12, 2019, 9:50 p.m. UTC
The antipattern described can be found with:
$ grep -e __section\(\" -r -e __section__\(\"

Link: https://bugs.llvm.org/show_bug.cgi?id=42950
Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>

---
 include/linux/compiler_attributes.h | 10 ++++++++++
 1 file changed, 10 insertions(+)

-- 
2.23.0.rc1.153.gdeed80330f-goog

Comments

Sedat Dilek Aug. 19, 2019, 6:01 p.m. UTC | #1
On Mon, Aug 12, 2019 at 11:53 PM Nick Desaulniers
<ndesaulniers@google.com> wrote:
>

> The antipattern described can be found with:

> $ grep -e __section\(\" -r -e __section__\(\"

>

> Link: https://bugs.llvm.org/show_bug.cgi?id=42950

> Signed-off-by: Nick Desaulniers <ndesaulniers@google.com>


Tested-by: Sedat Dilek <sedat.dilek@gmail.com> [ Linux v5.3-rc5 ]


Patchset "for-5.3/x86-section-name-escaping":

include/linux/compiler.h: remove unused KENTRY macro
include/linux: prefer __section from compiler_attributes.h
include/asm-generic: prefer __section from compiler_attributes.h
x86: prefer __section from compiler_attributes.h

Thanks.

- Sedat -

> ---

>  include/linux/compiler_attributes.h | 10 ++++++++++

>  1 file changed, 10 insertions(+)

>

> diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h

> index 6b318efd8a74..f8c008d7f616 100644

> --- a/include/linux/compiler_attributes.h

> +++ b/include/linux/compiler_attributes.h

> @@ -225,6 +225,16 @@

>  #define __pure                          __attribute__((__pure__))

>

>  /*

> + *  Note: Since this macro makes use of the "stringification operator" `#`, a

> + *        quoted string literal should not be passed to it. eg.

> + *        prefer:

> + *        __section(.foo)

> + *        to:

> + *        __section(".foo")

> + *        unless the section name is dynamically built up, in which case the

> + *        verbose __attribute__((__section__(".foo" x))) should be preferred.

> + *        See also: https://bugs.llvm.org/show_bug.cgi?id=42950

> + *

>   *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-section-function-attribute

>   *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-section-variable-attribute

>   * clang: https://clang.llvm.org/docs/AttributeReference.html#section-declspec-allocate

> --

> 2.23.0.rc1.153.gdeed80330f-goog

>
diff mbox series

Patch

diff --git a/include/linux/compiler_attributes.h b/include/linux/compiler_attributes.h
index 6b318efd8a74..f8c008d7f616 100644
--- a/include/linux/compiler_attributes.h
+++ b/include/linux/compiler_attributes.h
@@ -225,6 +225,16 @@ 
 #define __pure                          __attribute__((__pure__))
 
 /*
+ *  Note: Since this macro makes use of the "stringification operator" `#`, a
+ *        quoted string literal should not be passed to it. eg.
+ *        prefer:
+ *        __section(.foo)
+ *        to:
+ *        __section(".foo")
+ *        unless the section name is dynamically built up, in which case the
+ *        verbose __attribute__((__section__(".foo" x))) should be preferred.
+ *        See also: https://bugs.llvm.org/show_bug.cgi?id=42950
+ *
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-section-function-attribute
  *   gcc: https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html#index-section-variable-attribute
  * clang: https://clang.llvm.org/docs/AttributeReference.html#section-declspec-allocate