github.com/SagerNet/gvisor@v0.0.0-20210707092255-7731c139d75c/vdso/vdso_arm64.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 OUTPUT_FORMAT("elf64-littleaarch64", "elf64-bigaarch64", "elf64-littleaarch64") 33 OUTPUT_ARCH(aarch64) 34 35 SECTIONS { 36 /* The parameter page is mapped just before the VDSO. */ 37 _params = VDSO_PRELINK - 0x1000; 38 39 . = VDSO_PRELINK + SIZEOF_HEADERS; 40 41 .hash : { *(.hash) } :text 42 .gnu.hash : { *(.gnu.hash) } 43 .dynsym : { *(.dynsym) } 44 .dynstr : { *(.dynstr) } 45 .gnu.version : { *(.gnu.version) } 46 .gnu.version_d : { *(.gnu.version_d) } 47 .gnu.version_r : { *(.gnu.version_r) } 48 49 .note : { *(.note.*) } :text :note 50 51 .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr 52 .eh_frame : { KEEP (*(.eh_frame)) } :text 53 54 .dynamic : { *(.dynamic) } :text :dynamic 55 56 .rodata : { *(.rodata*) } :text 57 58 .altinstructions : { *(.altinstructions) } 59 .altinstr_replacement : { *(.altinstr_replacement) } 60 61 /* 62 * TODO(gvisor.dev/issue/157): Remove this alignment? Then the VDSO would fit 63 * in a single page. 64 */ 65 . = ALIGN(0x1000); 66 .text : { *(.text*) } :text =0xd503201f 67 68 /* 69 * N.B. There is no data/bss section. This VDSO neither needs nor uses a data 70 * section. We omit it entirely because some gcc/clang and gold/bfd version 71 * combinations struggle to handle an empty data PHDR segment (internal 72 * linker assertion failures result). 73 * 74 * If the VDSO does incorrectly include a data section, the linker will 75 * include it in the text segment. check_vdso.py looks for this degenerate 76 * case. 77 */ 78 } 79 80 PHDRS { 81 text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R | PF_X */ 82 dynamic PT_DYNAMIC FLAGS(4); /* PF_R */ 83 note PT_NOTE FLAGS(4); /* PF_R */ 84 eh_frame_hdr PT_GNU_EH_FRAME; 85 } 86 87 /* 88 * Define the symbols that are to be exported. 89 */ 90 VERSION { 91 LINUX_2.6.39 { 92 global: 93 __kernel_clock_getres; 94 __kernel_clock_gettime; 95 __kernel_gettimeofday; 96 __kernel_rt_sigreturn; 97 local: *; 98 }; 99 }