xref: /netbsd-src/external/gpl3/binutils.old/dist/ld/scripttempl/tic4xcoff.sc (revision e992f068c547fd6e84b3f104dc2340adcc955732)
1*e992f068Schristos# Copyright (C) 2014-2022 Free Software Foundation, Inc.
216dce513Schristos#
316dce513Schristos# Copying and distribution of this file, with or without modification,
416dce513Schristos# are permitted in any medium without royalty provided the copyright
516dce513Schristos# notice and this notice are preserved.
616dce513Schristos
716dce513Schristos# In microcomputer (MC) mode, the vectors are mapped into the on-chip ROM,
816dce513Schristos# otherwise in microprocessor (MP) mode the vectors are mapped to address 0
916dce513Schristos# on the external bus.  In MC mode, the on-chip ROM contains a bootloader program
1016dce513Schristos# that loads the internal RAM from the serial port or external ROM.
1116dce513Schristos#
1216dce513Schristos# Common configurations:
1316dce513Schristos# 1. MC mode, no external memory (serial boot).
1416dce513Schristos# 2. MC mode, external RAM (serial boot).
1516dce513Schristos# 3. MC mode, external ROM.
1616dce513Schristos# 4. MC mode, external ROM, external RAM.
1716dce513Schristos# 5. MP mode, external ROM.
1816dce513Schristos# 6. MP mode, external ROM, external RAM.
1916dce513Schristos# 7. MP mode, external RAM (dual-port with hosting CPU or external debugger).
2016dce513Schristos#
2116dce513Schristos# Config  TEXT     DATA/BSS
2216dce513Schristos# 1.      INT_RAM  INT_RAM   (mcmode,onchip)
2316dce513Schristos# 2.      EXT_RAM  EXT_RAM   (mcmode,extram)
2416dce513Schristos# 3.      INT_RAM  INT_RAM   (mcmode,onchip)
2516dce513Schristos# 4.      EXT_RAM  EXT_RAM   (mcmode,extram)
2616dce513Schristos# 5.      EXT_ROM  INT_RAM   (mpmode,onchip,extrom)
2716dce513Schristos# 6.      EXT_ROM  EXT_RAM   (mpmode,extram,extrom)
2816dce513Schristos# 7.      EXT_RAM  EXT_RAM   (mpmode,extram)
2916dce513Schristos#
3016dce513Schristos# In MC mode, TEXT and DATA are copied into RAM by the bootloader.
3116dce513Schristos#
3216dce513Schristos# In MP mode with external ROM, DATA needs to be copied into RAM at boot time.
3316dce513Schristos#
3416dce513Schristos# If there is external RAM it is better to use that and reserve the internal RAM
3516dce513Schristos# for data buffers.  However, the address of the external RAM needs to be specified.
3616dce513Schristos#
3716dce513Schristos# This emulation assumes config 7.
3816dce513Schristos
3916dce513Schristoscase $OUTPUT_ARCH in
4016dce513Schristos  tic3x) OUTPUT_ARCHNAME="TMS320C3x" ;;
4116dce513Schristos  tic4x) OUTPUT_ARCHNAME="TMS320C4x" ;;
4216dce513Schristosesac
4316dce513Schristos
4416dce513Schristoscase $ONCHIP in
4516dce513Schristos  yes) RAM=RAM;
4616dce513Schristos       STACK_SIZE_DEFAULT=128;
4716dce513Schristos       HEAP_SIZE_DEFAULT=0;
4816dce513Schristos       ;;
4916dce513Schristos  *)   RAM=EXT0;
5016dce513Schristos       STACK_SIZE_DEFAULT=0x1000;
5116dce513Schristos       HEAP_SIZE_DEFAULT=0x4000;
5216dce513Schristos       ;;
5316dce513Schristosesac
5416dce513Schristos
5516dce513SchristosTEXT_MEMORY=$RAM;
5616dce513SchristosDATA_MEMORY=$RAM;
5716dce513Schristos
5816dce513Schristos
5916dce513SchristosMEMORY_DEF="
6016dce513Schristos/* C30 memory space.  */
6116dce513SchristosMEMORY
6216dce513Schristos{
6316dce513Schristos   EXT0  :  org = 0x0000000, len = 0x800000  /* External address bus.  */
6416dce513Schristos   XBUS  :  org = 0x0800000, len = 0x002000  /* Expansion bus.         */
6516dce513Schristos   IOBUS :  org = 0x0804000, len = 0x002000  /* I/O BUS.               */
6616dce513Schristos   RAM0  :  org = 0x0809800, len = 0x000400  /* Internal RAM block 0.  */
6716dce513Schristos   RAM1  :  org = 0x0809a00, len = 0x000400  /* Internal RAM block 1.  */
6816dce513Schristos   RAM   :  org = 0x0809800, len = 0x000800  /* Internal RAM.          */
6916dce513Schristos   EXT1  :  org = 0x080a000, len = 0x7f6000  /* External address bus.  */
7016dce513Schristos}
7116dce513Schristos"
7216dce513Schristos
7316dce513Schristostest -z "$ENTRY" && ENTRY=_start
7416dce513Schristos
7516dce513Schristoscat <<EOF
7616dce513Schristos${RELOCATING+/* Linker script for $OUTPUT_ARCHNAME executable.  */}
7716dce513Schristos${RELOCATING-/* Linker script for $OUTPUT_ARCHNAME object file (ld -r).  */}
7816dce513Schristos
79*e992f068Schristos/* Copyright (C) 2014-2022 Free Software Foundation, Inc.
8016dce513Schristos
8116dce513Schristos   Copying and distribution of this script, with or without modification,
8216dce513Schristos   are permitted in any medium without royalty provided the copyright
8316dce513Schristos   notice and this notice are preserved.  */
8416dce513Schristos
8516dce513SchristosOUTPUT_FORMAT("${OUTPUT_FORMAT}")
8616dce513SchristosOUTPUT_ARCH("${OUTPUT_ARCH}")
8716dce513Schristos${LIB_SEARCH_DIRS}
8816dce513Schristos${RELOCATING+ENTRY (${ENTRY})}
8916dce513Schristos
9016dce513Schristos${RELOCATING+ __HEAP_SIZE = DEFINED(__HEAP_SIZE) ? __HEAP_SIZE : ${HEAP_SIZE_DEFAULT};}
9116dce513Schristos${RELOCATING+ __STACK_SIZE  = DEFINED(__STACK_SIZE)  ? __STACK_SIZE  : ${STACK_SIZE_DEFAULT};}
9216dce513Schristos
9316dce513Schristos${RELOCATING+${MEMORY_DEF}}
9416dce513Schristos
9516dce513Schristos/* In the small memory model the .data and .bss sections must be contiguous
9616dce513Schristos   when loaded and fit within the same page.   The DP register is loaded
9716dce513Schristos   with the page address.  */
9816dce513Schristos
9916dce513SchristosSECTIONS
10016dce513Schristos{
10116dce513Schristos  /* Reset, interrupt, and trap vectors.  */
10216dce513Schristos  .vectors ${RELOCATING+ 0} : {
10316dce513Schristos    *(.vectors)
10416dce513Schristos  } ${RELOCATING+ > ${TEXT_MEMORY}}
10516dce513Schristos  /* Constants.  */
10616dce513Schristos  .const : {
10716dce513Schristos    *(.const)
10816dce513Schristos  } ${RELOCATING+ > ${TEXT_MEMORY}}
10916dce513Schristos  /* Program code.  */
11016dce513Schristos  .text : {
11116dce513Schristos    ${RELOCATING+  __text =  .;}
112012573ebSchristos    ${RELOCATING+ KEEP (*(SORT_NONE(.init)))}
11316dce513Schristos    *(.text)
11416dce513Schristos    ${CONSTRUCTING+ ___CTOR_LIST__ = .;}
11516dce513Schristos    ${CONSTRUCTING+ LONG(___CTOR_END__ - ___CTOR_LIST__ - 2)}
11616dce513Schristos    ${CONSTRUCTING+ *(.ctors)}
11716dce513Schristos    ${CONSTRUCTING+ LONG(0);}
11816dce513Schristos    ${CONSTRUCTING+ ___CTOR_END__  = .;}
11916dce513Schristos    ${CONSTRUCTING+ ___DTOR_LIST__ = .;}
12016dce513Schristos    ${CONSTRUCTING+ LONG(___DTOR_END__ - ___DTOR_LIST__ - 2)}
12116dce513Schristos    ${CONSTRUCTING+ *(.dtors)}
12216dce513Schristos    ${CONSTRUCTING+ LONG(0)}
12316dce513Schristos    ${CONSTRUCTING+ ___DTOR_END__  = .;}
124012573ebSchristos    ${RELOCATING+ KEEP (*(SORT_NONE(.fini)))}
12516dce513Schristos    ${RELOCATING+  __etext =  .;}
12616dce513Schristos  } ${RELOCATING+ > ${TEXT_MEMORY}}
12716dce513Schristos  /* Global initialised variables.  */
12816dce513Schristos  .data :
12916dce513Schristos  {
13016dce513Schristos    ${RELOCATING+  __data  =  .;}
13116dce513Schristos    *(.data)
13216dce513Schristos    ${RELOCATING+  __edata  = .;}
13316dce513Schristos  } ${RELOCATING+ > ${DATA_MEMORY}}
13416dce513Schristos  /* Global uninitialised variables.  */
13516dce513Schristos  .bss : {
13616dce513Schristos    ${RELOCATING+ __bss  =  .;}
13716dce513Schristos    *(.bss)
13816dce513Schristos    *(COMMON)
13916dce513Schristos    ${RELOCATING+  __end  =  .;}
14016dce513Schristos  } ${RELOCATING+ > ${DATA_MEMORY}}
14116dce513Schristos  /* Heap.  */
14216dce513Schristos  .heap :
14316dce513Schristos  {
14416dce513Schristos    ${RELOCATING+ __heap  =  .;}
14516dce513Schristos    ${RELOCATING+ . += __HEAP_SIZE};
14616dce513Schristos  } ${RELOCATING+ > ${DATA_MEMORY}}
14716dce513Schristos  /* Stack (grows upward).  */
14816dce513Schristos  .stack :
14916dce513Schristos  {
15016dce513Schristos    ${RELOCATING+ __stack  =  .;}
15116dce513Schristos    *(.stack)
15216dce513Schristos    ${RELOCATING+ .  =  . + __STACK_SIZE};
15316dce513Schristos  } ${RELOCATING+ > ${DATA_MEMORY}}
15416dce513Schristos  .stab 0 ${RELOCATING+(NOLOAD)} :
15516dce513Schristos  {
15616dce513Schristos    [ .stab ]
15716dce513Schristos  }
15816dce513Schristos  .stabstr 0 ${RELOCATING+(NOLOAD)} :
15916dce513Schristos  {
16016dce513Schristos    [ .stabstr ]
16116dce513Schristos  }
16216dce513Schristos}
16316dce513SchristosEOF
164