Skip to contentSkip to conversation

riscv: vdso: fix section overlapping under some conditions

PATCH Superseded Jisheng Zhang 2 participants 3 messages Oct 31, 2022 – Nov 2, 2022 RISC-V

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: vdso: fix section overlapping under some conditions

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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.note range is [0x7C8, 0x803]
.text range is [0x800, 0x1993]

ld.lld: error: section .text file range overlaps with .dynamic

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.text range is [0x800, 0x1993]
.dynamic range is [0x808, 0x937]

ld.lld: error: section .note virtual address range overlaps with .text

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.note range is [0x7C8, 0x803]
.text range is [0x800, 0x1993]

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

---
 arch/riscv/kernel/vdso/vdso.lds.S | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
arch/riscv/kernel/vdso/vdso.lds.S +1 -7
index 01d94aae5bf5..344209d2e128 100644
@@ -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		: {
Signature · 1 line
2.37.2
#1 lore raw
Quoted 30 lines · Jisheng Zhang

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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.note range is [0x7C8, 0x803]
.text range is [0x800, 0x1993]

ld.lld: error: section .text file range overlaps with .dynamic

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.text range is [0x800, 0x1993]
.dynamic range is [0x808, 0x937]

ld.lld: error: section .note virtual address range overlaps with .text

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.note range is [0x7C8, 0x803]
.text range is [0x800, 0x1993]

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

---
 arch/riscv/kernel/vdso/vdso.lds.S | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
arch/riscv/kernel/vdso/vdso.lds.S +0 -0
index 01d94aae5bf5..344209d2e128 100644

arch/riscv/kernel/vdso/vdso.lds.S SECTIONS · line 40

Quoted 10 lines
arch/riscv/kernel/vdso/vdso.lds.S +0 -7
@@ -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?

arch/riscv/kernel/vdso/vdso.lds.S SECTIONS · line 34

Quoted 1 line
arch/riscv/kernel/vdso/vdso.lds.S +1 -0
+	. = 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

Quoted 11 lines
arch/riscv/kernel/vdso/vdso.lds.S +0 -0
 	.text		: { *(.text .text.*) }		:text
 
 	.data		: {
Signature · 7 lines
2.37.2


_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
#2 lore raw
Quoted 34 lines · Andrew Jones
Quoted 33 lines · Jisheng Zhang

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

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.note range is [0x7C8, 0x803]
.text range is [0x800, 0x1993]

ld.lld: error: section .text file range overlaps with .dynamic

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.text range is [0x800, 0x1993]
.dynamic range is [0x808, 0x937]

ld.lld: error: section .note virtual address range overlaps with .text

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

.note range is [0x7C8, 0x803]
.text range is [0x800, 0x1993]

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

---
 arch/riscv/kernel/vdso/vdso.lds.S | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
arch/riscv/kernel/vdso/vdso.lds.S +0 -0
index 01d94aae5bf5..344209d2e128 100644
@@ -31,13 +31,7 @@ SECTIONS
 
 	.rodata		: { *(.rodata .rodata.* .gnu.linkonce.r.*) }
 
Quoted 9 lines

arch/riscv/kernel/vdso/vdso.lds.S SECTIONS · line 40

Quoted 7 lines
arch/riscv/kernel/vdso/vdso.lds.S +0 -7
-	/*
-	 * 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,

Quoted 4 lines

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.

Quoted 7 lines

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

arch/riscv/kernel/vdso/vdso.lds.S SECTIONS · line 34

Quoted 1 line
arch/riscv/kernel/vdso/vdso.lds.S +1 -0
+	. = 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.