elf32lriscv.xswe 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /* Script for -shared -z combreloc -z separate-code -z relro -z now */
  2. /* Copyright (C) 2014-2020 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("elf32-littleriscv", "elf32-littleriscv",
  7. "elf32-littleriscv")
  8. OUTPUT_ARCH(riscv)
  9. ENTRY(_start)
  10. SEARCH_DIR("=/usr/local/lib/riscv64-linux-gnu"); SEARCH_DIR("=/lib/riscv64-linux-gnu"); SEARCH_DIR("=/usr/lib/riscv64-linux-gnu"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); SEARCH_DIR("=/usr/riscv64-linux-gnu/lib");
  11. SECTIONS
  12. {
  13. . = SEGMENT_START("text-segment", 0) + SIZEOF_HEADERS;
  14. .note.gnu.build-id : { *(.note.gnu.build-id) }
  15. .hash : { *(.hash) }
  16. .gnu.hash : { *(.gnu.hash) }
  17. .dynsym : { *(.dynsym) }
  18. .dynstr : { *(.dynstr) }
  19. .gnu.version : { *(.gnu.version) }
  20. .gnu.version_d : { *(.gnu.version_d) }
  21. .gnu.version_r : { *(.gnu.version_r) }
  22. .rela.dyn :
  23. {
  24. *(.rela.init)
  25. *(.rela.text .rela.text.* .rela.gnu.linkonce.t.*)
  26. *(.rela.fini)
  27. *(.rela.rodata .rela.rodata.* .rela.gnu.linkonce.r.*)
  28. *(.rela.data .rela.data.* .rela.gnu.linkonce.d.*)
  29. *(.rela.tdata .rela.tdata.* .rela.gnu.linkonce.td.*)
  30. *(.rela.tbss .rela.tbss.* .rela.gnu.linkonce.tb.*)
  31. *(.rela.ctors)
  32. *(.rela.dtors)
  33. *(.rela.got)
  34. *(.rela.sdata .rela.sdata.* .rela.gnu.linkonce.s.*)
  35. *(.rela.sbss .rela.sbss.* .rela.gnu.linkonce.sb.*)
  36. *(.rela.sdata2 .rela.sdata2.* .rela.gnu.linkonce.s2.*)
  37. *(.rela.sbss2 .rela.sbss2.* .rela.gnu.linkonce.sb2.*)
  38. *(.rela.bss .rela.bss.* .rela.gnu.linkonce.b.*)
  39. *(.rela.iplt)
  40. }
  41. .rela.plt :
  42. {
  43. *(.rela.plt)
  44. }
  45. . = ALIGN(CONSTANT (MAXPAGESIZE));
  46. .init :
  47. {
  48. KEEP (*(SORT_NONE(.init)))
  49. }
  50. .plt : { *(.plt) }
  51. .iplt : { *(.iplt) }
  52. .text :
  53. {
  54. *(.text.unlikely .text.*_unlikely .text.unlikely.*)
  55. *(.text.exit .text.exit.*)
  56. *(.text.startup .text.startup.*)
  57. *(.text.hot .text.hot.*)
  58. *(SORT(.text.sorted.*))
  59. *(.text .stub .text.* .gnu.linkonce.t.*)
  60. /* .gnu.warning sections are handled specially by elf.em. */
  61. *(.gnu.warning)
  62. }
  63. .fini :
  64. {
  65. KEEP (*(SORT_NONE(.fini)))
  66. }
  67. PROVIDE (__etext = .);
  68. PROVIDE (_etext = .);
  69. PROVIDE (etext = .);
  70. . = ALIGN(CONSTANT (MAXPAGESIZE));
  71. /* Adjust the address for the rodata segment. We want to adjust up to
  72. the same address within the page on the next page up. */
  73. . = SEGMENT_START("rodata-segment", ALIGN(CONSTANT (MAXPAGESIZE)) + (. & (CONSTANT (MAXPAGESIZE) - 1)));
  74. .rodata : { *(.rodata .rodata.* .gnu.linkonce.r.*) }
  75. .rodata1 : { *(.rodata1) }
  76. .eh_frame_hdr : { *(.eh_frame_hdr) *(.eh_frame_entry .eh_frame_entry.*) }
  77. .eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) *(.eh_frame.*) }
  78. .gcc_except_table : ONLY_IF_RO { *(.gcc_except_table .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. /* Adjust the address for the data segment. We want to adjust up to
  83. the same address within the page on the next page up. */
  84. . = DATA_SEGMENT_ALIGN (CONSTANT (MAXPAGESIZE), CONSTANT (COMMONPAGESIZE));
  85. /* Exception handling */
  86. .eh_frame : ONLY_IF_RW { KEEP (*(.eh_frame)) *(.eh_frame.*) }
  87. .gnu_extab : ONLY_IF_RW { *(.gnu_extab) }
  88. .gcc_except_table : ONLY_IF_RW { *(.gcc_except_table .gcc_except_table.*) }
  89. .exception_ranges : ONLY_IF_RW { *(.exception_ranges*) }
  90. /* Thread Local Storage sections */
  91. .tdata :
  92. {
  93. *(.tdata .tdata.* .gnu.linkonce.td.*)
  94. }
  95. .tbss : { *(.tbss .tbss.* .gnu.linkonce.tb.*) *(.tcommon) }
  96. .preinit_array :
  97. {
  98. KEEP (*(.preinit_array))
  99. }
  100. .init_array :
  101. {
  102. KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
  103. KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
  104. }
  105. .fini_array :
  106. {
  107. KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
  108. KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
  109. }
  110. .ctors :
  111. {
  112. /* gcc uses crtbegin.o to find the start of
  113. the constructors, so we make sure it is
  114. first. Because this is a wildcard, it
  115. doesn't matter if the user does not
  116. actually link against crtbegin.o; the
  117. linker won't look for a file to match a
  118. wildcard. The wildcard also means that it
  119. doesn't matter which directory crtbegin.o
  120. is in. */
  121. KEEP (*crtbegin.o(.ctors))
  122. KEEP (*crtbegin?.o(.ctors))
  123. /* We don't want to include the .ctor section from
  124. the crtend.o file until after the sorted ctors.
  125. The .ctor section from the crtend file contains the
  126. end of ctors marker and it must be last */
  127. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
  128. KEEP (*(SORT(.ctors.*)))
  129. KEEP (*(.ctors))
  130. }
  131. .dtors :
  132. {
  133. KEEP (*crtbegin.o(.dtors))
  134. KEEP (*crtbegin?.o(.dtors))
  135. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
  136. KEEP (*(SORT(.dtors.*)))
  137. KEEP (*(.dtors))
  138. }
  139. .jcr : { KEEP (*(.jcr)) }
  140. .data.rel.ro : { *(.data.rel.ro.local* .gnu.linkonce.d.rel.ro.local.*) *(.data.rel.ro .data.rel.ro.* .gnu.linkonce.d.rel.ro.*) }
  141. .dynamic : { *(.dynamic) }
  142. . = DATA_SEGMENT_RELRO_END (0, .);
  143. .data :
  144. {
  145. *(.data .data.* .gnu.linkonce.d.*)
  146. SORT(CONSTRUCTORS)
  147. }
  148. .data1 : { *(.data1) }
  149. .got : { *(.got.plt) *(.igot.plt) *(.got) *(.igot) }
  150. /* We want the small data sections together, so single-instruction offsets
  151. can access them all, and initialized data all before uninitialized, so
  152. we can shorten the on-disk segment size. */
  153. .sdata :
  154. {
  155. *(.srodata.cst16) *(.srodata.cst8) *(.srodata.cst4) *(.srodata.cst2) *(.srodata .srodata.*)
  156. *(.sdata2 .sdata2.* .gnu.linkonce.s2.*)
  157. *(.sdata .sdata.* .gnu.linkonce.s.*)
  158. }
  159. PROVIDE (_edata = .); PROVIDE (edata = .);
  160. . = .;
  161. PROVIDE (__bss_start = .);
  162. .sbss :
  163. {
  164. *(.sbss2 .sbss2.* .gnu.linkonce.sb2.*)
  165. *(.dynsbss)
  166. *(.sbss .sbss.* .gnu.linkonce.sb.*)
  167. *(.scommon)
  168. }
  169. .bss :
  170. {
  171. *(.dynbss)
  172. *(.bss .bss.* .gnu.linkonce.b.*)
  173. *(COMMON)
  174. /* Align here to ensure that the .bss section occupies space up to
  175. _end. Align after .bss to ensure correct alignment even if the
  176. .bss section disappears because there are no input sections.
  177. FIXME: Why do we need it? When there is no .bss section, we do not
  178. pad the .data section. */
  179. . = ALIGN(. != 0 ? 32 / 8 : 1);
  180. }
  181. . = ALIGN(32 / 8);
  182. . = SEGMENT_START("ldata-segment", .);
  183. . = ALIGN(32 / 8);
  184. PROVIDE (_end = .); PROVIDE (end = .);
  185. . = DATA_SEGMENT_END (.);
  186. /* Stabs debugging sections. */
  187. .stab 0 : { *(.stab) }
  188. .stabstr 0 : { *(.stabstr) }
  189. .stab.excl 0 : { *(.stab.excl) }
  190. .stab.exclstr 0 : { *(.stab.exclstr) }
  191. .stab.index 0 : { *(.stab.index) }
  192. .stab.indexstr 0 : { *(.stab.indexstr) }
  193. .comment 0 : { *(.comment) }
  194. .gnu.build.attributes : { *(.gnu.build.attributes .gnu.build.attributes.*) }
  195. /* DWARF debug sections.
  196. Symbols in the DWARF debugging sections are relative to the beginning
  197. of the section so we begin them at 0. */
  198. /* DWARF 1 */
  199. .debug 0 : { *(.debug) }
  200. .line 0 : { *(.line) }
  201. /* GNU DWARF 1 extensions */
  202. .debug_srcinfo 0 : { *(.debug_srcinfo) }
  203. .debug_sfnames 0 : { *(.debug_sfnames) }
  204. /* DWARF 1.1 and DWARF 2 */
  205. .debug_aranges 0 : { *(.debug_aranges) }
  206. .debug_pubnames 0 : { *(.debug_pubnames) }
  207. /* DWARF 2 */
  208. .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
  209. .debug_abbrev 0 : { *(.debug_abbrev) }
  210. .debug_line 0 : { *(.debug_line .debug_line.* .debug_line_end) }
  211. .debug_frame 0 : { *(.debug_frame) }
  212. .debug_str 0 : { *(.debug_str) }
  213. .debug_loc 0 : { *(.debug_loc) }
  214. .debug_macinfo 0 : { *(.debug_macinfo) }
  215. /* SGI/MIPS DWARF 2 extensions */
  216. .debug_weaknames 0 : { *(.debug_weaknames) }
  217. .debug_funcnames 0 : { *(.debug_funcnames) }
  218. .debug_typenames 0 : { *(.debug_typenames) }
  219. .debug_varnames 0 : { *(.debug_varnames) }
  220. /* DWARF 3 */
  221. .debug_pubtypes 0 : { *(.debug_pubtypes) }
  222. .debug_ranges 0 : { *(.debug_ranges) }
  223. /* DWARF Extension. */
  224. .debug_macro 0 : { *(.debug_macro) }
  225. .debug_addr 0 : { *(.debug_addr) }
  226. .gnu.attributes 0 : { KEEP (*(.gnu.attributes)) }
  227. /DISCARD/ : { *(.note.GNU-stack) *(.gnu_debuglink) *(.gnu.lto_*) }
  228. }