gvisor.dev/gvisor@v0.0.0-20240520182842-f9d4d51c7e0f/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 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr 47 .eh_frame : { KEEP (*(.eh_frame)) } :text 48 49 .dynamic : { *(.dynamic) } :text :dynamic 50 51 .rodata : { *(.rodata*) } :text 52 53 .altinstructions : { *(.altinstructions) } 54 .altinstr_replacement : { *(.altinstr_replacement) } 55 56 /* 57 * TODO(gvisor.dev/issue/157): Remove this alignment? Then the VDSO would fit 58 * in a single page. 59 */ 60 . = ALIGN(0x1000); 61 .text : { *(.text*) } :text =0x90909090 62 63 /* 64 * N.B. There is no data/bss section. This VDSO neither needs nor uses a data 65 * section. We omit it entirely because some gcc/clang and gold/bfd version 66 * combinations struggle to handle an empty data PHDR segment (internal 67 * linker assertion failures result). 68 * 69 * If the VDSO does incorrectly include a data section, the linker will 70 * include it in the text segment. check_vdso.py looks for this degenerate 71 * case. 72 */ 73 } 74 75 PHDRS { 76 text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R | PF_X */ 77 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 78 eh_frame_hdr PT_GNU_EH_FRAME; 79 } 80 81 /* 82 * Define the symbols that are to be exported. 83 */ 84 VERSION { 85 LINUX_2.6 { 86 global: 87 clock_gettime; 88 __vdso_clock_gettime; 89 gettimeofday; 90 __vdso_gettimeofday; 91 getcpu; 92 __vdso_getcpu; 93 time; 94 __vdso_time; 95 __kernel_rt_sigreturn; 96 97 local: *; 98 }; 99 }