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