gnu-nxflat-pcrel.ld 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  1. /****************************************************************************
  2. * examples/nxflat/gnu-nxflat-pcrel.ld
  3. *
  4. * Copyright (C) 2012 Gregory Nutt. All rights reserved.
  5. * Author: Gregory Nutt <gnutt@nuttx.org>
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions
  9. * are met:
  10. *
  11. * 1. Redistributions of source code must retain the above copyright
  12. * notice, this list of conditions and the following disclaimer.
  13. * 2. Redistributions in binary form must reproduce the above copyright
  14. * notice, this list of conditions and the following disclaimer in
  15. * the documentation and/or other materials provided with the
  16. * distribution.
  17. * 3. Neither the name NuttX nor the names of its contributors may be
  18. * used to endorse or promote products derived from this software
  19. * without specific prior written permission.
  20. *
  21. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  24. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  25. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  26. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  27. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  28. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  29. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  30. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  31. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  32. * POSSIBILITY OF SUCH DAMAGE.
  33. *
  34. ****************************************************************************/
  35. MEMORY
  36. {
  37. ISPACE : ORIGIN = 0x0, LENGTH = 2097152
  38. DSPACE : ORIGIN = 0x0, LENGTH = 2097152
  39. }
  40. /****************************************************************************
  41. * The XFLAT program image is divided into two segments:
  42. *
  43. * (1) ISpace (Instruction Space). This is the segment that contains
  44. * code (.text) as well as read-only data (.rodata). Everything in the
  45. * segment should be fetch-able machine PC instructions (jump, branch,
  46. * call, etc.) or PC-relative loads.
  47. * (2) DSpace (Data Space). This is the segment that contains read-write
  48. * data (.data, .bss). Everything in this segment should be access-able
  49. * with machine PIC load and store instructions.
  50. *
  51. * Older versions of GCC (at least up to GCC 4.3.3), use GOT-relative
  52. * addressing to access RO data. In that case, read-only data (.rodata) must
  53. * reside in D-Space and this linker script should NOT be used with those
  54. * older tools.
  55. *
  56. * Newer versions of GCC (at least as of GCC 4.6.3), use PC-relative
  57. * addressing to access RO data. In that case, read-only data (.rodata) must
  58. * reside in I-Space and this linker script should be used.
  59. *
  60. ****************************************************************************/
  61. SECTIONS
  62. {
  63. .text 0x00000000 :
  64. {
  65. /* ISpace is located at address 0. Every (unrelocated) ISpace
  66. * address is an offset from the beginning of this segment.
  67. */
  68. text_start = . ;
  69. *(.text)
  70. *(.text.*)
  71. *(.gnu.warning)
  72. *(.stub)
  73. *(.glue_7)
  74. *(.glue_7t)
  75. *(.jcr)
  76. /* C++ support: The .init and .fini sections contain XFLAT-
  77. * specific logic to manage static constructors and destructors.
  78. */
  79. *(.gnu.linkonce.t.*)
  80. *(.init)
  81. *(.fini)
  82. /* This is special code area at the end of the normal
  83. text section. It contains a small lookup table at
  84. the start followed by the code pointed to by entries
  85. in the lookup table. */
  86. . = ALIGN (4) ;
  87. PROVIDE(__ctbp = .);
  88. *(.call_table_data)
  89. *(.call_table_text)
  90. /* In this model, .rodata is access using PC-relative addressing
  91. * and, hence, must also reside in the .text section.
  92. */
  93. *(.rodata)
  94. *(.rodata1)
  95. *(.rodata.*)
  96. *(.gnu.linkonce.r*)
  97. _etext = . ;
  98. } > ISPACE
  99. /* DSpace is also located at address 0. Every (unrelocated) DSpace
  100. * address is an offset from the beginning of this segment.
  101. */
  102. .data 0x00000000 :
  103. {
  104. __data_start = . ;
  105. *(.data)
  106. *(.data1)
  107. *(.data.*)
  108. *(.gnu.linkonce.d*)
  109. *(.data1)
  110. *(.eh_frame)
  111. *(.gcc_except_table)
  112. *(.gnu.linkonce.s.*)
  113. *(__libc_atexit)
  114. *(__libc_subinit)
  115. *(__libc_subfreeres)
  116. *(.note.ABI-tag)
  117. /* C++ support. For each global and static local C++ object,
  118. * GCC creates a small subroutine to construct the object. Pointers
  119. * to these routines (not the routines themselves) are stored as
  120. * simple, linear arrays in the .ctors section of the object file.
  121. * Similarly, pointers to global/static destructor routines are
  122. * stored in .dtors.
  123. */
  124. *(.gnu.linkonce.d.*)
  125. _ctors_start = . ;
  126. *(.ctors)
  127. _ctors_end = . ;
  128. _dtors_start = . ;
  129. *(.dtors)
  130. _dtors_end = . ;
  131. . = ALIGN(4);
  132. _edata = . ;
  133. edata = ALIGN( 0x10 ) ;
  134. } > DSPACE
  135. .bss :
  136. {
  137. __bss_start = _edata ;
  138. *(.dynsbss)
  139. *(.sbss)
  140. *(.sbss.*)
  141. *(.scommon)
  142. *(.dynbss)
  143. *(.bss)
  144. *(.bss.*)
  145. *(.bss*)
  146. *(.gnu.linkonce.b*)
  147. *(COMMON)
  148. end = ALIGN( 0x10 ) ;
  149. _end = ALIGN( 0x10 ) ;
  150. } > DSPACE
  151. .got 0 : { *(.got.plt) *(.got) }
  152. .junk 0 : { *(.rel*) *(.rela*) }
  153. /* Stabs debugging sections. */
  154. .stab 0 : { *(.stab) }
  155. .stabstr 0 : { *(.stabstr) }
  156. .stab.excl 0 : { *(.stab.excl) }
  157. .stab.exclstr 0 : { *(.stab.exclstr) }
  158. .stab.index 0 : { *(.stab.index) }
  159. .stab.indexstr 0 : { *(.stab.indexstr) }
  160. .comment 0 : { *(.comment) }
  161. .debug_abbrev 0 : { *(.debug_abbrev) }
  162. .debug_info 0 : { *(.debug_info) }
  163. .debug_line 0 : { *(.debug_line) }
  164. .debug_pubnames 0 : { *(.debug_pubnames) }
  165. .debug_aranges 0 : { *(.debug_aranges) }
  166. }