elf32crx.sc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. # Linker Script for National Semiconductor's CRX-ELF32.
  2. #
  3. # Copyright (C) 2014-2015 Free Software Foundation, Inc.
  4. #
  5. # Copying and distribution of this file, with or without modification,
  6. # are permitted in any medium without royalty provided the copyright
  7. # notice and this notice are preserved.
  8. # The next line should be uncommented if it is desired to link
  9. # without libstart.o and directly enter main.
  10. # ENTRY=_main
  11. test -z "$ENTRY" && ENTRY=_start
  12. cat <<EOF
  13. /* Example Linker Script for linking NS CRX elf32 files.
  14. Copyright (C) 2014-2015 Free Software Foundation, Inc.
  15. Copying and distribution of this script, with or without modification,
  16. are permitted in any medium without royalty provided the copyright
  17. notice and this notice are preserved. */
  18. OUTPUT_FORMAT("${OUTPUT_FORMAT}")
  19. OUTPUT_ARCH(${ARCH})
  20. ${RELOCATING+ENTRY(${ENTRY})}
  21. /* Define memory regions. */
  22. MEMORY
  23. {
  24. rom : ORIGIN = 0x2, LENGTH = 3M
  25. ram : ORIGIN = 4M, LENGTH = 10M
  26. }
  27. /* Many sections come in three flavours. There is the 'real' section,
  28. like ".data". Then there are the per-procedure or per-variable
  29. sections, generated by -ffunction-sections and -fdata-sections in GCC,
  30. and useful for --gc-sections, which for a variable "foo" might be
  31. ".data.foo". Then there are the linkonce sections, for which the linker
  32. eliminates duplicates, which are named like ".gnu.linkonce.d.foo".
  33. The exact correspondences are:
  34. Section Linkonce section
  35. .text .gnu.linkonce.t.foo
  36. .rdata .gnu.linkonce.r.foo
  37. .data .gnu.linkonce.d.foo
  38. .bss .gnu.linkonce.b.foo
  39. .debug_info .gnu.linkonce.wi.foo */
  40. SECTIONS
  41. {
  42. .init :
  43. {
  44. __INIT_START = .;
  45. KEEP (*(.init))
  46. __INIT_END = .;
  47. } > rom
  48. .fini :
  49. {
  50. __FINI_START = .;
  51. KEEP (*(.fini))
  52. __FINI_END = .;
  53. } > rom
  54. .jcr :
  55. {
  56. KEEP (*(.jcr))
  57. } > rom
  58. .text :
  59. {
  60. __TEXT_START = .;
  61. *(.text) *(.text.*) *(.gnu.linkonce.t.*)
  62. __TEXT_END = .;
  63. } > rom
  64. .rdata :
  65. {
  66. __RDATA_START = .;
  67. *(.rdata_4) *(.rdata_2) *(.rdata_1) *(.rdata.*) *(.gnu.linkonce.r.*) *(.rodata.*)
  68. __RDATA_END = .;
  69. } > rom
  70. .ctor ALIGN(4) :
  71. {
  72. __CTOR_START = .;
  73. /* The compiler uses crtbegin.o to find the start
  74. of the constructors, so we make sure it is
  75. first. Because this is a wildcard, it
  76. doesn't matter if the user does not
  77. actually link against crtbegin.o; the
  78. linker won't look for a file to match a
  79. wildcard. The wildcard also means that it
  80. doesn't matter which directory crtbegin.o
  81. is in. */
  82. KEEP (*crtbegin.o(.ctors))
  83. KEEP (*crtbegin?.o(.ctors))
  84. /* We don't want to include the .ctor section from
  85. the crtend.o file until after the sorted ctors.
  86. The .ctor section from the crtend file contains the
  87. end of ctors marker and it must be last */
  88. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .ctors))
  89. KEEP (*(SORT(.ctors.*)))
  90. KEEP (*(.ctors))
  91. __CTOR_END = .;
  92. } > rom
  93. .dtor ALIGN(4) :
  94. {
  95. __DTOR_START = .;
  96. KEEP (*crtbegin.o(.dtors))
  97. KEEP (*crtbegin?.o(.dtors))
  98. KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o) .dtors))
  99. KEEP (*(SORT(.dtors.*)))
  100. KEEP (*(.dtors))
  101. __DTOR_END = .;
  102. } > rom
  103. .data :
  104. {
  105. __DATA_START = .;
  106. *(.data_4) *(.data_2) *(.data_1) *(.data) *(.data.*) *(.gnu.linkonce.d.*)
  107. __DATA_END = .;
  108. } > ram AT > rom
  109. .bss (NOLOAD) :
  110. {
  111. __BSS_START = .;
  112. *(.bss_4) *(.bss_2) *(.bss_1) *(.bss) *(COMMON) *(.bss.*) *(.gnu.linkonce.b.*)
  113. __BSS_END = .;
  114. } > ram
  115. /* You may change the sizes of the following sections to fit the actual
  116. size your program requires.
  117. The heap and stack are aligned to the bus width, as a speed optimization
  118. for accessing data located there. */
  119. .heap (NOLOAD) :
  120. {
  121. . = ALIGN(4);
  122. __HEAP_START = .;
  123. . += 0x2000; __HEAP_MAX = .;
  124. } > ram
  125. .stack (NOLOAD) :
  126. {
  127. . = ALIGN(4);
  128. . += 0x6000;
  129. __STACK_START = .;
  130. } > ram
  131. .istack (NOLOAD) :
  132. {
  133. . = ALIGN(4);
  134. . += 0x100;
  135. __ISTACK_START = .;
  136. } > ram
  137. .comment 0 : { *(.comment) }
  138. EOF
  139. . $srcdir/scripttempl/DWARF.sc
  140. cat <<EOF
  141. }
  142. __DATA_IMAGE_START = LOADADDR(.data);
  143. EOF