vdso-layout.lds.S 2.8 KB

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