1*4882a593Smuzhiyun/* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun#include <asm/vdso.h> 3*4882a593Smuzhiyun 4*4882a593Smuzhiyun/* 5*4882a593Smuzhiyun * Linker script for vDSO. This is an ELF shared object prelinked to 6*4882a593Smuzhiyun * its virtual address, and with only one read-only segment. 7*4882a593Smuzhiyun * This script controls its layout. 8*4882a593Smuzhiyun */ 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunSECTIONS 11*4882a593Smuzhiyun{ 12*4882a593Smuzhiyun /* 13*4882a593Smuzhiyun * User/kernel shared data is before the vDSO. This may be a little 14*4882a593Smuzhiyun * uglier than putting it after the vDSO, but it avoids issues with 15*4882a593Smuzhiyun * non-allocatable things that dangle past the end of the PT_LOAD 16*4882a593Smuzhiyun * segment. 17*4882a593Smuzhiyun */ 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun vvar_start = . - 4 * PAGE_SIZE; 20*4882a593Smuzhiyun vvar_page = vvar_start; 21*4882a593Smuzhiyun 22*4882a593Smuzhiyun /* Place all vvars at the offsets in asm/vvar.h. */ 23*4882a593Smuzhiyun#define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset; 24*4882a593Smuzhiyun#include <asm/vvar.h> 25*4882a593Smuzhiyun#undef EMIT_VVAR 26*4882a593Smuzhiyun 27*4882a593Smuzhiyun pvclock_page = vvar_start + PAGE_SIZE; 28*4882a593Smuzhiyun hvclock_page = vvar_start + 2 * PAGE_SIZE; 29*4882a593Smuzhiyun timens_page = vvar_start + 3 * PAGE_SIZE; 30*4882a593Smuzhiyun 31*4882a593Smuzhiyun#undef _ASM_X86_VVAR_H 32*4882a593Smuzhiyun /* Place all vvars in timens too at the offsets in asm/vvar.h. */ 33*4882a593Smuzhiyun#define EMIT_VVAR(name, offset) timens_ ## name = timens_page + offset; 34*4882a593Smuzhiyun#include <asm/vvar.h> 35*4882a593Smuzhiyun#undef EMIT_VVAR 36*4882a593Smuzhiyun 37*4882a593Smuzhiyun . = SIZEOF_HEADERS; 38*4882a593Smuzhiyun 39*4882a593Smuzhiyun .hash : { *(.hash) } :text 40*4882a593Smuzhiyun .gnu.hash : { *(.gnu.hash) } 41*4882a593Smuzhiyun .dynsym : { *(.dynsym) } 42*4882a593Smuzhiyun .dynstr : { *(.dynstr) } 43*4882a593Smuzhiyun .gnu.version : { *(.gnu.version) } 44*4882a593Smuzhiyun .gnu.version_d : { *(.gnu.version_d) } 45*4882a593Smuzhiyun .gnu.version_r : { *(.gnu.version_r) } 46*4882a593Smuzhiyun 47*4882a593Smuzhiyun .dynamic : { *(.dynamic) } :text :dynamic 48*4882a593Smuzhiyun 49*4882a593Smuzhiyun .rodata : { 50*4882a593Smuzhiyun *(.rodata*) 51*4882a593Smuzhiyun *(.data*) 52*4882a593Smuzhiyun *(.sdata*) 53*4882a593Smuzhiyun *(.got.plt) *(.got) 54*4882a593Smuzhiyun *(.gnu.linkonce.d.*) 55*4882a593Smuzhiyun *(.bss*) 56*4882a593Smuzhiyun *(.dynbss*) 57*4882a593Smuzhiyun *(.gnu.linkonce.b.*) 58*4882a593Smuzhiyun } :text 59*4882a593Smuzhiyun 60*4882a593Smuzhiyun /* 61*4882a593Smuzhiyun * Discard .note.gnu.property sections which are unused and have 62*4882a593Smuzhiyun * different alignment requirement from vDSO note sections. 63*4882a593Smuzhiyun */ 64*4882a593Smuzhiyun /DISCARD/ : { 65*4882a593Smuzhiyun *(.note.gnu.property) 66*4882a593Smuzhiyun } 67*4882a593Smuzhiyun .note : { *(.note.*) } :text :note 68*4882a593Smuzhiyun 69*4882a593Smuzhiyun .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr 70*4882a593Smuzhiyun .eh_frame : { KEEP (*(.eh_frame)) } :text 71*4882a593Smuzhiyun 72*4882a593Smuzhiyun 73*4882a593Smuzhiyun /* 74*4882a593Smuzhiyun * Text is well-separated from actual data: there's plenty of 75*4882a593Smuzhiyun * stuff that isn't used at runtime in between. 76*4882a593Smuzhiyun */ 77*4882a593Smuzhiyun 78*4882a593Smuzhiyun .text : { *(.text*) } :text =0x90909090, 79*4882a593Smuzhiyun 80*4882a593Smuzhiyun .altinstructions : { *(.altinstructions) } :text 81*4882a593Smuzhiyun .altinstr_replacement : { *(.altinstr_replacement) } :text 82*4882a593Smuzhiyun 83*4882a593Smuzhiyun /DISCARD/ : { 84*4882a593Smuzhiyun *(.discard) 85*4882a593Smuzhiyun *(.discard.*) 86*4882a593Smuzhiyun *(__bug_table) 87*4882a593Smuzhiyun } 88*4882a593Smuzhiyun} 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun/* 91*4882a593Smuzhiyun * Very old versions of ld do not recognize this name token; use the constant. 92*4882a593Smuzhiyun */ 93*4882a593Smuzhiyun#define PT_GNU_EH_FRAME 0x6474e550 94*4882a593Smuzhiyun 95*4882a593Smuzhiyun/* 96*4882a593Smuzhiyun * We must supply the ELF program headers explicitly to get just one 97*4882a593Smuzhiyun * PT_LOAD segment, and set the flags explicitly to make segments read-only. 98*4882a593Smuzhiyun */ 99*4882a593SmuzhiyunPHDRS 100*4882a593Smuzhiyun{ 101*4882a593Smuzhiyun text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ 102*4882a593Smuzhiyun dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 103*4882a593Smuzhiyun note PT_NOTE FLAGS(4); /* PF_R */ 104*4882a593Smuzhiyun eh_frame_hdr PT_GNU_EH_FRAME; 105*4882a593Smuzhiyun} 106