Skip to content

Commit 8f8c1ff

Browse files
xhackerustcpalmer-dabbelt
authored andcommitted
riscv: vdso.lds.S: remove hardcoded 0x800 .text start addr
I believe the hardcoded 0x800 and related comments come from the long history VDSO_TEXT_OFFSET in x86 vdso code, but commit 5b93049 ("x86 vDSO: generate vdso-syms.lds") and commit f6b46eb ("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. Signed-off-by: Jisheng Zhang <[email protected]> Reviewed-by: Andrew Jones <[email protected]> Tested-by: Emil Renner Berthing <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent 49cfbdc commit 8f8c1ff

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

arch/riscv/kernel/vdso/vdso.lds.S

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,8 @@ SECTIONS
2323
.gnu.version_d : { *(.gnu.version_d) }
2424
.gnu.version_r : { *(.gnu.version_r) }
2525

26-
.note : { *(.note.*) } :text :note
2726
.dynamic : { *(.dynamic) } :text :dynamic
2827

29-
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
30-
.eh_frame : { KEEP (*(.eh_frame)) } :text
31-
3228
.rodata : {
3329
*(.rodata .rodata.* .gnu.linkonce.r.*)
3430
*(.got.plt) *(.got)
@@ -37,13 +33,16 @@ SECTIONS
3733
*(.bss .bss.* .gnu.linkonce.b.*)
3834
}
3935

36+
.note : { *(.note.*) } :text :note
37+
38+
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
39+
.eh_frame : { KEEP (*(.eh_frame)) } :text
40+
4041
/*
41-
* This linker script is used both with -r and with -shared.
42-
* For the layouts to match, we need to skip more than enough
43-
* space for the dynamic symbol table, etc. If this amount is
44-
* insufficient, ld -shared will error; simply increase it here.
42+
* Text is well-separated from actual data: there's plenty of
43+
* stuff that isn't used at runtime in between.
4544
*/
46-
. = 0x800;
45+
. = ALIGN(16);
4746
.text : { *(.text .text.*) } :text
4847

4948
. = ALIGN(4);

0 commit comments

Comments
 (0)