162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * Copyright (C) 2015 Imagination Technologies
462306a36Sopenharmony_ci * Author: Alex Smith <alex.smith@imgtec.com>
562306a36Sopenharmony_ci */
662306a36Sopenharmony_ci
762306a36Sopenharmony_ci#include <asm/sgidefs.h>
862306a36Sopenharmony_ci
962306a36Sopenharmony_ci#if _MIPS_SIM == _MIPS_SIM_ABI64
1062306a36Sopenharmony_ciOUTPUT_FORMAT("elf64-tradlittlemips", "elf64-tradbigmips", "elf64-tradlittlemips")
1162306a36Sopenharmony_ci#elif _MIPS_SIM == _MIPS_SIM_NABI32
1262306a36Sopenharmony_ciOUTPUT_FORMAT("elf32-ntradlittlemips", "elf32-ntradbigmips", "elf32-ntradlittlemips")
1362306a36Sopenharmony_ci#else
1462306a36Sopenharmony_ciOUTPUT_FORMAT("elf32-tradlittlemips", "elf32-tradbigmips", "elf32-tradlittlemips")
1562306a36Sopenharmony_ci#endif
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ciOUTPUT_ARCH(mips)
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ciSECTIONS
2062306a36Sopenharmony_ci{
2162306a36Sopenharmony_ci	PROVIDE(_start = .);
2262306a36Sopenharmony_ci	. = SIZEOF_HEADERS;
2362306a36Sopenharmony_ci
2462306a36Sopenharmony_ci	/*
2562306a36Sopenharmony_ci	 * In order to retain compatibility with older toolchains we provide the
2662306a36Sopenharmony_ci	 * ABI flags section ourself. Newer assemblers will automatically
2762306a36Sopenharmony_ci	 * generate .MIPS.abiflags sections so we discard such input sections,
2862306a36Sopenharmony_ci	 * and then manually define our own section here. genvdso will patch
2962306a36Sopenharmony_ci	 * this section to have the correct name/type.
3062306a36Sopenharmony_ci	 */
3162306a36Sopenharmony_ci	.mips_abiflags	: { *(.mips_abiflags) } 	:text :abiflags
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci	.reginfo	: { *(.reginfo) }		:text :reginfo
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ci	.hash		: { *(.hash) }			:text
3662306a36Sopenharmony_ci	.gnu.hash	: { *(.gnu.hash) }
3762306a36Sopenharmony_ci	.dynsym		: { *(.dynsym) }
3862306a36Sopenharmony_ci	.dynstr		: { *(.dynstr) }
3962306a36Sopenharmony_ci	.gnu.version	: { *(.gnu.version) }
4062306a36Sopenharmony_ci	.gnu.version_d	: { *(.gnu.version_d) }
4162306a36Sopenharmony_ci	.gnu.version_r	: { *(.gnu.version_r) }
4262306a36Sopenharmony_ci
4362306a36Sopenharmony_ci	.note		: { *(.note.*) }		:text :note
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci	.text		: { *(.text*) }			:text
4662306a36Sopenharmony_ci	PROVIDE (__etext = .);
4762306a36Sopenharmony_ci	PROVIDE (_etext = .);
4862306a36Sopenharmony_ci	PROVIDE (etext = .);
4962306a36Sopenharmony_ci
5062306a36Sopenharmony_ci	.eh_frame_hdr	: { *(.eh_frame_hdr) }		:text :eh_frame_hdr
5162306a36Sopenharmony_ci	.eh_frame	: { KEEP (*(.eh_frame)) }	:text
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci	.dynamic	: { *(.dynamic) }		:text :dynamic
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci	.rodata		: { *(.rodata*) }		:text
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ci	_end = .;
5862306a36Sopenharmony_ci	PROVIDE(end = .);
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ci	/DISCARD/	: {
6162306a36Sopenharmony_ci		*(.MIPS.abiflags)
6262306a36Sopenharmony_ci		*(.gnu.attributes)
6362306a36Sopenharmony_ci		*(.note.GNU-stack)
6462306a36Sopenharmony_ci		*(.data .data.* .gnu.linkonce.d.* .sdata*)
6562306a36Sopenharmony_ci		*(.bss .sbss .dynbss .dynsbss)
6662306a36Sopenharmony_ci	}
6762306a36Sopenharmony_ci}
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ciPHDRS
7062306a36Sopenharmony_ci{
7162306a36Sopenharmony_ci	/*
7262306a36Sopenharmony_ci	 * Provide a PT_MIPS_ABIFLAGS header to assign the ABI flags section
7362306a36Sopenharmony_ci	 * to. We can specify the header type directly here so no modification
7462306a36Sopenharmony_ci	 * is needed later on.
7562306a36Sopenharmony_ci	 */
7662306a36Sopenharmony_ci	abiflags	0x70000003;
7762306a36Sopenharmony_ci
7862306a36Sopenharmony_ci	/*
7962306a36Sopenharmony_ci	 * The ABI flags header must exist directly after the PT_INTERP header,
8062306a36Sopenharmony_ci	 * so we must explicitly place the PT_MIPS_REGINFO header after it to
8162306a36Sopenharmony_ci	 * stop the linker putting one in at the start.
8262306a36Sopenharmony_ci	 */
8362306a36Sopenharmony_ci	reginfo		0x70000000;
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci	text		PT_LOAD		FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
8662306a36Sopenharmony_ci	dynamic		PT_DYNAMIC	FLAGS(4);		/* PF_R */
8762306a36Sopenharmony_ci	note		PT_NOTE		FLAGS(4);		/* PF_R */
8862306a36Sopenharmony_ci	eh_frame_hdr	PT_GNU_EH_FRAME;
8962306a36Sopenharmony_ci}
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ciVERSION
9262306a36Sopenharmony_ci{
9362306a36Sopenharmony_ci	LINUX_2.6 {
9462306a36Sopenharmony_ci#ifndef CONFIG_MIPS_DISABLE_VDSO
9562306a36Sopenharmony_ci	global:
9662306a36Sopenharmony_ci		__vdso_clock_gettime;
9762306a36Sopenharmony_ci#ifdef CONFIG_MIPS_CLOCK_VSYSCALL
9862306a36Sopenharmony_ci		__vdso_gettimeofday;
9962306a36Sopenharmony_ci#endif
10062306a36Sopenharmony_ci		__vdso_clock_getres;
10162306a36Sopenharmony_ci#if _MIPS_SIM != _MIPS_SIM_ABI64
10262306a36Sopenharmony_ci		__vdso_clock_gettime64;
10362306a36Sopenharmony_ci#endif
10462306a36Sopenharmony_ci#endif
10562306a36Sopenharmony_ci	local: *;
10662306a36Sopenharmony_ci	};
10762306a36Sopenharmony_ci}
108