vdso-layout.lds.S 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. SECTIONS
  9. {
  10. /*
  11. * User/kernel shared data is before the vDSO. This may be a little
  12. * uglier than putting it after the vDSO, but it avoids issues with
  13. * non-allocatable things that dangle past the end of the PT_LOAD
  14. * segment.
  15. */
  16. vvar_start = . - 4 * PAGE_SIZE;
  17. vvar_page = vvar_start;
  18. /* Place all vvars at the offsets in asm/vvar.h. */
  19. #define EMIT_VVAR(name, offset) vvar_ ## name = vvar_page + offset;
  20. #include <asm/vvar.h>
  21. #undef EMIT_VVAR
  22. pvclock_page = vvar_start + PAGE_SIZE;
  23. hvclock_page = vvar_start + 2 * PAGE_SIZE;
  24. timens_page = vvar_start + 3 * PAGE_SIZE;
  25. #undef _ASM_X86_VVAR_H
  26. /* Place all vvars in timens too at the offsets in asm/vvar.h. */
  27. #define EMIT_VVAR(name, offset) timens_ ## name = timens_page + offset;
  28. #include <asm/vvar.h>
  29. #undef EMIT_VVAR
  30. . = SIZEOF_HEADERS;
  31. .hash : { *(.hash) } :text
  32. .gnu.hash : { *(.gnu.hash) }
  33. .dynsym : { *(.dynsym) }
  34. .dynstr : { *(.dynstr) }
  35. .gnu.version : { *(.gnu.version) }
  36. .gnu.version_d : { *(.gnu.version_d) }
  37. .gnu.version_r : { *(.gnu.version_r) }
  38. .dynamic : { *(.dynamic) } :text :dynamic
  39. .rodata : {
  40. *(.rodata*)
  41. *(.data*)
  42. *(.sdata*)
  43. *(.got.plt) *(.got)
  44. *(.gnu.linkonce.d.*)
  45. *(.bss*)
  46. *(.dynbss*)
  47. *(.gnu.linkonce.b.*)
  48. } :text
  49. /*
  50. * Discard .note.gnu.property sections which are unused and have
  51. * different alignment requirement from vDSO note sections.
  52. */
  53. /DISCARD/ : {
  54. *(.note.gnu.property)
  55. }
  56. .note : { *(.note.*) } :text :note
  57. .eh_frame_hdr : { *(.eh_frame_hdr) } :text :eh_frame_hdr
  58. .eh_frame : { KEEP (*(.eh_frame)) } :text
  59. /*
  60. * Text is well-separated from actual data: there's plenty of
  61. * stuff that isn't used at runtime in between.
  62. */
  63. .text : {
  64. *(.text*)
  65. } :text =0x90909090,
  66. .altinstructions : { *(.altinstructions) } :text
  67. .altinstr_replacement : { *(.altinstr_replacement) } :text
  68. __ex_table : { *(__ex_table) } :text
  69. /DISCARD/ : {
  70. *(.discard)
  71. *(.discard.*)
  72. *(__bug_table)
  73. }
  74. }
  75. /*
  76. * Very old versions of ld do not recognize this name token; use the constant.
  77. */
  78. #define PT_GNU_EH_FRAME 0x6474e550
  79. /*
  80. * We must supply the ELF program headers explicitly to get just one
  81. * PT_LOAD segment, and set the flags explicitly to make segments read-only.
  82. */
  83. PHDRS
  84. {
  85. text PT_LOAD FLAGS(5) FILEHDR PHDRS; /* PF_R|PF_X */
  86. dynamic PT_DYNAMIC FLAGS(4); /* PF_R */
  87. note PT_NOTE FLAGS(4); /* PF_R */
  88. eh_frame_hdr PT_GNU_EH_FRAME;
  89. }