riscv: vdso.lds.S: some improvement
cover riscv: vdso.lds.S: some improvement
This series renews one of my last year RFC patch[1], tries to improve the vdso layout a bit.
patch1 removes useless symbols
patch2 merges .data section of vdso into .rodata because they are readonly
patch3 is the real renew patch, it removes hardcoded 0x800 .text start addr. But I rewrite the commit msg per Andrew's suggestions and move move .note, .eh_frame_hdr, and .eh_frame between .rodata and .text to keep the actual code well away from the non-instruction data.
Jisheng Zhang (3):
riscv: vdso.lds.S: drop __alt_start and __alt_end symbols
riscv: vdso.lds.S: merge .data section into .rodata section
riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr
arch/riscv/kernel/vdso/vdso.lds.S | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
Signature · 1 line
2.40.1
PATCH 1/3 riscv: vdso.lds.S: drop __alt_start and __alt_end symbols
These two symbols are not used, remove them.
--- arch/riscv/kernel/vdso/vdso.lds.S | 2 -- 1 file changed, 2 deletions(-)
arch/riscv/kernel/vdso/vdso.lds.S +0 -2
@@ -42,9 +42,7 @@ SECTIONS . = ALIGN(4); .alternative : { - __alt_start = .; *(.alternative) - __alt_end = .; } .data : {
Signature · 1 line
2.40.1
PATCH 2/3 riscv: vdso.lds.S: merge .data section into .rodata section
In reply to Jisheng ZhangThe .data section doesn't need to be separate from .rodata section, they are both readonly.
--- arch/riscv/kernel/vdso/vdso.lds.S | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
arch/riscv/kernel/vdso/vdso.lds.S +7 -8
@@ -29,7 +29,13 @@ SECTIONS .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr .eh_frame : { KEEP (*(.eh_frame)) } :text - .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata : { + *(.rodata .rodata.* .gnu.linkonce.r.*) + *(.got.plt) *(.got) + *(.data .data.* .gnu.linkonce.d.*) + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*) + } /* * This linker script is used both with -r and with -shared.
@@ -44,13 +50,6 @@ SECTIONS .alternative : { *(.alternative) } - - .data : { - *(.got.plt) *(.got) - *(.data .data.* .gnu.linkonce.d.*) - *(.dynbss) - *(.bss .bss.* .gnu.linkonce.b.*) - } } /*
Signature · 1 line
2.40.1
Re: [PATCH 2/3] riscv: vdso.lds.S: merge .data section into .rodata section
Quoted 13 lines · Jisheng Zhang
The .data section doesn't need to be separate from .rodata section, they are both readonly.
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/kernel/vdso/vdso.lds.S | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)arch/riscv/kernel/vdso/vdso.lds.S +0
-0
arch/riscv/kernel/vdso/vdso.lds.S SECTIONS · line 37
Quoted 10 lines
arch/riscv/kernel/vdso/vdso.lds.S +6
-1@@ -29,7 +29,13 @@ SECTIONS .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr .eh_frame : { KEEP (*(.eh_frame)) } :text - .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata : { + *(.rodata .rodata.* .gnu.linkonce.r.*) + *(.got.plt) *(.got) + *(.data .data.* .gnu.linkonce.d.*) + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*)
Looking at other architectures, it appears the last three lines of sections could be discarded, but I don't know enough about this to state they should be.
Thanks,
drew
Quoted 21 lines
arch/riscv/kernel/vdso/vdso.lds.S +1
-7+ } /* * This linker script is used both with -r and with -shared.@@ -44,13 +50,6 @@ SECTIONS .alternative : { *(.alternative) } - - .data : { - *(.got.plt) *(.got) - *(.data .data.* .gnu.linkonce.d.*) - *(.dynbss) - *(.bss .bss.* .gnu.linkonce.b.*) - } } /*Signature · 1 line
2.40.1
Re: [PATCH 2/3] riscv: vdso.lds.S: merge .data section into .rodata section
Quoted 17 lines · Andrew Jones
Quoted 16 lines · Jisheng Zhang
The .data section doesn't need to be separate from .rodata section, they are both readonly.
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/kernel/vdso/vdso.lds.S | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)arch/riscv/kernel/vdso/vdso.lds.S +0
-0@@ -29,7 +29,13 @@ SECTIONS .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr .eh_frame : { KEEP (*(.eh_frame)) } :text
Quoted 10 lines
arch/riscv/kernel/vdso/vdso.lds.S SECTIONS · line 37
Quoted 7 lines
arch/riscv/kernel/vdso/vdso.lds.S +6
-1- .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) } + .rodata : { + *(.rodata .rodata.* .gnu.linkonce.r.*) + *(.got.plt) *(.got) + *(.data .data.* .gnu.linkonce.d.*) + *(.dynbss) + *(.bss .bss.* .gnu.linkonce.b.*)Looking at other architectures, it appears the last three lines of sections could be discarded, but I don't know enough about this to
Hi Andrew,
I checked x86, they still keep those sections. From another side, even if those sections are not needed, removing unused sections could be an independent patch, for safe reason or bisect reason.
Thanks
Quoted 23 lines
state they should be.
Thanks,
drewQuoted 17 lines
arch/riscv/kernel/vdso/vdso.lds.S +1
-7+ } /* * This linker script is used both with -r and with -shared.@@ -44,13 +50,6 @@ SECTIONS .alternative : { *(.alternative) } - - .data : { - *(.got.plt) *(.got) - *(.data .data.* .gnu.linkonce.d.*) - *(.dynbss) - *(.bss .bss.* .gnu.linkonce.b.*) - } }
Quoted 4 lines
Quoted 4 lines
arch/riscv/kernel/vdso/vdso.lds.S +0
-0/*Signature · 1 line
2.40.1
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
PATCH 3/3 riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr
In reply to Jisheng ZhangI believe the hardcoded 0x800 and related comments come from the long history VDSO_TEXT_OFFSET in x86 vdso code, but commit 5b9304933730 ("x86 vDSO: generate vdso-syms.lds") and commit f6b46ebf904f ("x86
vDSO: new layout") removes the comment and hard coding for x86.
Similar as x86 and other arch, riscv doesn't need the rigid layout using VDSO_TEXT_OFFSET since it "no longer matters to the kernel". so we could remove the hard coding now, and removing it brings a small vdso.so and aligns with other architectures.
Also, having enough separation between data and text is important for I-cache, so similar as x86, move .note, .eh_frame_hdr, and .eh_frame between .rodata and .text.
--- arch/riscv/kernel/vdso/vdso.lds.S | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)
arch/riscv/kernel/vdso/vdso.lds.S +8 -9
@@ -23,12 +23,8 @@ SECTIONS .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } - .note : { *(.note.*) } :text :note .dynamic : { *(.dynamic) } :text :dynamic - .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr - .eh_frame : { KEEP (*(.eh_frame)) } :text - .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) *(.got.plt) *(.got)
@@ -37,13 +33,16 @@ SECTIONS *(.bss .bss.* .gnu.linkonce.b.*) } + .note : { *(.note.*) } :text :note + + .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr + .eh_frame : { KEEP (*(.eh_frame)) } :text + /* - * 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. + * Text is well-separated from actual data: there's plenty of + * stuff that isn't used at runtime in between. */ - . = 0x800; + . = ALIGN(16); .text : { *(.text .text.*) } :text . = ALIGN(4);
Signature · 1 line
2.40.1
Re: [PATCH 3/3] riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr
Quoted 61 lines · Jisheng Zhang
I believe the hardcoded
0x800and related comments come from the long historyVDSO_TEXT_OFFSETin x86 vdso code, but commit5b9304933730("x86 vDSO: generatevdso-syms.lds") and commitf6b46ebf904f("x86
vDSO: new layout") removes the comment and hard coding for x86.Similar as x86 and other arch, riscv doesn't need the rigid layout using
VDSO_TEXT_OFFSETsince it "no longer matters to the kernel". so we could remove the hard coding now, and removing it brings a small vdso.so and aligns with other architectures.Also, having enough separation between data and text is important for I-cache, so similar as x86, move .note, .eh_frame_hdr, and .eh_frame between .rodata and .text.
Signed-off-by Jisheng Zhang <[email protected]>--- arch/riscv/kernel/vdso/vdso.lds.S | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-)arch/riscv/kernel/vdso/vdso.lds.S +8
-9@@ -23,12 +23,8 @@ SECTIONS .gnu.version_d : { *(.gnu.version_d) } .gnu.version_r : { *(.gnu.version_r) } - .note : { *(.note.*) } :text :note .dynamic : { *(.dynamic) } :text :dynamic - .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr - .eh_frame : { KEEP (*(.eh_frame)) } :text - .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) *(.got.plt) *(.got)@@ -37,13 +33,16 @@ SECTIONS *(.bss .bss.* .gnu.linkonce.b.*) } + .note : { *(.note.*) } :text :note + + .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr + .eh_frame : { KEEP (*(.eh_frame)) } :text + /* - * 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. + * Text is well-separated from actual data: there's plenty of + * stuff that isn't used at runtime in between. */ - . = 0x800; + . = ALIGN(16); .text : { *(.text .text.*) } :text . = ALIGN(4);Signature · 1 line
2.40.1
Thanks,
drew
Quoted 11 lines · Jisheng Zhang
This series renews one of my last year RFC patch[1], tries to improve the vdso layout a bit.
patch1 removes useless symbols
patch2 merges .data section of vdso into .rodata because they are readonly
patch3 is the real renew patch, it removes hardcoded0x800.text start addr. But I rewrite the commit msg per Andrew's suggestions and move move .note, .eh_frame_hdr, and .eh_frame between .rodata and .text to keep the actual code well away from the non-instruction data.
Quoted 1 line
Works fine on the VisionFive 2 and Unmatched.
Quoted 8 lines
Jisheng Zhang (3):
riscv:vdso.lds.S: drop__alt_startand__alt_endsymbols
riscv:vdso.lds.S: merge .data section into .rodata section
riscv:vdso.lds.S: remove hardcoded0x800.text start addrarch/riscv/kernel/vdso/vdso.lds.S | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-)
Quoted 8 lines
--
2.40.1_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv
_______________________________________________
linux-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-riscv