2007-09-24 11:05:34

by Roland McGrath

[permalink] [raw]
Subject: [PATCH 1/2] x86_64 vDSO linker script cleanup


I can't see the reason ". = VDSO_PRELINK + 0x900;" was ever there in the
linker script for the x86_64 vDSO. I can't find anything that depends on
this magic offset, or that should care at all about the particular location
of of the .data section (all from vvar.c) in the vDSO image. If it is
really desireable to place .data at 0x900, then it should be after all the
other sections so they fill in the space up to 0x900.

This removes the 0x900 magic and cleans up the output sections generally in
the vDSO linker script. This saves a few hundred bytes in the size of the
vDSO file, bringing it back well under 4kb total so that its vma only needs
one page.

Signed-off-by: Roland McGrath <[email protected]>
---
arch/x86_64/vdso/vdso.lds.S | 16 +++++++++-------
1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/arch/x86_64/vdso/vdso.lds.S b/arch/x86_64/vdso/vdso.lds.S
index b9a60e6..667d324 100644
--- a/arch/x86_64/vdso/vdso.lds.S
+++ b/arch/x86_64/vdso/vdso.lds.S
@@ -26,13 +26,16 @@ SECTIONS
is insufficient, ld -shared will barf. Just increase it here. */
. = VDSO_PRELINK + VDSO_TEXT_OFFSET;

- .text : { *(.text) } :text
- .text.ptr : { *(.text.ptr) } :text
- . = VDSO_PRELINK + 0x900;
- .data : { *(.data) } :text
- .bss : { *(.bss) } :text
+ .text : { *(.text*) } :text
+ .rodata : { *(.rodata*) } :text
+ .data : {
+ *(.data*)
+ *(.sdata*)
+ *(.bss*)
+ *(.dynbss*)
+ } :text

- .altinstructions : { *(.altinstructions) } :text
+ .altinstructions : { *(.altinstructions) } :text
.altinstr_replacement : { *(.altinstr_replacement) } :text

.note : { *(.note.*) } :text :note
@@ -42,7 +45,6 @@ SECTIONS
.useless : {
*(.got.plt) *(.got)
*(.gnu.linkonce.d.*)
- *(.dynbss)
*(.gnu.linkonce.b.*)
} :text
}


2007-10-11 07:40:52

by Roland McGrath

[permalink] [raw]
Subject: [PATCH] x86_64 vDSO linker script cleanup

This replaces my earlier patch by the same title:
x86_64-vdso-linker-script-cleanup.patch


Thanks,
Roland

---

[PATCH] x86_64 vDSO linker script cleanup

This reorganizes the x86_64 vDSO layout to pack the contents better.
This yields a smaller image, while keeping code cache-aligned away
from data, and leaving more room to grow both in the .note section
(where --build-id can add some), and in the code (.text) section,
before the image grows past one 4kb page.

Signed-off-by: Roland McGrath <[email protected]>
Cc: Andi Kleen <[email protected]>
---
arch/x86_64/vdso/vdso.lds.S | 47 +++++++++++++++++++++++++++++-------------
1 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/arch/x86_64/vdso/vdso.lds.S b/arch/x86_64/vdso/vdso.lds.S
index b9a60e6..726bc6d 100644
--- a/arch/x86_64/vdso/vdso.lds.S
+++ b/arch/x86_64/vdso/vdso.lds.S
@@ -20,30 +20,47 @@ SECTIONS
.gnu.version_d : { *(.gnu.version_d) }
.gnu.version_r : { *(.gnu.version_r) }

+ /* The kernel does not need to know these addresses,
+ so they don't need to be before VDSO_TEXT_OFFSET.
+ Pack these in here to sop up the space used for the alignment. */
+ .note : { *(.note.*) } :text :note
+ .useless : {
+ *(.got.plt) *(.got)
+ *(.gnu.linkonce.d.*)
+ *(.gnu.linkonce.b.*)
+ } :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 et al. If this amount
- is insufficient, ld -shared will barf. Just increase it here. */
+ is insufficient, ld -shared will barf.
+ Just increase VDSO_TEXT_OFFSET (in voffset.h). */
. = VDSO_PRELINK + VDSO_TEXT_OFFSET;

- .text : { *(.text) } :text
- .text.ptr : { *(.text.ptr) } :text
- . = VDSO_PRELINK + 0x900;
- .data : { *(.data) } :text
- .bss : { *(.bss) } :text
+ .rodata : { *(.rodata*) } :text
+ .data : {
+ *(.data*)
+ *(.sdata*)
+ *(.bss*)
+ *(.dynbss*)
+ } :text

- .altinstructions : { *(.altinstructions) } :text
- .altinstr_replacement : { *(.altinstr_replacement) } :text
+ .dynamic : { *(.dynamic) } :text :dynamic

- .note : { *(.note.*) } :text :note
.eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
.eh_frame : { KEEP (*(.eh_frame)) } :text
- .dynamic : { *(.dynamic) } :text :dynamic
- .useless : {
- *(.got.plt) *(.got)
- *(.gnu.linkonce.d.*)
- *(.dynbss)
- *(.gnu.linkonce.b.*)
+
+ .altinstructions : { *(.altinstructions) } :text
+ .altinstr_replacement : { *(.altinstr_replacement) } :text
+
+ /* Separate actual executed code from other data for happy caches. */
+ . = ALIGN(128);
+
+ .text : {
+ FILL(0x90909090);
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ KEEP (*(.text.*personality*))
+ . = ALIGN(128);
} :text
}

2007-10-11 11:24:00

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH] x86_64 vDSO linker script cleanup

On Thu, Oct 11, 2007 at 12:40:37AM -0700, Roland McGrath wrote:
> This replaces my earlier patch by the same title:
> x86_64-vdso-linker-script-cleanup.patch

Hi Roland.

I have been through a number of arch linker scripts lately
introducing a consistent style.
I decided upon a style matching what we have for c today:
indent with one tab, nothing after starting {,
indendt after starting { etc.

Would you mind introducing same style for the vdso linker script?

I could do it just fine but I'm afraid to clash with your work.

None of my clean-up patches has hit -linus yet but I
assume most will do so during the merge window. All arch maintainers
has accepted the cleanup patches.

Latest in the series was parisc - patch is here:
http://lists.parisc-linux.org/pipermail/parisc-linux/2007-October/031967.html

Sam