^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * Linker script for vDSO. This is an ELF shared object prelinked to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * its virtual address, and with only one read-only segment.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * This script controls its layout.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #if defined(BUILD_VDSO64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) # define SHDR_SIZE 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #elif defined(BUILD_VDSO32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) # define SHDR_SIZE 40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) # error unknown VDSO target
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #define NUM_FAKE_SHDRS 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) SECTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * User/kernel shared data is before the vDSO. This may be a little
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * uglier than putting it after the vDSO, but it avoids issues with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * non-allocatable things that dangle past the end of the PT_LOAD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) * segment. Page size is 8192 for both 64-bit and 32-bit vdso binaries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) vvar_start = . -8192;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) vvar_data = vvar_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) . = SIZEOF_HEADERS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) .hash : { *(.hash) } :text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) .gnu.hash : { *(.gnu.hash) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) .dynsym : { *(.dynsym) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) .dynstr : { *(.dynstr) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) .gnu.version : { *(.gnu.version) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) .gnu.version_d : { *(.gnu.version_d) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) .gnu.version_r : { *(.gnu.version_r) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) .dynamic : { *(.dynamic) } :text :dynamic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) .rodata : {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) *(.rodata*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) *(.data*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) *(.sdata*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *(.got.plt) *(.got)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) *(.gnu.linkonce.d.*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) *(.bss*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) *(.dynbss*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) *(.gnu.linkonce.b.*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * Ideally this would live in a C file: kept in here for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * compatibility with x86-64.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) VDSO_FAKE_SECTION_TABLE_START = .;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) . = . + NUM_FAKE_SHDRS * SHDR_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) VDSO_FAKE_SECTION_TABLE_END = .;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) } :text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .fake_shstrtab : { *(.fake_shstrtab) } :text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) .note : { *(.note.*) } :text :note
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) .eh_frame : { KEEP (*(.eh_frame)) } :text
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * Text is well-separated from actual data: there's plenty of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * stuff that isn't used at runtime in between.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) .text : { *(.text*) } :text =0x90909090,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) /DISCARD/ : {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) *(.discard)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) *(.discard.*)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) *(__bug_table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) * Very old versions of ld do not recognize this name token; use the constant.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define PT_GNU_EH_FRAME 0x6474e550
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) * We must supply the ELF program headers explicitly to get just one
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * PT_LOAD segment, and set the flags explicitly to make segments read-only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) PHDRS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) note PT_NOTE FLAGS(4); /* PF_R */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) eh_frame_hdr PT_GNU_EH_FRAME;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) }