1/* SPDX-License-Identifier: GPL-2.0-or-later */
2/*
3 * Copyright (C) 2015 Imagination Technologies
4 * Author: Alex Smith <alex.smith@imgtec.com>
5 */
6
7#include <asm/sgidefs.h>
8#include <asm/vdso/vdso.h>
9#include <vdso/datapage.h>
10
11#if _MIPS_SIM == _MIPS_SIM_ABI64
12OUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips", "elf64-tradlittlemips")
13#elif _MIPS_SIM == _MIPS_SIM_NABI32
14OUTPUT_FORMAT("elf32-ntradlittlemips", "elf32-ntradbigmips", "elf32-ntradlittlemips")
15#else
16OUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips", "elf32-tradlittlemips")
17#endif
18
19OUTPUT_ARCH(mips)
20
21SECTIONS
22{
23	VDSO_VVAR_SYMS
24
25	. = SIZEOF_HEADERS;
26
27	/*
28	 * In order to retain compatibility with older toolchains we provide the
29	 * ABI flags section ourself. Newer assemblers will automatically
30	 * generate .MIPS.abiflags sections so we discard such input sections,
31	 * and then manually define our own section here. genvdso will patch
32	 * this section to have the correct name/type.
33	 */
34	.mips_abiflags	: { *(.mips_abiflags) } 	:text :abiflags
35
36	.reginfo	: { *(.reginfo) }		:text :reginfo
37
38	.hash		: { *(.hash) }			:text
39	.gnu.hash	: { *(.gnu.hash) }
40	.dynsym		: { *(.dynsym) }
41	.dynstr		: { *(.dynstr) }
42	.gnu.version	: { *(.gnu.version) }
43	.gnu.version_d	: { *(.gnu.version_d) }
44	.gnu.version_r	: { *(.gnu.version_r) }
45
46	.note		: { *(.note.*) }		:text :note
47
48	.text		: { *(.text*) }			:text
49	PROVIDE (__etext = .);
50	PROVIDE (_etext = .);
51	PROVIDE (etext = .);
52
53	.eh_frame_hdr	: { *(.eh_frame_hdr) }		:text :eh_frame_hdr
54	.eh_frame	: { KEEP (*(.eh_frame)) }	:text
55
56	.dynamic	: { *(.dynamic) }		:text :dynamic
57
58	.rodata		: { *(.rodata*) }		:text
59
60	_end = .;
61	PROVIDE(end = .);
62
63	/DISCARD/	: {
64		*(.MIPS.abiflags)
65		*(.gnu.attributes)
66		*(.note.GNU-stack)
67		*(.data .data.* .gnu.linkonce.d.* .sdata*)
68		*(.bss .sbss .dynbss .dynsbss)
69	}
70}
71
72PHDRS
73{
74	/*
75	 * Provide a PT_MIPS_ABIFLAGS header to assign the ABI flags section
76	 * to. We can specify the header type directly here so no modification
77	 * is needed later on.
78	 */
79	abiflags	0x70000003;
80
81	/*
82	 * The ABI flags header must exist directly after the PT_INTERP header,
83	 * so we must explicitly place the PT_MIPS_REGINFO header after it to
84	 * stop the linker putting one in at the start.
85	 */
86	reginfo		0x70000000;
87
88	text		PT_LOAD		FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
89	dynamic		PT_DYNAMIC	FLAGS(4);		/* PF_R */
90	note		PT_NOTE		FLAGS(4);		/* PF_R */
91	eh_frame_hdr	PT_GNU_EH_FRAME;
92}
93
94VERSION
95{
96	LINUX_2.6 {
97#ifndef CONFIG_MIPS_DISABLE_VDSO
98	global:
99		__vdso_clock_gettime;
100#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
101		__vdso_gettimeofday;
102#endif
103		__vdso_clock_getres;
104#if _MIPS_SIM != _MIPS_SIM_ABI64
105		__vdso_clock_gettime64;
106#endif
107#endif
108	local: *;
109	};
110}
111