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 = . - 2 * 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. . = SIZEOF_HEADERS;
  33. .hash : { *(.hash) } :text
  34. .gnu.hash : { *(.gnu.hash) }
  35. .dynsym : { *(.dynsym) }
  36. .dynstr : { *(.dynstr) }
  37. .gnu.version : { *(.gnu.version) }
  38. .gnu.version_d : { *(.gnu.version_d) }
  39. .gnu.version_r : { *(.gnu.version_r) }
  40. .dynamic : { *(.dynamic) } :text :dynamic
  41. .rodata : {
  42. *(.rodata*)
  43. *(.data*)
  44. *(.sdata*)
  45. *(.got.plt) *(.got)
  46. *(.gnu.linkonce.d.*)
  47. *(.bss*)
  48. *(.dynbss*)
  49. *(.gnu.linkonce.b.*)
  50. /*
  51. * Ideally this would live in a C file, but that won't
  52. * work cleanly for x32 until we start building the x32
  53. * C code using an x32 toolchain.
  54. */
  55. VDSO_FAKE_SECTION_TABLE_START = .;
  56. . = . + NUM_FAKE_SHDRS * SHDR_SIZE;
  57. VDSO_FAKE_SECTION_TABLE_END = .;
  58. } :text
  59. .fake_shstrtab : { *(.fake_shstrtab) } :text
  60. .note : { *(.note.*) } :text :note
  61. .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
  62. .eh_frame : { KEEP (*(.eh_frame)) } :text
  63. /*
  64. * Text is well-separated from actual data: there's plenty of
  65. * stuff that isn't used at runtime in between.
  66. */
  67. .text : { *(.text*) } :text =0x90909090,
  68. /*
  69. * At the end so that eu-elflint stays happy when vdso2c strips
  70. * these. A better implementation would avoid allocating space
  71. * for these.
  72. */
  73. .altinstructions : { *(.altinstructions) } :text
  74. .altinstr_replacement : { *(.altinstr_replacement) } :text
  75. /DISCARD/ : {
  76. *(.discard)
  77. *(.discard.*)
  78. *(__bug_table)
  79. }
  80. }
  81. /*
  82. * Very old versions of ld do not recognize this name token; use the constant.
  83. */
  84. #define PT_GNU_EH_FRAME 0x6474e550
  85. /*
  86. * We must supply the ELF program headers explicitly to get just one
  87. * PT_LOAD segment, and set the flags explicitly to make segments read-only.
  88. */
  89. PHDRS
  90. {
  91. text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
  92. dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
  93. note PT_NOTE FLAGS(4); /* PF_R */
  94. eh_frame_hdr PT_GNU_EH_FRAME;
  95. }