1/* SPDX-License-Identifier: GPL-2.0 */
2#include <asm/vdso.h>
3#include <asm/vdso/vsyscall.h>
4#include <vdso/datapage.h>
5
6/*
7 * Linker script for vDSO. This is an ELF shared object prelinked to
8 * its virtual address, and with only one read-only segment.
9 * This script controls its layout.
10 */
11
12SECTIONS
13{
14 /*
15 * User/kernel shared data is before the vDSO. This may be a little
16 * uglier than putting it after the vDSO, but it avoids issues with
17 * non-allocatable things that dangle past the end of the PT_LOAD
18 * segment.
19 */
20
21 VDSO_VVAR_SYMS
22
23 vclock_pages = VDSO_VCLOCK_PAGES_START(vdso_u_data);
24 pvclock_page = vclock_pages + VDSO_PAGE_PVCLOCK_OFFSET * PAGE_SIZE;
25 hvclock_page = vclock_pages + VDSO_PAGE_HVCLOCK_OFFSET * PAGE_SIZE;
26
27 . = SIZEOF_HEADERS;
28
29 .hash : { *(.hash) } :text
30 .gnu.hash : { *(.gnu.hash) }
31 .dynsym : { *(.dynsym) }
32 .dynstr : { *(.dynstr) }
33 .gnu.version : { *(.gnu.version) }
34 .gnu.version_d : { *(.gnu.version_d) }
35 .gnu.version_r : { *(.gnu.version_r) }
36
37 .dynamic : { *(.dynamic) } :text :dynamic
38
39 .rodata : {
40 *(.rodata*)
41 *(.data*)
42 *(.sdata*)
43 *(.got.plt) *(.got)
44 *(.gnu.linkonce.d.*)
45 *(.bss*)
46 *(.dynbss*)
47 *(.gnu.linkonce.b.*)
48 } :text
49
50 /*
51 * Discard .note.gnu.property sections which are unused and have
52 * different alignment requirement from vDSO note sections.
53 */
54 /DISCARD/ : {
55 *(.note.gnu.property)
56 }
57 .note : { *(.note.*) } :text :note
58
59 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
60 .eh_frame : { KEEP (*(.eh_frame)) } :text
61
62
63 /*
64 * Text is well-separated from actual data: there's plenty of
65 * stuff that isn't used at runtime in between.
66 */
67
68 .text : {
69 *(.text*)
70 } :text =0x90909090,
71
72
73
74 .altinstructions : { *(.altinstructions) } :text
75 .altinstr_replacement : { *(.altinstr_replacement) } :text
76
77 __ex_table : { *(__ex_table) } :text
78
79 /DISCARD/ : {
80 *(.discard)
81 *(.discard.*)
82 *(__bug_table)
83 }
84}
85
86/*
87 * Very old versions of ld do not recognize this name token; use the constant.
88 */
89#define PT_GNU_EH_FRAME 0x6474e550
90
91/*
92 * We must supply the ELF program headers explicitly to get just one
93 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
94 */
95PHDRS
96{
97 text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
98 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
99 note PT_NOTE FLAGS(4); /* PF_R */
100 eh_frame_hdr PT_GNU_EH_FRAME;
101}
102

source code of linux/arch/x86/entry/vdso/vdso-layout.lds.S