ldscript.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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 SECTION_VECTOR(_sym_, _sec_, _vma_, _lma_) \
  37. .##_sym_##.##_sec_ _vma_ : _lma_ \
  38. { \
  39. . = ALIGN(4); \
  40. _##_sym_##_##_sec_##_start = ABSOLUTE(.); \
  41. KEEP(*(.##_sym_##.##_sec_)) \
  42. _##_sym_##_##_sec_##_end = ABSOLUTE(.); \
  43. }
  44. /* In MMU configs there are two aliases of SYSROM, cached and uncached.
  45. * For various reasons it is simpler to use the uncached mapping for load
  46. * addresses, so ROM sections end up contiguous with the reset vector and
  47. * we get a compact binary image. However we can gain performance by doing
  48. * the unpacking from the cached ROM mapping. So we adjust all the load
  49. * addresses in the ROM store table with an offset to the cached mapping,
  50. * including the symbols referring to the ROM store table itself.
  51. */
  52. #define SECTION_ResetVector(_vma_, _lma_) \
  53. .ResetVector.text _vma_ : _lma_ \
  54. { \
  55. FORCE_OUTPUT; \
  56. KEEP(*(.ResetVector.text)); \
  57. KEEP(*(.reset.literal .reset.text)) \
  58. }
  59. #define SECTION_text(_vma_, _lma_) \
  60. .text _vma_ : _lma_ \
  61. { \
  62. _text_start = ABSOLUTE(.); \
  63. *(.literal .text) \
  64. *(.literal.* .text.* .stub) \
  65. *(.gnu.warning .gnu.linkonce.literal.*) \
  66. *(.gnu.linkonce.t.*.literal .gnu.linkonce.t.*) \
  67. *(.fini.literal) \
  68. *(.fini) \
  69. *(.gnu.version) \
  70. _text_end = ABSOLUTE(.); \
  71. }
  72. #define SECTION_rodata(_vma_, _lma_) \
  73. .rodata _vma_ : _lma_ \
  74. { \
  75. _rodata_start = ABSOLUTE(.); \
  76. *(.rodata) \
  77. *(.rodata.*) \
  78. *(.dtb.init.rodata) \
  79. *(.gnu.linkonce.r.*) \
  80. *(.rodata1) \
  81. __XT_EXCEPTION_TABLE__ = ABSOLUTE(.); \
  82. *(.xt_except_table) \
  83. *(.gcc_except_table) \
  84. *(.gnu.linkonce.e.*) \
  85. *(.gnu.version_r) \
  86. . = ALIGN(16); \
  87. _rodata_end = ABSOLUTE(.); \
  88. }
  89. #define SECTION_u_boot_list(_vma_, _lma_) \
  90. .u_boot_list _vma_ : _lma_ \
  91. { \
  92. _u_boot_list_start = ABSOLUTE(.); \
  93. KEEP(*(SORT(.u_boot_list*))); \
  94. _u_boot_list_end = ABSOLUTE(.); \
  95. }
  96. #define SECTION_data(_vma_, _lma_) \
  97. .data _vma_ : _lma_ \
  98. { \
  99. _data_start = ABSOLUTE(.); \
  100. *(.data) \
  101. *(.data.*) \
  102. *(.gnu.linkonce.d.*) \
  103. *(.data1) \
  104. *(.sdata) \
  105. *(.sdata.*) \
  106. *(.gnu.linkonce.s.*) \
  107. *(.sdata2) \
  108. *(.sdata2.*) \
  109. *(.gnu.linkonce.s2.*) \
  110. *(.jcr) \
  111. *(.eh_frame) \
  112. *(.dynamic) \
  113. *(.gnu.version_d) \
  114. _data_end = ABSOLUTE(.); \
  115. }
  116. #define SECTION_lit4(_vma_, _lma_) \
  117. .lit4 _vma_ : _lma_ \
  118. { \
  119. _lit4_start = ABSOLUTE(.); \
  120. *(*.lit4) \
  121. *(.gnu.linkonce.lit4.*) \
  122. _lit4_end = ABSOLUTE(.); \
  123. }
  124. #define SECTION_bss(_vma_, _lma_) \
  125. .bss _vma_ : _lma_ \
  126. { \
  127. . = ALIGN(8); \
  128. _bss_start = ABSOLUTE(.); \
  129. __bss_start = ABSOLUTE(.); \
  130. *(.dynsbss) \
  131. *(.sbss) \
  132. *(.sbss.*) \
  133. *(.gnu.linkonce.sb.*) \
  134. *(.scommon) \
  135. *(.sbss2) \
  136. *(.sbss2.*) \
  137. *(.gnu.linkonce.sb2.*) \
  138. *(.dynbss) \
  139. *(.bss) \
  140. *(.bss.*) \
  141. *(.gnu.linkonce.b.*) \
  142. *(COMMON) \
  143. *(.sram.bss) \
  144. . = ALIGN(8); \
  145. _bss_end = ABSOLUTE(.); \
  146. __bss_end = ABSOLUTE(.); \
  147. _end = ALIGN(0x8); \
  148. PROVIDE(end = ALIGN(0x8)); \
  149. _stack_sentry = ALIGN(0x8); \
  150. }
  151. #define SECTION_debug \
  152. .debug 0 : { *(.debug) } \
  153. .line 0 : { *(.line) } \
  154. .debug_srcinfo 0 : { *(.debug_srcinfo) } \
  155. .debug_sfnames 0 : { *(.debug_sfnames) } \
  156. .debug_aranges 0 : { *(.debug_aranges) } \
  157. .debug_pubnames 0 : { *(.debug_pubnames) } \
  158. .debug_info 0 : { *(.debug_info) } \
  159. .debug_abbrev 0 : { *(.debug_abbrev) } \
  160. .debug_line 0 : { *(.debug_line) } \
  161. .debug_frame 0 : { *(.debug_frame) } \
  162. .debug_str 0 : { *(.debug_str) } \
  163. .debug_loc 0 : { *(.debug_loc) } \
  164. .debug_macinfo 0 : { *(.debug_macinfo) } \
  165. .debug_weaknames 0 : { *(.debug_weaknames) } \
  166. .debug_funcnames 0 : { *(.debug_funcnames) } \
  167. .debug_typenames 0 : { *(.debug_typenames) } \
  168. .debug_varnames 0 : { *(.debug_varnames) }
  169. #define SECTION_xtensa \
  170. .xt.insn 0 : \
  171. { \
  172. KEEP (*(.xt.insn)) \
  173. KEEP (*(.gnu.linkonce.x.*)) \
  174. } \
  175. .xt.prop 0 : \
  176. { \
  177. KEEP (*(.xt.prop)) \
  178. KEEP (*(.xt.prop.*)) \
  179. KEEP (*(.gnu.linkonce.prop.*)) \
  180. } \
  181. .xt.lit 0 : \
  182. { \
  183. KEEP (*(.xt.lit)) \
  184. KEEP (*(.xt.lit.*)) \
  185. KEEP (*(.gnu.linkonce.p.*)) \
  186. } \
  187. .xt.profile_range 0 : \
  188. { \
  189. KEEP (*(.xt.profile_range)) \
  190. KEEP (*(.gnu.linkonce.profile_range.*)) \
  191. } \
  192. .xt.profile_ranges 0 : \
  193. { \
  194. KEEP (*(.xt.profile_ranges)) \
  195. KEEP (*(.gnu.linkonce.xt.profile_ranges.*)) \
  196. } \
  197. .xt.profile_files 0 : \
  198. { \
  199. KEEP (*(.xt.profile_files)) \
  200. KEEP (*(.gnu.linkonce.xt.profile_files.*)) \
  201. }
  202. #endif /* _XTENSA_LDSCRIPT_H */