diff mbox series

[v4,mips-next,6/7] vmlinux.lds.h: catch compound literals into data and BSS

Message ID 20210107132010.463129-3-alobakin@pm.me
State Superseded
Headers show
Series MIPS: vmlinux.lds.S sections fixes & cleanup | expand

Commit Message

Alexander Lobakin Jan. 7, 2021, 1:20 p.m. UTC
When building kernel with LD_DEAD_CODE_DATA_ELIMINATION, LLVM stack
generates separate sections for compound literals, just like in case
with enabled LTO [0]:

ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):
(.data..compoundliteral.14) is being placed in
'.data..compoundliteral.14'
ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):
(.data..compoundliteral.15) is being placed in
'.data..compoundliteral.15'
ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):
(.data..compoundliteral.16) is being placed in
'.data..compoundliteral.16'
ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):
(.data..compoundliteral.17) is being placed in
'.data..compoundliteral.17'

[...]

Handle this by adding the related sections to generic definitions
as suggested by Sami [0].

[0] https://lore.kernel.org/lkml/20201211184633.3213045-3-samitolvanen@google.com

Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
---
 include/asm-generic/vmlinux.lds.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

Nathan Chancellor Jan. 8, 2021, 9:19 p.m. UTC | #1
On Thu, Jan 07, 2021 at 01:20:55PM +0000, Alexander Lobakin wrote:
> When building kernel with LD_DEAD_CODE_DATA_ELIMINATION, LLVM stack

> generates separate sections for compound literals, just like in case

> with enabled LTO [0]:

> 

> ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):

> (.data..compoundliteral.14) is being placed in

> '.data..compoundliteral.14'

> ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):

> (.data..compoundliteral.15) is being placed in

> '.data..compoundliteral.15'

> ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):

> (.data..compoundliteral.16) is being placed in

> '.data..compoundliteral.16'

> ld.lld: warning: drivers/built-in.a(mtd/nand/spi/gigadevice.o):

> (.data..compoundliteral.17) is being placed in

> '.data..compoundliteral.17'

> 

> [...]

> 

> Handle this by adding the related sections to generic definitions

> as suggested by Sami [0].

> 

> [0] https://lore.kernel.org/lkml/20201211184633.3213045-3-samitolvanen@google.com

> 

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

> Signed-off-by: Alexander Lobakin <alobakin@pm.me>


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


> ---

>  include/asm-generic/vmlinux.lds.h | 6 +++---

>  1 file changed, 3 insertions(+), 3 deletions(-)

> 

> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h

> index b2b3d81b1535..5f2f5b1db84f 100644

> --- a/include/asm-generic/vmlinux.lds.h

> +++ b/include/asm-generic/vmlinux.lds.h

> @@ -95,10 +95,10 @@

>   */

>  #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION

>  #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*

> -#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX*

> +#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral*

>  #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*

> -#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*

> -#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*

> +#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*

> +#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*

>  #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*

>  #else

>  #define TEXT_MAIN .text

> -- 

> 2.30.0

> 

>
diff mbox series

Patch

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index b2b3d81b1535..5f2f5b1db84f 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -95,10 +95,10 @@ 
  */
 #ifdef CONFIG_LD_DEAD_CODE_DATA_ELIMINATION
 #define TEXT_MAIN .text .text.[0-9a-zA-Z_]*
-#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..LPBX*
+#define DATA_MAIN .data .data.[0-9a-zA-Z_]* .data..L* .data..compoundliteral*
 #define SDATA_MAIN .sdata .sdata.[0-9a-zA-Z_]*
-#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]*
-#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]*
+#define RODATA_MAIN .rodata .rodata.[0-9a-zA-Z_]* .rodata..L*
+#define BSS_MAIN .bss .bss.[0-9a-zA-Z_]* .bss..compoundliteral*
 #define SBSS_MAIN .sbss .sbss.[0-9a-zA-Z_]*
 #else
 #define TEXT_MAIN .text