tic4xcoff.sc 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. # Copyright (C) 2014-2022 Free Software Foundation, Inc.
  2. #
  3. # Copying and distribution of this file, with or without modification,
  4. # are permitted in any medium without royalty provided the copyright
  5. # notice and this notice are preserved.
  6. # In microcomputer (MC) mode, the vectors are mapped into the on-chip ROM,
  7. # otherwise in microprocessor (MP) mode the vectors are mapped to address 0
  8. # on the external bus. In MC mode, the on-chip ROM contains a bootloader program
  9. # that loads the internal RAM from the serial port or external ROM.
  10. #
  11. # Common configurations:
  12. # 1. MC mode, no external memory (serial boot).
  13. # 2. MC mode, external RAM (serial boot).
  14. # 3. MC mode, external ROM.
  15. # 4. MC mode, external ROM, external RAM.
  16. # 5. MP mode, external ROM.
  17. # 6. MP mode, external ROM, external RAM.
  18. # 7. MP mode, external RAM (dual-port with hosting CPU or external debugger).
  19. #
  20. # Config TEXT DATA/BSS
  21. # 1. INT_RAM INT_RAM (mcmode,onchip)
  22. # 2. EXT_RAM EXT_RAM (mcmode,extram)
  23. # 3. INT_RAM INT_RAM (mcmode,onchip)
  24. # 4. EXT_RAM EXT_RAM (mcmode,extram)
  25. # 5. EXT_ROM INT_RAM (mpmode,onchip,extrom)
  26. # 6. EXT_ROM EXT_RAM (mpmode,extram,extrom)
  27. # 7. EXT_RAM EXT_RAM (mpmode,extram)
  28. #
  29. # In MC mode, TEXT and DATA are copied into RAM by the bootloader.
  30. #
  31. # In MP mode with external ROM, DATA needs to be copied into RAM at boot time.
  32. #
  33. # If there is external RAM it is better to use that and reserve the internal RAM
  34. # for data buffers. However, the address of the external RAM needs to be specified.
  35. #
  36. # This emulation assumes config 7.
  37. case $OUTPUT_ARCH in
  38. tic3x) OUTPUT_ARCHNAME="TMS320C3x" ;;
  39. tic4x) OUTPUT_ARCHNAME="TMS320C4x" ;;
  40. esac
  41. case $ONCHIP in
  42. yes) RAM=RAM;
  43. STACK_SIZE_DEFAULT=128;
  44. HEAP_SIZE_DEFAULT=0;
  45. ;;
  46. *) RAM=EXT0;
  47. STACK_SIZE_DEFAULT=0x1000;
  48. HEAP_SIZE_DEFAULT=0x4000;
  49. ;;
  50. esac
  51. TEXT_MEMORY=$RAM;
  52. DATA_MEMORY=$RAM;
  53. MEMORY_DEF="
  54. /* C30 memory space. */
  55. MEMORY
  56. {
  57. EXT0 : org = 0x0000000, len = 0x800000 /* External address bus. */
  58. XBUS : org = 0x0800000, len = 0x002000 /* Expansion bus. */
  59. IOBUS : org = 0x0804000, len = 0x002000 /* I/O BUS. */
  60. RAM0 : org = 0x0809800, len = 0x000400 /* Internal RAM block 0. */
  61. RAM1 : org = 0x0809a00, len = 0x000400 /* Internal RAM block 1. */
  62. RAM : org = 0x0809800, len = 0x000800 /* Internal RAM. */
  63. EXT1 : org = 0x080a000, len = 0x7f6000 /* External address bus. */
  64. }
  65. "
  66. test -z "$ENTRY" && ENTRY=_start
  67. cat <<EOF
  68. ${RELOCATING+/* Linker script for $OUTPUT_ARCHNAME executable. */}
  69. ${RELOCATING-/* Linker script for $OUTPUT_ARCHNAME object file (ld -r). */}
  70. /* Copyright (C) 2014-2022 Free Software Foundation, Inc.
  71. Copying and distribution of this script, with or without modification,
  72. are permitted in any medium without royalty provided the copyright
  73. notice and this notice are preserved. */
  74. OUTPUT_FORMAT("${OUTPUT_FORMAT}")
  75. OUTPUT_ARCH("${OUTPUT_ARCH}")
  76. ${LIB_SEARCH_DIRS}
  77. ${RELOCATING+ENTRY (${ENTRY})}
  78. ${RELOCATING+ __HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : ${HEAP_SIZE_DEFAULT};}
  79. ${RELOCATING+ __STACK_SIZE = DEFINED(__STACK_SIZE) ? __STACK_SIZE : ${STACK_SIZE_DEFAULT};}
  80. ${RELOCATING+${MEMORY_DEF}}
  81. /* In the small memory model the .data and .bss sections must be contiguous
  82. when loaded and fit within the same page. The DP register is loaded
  83. with the page address. */
  84. SECTIONS
  85. {
  86. /* Reset, interrupt, and trap vectors. */
  87. .vectors ${RELOCATING+ 0} : {
  88. *(.vectors)
  89. } ${RELOCATING+ > ${TEXT_MEMORY}}
  90. /* Constants. */
  91. .const : {
  92. *(.const)
  93. } ${RELOCATING+ > ${TEXT_MEMORY}}
  94. /* Program code. */
  95. .text : {
  96. ${RELOCATING+ __text = .;}
  97. ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
  98. *(.text)
  99. ${CONSTRUCTING+ ___CTOR_LIST__ = .;}
  100. ${CONSTRUCTING+ LONG(___CTOR_END__ - ___CTOR_LIST__ - 2)}
  101. ${CONSTRUCTING+ *(.ctors)}
  102. ${CONSTRUCTING+ LONG(0);}
  103. ${CONSTRUCTING+ ___CTOR_END__ = .;}
  104. ${CONSTRUCTING+ ___DTOR_LIST__ = .;}
  105. ${CONSTRUCTING+ LONG(___DTOR_END__ - ___DTOR_LIST__ - 2)}
  106. ${CONSTRUCTING+ *(.dtors)}
  107. ${CONSTRUCTING+ LONG(0)}
  108. ${CONSTRUCTING+ ___DTOR_END__ = .;}
  109. ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
  110. ${RELOCATING+ __etext = .;}
  111. } ${RELOCATING+ > ${TEXT_MEMORY}}
  112. /* Global initialised variables. */
  113. .data :
  114. {
  115. ${RELOCATING+ __data = .;}
  116. *(.data)
  117. ${RELOCATING+ __edata = .;}
  118. } ${RELOCATING+ > ${DATA_MEMORY}}
  119. /* Global uninitialised variables. */
  120. .bss : {
  121. ${RELOCATING+ __bss = .;}
  122. *(.bss)
  123. *(COMMON)
  124. ${RELOCATING+ __end = .;}
  125. } ${RELOCATING+ > ${DATA_MEMORY}}
  126. /* Heap. */
  127. .heap :
  128. {
  129. ${RELOCATING+ __heap = .;}
  130. ${RELOCATING+ . += __HEAP_SIZE};
  131. } ${RELOCATING+ > ${DATA_MEMORY}}
  132. /* Stack (grows upward). */
  133. .stack :
  134. {
  135. ${RELOCATING+ __stack = .;}
  136. *(.stack)
  137. ${RELOCATING+ . = . + __STACK_SIZE};
  138. } ${RELOCATING+ > ${DATA_MEMORY}}
  139. .stab 0 ${RELOCATING+(NOLOAD)} :
  140. {
  141. [ .stab ]
  142. }
  143. .stabstr 0 ${RELOCATING+(NOLOAD)} :
  144. {
  145. [ .stabstr ]
  146. }
  147. }
  148. EOF