xref: /linux/arch/arm64/kernel/vdso/vdso.lds.S (revision 7f71507851fc7764b36a3221839607d3a45c2025)
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	}
45	.note		: { *(.note.*) }		:text	:note
46
47	. = ALIGN(16);
48
49	.text		: { *(.text*) }			:text	=0xd503201f
50	PROVIDE (__etext = .);
51	PROVIDE (_etext = .);
52	PROVIDE (etext = .);
53
54	. = ALIGN(4);
55	.altinstructions : {
56		*(.altinstructions)
57	}
58
59	.dynamic	: { *(.dynamic) }		:text	:dynamic
60
61	.rela.dyn	: ALIGN(8) { *(.rela .rela*) }
62
63	.rodata		: {
64		*(.rodata*)
65		*(.got)
66		*(.got.plt)
67		*(.plt)
68		*(.plt.*)
69		*(.iplt)
70		*(.igot .igot.plt)
71	}						:text
72
73	_end = .;
74	PROVIDE(end = .);
75
76	DWARF_DEBUG
77	ELF_DETAILS
78
79	/DISCARD/	: {
80		*(.data .data.* .gnu.linkonce.d.* .sdata*)
81		*(.bss .sbss .dynbss .dynsbss)
82		*(.eh_frame .eh_frame_hdr)
83	}
84}
85
86/*
87 * We must supply the ELF program headers explicitly to get just one
88 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
89 */
90PHDRS
91{
92	text		PT_LOAD		FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
93	dynamic		PT_DYNAMIC	FLAGS(4);		/* PF_R */
94	note		PT_NOTE		FLAGS(4);		/* PF_R */
95}
96
97/*
98 * This controls what symbols we export from the DSO.
99 */
100VERSION
101{
102	LINUX_2.6.39 {
103	global:
104		__kernel_rt_sigreturn;
105		__kernel_gettimeofday;
106		__kernel_clock_gettime;
107		__kernel_clock_getres;
108		__kernel_getrandom;
109	local: *;
110	};
111}
112
113/*
114 * Make the sigreturn code visible to the kernel.
115 */
116VDSO_sigtramp		= __kernel_rt_sigreturn;
117