1d603c8e1SIngo Molnar#include <asm/vdso.h> 2d603c8e1SIngo Molnar 3d603c8e1SIngo Molnar/* 4d603c8e1SIngo Molnar * Linker script for vDSO. This is an ELF shared object prelinked to 5d603c8e1SIngo Molnar * its virtual address, and with only one read-only segment. 6d603c8e1SIngo Molnar * This script controls its layout. 7d603c8e1SIngo Molnar */ 8d603c8e1SIngo Molnar 9d603c8e1SIngo Molnar#if defined(BUILD_VDSO64) 10d603c8e1SIngo Molnar# define SHDR_SIZE 64 11d603c8e1SIngo Molnar#elif defined(BUILD_VDSO32) || defined(BUILD_VDSOX32) 12d603c8e1SIngo Molnar# define SHDR_SIZE 40 13d603c8e1SIngo Molnar#else 14d603c8e1SIngo Molnar# error unknown VDSO target 15d603c8e1SIngo Molnar#endif 16d603c8e1SIngo Molnar 17d603c8e1SIngo Molnar#define NUM_FAKE_SHDRS 13 18d603c8e1SIngo Molnar 19d603c8e1SIngo MolnarSECTIONS 20d603c8e1SIngo Molnar{ 21d603c8e1SIngo Molnar /* 22d603c8e1SIngo Molnar * User/kernel shared data is before the vDSO. This may be a little 23d603c8e1SIngo Molnar * uglier than putting it after the vDSO, but it avoids issues with 24d603c8e1SIngo Molnar * non-allocatable things that dangle past the end of the PT_LOAD 25d603c8e1SIngo Molnar * segment. 26d603c8e1SIngo Molnar */ 27d603c8e1SIngo Molnar 28*1ed95e52SAndy Lutomirski vvar_start = . - 2 * PAGE_SIZE; 29d603c8e1SIngo Molnar vvar_page = vvar_start; 30d603c8e1SIngo Molnar 31d603c8e1SIngo Molnar /* Place all vvars at the offsets in asm/vvar.h. */ 32d603c8e1SIngo Molnar#define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset; 33d603c8e1SIngo Molnar#define __VVAR_KERNEL_LDS 34d603c8e1SIngo Molnar#include <asm/vvar.h> 35d603c8e1SIngo Molnar#undef __VVAR_KERNEL_LDS 36d603c8e1SIngo Molnar#undef EMIT_VVAR 37d603c8e1SIngo Molnar 38*1ed95e52SAndy Lutomirski pvclock_page = vvar_start + PAGE_SIZE; 39d603c8e1SIngo Molnar 40d603c8e1SIngo Molnar . = SIZEOF_HEADERS; 41d603c8e1SIngo Molnar 42d603c8e1SIngo Molnar .hash : { *(.hash) } :text 43d603c8e1SIngo Molnar .gnu.hash : { *(.gnu.hash) } 44d603c8e1SIngo Molnar .dynsym : { *(.dynsym) } 45d603c8e1SIngo Molnar .dynstr : { *(.dynstr) } 46d603c8e1SIngo Molnar .gnu.version : { *(.gnu.version) } 47d603c8e1SIngo Molnar .gnu.version_d : { *(.gnu.version_d) } 48d603c8e1SIngo Molnar .gnu.version_r : { *(.gnu.version_r) } 49d603c8e1SIngo Molnar 50d603c8e1SIngo Molnar .dynamic : { *(.dynamic) } :text :dynamic 51d603c8e1SIngo Molnar 52d603c8e1SIngo Molnar .rodata : { 53d603c8e1SIngo Molnar *(.rodata*) 54d603c8e1SIngo Molnar *(.data*) 55d603c8e1SIngo Molnar *(.sdata*) 56d603c8e1SIngo Molnar *(.got.plt) *(.got) 57d603c8e1SIngo Molnar *(.gnu.linkonce.d.*) 58d603c8e1SIngo Molnar *(.bss*) 59d603c8e1SIngo Molnar *(.dynbss*) 60d603c8e1SIngo Molnar *(.gnu.linkonce.b.*) 61d603c8e1SIngo Molnar 62d603c8e1SIngo Molnar /* 63d603c8e1SIngo Molnar * Ideally this would live in a C file, but that won't 64d603c8e1SIngo Molnar * work cleanly for x32 until we start building the x32 65d603c8e1SIngo Molnar * C code using an x32 toolchain. 66d603c8e1SIngo Molnar */ 67d603c8e1SIngo Molnar VDSO_FAKE_SECTION_TABLE_START = .; 68d603c8e1SIngo Molnar . = . + NUM_FAKE_SHDRS * SHDR_SIZE; 69d603c8e1SIngo Molnar VDSO_FAKE_SECTION_TABLE_END = .; 70d603c8e1SIngo Molnar } :text 71d603c8e1SIngo Molnar 72d603c8e1SIngo Molnar .fake_shstrtab : { *(.fake_shstrtab) } :text 73d603c8e1SIngo Molnar 74d603c8e1SIngo Molnar 75d603c8e1SIngo Molnar .note : { *(.note.*) } :text :note 76d603c8e1SIngo Molnar 77d603c8e1SIngo Molnar .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr 78d603c8e1SIngo Molnar .eh_frame : { KEEP (*(.eh_frame)) } :text 79d603c8e1SIngo Molnar 80d603c8e1SIngo Molnar 81d603c8e1SIngo Molnar /* 82d603c8e1SIngo Molnar * Text is well-separated from actual data: there's plenty of 83d603c8e1SIngo Molnar * stuff that isn't used at runtime in between. 84d603c8e1SIngo Molnar */ 85d603c8e1SIngo Molnar 86d603c8e1SIngo Molnar .text : { *(.text*) } :text =0x90909090, 87d603c8e1SIngo Molnar 88d603c8e1SIngo Molnar /* 89d603c8e1SIngo Molnar * At the end so that eu-elflint stays happy when vdso2c strips 90d603c8e1SIngo Molnar * these. A better implementation would avoid allocating space 91d603c8e1SIngo Molnar * for these. 92d603c8e1SIngo Molnar */ 93d603c8e1SIngo Molnar .altinstructions : { *(.altinstructions) } :text 94d603c8e1SIngo Molnar .altinstr_replacement : { *(.altinstr_replacement) } :text 95d603c8e1SIngo Molnar 96d603c8e1SIngo Molnar /DISCARD/ : { 97d603c8e1SIngo Molnar *(.discard) 98d603c8e1SIngo Molnar *(.discard.*) 99d603c8e1SIngo Molnar *(__bug_table) 100d603c8e1SIngo Molnar } 101d603c8e1SIngo Molnar} 102d603c8e1SIngo Molnar 103d603c8e1SIngo Molnar/* 104d603c8e1SIngo Molnar * Very old versions of ld do not recognize this name token; use the constant. 105d603c8e1SIngo Molnar */ 106d603c8e1SIngo Molnar#define PT_GNU_EH_FRAME 0x6474e550 107d603c8e1SIngo Molnar 108d603c8e1SIngo Molnar/* 109d603c8e1SIngo Molnar * We must supply the ELF program headers explicitly to get just one 110d603c8e1SIngo Molnar * PT_LOAD segment, and set the flags explicitly to make segments read-only. 111d603c8e1SIngo Molnar */ 112d603c8e1SIngo MolnarPHDRS 113d603c8e1SIngo Molnar{ 114d603c8e1SIngo Molnar text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */ 115d603c8e1SIngo Molnar dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 116d603c8e1SIngo Molnar note PT_NOTE FLAGS(4); /* PF_R */ 117d603c8e1SIngo Molnar eh_frame_hdr PT_GNU_EH_FRAME; 118d603c8e1SIngo Molnar} 119