vdso-layout.lds.S 2.8 KB

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