ldscript.h 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. /* SPDX-License-Identifier: GPL-2.0+ */
  2. /*
  3. * (C) Copyright 2007 Tensilica, Inc.
  4. * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
  5. */
  6. #ifndef _XTENSA_LDSCRIPT_H
  7. #define _XTENSA_LDSCRIPT_H
  8. /*
  9. * This linker script is pre-processed with CPP to avoid hard-coding
  10. * addresses that depend on the Xtensa core configuration, because
  11. * this FPGA board can be used with a huge variety of Xtensa cores.
  12. */
  13. #include <asm/arch/core.h>
  14. #include <asm/addrspace.h>
  15. #define ALIGN_LMA 4
  16. #define LMA_EQ_VMA
  17. #define FORCE_OUTPUT . = .
  18. #define FOLLOWING(sec) \
  19. AT(((LOADADDR(sec) + SIZEOF(sec) + ALIGN_LMA-1)) & ~(ALIGN_LMA-1))
  20. /*
  21. * Specify an output section that will be added to the ROM store table
  22. * (PACKED_SECTION) or one that will be resident in ROM (RESIDENT_SECTION).
  23. * 'symname' is a base name for section boundary symbols *_start & *_end.
  24. * 'lma' is the load address at which a section will be packed in ROM.
  25. * 'region' is the basename identifying a memory region and program header.
  26. * 'keep' prevents removal of empty sections (must be 'KEEP' or 'NOKEEP').
  27. */
  28. #define RELOCATE1(_sec_) \
  29. LONG(_##_sec_##_start); \
  30. LONG(_##_sec_##_end); \
  31. LONG(LOADADDR(.##_sec_));
  32. #define RELOCATE2(_sym_, _sec_) \
  33. LONG(_##_sym_##_##_sec_##_start); \
  34. LONG(_##_sym_##_##_sec_##_end); \
  35. LONG(LOADADDR(.##_sym_##.##_sec_));
  36. #define RELOCATE_USER1(_sec_) \
  37. LONG(_##_sec_##_start); \
  38. LONG(_##_sec_##_end); \
  39. LONG(LOADADDR(_sec_));
  40. #define SECTION_VECTOR(_sym_, _sec_, _vma_, _lma_) \
  41. .##_sym_##.##_sec_ _vma_ : _lma_ \
  42. { \
  43. . = ALIGN(4); \
  44. _##_sym_##_##_sec_##_start = ABSOLUTE(.); \
  45. KEEP(*(.##_sym_##.##_sec_)) \
  46. _##_sym_##_##_sec_##_end = ABSOLUTE(.); \
  47. }
  48. /* In MMU configs there are two aliases of SYSROM, cached and uncached.
  49. * For various reasons it is simpler to use the uncached mapping for load
  50. * addresses, so ROM sections end up contiguous with the reset vector and
  51. * we get a compact binary image. However we can gain performance by doing
  52. * the unpacking from the cached ROM mapping. So we adjust all the load
  53. * addresses in the ROM store table with an offset to the cached mapping,
  54. * including the symbols referring to the ROM store table itself.
  55. */
  56. #define SECTION_ResetVector(_vma_, _lma_) \
  57. .ResetVector.text _vma_ : _lma_ \
  58. { \
  59. FORCE_OUTPUT; \
  60. KEEP(*(.ResetVector.text)); \
  61. KEEP(*(.reset.literal .reset.text)) \
  62. }
  63. #define SECTION_text(_vma_, _lma_) \
  64. .text _vma_ : _lma_ \
  65. { \
  66. _text_start = ABSOLUTE(.); \
  67. *(.literal .text) \
  68. *(.literal.* .text.* .stub) \
  69. *(.gnu.warning .gnu.linkonce.literal.*) \
  70. *(.gnu.linkonce.t.*.literal .gnu.linkonce.t.*) \
  71. *(.fini.literal) \
  72. *(.fini) \
  73. *(.gnu.version) \
  74. _text_end = ABSOLUTE(.); \
  75. }
  76. #define SECTION_rodata(_vma_, _lma_) \
  77. .rodata _vma_ : _lma_ \
  78. { \
  79. _rodata_start = ABSOLUTE(.); \
  80. *(.rodata) \
  81. *(.rodata.*) \
  82. *(.dtb.init.rodata) \
  83. *(.gnu.linkonce.r.*) \
  84. *(.rodata1) \
  85. __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); \
  86. *(.xt_except_table) \
  87. *(.gcc_except_table) \
  88. *(.gnu.linkonce.e.*) \
  89. *(.gnu.version_r) \
  90. . = ALIGN(16); \
  91. _rodata_end = ABSOLUTE(.); \
  92. }
  93. #define SECTION_u_boot_list(_vma_, _lma_) \
  94. __u_boot_list _vma_ : _lma_ \
  95. { \
  96. ___u_boot_list_start = ABSOLUTE(.); \
  97. KEEP(*(SORT(__u_boot_list*))); \
  98. ___u_boot_list_end = ABSOLUTE(.); \
  99. }
  100. #define SECTION_data(_vma_, _lma_) \
  101. .data _vma_ : _lma_ \
  102. { \
  103. _data_start = ABSOLUTE(.); \
  104. *(.data) \
  105. *(.data.*) \
  106. *(.gnu.linkonce.d.*) \
  107. *(.data1) \
  108. *(.sdata) \
  109. *(.sdata.*) \
  110. *(.gnu.linkonce.s.*) \
  111. *(.sdata2) \
  112. *(.sdata2.*) \
  113. *(.gnu.linkonce.s2.*) \
  114. *(.jcr) \
  115. *(.eh_frame) \
  116. *(.dynamic) \
  117. *(.gnu.version_d) \
  118. _data_end = ABSOLUTE(.); \
  119. }
  120. #define SECTION_lit4(_vma_, _lma_) \
  121. .lit4 _vma_ : _lma_ \
  122. { \
  123. _lit4_start = ABSOLUTE(.); \
  124. *(*.lit4) \
  125. *(.gnu.linkonce.lit4.*) \
  126. _lit4_end = ABSOLUTE(.); \
  127. }
  128. #define SECTION_bss(_vma_, _lma_) \
  129. .bss _vma_ : _lma_ \
  130. { \
  131. . = ALIGN(8); \
  132. _bss_start = ABSOLUTE(.); \
  133. __bss_start = ABSOLUTE(.); \
  134. *(.dynsbss) \
  135. *(.sbss) \
  136. *(.sbss.*) \
  137. *(.gnu.linkonce.sb.*) \
  138. *(.scommon) \
  139. *(.sbss2) \
  140. *(.sbss2.*) \
  141. *(.gnu.linkonce.sb2.*) \
  142. *(.dynbss) \
  143. *(.bss) \
  144. *(.bss.*) \
  145. *(.gnu.linkonce.b.*) \
  146. *(COMMON) \
  147. *(.sram.bss) \
  148. . = ALIGN(8); \
  149. _bss_end = ABSOLUTE(.); \
  150. __bss_end = ABSOLUTE(.); \
  151. _end = ALIGN(0x8); \
  152. PROVIDE(end = ALIGN(0x8)); \
  153. _stack_sentry = ALIGN(0x8); \
  154. }
  155. #define SECTION_debug \
  156. .debug 0 : { *(.debug) } \
  157. .line 0 : { *(.line) } \
  158. .debug_srcinfo 0 : { *(.debug_srcinfo) } \
  159. .debug_sfnames 0 : { *(.debug_sfnames) } \
  160. .debug_aranges 0 : { *(.debug_aranges) } \
  161. .debug_pubnames 0 : { *(.debug_pubnames) } \
  162. .debug_info 0 : { *(.debug_info) } \
  163. .debug_abbrev 0 : { *(.debug_abbrev) } \
  164. .debug_line 0 : { *(.debug_line) } \
  165. .debug_frame 0 : { *(.debug_frame) } \
  166. .debug_str 0 : { *(.debug_str) } \
  167. .debug_loc 0 : { *(.debug_loc) } \
  168. .debug_macinfo 0 : { *(.debug_macinfo) } \
  169. .debug_weaknames 0 : { *(.debug_weaknames) } \
  170. .debug_funcnames 0 : { *(.debug_funcnames) } \
  171. .debug_typenames 0 : { *(.debug_typenames) } \
  172. .debug_varnames 0 : { *(.debug_varnames) }
  173. #define SECTION_xtensa \
  174. .xt.insn 0 : \
  175. { \
  176. KEEP (*(.xt.insn)) \
  177. KEEP (*(.gnu.linkonce.x.*)) \
  178. } \
  179. .xt.prop 0 : \
  180. { \
  181. KEEP (*(.xt.prop)) \
  182. KEEP (*(.xt.prop.*)) \
  183. KEEP (*(.gnu.linkonce.prop.*)) \
  184. } \
  185. .xt.lit 0 : \
  186. { \
  187. KEEP (*(.xt.lit)) \
  188. KEEP (*(.xt.lit.*)) \
  189. KEEP (*(.gnu.linkonce.p.*)) \
  190. } \
  191. .xt.profile_range 0 : \
  192. { \
  193. KEEP (*(.xt.profile_range)) \
  194. KEEP (*(.gnu.linkonce.profile_range.*)) \
  195. } \
  196. .xt.profile_ranges 0 : \
  197. { \
  198. KEEP (*(.xt.profile_ranges)) \
  199. KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) \
  200. } \
  201. .xt.profile_files 0 : \
  202. { \
  203. KEEP (*(.xt.profile_files)) \
  204. KEEP (*(.gnu.linkonce.xt.profile_files.*)) \
  205. }
  206. #endif /* _XTENSA_LDSCRIPT_H */