Advertisement
Gallefray

ldscript.ld

Mar 31st, 2016
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.48 KB | None | 0 0
  1. /* Script for -z combreloc: combine and sort reloc sections */
  2. /* Copyright (C) 2014-2015 Free Software Foundation, Inc.
  3. Copying and distribution of this script, with or without modification,
  4. are permitted in any medium without royalty provided the copyright
  5. notice and this notice are preserved. */
  6. OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64",
  7. "elf64-x86-64")
  8. OUTPUT_ARCH(i386:x86-64)
  9. ENTRY(_start)
  10. SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib64"); SEARCH_DIR("/usr/lib"); SEARCH_DIR("/usr/local/lib"); SEARCH_DIR("/usr/x86_64-pc-linux-gnu/lib");
  11. SECTIONS
  12. {
  13. /* Read-only sections, merged into text segment: */
  14. PROVIDE (__executable_start = SEGMENT_START("text-segment", 0x400000)); . = SEGMENT_START("text-segment", 0x400000) + SIZEOF_HEADERS;
  15. .interp : { *(.interp) }
  16. .note.gnu.build-id : { *(.note.gnu.build-id) }
  17. .hash : { *(.hash) }
  18. .gnu.hash : { *(.gnu.hash) }
  19. .dynsym : { *(.dynsym) }
  20. .dynstr : { *(.dynstr) }
  21. .gnu.version : { *(.gnu.version) }
  22. .gnu.version_d : { *(.gnu.version_d) }
  23. .gnu.version_r : { *(.gnu.version_r) }
  24. .rela.dyn :
  25. {
  26. *(.rela.init)
  27. *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
  28. *(.rela.fini)
  29. *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
  30. *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
  31. *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
  32. *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
  33. *(.rela.ctors)
  34. *(.rela.dtors)
  35. *(.rela.got)
  36. *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
  37. *(.rela.ldata .rela.ldata.* .rela.gnu.linkonce.l.*)
  38. *(.rela.lbss .rela.lbss.* .rela.gnu.linkonce.lb.*)
  39. *(.rela.lrodata .rela.lrodata.* .rela.gnu.linkonce.lr.*)
  40. *(.rela.ifunc)
  41. }
  42. .rela.plt :
  43. {
  44. *(.rela.plt)
  45. PROVIDE_HIDDEN (__rela_iplt_start = .);
  46. *(.rela.iplt)
  47. PROVIDE_HIDDEN (__rela_iplt_end = .);
  48. }
  49. .init :
  50. {
  51. KEEP (*(SORT_NONE(.init)))
  52. }
  53. .plt : { *(.plt) *(.iplt) }
  54. .plt.got : { *(.plt.got) }
  55. .plt.bnd : { *(.plt.bnd) }
  56. .text :
  57. {
  58. *(.text.unlikely .text.*_unlikely .text.unlikely.*)
  59. *(.text.exit .text.exit.*)
  60. *(.text.startup .text.startup.*)
  61. *(.text.hot .text.hot.*)
  62. *(.text .stub .text.* .gnu.linkonce.t.*)
  63. /* .gnu.warning sections are handled specially by elf32.em. */
  64. *(.gnu.warning)
  65. }
  66. .fini :
  67. {
  68. KEEP (*(SORT_NONE(.fini)))
  69. }
  70. PROVIDE (__etext = .);
  71. PROVIDE (_etext = .);
  72. PROVIDE (etext = .);
  73. .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
  74. .rodata1 : { *(.rodata1) }
  75. .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
  76. .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
  77. .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table
  78. .gcc_except_table.*) }
  79. .gnu_extab : ONLY_IF_RO { *(.gnu_extab*) }
  80. /* These sections are generated by the Sun/Oracle C++ compiler. */
  81. .exception_ranges : ONLY_IF_RO { *(.exception_ranges
  82. .exception_ranges*) }
  83. /* Adjust the address for the data segment. We want to adjust up to
  84. the same address within the page on the next page up. */
  85. . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  86. /* Exception handling */
  87. .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
  88. .gnu_extab : ONLY_IF_RW { *(.gnu_extab) }
  89. .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  90. .exception_ranges : ONLY_IF_RW { *(.exception_ranges .exception_ranges*) }
  91. /* Thread Local Storage sections */
  92. .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
  93. .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  94. .preinit_array :
  95. {
  96. PROVIDE_HIDDEN (__preinit_array_start = .);
  97. KEEP (*(.preinit_array))
  98. PROVIDE_HIDDEN (__preinit_array_end = .);
  99. }
  100. .init_array :
  101. {
  102. PROVIDE_HIDDEN (__init_array_start = .);
  103. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  104. KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  105. PROVIDE_HIDDEN (__init_array_end = .);
  106. }
  107. .fini_array :
  108. {
  109. PROVIDE_HIDDEN (__fini_array_start = .);
  110. KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  111. KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  112. PROVIDE_HIDDEN (__fini_array_end = .);
  113. }
  114. .ctors :
  115. {
  116. /* gcc uses crtbegin.o to find the start of
  117. the constructors, so we make sure it is
  118. first. Because this is a wildcard, it
  119. doesn't matter if the user does not
  120. actually link against crtbegin.o; the
  121. linker won't look for a file to match a
  122. wildcard. The wildcard also means that it
  123. doesn't matter which directory crtbegin.o
  124. is in. */
  125. KEEP (*crtbegin.o(.ctors))
  126. KEEP (*crtbegin?.o(.ctors))
  127. /* We don't want to include the .ctor section from
  128. the crtend.o file until after the sorted ctors.
  129. The .ctor section from the crtend file contains the
  130. end of ctors marker and it must be last */
  131. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  132. KEEP (*(SORT(.ctors.*)))
  133. KEEP (*(.ctors))
  134. }
  135. .dtors :
  136. {
  137. KEEP (*crtbegin.o(.dtors))
  138. KEEP (*crtbegin?.o(.dtors))
  139. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  140. KEEP (*(SORT(.dtors.*)))
  141. KEEP (*(.dtors))
  142. }
  143. .jcr : { KEEP (*(.jcr)) }
  144. .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
  145. .dynamic : { *(.dynamic) }
  146. .got : { *(.got) *(.igot) }
  147. . = DATA_SEGMENT_RELRO_END (SIZEOF (.got.plt) >= 24 ? 24 : 0, .);
  148. .got.plt : { *(.got.plt) *(.igot.plt) }
  149. .data :
  150. {
  151. *(.data .data.* .gnu.linkonce.d.*)
  152. SORT(CONSTRUCTORS)
  153. }
  154. .data1 : { *(.data1) }
  155. _edata = .; PROVIDE (edata = .);
  156. . = .;
  157. __bss_start = .;
  158. .bss :
  159. {
  160. *(.dynbss)
  161. *(.bss .bss.* .gnu.linkonce.b.*)
  162. *(COMMON)
  163. /* Align here to ensure that the .bss section occupies space up to
  164. _end. Align after .bss to ensure correct alignment even if the
  165. .bss section disappears because there are no input sections.
  166. FIXME: Why do we need it? When there is no .bss section, we don't
  167. pad the .data section. */
  168. . = ALIGN(. != 0 ? 64 / 8 : 1);
  169. }
  170. .lbss :
  171. {
  172. *(.dynlbss)
  173. *(.lbss .lbss.* .gnu.linkonce.lb.*)
  174. *(LARGE_COMMON)
  175. }
  176. . = ALIGN(64 / 8);
  177. . = SEGMENT_START("ldata-segment", .);
  178. .lrodata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
  179. {
  180. *(.lrodata .lrodata.* .gnu.linkonce.lr.*)
  181. }
  182. .ldata ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)) :
  183. {
  184. *(.ldata .ldata.* .gnu.linkonce.l.*)
  185. . = ALIGN(. != 0 ? 64 / 8 : 1);
  186. }
  187. . = ALIGN(64 / 8);
  188. _end = .; PROVIDE (end = .);
  189. . = DATA_SEGMENT_END (.);
  190. /* Stabs debugging sections. */
  191. .stab 0 : { *(.stab) }
  192. .stabstr 0 : { *(.stabstr) }
  193. .stab.excl 0 : { *(.stab.excl) }
  194. .stab.exclstr 0 : { *(.stab.exclstr) }
  195. .stab.index 0 : { *(.stab.index) }
  196. .stab.indexstr 0 : { *(.stab.indexstr) }
  197. .comment 0 : { *(.comment) }
  198. /* DWARF debug sections.
  199. Symbols in the DWARF debugging sections are relative to the beginning
  200. of the section so we begin them at 0. */
  201. /* DWARF 1 */
  202. .debug 0 : { *(.debug) }
  203. .line 0 : { *(.line) }
  204. /* GNU DWARF 1 extensions */
  205. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  206. .debug_sfnames 0 : { *(.debug_sfnames) }
  207. /* DWARF 1.1 and DWARF 2 */
  208. .debug_aranges 0 : { *(.debug_aranges) }
  209. .debug_pubnames 0 : { *(.debug_pubnames) }
  210. /* DWARF 2 */
  211. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  212. .debug_abbrev 0 : { *(.debug_abbrev) }
  213. .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end ) }
  214. .debug_frame 0 : { *(.debug_frame) }
  215. .debug_str 0 : { *(.debug_str) }
  216. .debug_loc 0 : { *(.debug_loc) }
  217. .debug_macinfo 0 : { *(.debug_macinfo) }
  218. /* SGI/MIPS DWARF 2 extensions */
  219. .debug_weaknames 0 : { *(.debug_weaknames) }
  220. .debug_funcnames 0 : { *(.debug_funcnames) }
  221. .debug_typenames 0 : { *(.debug_typenames) }
  222. .debug_varnames 0 : { *(.debug_varnames) }
  223. /* DWARF 3 */
  224. .debug_pubtypes 0 : { *(.debug_pubtypes) }
  225. .debug_ranges 0 : { *(.debug_ranges) }
  226. /* DWARF Extension. */
  227. .debug_macro 0 : { *(.debug_macro) }
  228. .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  229. /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
  230.  
  231. .endend . : {
  232. PROVIDE(start_of_file = __executable_start);
  233. PROVIDE(end_of_file = .);
  234. }
  235. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement