diff options
author | Andy Lutomirski <luto@amacapital.net> | 2014-06-18 18:59:49 -0400 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2014-06-19 18:45:26 -0400 |
commit | 0e3727a8839c988a3c56170bc8da76d55a16acad (patch) | |
tree | bfecd620ea122be019fdf446d4c716244838fdfd /arch/x86/vdso | |
parent | bfad381c0d1e19cae8461e105d8d4387dd2a14fe (diff) |
x86/vdso: Remove some redundant in-memory section headers
.data doesn't need to be separate from .rodata: they're both readonly.
.altinstructions and .altinstr_replacement aren't needed by anything
except vdso2c; strip them from the final image.
While we're at it, rather than aligning the actual executable text,
just shove some unused-at-runtime data in between real data and
text.
My vdso image is still above 4k, but I'm disinclined to try to
trim it harder for 3.16. For future trimming, I suspect that these
sections could be moved to later in the file and dropped from
the in-memory image:
.gnu.version and .gnu.version_d (this may lose versions in gdb)
.eh_frame (should be harmless)
.eh_frame_hdr (I'm not really sure)
.hash (AFAIK nothing needs this section header)
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Link: http://lkml.kernel.org/r/2e96d0c49016ea6d026a614ae645e93edd325961.1403129369.git.luto@amacapital.net
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'arch/x86/vdso')
-rw-r--r-- | arch/x86/vdso/vdso-fakesections.c | 3 | ||||
-rw-r--r-- | arch/x86/vdso/vdso-layout.lds.S | 43 | ||||
-rw-r--r-- | arch/x86/vdso/vdso2c.h | 4 |
3 files changed, 26 insertions, 24 deletions
diff --git a/arch/x86/vdso/vdso-fakesections.c b/arch/x86/vdso/vdso-fakesections.c index 56927a7e4977..aa5fbfab20a5 100644 --- a/arch/x86/vdso/vdso-fakesections.c +++ b/arch/x86/vdso/vdso-fakesections.c | |||
@@ -16,9 +16,6 @@ const char fake_shstrtab[] __attribute__((section(".fake_shstrtab"))) = | |||
16 | ".rodata\0" | 16 | ".rodata\0" |
17 | ".fake_shstrtab\0" /* Yay, self-referential code. */ | 17 | ".fake_shstrtab\0" /* Yay, self-referential code. */ |
18 | ".note\0" | 18 | ".note\0" |
19 | ".data\0" | ||
20 | ".altinstructions\0" | ||
21 | ".altinstr_replacement\0" | ||
22 | ".eh_frame_hdr\0" | 19 | ".eh_frame_hdr\0" |
23 | ".eh_frame\0" | 20 | ".eh_frame\0" |
24 | ".text"; | 21 | ".text"; |
diff --git a/arch/x86/vdso/vdso-layout.lds.S b/arch/x86/vdso/vdso-layout.lds.S index e4cbc2145bab..9197544eea9a 100644 --- a/arch/x86/vdso/vdso-layout.lds.S +++ b/arch/x86/vdso/vdso-layout.lds.S | |||
@@ -14,7 +14,7 @@ | |||
14 | # error unknown VDSO target | 14 | # error unknown VDSO target |
15 | #endif | 15 | #endif |
16 | 16 | ||
17 | #define NUM_FAKE_SHDRS 16 | 17 | #define NUM_FAKE_SHDRS 13 |
18 | 18 | ||
19 | SECTIONS | 19 | SECTIONS |
20 | { | 20 | { |
@@ -28,15 +28,17 @@ SECTIONS | |||
28 | .gnu.version_d : { *(.gnu.version_d) } | 28 | .gnu.version_d : { *(.gnu.version_d) } |
29 | .gnu.version_r : { *(.gnu.version_r) } | 29 | .gnu.version_r : { *(.gnu.version_r) } |
30 | 30 | ||
31 | .note : { *(.note.*) } :text :note | ||
32 | |||
33 | .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr | ||
34 | .eh_frame : { KEEP (*(.eh_frame)) } :text | ||
35 | |||
36 | .dynamic : { *(.dynamic) } :text :dynamic | 31 | .dynamic : { *(.dynamic) } :text :dynamic |
37 | 32 | ||
38 | .rodata : { | 33 | .rodata : { |
39 | *(.rodata*) | 34 | *(.rodata*) |
35 | *(.data*) | ||
36 | *(.sdata*) | ||
37 | *(.got.plt) *(.got) | ||
38 | *(.gnu.linkonce.d.*) | ||
39 | *(.bss*) | ||
40 | *(.dynbss*) | ||
41 | *(.gnu.linkonce.b.*) | ||
40 | 42 | ||
41 | /* | 43 | /* |
42 | * Ideally this would live in a C file, but that won't | 44 | * Ideally this would live in a C file, but that won't |
@@ -50,28 +52,29 @@ SECTIONS | |||
50 | 52 | ||
51 | .fake_shstrtab : { *(.fake_shstrtab) } :text | 53 | .fake_shstrtab : { *(.fake_shstrtab) } :text |
52 | 54 | ||
53 | .data : { | ||
54 | *(.data*) | ||
55 | *(.sdata*) | ||
56 | *(.got.plt) *(.got) | ||
57 | *(.gnu.linkonce.d.*) | ||
58 | *(.bss*) | ||
59 | *(.dynbss*) | ||
60 | *(.gnu.linkonce.b.*) | ||
61 | } | ||
62 | 55 | ||
63 | .altinstructions : { *(.altinstructions) } | 56 | .note : { *(.note.*) } :text :note |
64 | .altinstr_replacement : { *(.altinstr_replacement) } | 57 | |
58 | .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr | ||
59 | .eh_frame : { KEEP (*(.eh_frame)) } :text | ||
60 | |||
65 | 61 | ||
66 | /* | 62 | /* |
67 | * Align the actual code well away from the non-instruction data. | 63 | * Text is well-separated from actual data: there's plenty of |
68 | * This is the best thing for the I-cache. | 64 | * stuff that isn't used at runtime in between. |
69 | */ | 65 | */ |
70 | . = ALIGN(0x100); | ||
71 | 66 | ||
72 | .text : { *(.text*) } :text =0x90909090, | 67 | .text : { *(.text*) } :text =0x90909090, |
73 | 68 | ||
74 | /* | 69 | /* |
70 | * At the end so that eu-elflint stays happy when vdso2c strips | ||
71 | * these. A better implementation would avoid allocating space | ||
72 | * for these. | ||
73 | */ | ||
74 | .altinstructions : { *(.altinstructions) } :text | ||
75 | .altinstr_replacement : { *(.altinstr_replacement) } :text | ||
76 | |||
77 | /* | ||
75 | * The remainder of the vDSO consists of special pages that are | 78 | * The remainder of the vDSO consists of special pages that are |
76 | * shared between the kernel and userspace. It needs to be at the | 79 | * shared between the kernel and userspace. It needs to be at the |
77 | * end so that it doesn't overlap the mapping of the actual | 80 | * end so that it doesn't overlap the mapping of the actual |
diff --git a/arch/x86/vdso/vdso2c.h b/arch/x86/vdso/vdso2c.h index f01ed4bde880..f42e2ddc663d 100644 --- a/arch/x86/vdso/vdso2c.h +++ b/arch/x86/vdso/vdso2c.h | |||
@@ -92,7 +92,9 @@ static void BITSFUNC(copy_section)(struct BITSFUNC(fake_sections) *out, | |||
92 | { | 92 | { |
93 | uint64_t flags = GET_LE(&in->sh_flags); | 93 | uint64_t flags = GET_LE(&in->sh_flags); |
94 | 94 | ||
95 | bool copy = flags & SHF_ALLOC; | 95 | bool copy = flags & SHF_ALLOC && |
96 | strcmp(name, ".altinstructions") && | ||
97 | strcmp(name, ".altinstr_replacement"); | ||
96 | 98 | ||
97 | if (!copy) | 99 | if (!copy) |
98 | return; | 100 | return; |