diff mbox series

riscv: vdso: fix section overlapping under some conditions

Message ID 20221031175842.1699-1-jszhang@kernel.org (mailing list archive)
State Superseded
Delegated to: Palmer Dabbelt
Headers show
Series riscv: vdso: fix section overlapping under some conditions | expand

Checks

Context Check Description
conchuod/patch_count success Link
conchuod/cover_letter success Single patches do not need cover letters
conchuod/tree_selection success Guessed tree name to be for-next
conchuod/fixes_present success Fixes tag not required for -next series
conchuod/verify_signedoff success Signed-off-by tag matches author and committer
conchuod/kdoc success Errors and warnings before: 0 this patch: 0
conchuod/module_param success Was 0 now: 0
conchuod/cc_maintainers warning 1 maintainers not CCed: foo.bar@bar.com
conchuod/build_warn_rv64 fail Errors and warnings before: 0 this patch: 0
conchuod/dtb_warn_rv64 success Errors and warnings before: 0 this patch: 0
conchuod/header_inline success No static functions without inline keyword in header files
conchuod/checkpatch success total: 0 errors, 0 warnings, 0 checks, 14 lines checked
conchuod/source_inline success Was 0 now: 0
conchuod/verify_fixes success No Fixes tag

Commit Message

Jisheng Zhang Oct. 31, 2022, 5:58 p.m. UTC
lkp reported a build error, I tried the config and can reproduce
build error as below:

  VDSOLD  arch/riscv/kernel/vdso/vdso.so.dbg
ld.lld: error: section .note file range overlaps with .text
>>> .note range is [0x7C8, 0x803]
>>> .text range is [0x800, 0x1993]

ld.lld: error: section .text file range overlaps with .dynamic
>>> .text range is [0x800, 0x1993]
>>> .dynamic range is [0x808, 0x937]

ld.lld: error: section .note virtual address range overlaps with .text
>>> .note range is [0x7C8, 0x803]
>>> .text range is [0x800, 0x1993]

Fix it by removing the hardcoding 0x800 and related comments.

Link: https://lore.kernel.org/lkml/202210122123.Cc4FPShJ-lkp@intel.com/#r
Reported-by: kernel test robot <lkp@intel.com>
Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
---
 arch/riscv/kernel/vdso/vdso.lds.S | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

Comments

Andrew Jones Nov. 1, 2022, 9:19 a.m. UTC | #1
On Tue, Nov 01, 2022 at 01:58:42AM +0800, Jisheng Zhang wrote:
> lkp reported a build error, I tried the config and can reproduce
> build error as below:
> 
>   VDSOLD  arch/riscv/kernel/vdso/vdso.so.dbg
> ld.lld: error: section .note file range overlaps with .text
> >>> .note range is [0x7C8, 0x803]
> >>> .text range is [0x800, 0x1993]
> 
> ld.lld: error: section .text file range overlaps with .dynamic
> >>> .text range is [0x800, 0x1993]
> >>> .dynamic range is [0x808, 0x937]
> 
> ld.lld: error: section .note virtual address range overlaps with .text
> >>> .note range is [0x7C8, 0x803]
> >>> .text range is [0x800, 0x1993]
> 
> Fix it by removing the hardcoding 0x800 and related comments.
> 
> Link: https://lore.kernel.org/lkml/202210122123.Cc4FPShJ-lkp@intel.com/#r
> Reported-by: kernel test robot <lkp@intel.com>
> Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> ---
>  arch/riscv/kernel/vdso/vdso.lds.S | 8 +-------
>  1 file changed, 1 insertion(+), 7 deletions(-)
> 
> diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vdso.lds.S
> index 01d94aae5bf5..344209d2e128 100644
> --- a/arch/riscv/kernel/vdso/vdso.lds.S
> +++ b/arch/riscv/kernel/vdso/vdso.lds.S
> @@ -31,13 +31,7 @@ SECTIONS
>  
>  	.rodata		: { *(.rodata .rodata.* .gnu.linkonce.r.*) }
>  
> -	/*
> -	 * This linker script is used both with -r and with -shared.
> -	 * For the layouts to match, we need to skip more than enough
> -	 * space for the dynamic symbol table, etc. If this amount is
> -	 * insufficient, ld -shared will error; simply increase it here.
> -	 */
> -	. = 0x800;

Hi Jisheng,

