1/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * This is the infamous ld script for the 64 bits vdso
4 * library
5 */
6#include <asm/vdso.h>
7#include <asm/page.h>
8#include <asm-generic/vmlinux.lds.h>
9#include <vdso/datapage.h>
10
11#ifdef __LITTLE_ENDIAN__
12OUTPUT_FORMAT("elf64-powerpcle", "elf64-powerpcle", "elf64-powerpcle")
13#else
14OUTPUT_FORMAT("elf64-powerpc", "elf64-powerpc", "elf64-powerpc")
15#endif
16OUTPUT_ARCH(powerpc:common64)
17
18SECTIONS
19{
20	VDSO_VVAR_SYMS
21
22	. = SIZEOF_HEADERS;
23
24	.hash		: { *(.hash) }			:text
25	.gnu.hash	: { *(.gnu.hash) }
26	.dynsym		: { *(.dynsym) }
27	.dynstr		: { *(.dynstr) }
28	.gnu.version	: { *(.gnu.version) }
29	.gnu.version_d	: { *(.gnu.version_d) }
30	.gnu.version_r	: { *(.gnu.version_r) }
31
32	.note		: { *(.note.*) }		:text	:note
33
34	. = ALIGN(16);
35	.text		: {
36		*(.text .stub .text.* .gnu.linkonce.t.* __ftr_alt_*)
37		*(.sfpr)
38	}						:text
39	PROVIDE(__etext = .);
40	PROVIDE(_etext = .);
41	PROVIDE(etext = .);
42
43	. = ALIGN(8);
44	VDSO_ftr_fixup_start = .;
45	__ftr_fixup	: { *(__ftr_fixup) }
46	VDSO_ftr_fixup_end = .;
47
48	. = ALIGN(8);
49	VDSO_mmu_ftr_fixup_start = .;
50	__mmu_ftr_fixup	: { *(__mmu_ftr_fixup) }
51	VDSO_mmu_ftr_fixup_end = .;
52
53	. = ALIGN(8);
54	VDSO_lwsync_fixup_start = .;
55	__lwsync_fixup	: { *(__lwsync_fixup) }
56	VDSO_lwsync_fixup_end = .;
57
58	. = ALIGN(8);
59	VDSO_fw_ftr_fixup_start = .;
60	__fw_ftr_fixup	: { *(__fw_ftr_fixup) }
61	VDSO_fw_ftr_fixup_end = .;
62
63	/*
64	 * Other stuff is appended to the text segment:
65	 */
66	.rodata		: { *(.rodata .rodata.* .gnu.linkonce.r.*) }
67	.rodata1	: { *(.rodata1) }
68
69	.dynamic	: { *(.dynamic) }		:text	:dynamic
70
71	.eh_frame_hdr	: { *(.eh_frame_hdr) }		:text	:eh_frame_hdr
72	.eh_frame	: { KEEP (*(.eh_frame)) }	:text
73	.gcc_except_table : { *(.gcc_except_table) }
74	.rela.dyn ALIGN(8) : { *(.rela .rela*) }
75
76	.got ALIGN(8)	: { *(.got .toc) }
77
78	_end = .;
79	PROVIDE(end = .);
80
81	DWARF_DEBUG
82	ELF_DETAILS
83
84	/DISCARD/	: {
85		*(.note.GNU-stack)
86		*(*.EMB.apuinfo)
87		*(.branch_lt)
88		*(.data .data.* .gnu.linkonce.d.* .sdata*)
89		*(.bss .sbss .dynbss .dynsbss)
90		*(.opd)
91		*(.glink .iplt .plt)
92	}
93}
94
95/*
96 * Very old versions of ld do not recognize this name token; use the constant.
97 */
98#define PT_GNU_EH_FRAME	0x6474e550
99
100/*
101 * We must supply the ELF program headers explicitly to get just one
102 * PT_LOAD segment, and set the flags explicitly to make segments read-only.
103 */
104PHDRS
105{
106	text		PT_LOAD FILEHDR PHDRS FLAGS(5);	/* PF_R|PF_X */
107	dynamic		PT_DYNAMIC FLAGS(4);		/* PF_R */
108	note		PT_NOTE FLAGS(4);		/* PF_R */
109	eh_frame_hdr	PT_GNU_EH_FRAME;
110}
111
112/*
113 * This controls what symbols we export from the DSO.
114 */
115VERSION
116{
117	VDSO_VERSION_STRING {
118	global:
119		__kernel_get_syscall_map;
120		__kernel_gettimeofday;
121		__kernel_clock_gettime;
122		__kernel_clock_getres;
123		__kernel_get_tbfreq;
124		__kernel_sync_dicache;
125		__kernel_sigtramp_rt64;
126		__kernel_getcpu;
127		__kernel_time;
128		__kernel_getrandom;
129
130	local: *;
131	};
132}
133
134/*
135 * Make the sigreturn code visible to the kernel.
136 */
137VDSO_sigtramp_rt64	= __kernel_start_sigtramp_rt64;
138