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