Removing this hard coded value is a good thing, but I don't understand
why, if it was necessary before, that it's no longer necessary. Can you
please explain that in the commit message? If the linker improved in
this regard, then do we need to document a new minimum linker version?

> +	. = ALIGN(16);

Aligning text to a 4-byte boundary makes sense to me, but I don't
understand the 16-byte boundary requirement. Can you please explain
this for my education?

Thanks,
drew

>  	.text		: { *(.text .text.*) }		:text
>  
>  	.data		: {
> -- 
> 2.37.2
> 
> 
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Jisheng Zhang Nov. 2, 2022, 5:28 p.m. UTC | #2
On Tue, Nov 01, 2022 at 10:19:42AM +0100, Andrew Jones wrote:
> On Tue, Nov 01, 2022 at 01:58:42AM +0800, Jisheng Zhang wrote:
> > lkp reported a build error, I tried the config and can reproduce
> > build error as below:
> > 
> >   VDSOLD  arch/riscv/kernel/vdso/vdso.so.dbg
> > ld.lld: error: section .note file range overlaps with .text
> > >>> .note range is [0x7C8, 0x803]
> > >>> .text range is [0x800, 0x1993]
> > 
> > ld.lld: error: section .text file range overlaps with .dynamic
> > >>> .text range is [0x800, 0x1993]
> > >>> .dynamic range is [0x808, 0x937]
> > 
> > ld.lld: error: section .note virtual address range overlaps with .text
> > >>> .note range is [0x7C8, 0x803]
> > >>> .text range is [0x800, 0x1993]
> > 
> > Fix it by removing the hardcoding 0x800 and related comments.
> > 
> > Link: https://lore.kernel.org/lkml/202210122123.Cc4FPShJ-lkp@intel.com/#r
> > Reported-by: kernel test robot <lkp@intel.com>
> > Signed-off-by: Jisheng Zhang <jszhang@kernel.org>
> > ---
> >  arch/riscv/kernel/vdso/vdso.lds.S | 8 +-------
> >  1 file changed, 1 insertion(+), 7 deletions(-)
> > 
> > diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vdso.lds.S
> > index 01d94aae5bf5..344209d2e128 100644
> > --- a/arch/riscv/kernel/vdso/vdso.lds.S
> > +++ b/arch/riscv/kernel/vdso/vdso.lds.S
> > @@ -31,13 +31,7 @@ SECTIONS
> >  
> >  	.rodata		: { *(.rodata .rodata.* .gnu.linkonce.r.*) }
> >  
> > -	/*
> > -	 * This linker script is used both with -r and with -shared.
> > -	 * For the layouts to match, we need to skip more than enough
> > -	 * space for the dynamic symbol table, etc. If this amount is
> > -	 * insufficient, ld -shared will error; simply increase it here.
> > -	 */
> > -	. = 0x800;
> 
> Hi Jisheng,

Hi Andrew,

> 
> Removing this hard coded value is a good thing, but I don't understand
> why, if it was necessary before, that it's no longer necessary. Can you
> please explain that in the commit message? If the linker improved in

To be honest, I dunno. The hardcoded 0x800 was there from day1, maybe
Palmer knew the details.

> this regard, then do we need to document a new minimum linker version?


> 
> > +	. = ALIGN(16);
> 
> Aligning text to a 4-byte boundary makes sense to me, but I don't

Aha, I think align text to 4byte is fine. In my old memories, I was
told to align function entry at 16byte boundary, I'm not sure this
is still true.

PS: I just sent out v2 of this fix. The fix method is different and
think v2 is the correct fix while this v1 is an improvement.
diff mbox series

Patch

diff --git a/arch/riscv/kernel/vdso/vdso.lds.S b/arch/riscv/kernel/vdso/vdso.lds.S
index 01d94aae5bf5..344209d2e128 100644
--- a/arch/riscv/kernel/vdso/vdso.lds.S
+++ b/arch/riscv/kernel/vdso/vdso.lds.S
@@ -31,13 +31,7 @@  SECTIONS
 
 	.rodata		: { *(.rodata .rodata.* .gnu.linkonce.r.*) }
 
-	/*
-	 * This linker script is used both with -r and with -shared.
-	 * For the layouts to match, we need to skip more than enough
-	 * space for the dynamic symbol table, etc. If this amount is
-	 * insufficient, ld -shared will error; simply increase it here.
-	 */
-	. = 0x800;
+	. = ALIGN(16);
 	.text		: { *(.text .text.*) }		:text
 
 	.data		: {