blob: e4cbc2145bab167c2b257de5dfdd28690279a7dc [file] [log] [blame]
Andy Lutomirski18d0a6f2014-05-05 12:19:35 -07001#include <asm/vdso.h>
2
Roland McGrathf6b46eb2008-01-30 13:30:41 +01003/*
4 * Linker script for vDSO. This is an ELF shared object prelinked to
5 * its virtual address, and with only one read-only segment.
6 * This script controls its layout.
7 */
8
Andy Lutomirskibfad3812014-06-18 15:59:48 -07009#if defined(BUILD_VDSO64)
10# define SHDR_SIZE 64
11#elif defined(BUILD_VDSO32) || defined(BUILD_VDSOX32)
12# define SHDR_SIZE 40
13#else
14# error unknown VDSO target
15#endif
16
17#define NUM_FAKE_SHDRS 16
18
Roland McGrathf6b46eb2008-01-30 13:30:41 +010019SECTIONS
20{
Andy Lutomirskib0b49f22014-03-13 16:01:26 -070021 . = SIZEOF_HEADERS;
Roland McGrathf6b46eb2008-01-30 13:30:41 +010022
23 .hash : { *(.hash) } :text
24 .gnu.hash : { *(.gnu.hash) }
25 .dynsym : { *(.dynsym) }
26 .dynstr : { *(.dynstr) }
27 .gnu.version : { *(.gnu.version) }
28 .gnu.version_d : { *(.gnu.version_d) }
29 .gnu.version_r : { *(.gnu.version_r) }
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
37
Andy Lutomirskibfad3812014-06-18 15:59:48 -070038 .rodata : {
39 *(.rodata*)
40
41 /*
42 * Ideally this would live in a C file, but that won't
43 * work cleanly for x32 until we start building the x32
44 * C code using an x32 toolchain.
45 */
46 VDSO_FAKE_SECTION_TABLE_START = .;
47 . = . + NUM_FAKE_SHDRS * SHDR_SIZE;
48 VDSO_FAKE_SECTION_TABLE_END = .;
49 } :text
50
51 .fake_shstrtab : { *(.fake_shstrtab) } :text
52
Roland McGrathf6b46eb2008-01-30 13:30:41 +010053 .data : {
Andy Lutomirskibfad3812014-06-18 15:59:48 -070054 *(.data*)
55 *(.sdata*)
56 *(.got.plt) *(.got)
57 *(.gnu.linkonce.d.*)
58 *(.bss*)
59 *(.dynbss*)
60 *(.gnu.linkonce.b.*)
Roland McGrathf6b46eb2008-01-30 13:30:41 +010061 }
62
63 .altinstructions : { *(.altinstructions) }
64 .altinstr_replacement : { *(.altinstr_replacement) }
65
66 /*
67 * Align the actual code well away from the non-instruction data.
68 * This is the best thing for the I-cache.
69 */
70 . = ALIGN(0x100);
71
Andy Lutomirski378ed3c2014-04-03 10:53:43 -070072 .text : { *(.text*) } :text =0x90909090,
73
74 /*
Andy Lutomirski18d0a6f2014-05-05 12:19:35 -070075 * The remainder of the vDSO consists of special pages that are
76 * 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
78 * vDSO image.
Andy Lutomirski378ed3c2014-04-03 10:53:43 -070079 */
H. Peter Anvin26f5ef22014-03-25 13:41:36 -070080
Andy Lutomirski18d0a6f2014-05-05 12:19:35 -070081 . = ALIGN(PAGE_SIZE);
82 vvar_page = .;
83
84 /* Place all vvars at the offsets in asm/vvar.h. */
85#define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset;
86#define __VVAR_KERNEL_LDS
87#include <asm/vvar.h>
88#undef __VVAR_KERNEL_LDS
89#undef EMIT_VVAR
90
91 . = vvar_page + PAGE_SIZE;
92
93 hpet_page = .;
94 . = . + PAGE_SIZE;
Andy Lutomirski18d0a6f2014-05-05 12:19:35 -070095
96 . = ALIGN(PAGE_SIZE);
97 end_mapping = .;
98
H. Peter Anvin26f5ef22014-03-25 13:41:36 -070099 /DISCARD/ : {
100 *(.discard)
101 *(.discard.*)
Andy Lutomirski5f56e712014-06-18 15:59:46 -0700102 *(__bug_table)
H. Peter Anvin26f5ef22014-03-25 13:41:36 -0700103 }
Roland McGrathf6b46eb2008-01-30 13:30:41 +0100104}
105
106/*
107 * Very old versions of ld do not recognize this name token; use the constant.
108 */
109#define PT_GNU_EH_FRAME 0x6474e550
110
111/*
112 * We must supply the ELF program headers explicitly to get just one
113 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
114 */
115PHDRS
116{
117 text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
118 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
119 note PT_NOTE FLAGS(4); /* PF_R */
120 eh_frame_hdr PT_GNU_EH_FRAME;
Roland McGrathf6b46eb2008-01-30 13:30:41 +0100121}