github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/vdso/vdso_amd64.lds (about) 1 /* 2 * Linker script for the VDSO. 3 * 4 * The VDSO is essentially a normal ELF shared library that is mapped into the 5 * address space of the process that is going to use it. The address of the 6 * VDSO is passed to the runtime linker in the AT_SYSINFO_EHDR entry of the aux 7 * vector. 8 * 9 * There are, however, three ways in which the VDSO differs from a normal 10 * shared library: 11 * 12 * - The runtime linker does not attempt to process any relocations for the 13 * VDSO so it is the responsibility of whoever loads the VDSO into the 14 * address space to do this if necessary. Because of this restriction we are 15 * careful to ensure that the VDSO does not need to have any relocations 16 * applied to it. 17 * 18 * - Although the VDSO is position independent and would normally be linked at 19 * virtual address 0, the Linux kernel VDSO is actually linked at a non zero 20 * virtual address and the code in the system runtime linker that handles the 21 * VDSO expects this to be the case so we have to explicitly link this VDSO 22 * at a non zero address. The actual address is arbitrary, but we use the 23 * same one as the Linux kernel VDSO. 24 * 25 * - The VDSO will be directly mmapped by the sentry, rather than going through 26 * a normal ELF loading process. The VDSO must be carefully constructed such 27 * that the layout in the ELF file is identical to the layout in memory. 28 */ 29 30 VDSO_PRELINK = 0xffffffffff700000; 31 32 SECTIONS { 33 /* The parameter page is mapped just before the VDSO. */ 34 _params = VDSO_PRELINK - 0x1000; 35 36 . = VDSO_PRELINK + SIZEOF_HEADERS; 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 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr 49 .eh_frame : { KEEP (*(.eh_frame)) } :text 50 51 .dynamic : { *(.dynamic) } :text :dynamic 52 53 .rodata : { *(.rodata*) } :text 54 55 .altinstructions : { *(.altinstructions) } 56 .altinstr_replacement : { *(.altinstr_replacement) } 57 58 /* 59 * TODO(gvisor.dev/issue/157): Remove this alignment? Then the VDSO would fit 60 * in a single page. 61 */ 62 . = ALIGN(0x1000); 63 .text : { *(.text*) } :text =0x90909090 64 65 /* 66 * N.B. There is no data/bss section. This VDSO neither needs nor uses a data 67 * section. We omit it entirely because some gcc/clang and gold/bfd version 68 * combinations struggle to handle an empty data PHDR segment (internal 69 * linker assertion failures result). 70 * 71 * If the VDSO does incorrectly include a data section, the linker will 72 * include it in the text segment. check_vdso.py looks for this degenerate 73 * case. 74 */ 75 } 76 77 PHDRS { 78 text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R | PF_X */ 79 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 80 note PT_NOTE FLAGS(4); /* PF_R */ 81 eh_frame_hdr PT_GNU_EH_FRAME; 82 } 83 84 /* 85 * Define the symbols that are to be exported. 86 */ 87 VERSION { 88 LINUX_2.6 { 89 global: 90 clock_gettime; 91 __vdso_clock_gettime; 92 gettimeofday; 93 __vdso_gettimeofday; 94 getcpu; 95 __vdso_getcpu; 96 time; 97 __vdso_time; 98 __kernel_rt_sigreturn; 99 100 local: *; 101 }; 102 }