elf64ltsmip.xdw 9.8 KB

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