diff mbox series

[v5,mips-next,1/9] MIPS: vmlinux.lds.S: add missing PAGE_ALIGNED_DATA() section

Message ID 20210110115546.30970-1-alobakin@pm.me
State Accepted
Commit 8ac7c87acdcac156670f9920c8acbd84308ff4b1
Headers show
Series MIPS: vmlinux.lds.S sections fixes & cleanup | expand

Commit Message

Alexander Lobakin Jan. 10, 2021, 11:56 a.m. UTC
MIPS uses its own declaration of rwdata, and thus it should be kept
in sync with the asm-generic one. Currently PAGE_ALIGNED_DATA() is
missing from the linker script, which emits the following ld
warnings:

mips-alpine-linux-musl-ld: warning: orphan section
`.data..page_aligned' from `arch/mips/kernel/vdso.o' being placed
in section `.data..page_aligned'
mips-alpine-linux-musl-ld: warning: orphan section
`.data..page_aligned' from `arch/mips/vdso/vdso-image.o' being placed
in section `.data..page_aligned'

Add the necessary declaration, so the mentioned structures will be
placed in vmlinux as intended:

ffffffff80630580 D __end_once
ffffffff80630580 D __start___dyndbg
ffffffff80630580 D __start_once
ffffffff80630580 D __stop___dyndbg
ffffffff80634000 d mips_vdso_data
ffffffff80638000 d vdso_data
ffffffff80638580 D _gp
ffffffff8063c000 T __init_begin
ffffffff8063c000 D _edata
ffffffff8063c000 T _sinittext

->

ffffffff805a4000 D __end_init_task
ffffffff805a4000 D __nosave_begin
ffffffff805a4000 D __nosave_end
ffffffff805a4000 d mips_vdso_data
ffffffff805a8000 d vdso_data
ffffffff805ac000 D mmlist_lock
ffffffff805ac080 D tasklist_lock

Fixes: ebb5e78cc634 ("MIPS: Initial implementation of a VDSO")
Cc: stable@vger.kernel.org # 4.4+
Signed-off-by: Alexander Lobakin <alobakin@pm.me>
Reviewed-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Nathan Chancellor <natechancellor@gmail.com>
---
 arch/mips/kernel/vmlinux.lds.S | 1 +
 1 file changed, 1 insertion(+)

Comments

Nathan Chancellor Jan. 11, 2021, 2:05 a.m. UTC | #1
On Sun, Jan 10, 2021 at 11:56:54AM +0000, Alexander Lobakin wrote:
> When building kernel with both LD_DEAD_CODE_DATA_ELIMINATION and

> UBSAN, LLVM stack generates lots of "unnamed data" sections:

> 

> ld.lld: warning: net/built-in.a(netfilter/utils.o): (.data.$__unnamed_2)

> is being placed in '.data.$__unnamed_2'

> ld.lld: warning: net/built-in.a(netfilter/utils.o): (.data.$__unnamed_3)

> is being placed in '.data.$__unnamed_3'

> ld.lld: warning: net/built-in.a(netfilter/utils.o): (.data.$__unnamed_4)

> is being placed in '.data.$__unnamed_4'

> ld.lld: warning: net/built-in.a(netfilter/utils.o): (.data.$__unnamed_5)

> is being placed in '.data.$__unnamed_5'

> 

> [...]

> 

> Also handle this by adding the related sections to generic definitions.

> 

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


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


> ---

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

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

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

> index 5f2f5b1db84f..cc659e77fcb0 100644

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

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

> @@ -95,7 +95,7 @@

>   */

>  #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..L* .data..compoundliteral*

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

>  #define SDATA_MAIN .sdata .sdata.[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*

> -- 

> 2.30.0

> 

>
diff mbox series

Patch

diff --git a/arch/mips/kernel/vmlinux.lds.S b/arch/mips/kernel/vmlinux.lds.S
index 5e97e9d02f98..83e27a181206 100644
--- a/arch/mips/kernel/vmlinux.lds.S
+++ b/arch/mips/kernel/vmlinux.lds.S
@@ -90,6 +90,7 @@  SECTIONS
 
 		INIT_TASK_DATA(THREAD_SIZE)
 		NOSAVE_DATA
+		PAGE_ALIGNED_DATA(PAGE_SIZE)
 		CACHELINE_ALIGNED_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
 		READ_MOSTLY_DATA(1 << CONFIG_MIPS_L1_CACHE_SHIFT)
 		DATA_DATA