xref: /linux/arch/arm64/kernel/vdso/vdso.lds.S (revision 111b29599c189247919a514b6c3a93e828db27c2)
1/* SPDX-License-Identifier: GPL-2.0-only */
2/*
3 * GNU linker script for the VDSO library.
4*
5 * Copyright (C) 2012 ARM Limited
6 *
7 * Author: Will Deacon <will.deacon@arm.com>
8 * Heavily based on the vDSO linker scripts for other archs.
9 */
10
11#include <linux/const.h>
12#include <asm/page.h>
13#include <asm/vdso.h>
14#include <asm/vdso/vsyscall.h>
15#include <asm-generic/vmlinux.lds.h>
16#include <vdso/datapage.h>
17
18OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64", "elf64-littleaarch64")
19OUTPUT_ARCH(aarch64)
20
21SECTIONS
22{
23	PROVIDE(_vdso_data = . - __VVAR_PAGES * PAGE_SIZE);
24	PROVIDE(_vdso_rng_data = _vdso_data + __VDSO_RND_DATA_OFFSET);
25#ifdef CONFIG_TIME_NS
26	PROVIDE(_timens_data = _vdso_data + PAGE_SIZE);
27#endif
28	. = SIZEOF_HEADERS;
29
30	.hash		: { *(.hash) }			:text
31	.gnu.hash	: { *(.gnu.hash) }
32	.dynsym		: { *(.dynsym) }
33	.dynstr		: { *(.dynstr) }
34	.gnu.version	: { *(.gnu.version) }
35	.gnu.version_d	: { *(.gnu.version_d) }
36	.gnu.version_r	: { *(.gnu.version_r) }
37
38	/*
39	 * Discard .note.gnu.property sections which are unused and have
40	 * different alignment requirement from vDSO note sections.
41	 */
42	/DISCARD/	: {
43		*(.note.GNU-stack .note.gnu.property)
44		*(.ARM.attributes)
45	}
46	.note		: { *(.note.*) }		:text	:note
47
48	. = ALIGN(16);
49
50	.text		: { *(.text*) }			:text	=0xd503201f
51	PROVIDE (__etext = .);
52	PROVIDE (_etext = .);
53	PROVIDE (etext = .);
54
55	. = ALIGN(4);
56	.altinstructions : {
57		*(.altinstructions)
58	}
59
60	.dynamic	: { *(.dynamic) }		:text	:dynamic
61
62	.rela.dyn	: ALIGN(8) { *(.rela .rela*) }
63
64	.rodata		: {
65		*(.rodata*)
66		*(.got)
67		*(.got.plt)
68		*(.plt)
69		*(.plt.*)
70		*(.iplt)
71		*(.igot .igot.plt)
72	}						:text
73
74	_end = .;
75	PROVIDE(end = .);
76
77	DWARF_DEBUG
78	ELF_DETAILS
79
80	/DISCARD/	: {
81		*(.data .data.* .gnu.linkonce.d.* .sdata*)
82		*(.bss .sbss .dynbss .dynsbss)
83		*(.eh_frame .eh_frame_hdr)
84	}
85}
86
87/*
88 * We must supply the ELF program headers explicitly to get just one
89 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
90 */
91PHDRS
92{
93	text		PT_LOAD		FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
94	dynamic		PT_DYNAMIC	FLAGS(4);		/* PF_R */
95	note		PT_NOTE		FLAGS(4);		/* PF_R */
96}
97
98/*
99 * This controls what symbols we export from the DSO.
100 */
101VERSION
102{
103	LINUX_2.6.39 {
104	global:
105		__kernel_rt_sigreturn;
106		__kernel_gettimeofday;
107		__kernel_clock_gettime;
108		__kernel_clock_getres;
109		__kernel_getrandom;
110	local: *;
111	};
112}
113
114/*
115 * Make the sigreturn code visible to the kernel.
116 */
117VDSO_sigtramp		= __kernel_rt_sigreturn;
118