vdso-layout.lds.S 2.2 KB

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