#---------------------------------------------------------------------------
#  Project:  NitroSDK - tools - makelcf
#  File:     ARM9-TS.lcf.template
#
#  Copyright 2003-2006 Nintendo.  All rights reserved.
#
#  These coded instructions, statements, and computer programs contain
#  proprietary information of Nintendo of America Inc. and/or Nintendo
#  Company Ltd., and are protected by Federal copyright law.  They may
#  not be disclosed to third parties or copied or duplicated in any form,
#  in whole or in part, without the prior written consent of Nintendo.
#
#  $Log: ARM9-TS.lcf.template,v $
#  Revision 1.3  03/30/2006 00:31:29 AM  yasu
#  revised NUMBER_OVERLAYS to NUMBER.OVERLAYS
#
#  Revision 1.2  03/29/2006 13:19:14 AM  yasu
#  NUMBER_OVERLAYS revised to NUMBER.OVERLAYS
#
#  Revision 1.1  09/05/2005 01:38:31 AM  yasu
#  Record template before editing tags
#
#  Revision 1.28  08/26/2005 11:22:16 AM  yasu
#  overlay support for ITCM/DTCM
#
#  Revision 1.27  06/20/2005 12:29:20 AM  yasu
#  Changed Surffix to Suffix
#
#  Revision 1.26  06/14/2005 09:03:42  yada
#  fix around minus value of SDK_STACKSIZE
#
#  Revision 1.25  04/13/2005 12:51:00  terui
#  Change SDK_AUTOLOAD_DTCM_START 0x027c0000 -> 0x027e0000
#
#  Revision 1.24  03/30/2005 00:02:14  yosizaki
#  fix copyright header.
#
#  Revision 1.23  03/25/2005 12:54:59 AM  yasu
#  Include .version section
#
#  Revision 1.22  10/03/2004 02:00:56 AM  yasu
#  Output component file list for compstatic tool
#
#  Revision 1.21  09/27/2004 05:28:21 AM  yasu
#  Support .sinit
#
#  Revision 1.20  09/09/2004 11:49:20 AM  yasu
#  Support compstatic in default
#
#  Revision 1.19  09/06/2004 06:40:00 AM  yasu
#  Add labels for digest
#
#  Revision 1.18  08/20/2004 06:19:59 AM  yasu
#  DTCM moves to 0x027c0000 at default
#
#  Revision 1.17  08/02/2004 10:38:53 AM  yasu
#  Add autoload-done callback address in overlaydefs
#
#  Revision 1.16  07/26/2004 02:22:32 AM  yasu
#  Change DTCM address to 0x023c0000
#
#  Revision 1.15  07/26/2004 00:08:27 AM  yasu
#  Fix label of exception table
#
#  Revision 1.14  07/24/2004 05:42:25 AM  yasu
#  Set default values for SDK_AUTOGEN_xTCM_START
#
#  Revision 1.13  07/23/2004 11:32:14 AM  yasu
#  Define labels for __exception_table_start__ and _end__
#
#  Revision 1.12  07/12/2004 12:21:08 AM  yasu
#  Check size of ITCM/DTCM
#
#  Revision 1.11  07/10/2004 04:10:26 AM  yasu
#  Support command 'Library'
#
#  Revision 1.10  07/02/2004 08:13:02 AM  yasu
#  Support OBJECT( )
#
#  Revision 1.9	 07/01/2004 12:54:38  yasu
#  support ITCM/DTCM/WRAM autoload
#
#  Revision 1.8	 07/01/2004 10:41:46  yasu
#  support autoload
#
#  Revision 1.7	 06/02/2004 07:35:37  yasu
#  Set libsyscall.a in FORCE_ACTIVE
#  Put NitroMain at the top of ROM image
#
#  Revision 1.6	 06/02/2004 04:56:28  yasu
#  Change to fit to new ROM map of TS
#
#  Revision 1.5	 2004/06/01 06:12:00  miya
#  add padding at top of ROM image.
#
#  Revision 1.4	 04/26/2004 12:16:48  yasu
#  add KEEP_SECTIONS
#
#  Revision 1.3	 04/20/2004 07:41:32  yasu
#  Set STATICINIT instead of .ctor temporarily
#
#  Revision 1.2	 04/14/2004 07:16:42  yasu
#  add ALIGN(32) for convenience to handle cache line
#
#  Revision 1.1	 04/06/2004 01:59:54  yasu
#  newly added
#
#  $NoKeywords: $
#---------------------------------------------------------------------------
MEMORY
{
	<STATIC.NAME>		(RWX) : ORIGIN = <STATIC.ADDRESS>,   LENGTH = 0x0 >  <STATIC.NAME><PROPERTY.SUFFIX>
	<FOREACH.AUTOLOADS>
	<AUTOLOAD.NAME>		(RWX) : ORIGIN = <AUTOLOAD.ADDRESS>, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.SUFFIX>
	<END.AUTOLOADS>
	AUTOLOAD_INFO__		(RWX) : ORIGIN = 0, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.SUFFIX>
	STATIC_FOOTER__		(RWX) : ORIGIN = 0, LENGTH = 0x0 >> <STATIC.NAME><PROPERTY.SUFFIX>
	
	<PROPERTY.OVERLAYDEFS>	(RW)  : ORIGIN = AFTER(<STATIC.NAME>), LENGTH = 0x0 > <PROPERTY.OVERLAYDEFS><PROPERTY.SUFFIX>
	<PROPERTY.OVERLAYTABLE>	(RW)  : ORIGIN = AFTER(<STATIC.NAME>), LENGTH = 0x0 > <PROPERTY.OVERLAYTABLE><PROPERTY.SUFFIX>
	<FOREACH.OVERLAYS>
	<OVERLAY.NAME>		(RWXO): ORIGIN = <OVERLAY.ADDRESS>, LENGTH = 0x0 > <OVERLAY.NAME><PROPERTY.SUFFIX>
	<END.OVERLAYS>
	MAIN_EX__		(RW)  : ORIGIN = 0x02400000, LENGTH = 0x0
	ARENA__			(RW)  : ORIGIN = AFTER(<STATIC.NAME><FOREACH.OVERLAYS=MAIN>,<OVERLAY.NAME><END.OVERLAYS>), LENGTH = 0x0
	ARENA_EX__		(RW)  : ORIGIN = AFTER(MAIN_EX__<FOREACH.OVERLAYS=MAINEX>,<OVERLAY.NAME><END.OVERLAYS>), LENGTH = 0x0
	ARENA_ITCM__		(RW)  : ORIGIN = AFTER(ITCM<FOREACH.OVERLAYS=ITCM>,<OVERLAY.NAME><END.OVERLAYS>), LENGTH = 0x0
	ARENA_DTCM__		(RW)  : ORIGIN = AFTER(DTCM<FOREACH.OVERLAYS=DTCM>,<OVERLAY.NAME><END.OVERLAYS>), LENGTH = 0x0
	MODULE_FILES__		(RW)  : ORIGIN = 0x0, LENGTH = 0x0     > component.files
	ITCM__			(RWX) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check
	DTCM__			(RW)  : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check
}

FORCE_ACTIVE
{
	SVC_SoftReset
}

KEEP_SECTION
{
	.sinit
}

SECTIONS
{
	############################ STATIC #################################
	.<STATIC.NAME>:
	{
	ALIGNALL(4);			. = ALIGN(32);	# Fit to cache line
	
	#
	#  TEXT BLOCK: READ ONLY
	#
	SDK_STATIC_START		=.;
	SDK_STATIC_TEXT_START		=.;
					#:::::::::: text/rodata
					libsyscall.a (.text)
					crt0.o (.text)
					crt0.o (.rodata)
					* (.version)
					OBJECT(NitroMain,*)
					<FOREACH.STATIC.OBJECTS=.text>
					<STATIC.OBJECT=.text:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.text>
					<STATIC.LIBRARY=.text:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);
					* (.exception)
					. = ALIGN(4);
	SDK_STATIC_ETABLE_START		=.;
					EXCEPTION
	SDK_STATIC_ETABLE_END		=.;
					. = ALIGN(4);
					<FOREACH.STATIC.OBJECTS=.init>
					<STATIC.OBJECT=.init:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.init>
					<STATIC.LIBRARY=.init:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);
					<FOREACH.STATIC.OBJECTS=.rodata>
					<STATIC.OBJECT=.rodata:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.rodata>
					<STATIC.LIBRARY=.rodata:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);

	SDK_STATIC_SINIT_START		=.;
					#:::::::::: ctor
					<FOREACH.STATIC.OBJECTS=.ctor>
					<STATIC.OBJECT=.ctor:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.ctor>
					<STATIC.LIBRARY=.ctor:t>
					<END.STATIC.LIBRARIES>
					<FOREACH.STATIC.OBJECTS=.sinit>
					<STATIC.OBJECT=.sinit:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.sinit>
					<STATIC.LIBRARY=.sinit:t>
					<END.STATIC.LIBRARIES>
					WRITEW	0;
					#:::::::::: ctor
	SDK_STATIC_SINIT_END		=.;

					#:::::::::: text/rodata
					. = ALIGN(32);
	SDK_STATIC_TEXT_END		=.;
	
	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_STATIC_DATA_START		=.;
					#:::::::::: data
					<FOREACH.STATIC.OBJECTS=.sdata>
					<STATIC.OBJECT=.sdata:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.sdata>
					<STATIC.LIBRARY=.sdata:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);
					<FOREACH.STATIC.OBJECTS=.data>
					<STATIC.OBJECT=.data:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.data>
					<STATIC.LIBRARY=.data:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);
	SDK_OVERLAY_DIGEST		=.;
					# NO DIGEST
	SDK_OVERLAY_DIGEST_END		=.;
					#:::::::::: data
					. = ALIGN(32);
	SDK_STATIC_DATA_END		=.;
	SDK_STATIC_END			=.;

	SDK_STATIC_TEXT_SIZE		= SDK_STATIC_TEXT_END - SDK_STATIC_TEXT_START;
	SDK_STATIC_DATA_SIZE		= SDK_STATIC_DATA_END - SDK_STATIC_DATA_START;
	SDK_STATIC_SIZE			= SDK_STATIC_END      - SDK_STATIC_START;
	__sinit__			= SDK_STATIC_SINIT_START;	# for static initializer
	__exception_table_start__	= SDK_STATIC_ETABLE_START;	# for exception table
	__exception_table_end__		= SDK_STATIC_ETABLE_END;	# for exception table
	} > <STATIC.NAME>

	.<STATIC.NAME>_bss:
	{
	ALIGNALL(4);			. = ALIGN(32);

	#
	#  BSS BLOCK
	#
	SDK_STATIC_BSS_START		=.;
					#:::::::::: bss
					<FOREACH.STATIC.OBJECTS=.sbss>
					<STATIC.OBJECT=.sbss:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.sbss>
					<STATIC.LIBRARY=.sbss:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);
					<FOREACH.STATIC.OBJECTS=.bss>
					<STATIC.OBJECT=.bss:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.bss>
					<STATIC.LIBRARY=.bss:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);
					#:::::::::: bss
					. = ALIGN(32);
	SDK_STATIC_BSS_END		= .;
	SDK_STATIC_BSS_SIZE		= SDK_STATIC_BSS_END - SDK_STATIC_BSS_START;

	} >> <STATIC.NAME>
	
	
	############################ AUTOLOADS ##############################
	SDK_AUTOLOAD_ITCM_START			= 0x01ff8000;
	SDK_AUTOLOAD_ITCM_END			= SDK_AUTOLOAD_ITCM_START;
	SDK_AUTOLOAD_ITCM_BSS_END		= SDK_AUTOLOAD_ITCM_START;
	SDK_AUTOLOAD_DTCM_START			= 0x027e0000;
	SDK_AUTOLOAD_DTCM_END			= SDK_AUTOLOAD_DTCM_START;
	SDK_AUTOLOAD_DTCM_BSS_END		= SDK_AUTOLOAD_DTCM_START;
	SDK_AUTOLOAD_START			= SDK_STATIC_END;
	SDK_AUTOLOAD_SIZE			= 0;
	SDK_AUTOLOAD_NUMBER			= <NUMBER.AUTOLOADS>;

<FOREACH.AUTOLOADS>
	.<AUTOLOAD.NAME>:
	{
	ALIGNALL(4);				. = ALIGN(32);
	
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_ID		=<AUTOLOAD.ID>;
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_START	=.;
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_TEXT_START	=.;
						#:::::::::: text/rodata
						<FOREACH.AUTOLOAD.OBJECTS=.text>
						<AUTOLOAD.OBJECT=.text:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.text>
						<AUTOLOAD.LIBRARY=.text:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.AUTOLOAD.OBJECTS=.itcm>
						<AUTOLOAD.OBJECT=.itcm:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.itcm>
						<AUTOLOAD.LIBRARY=.itcm:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.AUTOLOAD.OBJECTS=.rodata>
						<AUTOLOAD.OBJECT=.rodata:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.rodata>
						<AUTOLOAD.LIBRARY=.rodata:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						#:::::::::: text/rodata
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE BLOCK
	#
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_DATA_START	=.;
						#:::::::::: data
						<FOREACH.AUTOLOAD.OBJECTS=.sdata>
						<AUTOLOAD.OBJECT=.sdata:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.sdata>
						<AUTOLOAD.LIBRARY=.sdata:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.AUTOLOAD.OBJECTS=.data>
						<AUTOLOAD.OBJECT=.data:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.data>
						<AUTOLOAD.LIBRARY=.data:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.AUTOLOAD.OBJECTS=.dtcm>
						<AUTOLOAD.OBJECT=.dtcm:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.dtcm>
						<AUTOLOAD.LIBRARY=.dtcm:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_DATA_END	=.;
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_END	=.;
	
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_TEXT_SIZE	= SDK_AUTOLOAD_<AUTOLOAD.NAME>_TEXT_END - SDK_AUTOLOAD_<AUTOLOAD.NAME>_TEXT_START;
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_DATA_SIZE	= SDK_AUTOLOAD_<AUTOLOAD.NAME>_DATA_END - SDK_AUTOLOAD_<AUTOLOAD.NAME>_DATA_START;
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_SIZE	= SDK_AUTOLOAD_<AUTOLOAD.NAME>_END	- SDK_AUTOLOAD_<AUTOLOAD.NAME>_START;
	SDK_AUTOLOAD_SIZE			= SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD_<AUTOLOAD.NAME>_SIZE;

	} > <AUTOLOAD.NAME>

	.<AUTOLOAD.NAME>_bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
	
	#
	#  BSS BLOCK
	#
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_BSS_START	= .;
						#:::::::::: bss
						<FOREACH.AUTOLOAD.OBJECTS=.sbss>
						<AUTOLOAD.OBJECT=.sbss:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.sbss>
						<AUTOLOAD.LIBRARY=.sbss:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.AUTOLOAD.OBJECTS=.bss>
						<AUTOLOAD.OBJECT=.bss:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.bss>
						<AUTOLOAD.LIBRARY=.bss:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_BSS_END	= .;

	SDK_AUTOLOAD_<AUTOLOAD.NAME>_BSS_SIZE	= SDK_AUTOLOAD_<AUTOLOAD.NAME>_BSS_END - SDK_AUTOLOAD_<AUTOLOAD.NAME>_BSS_START;

	} >> <AUTOLOAD.NAME>

<END.AUTOLOADS>

	############################ AUTOLOAD_INFO ##########################
	.AUTOLOAD_INFO__:
	{
<FOREACH.AUTOLOADS>
		WRITEW ADDR(.<AUTOLOAD.NAME>);
		WRITEW SDK_AUTOLOAD_<AUTOLOAD.NAME>_SIZE;
		WRITEW SDK_AUTOLOAD_<AUTOLOAD.NAME>_BSS_SIZE;
<END.AUTOLOADS>
	} > AUTOLOAD_INFO__
	
	SDK_AUTOLOAD_LIST			= SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE;
	SDK_AUTOLOAD_LIST_END			= SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.AUTOLOAD_INFO__);
	SDK_AUTOLOAD_SIZE			= SDK_AUTOLOAD_SIZE  + SIZEOF(.AUTOLOAD_INFO__);
	
	############################ STATIC_FOOTER ##########################
	.STATIC_FOOTER__:
	{
		WRITEW 0xdec00621;		# LE(0x2106C0DE) = NITRO CODE
		WRITEW _start_ModuleParams - ADDR(.<STATIC.NAME>);
		WRITEW 0;			# NO DIGEST
	} > STATIC_FOOTER__
	
	############################ OVERLAYS ###############################
	SDK_OVERLAY_NUMBER			= <NUMBER.OVERLAYS>;

<FOREACH.OVERLAYS>
	.<OVERLAY.NAME>:
	{
	ALIGNALL(4);				. = ALIGN(32);
	
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_<OVERLAY.NAME>_ID		=<OVERLAY.ID>;	### SEGMENT <OVERLAY.NAME> OVERLAY ID
	SDK_OVERLAY_<OVERLAY.NAME>_START	=.;
	SDK_OVERLAY_<OVERLAY.NAME>_TEXT_START	=.;
						#:::::::::: text/rodata
						<FOREACH.OVERLAY.OBJECTS=.text>
						<OVERLAY.OBJECT=.text:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.text>
						<OVERLAY.LIBRARY=.text:t>
						<END.OVERLAY.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.OVERLAY.OBJECTS=.rodata>
						<OVERLAY.OBJECT=.rodata:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.rodata>
						<OVERLAY.LIBRARY=.rodata:t>
						<END.OVERLAY.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.OVERLAY.OBJECTS=.init>
						<OVERLAY.OBJECT=.init:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.init>
						<OVERLAY.LIBRARY=.init:t>
						<END.OVERLAY.LIBRARIES>
						. = ALIGN(4);
	SDK_OVERLAY_<OVERLAY.NAME>_SINIT_START	=.;
						#:::::::::: ctor
						<FOREACH.OVERLAY.OBJECTS=.ctor>
						<OVERLAY.OBJECT=.ctor:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.ctor>
						<OVERLAY.LIBRARY=.ctor:t>
						<END.OVERLAY.LIBRARIES>
						<FOREACH.OVERLAY.OBJECTS=.sinit>
						<OVERLAY.OBJECT=.sinit:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.sinit>
						<OVERLAY.LIBRARY=.sinit:t>
						<END.OVERLAY.LIBRARIES>
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY_<OVERLAY.NAME>_SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(32);
	SDK_OVERLAY_<OVERLAY.NAME>_TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_OVERLAY_<OVERLAY.NAME>_DATA_START	=.;
						#:::::::::: data
						<FOREACH.OVERLAY.OBJECTS=.sdata>
						<OVERLAY.OBJECT=.sdata:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.sdata>
						<OVERLAY.LIBRARY=.sdata:t>
						<END.OVERLAY.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.OVERLAY.OBJECTS=.data>
						<OVERLAY.OBJECT=.data:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.data>
						<OVERLAY.LIBRARY=.data:t>
						<END.OVERLAY.LIBRARIES>
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_OVERLAY_<OVERLAY.NAME>_DATA_END	=.;
	SDK_OVERLAY_<OVERLAY.NAME>_END		=.;

	SDK_OVERLAY_<OVERLAY.NAME>_TEXT_SIZE	= SDK_OVERLAY_<OVERLAY.NAME>_TEXT_END - SDK_OVERLAY_<OVERLAY.NAME>_TEXT_START;
	SDK_OVERLAY_<OVERLAY.NAME>_DATA_SIZE	= SDK_OVERLAY_<OVERLAY.NAME>_DATA_END - SDK_OVERLAY_<OVERLAY.NAME>_DATA_START;
	SDK_OVERLAY_<OVERLAY.NAME>_SIZE		= SDK_OVERLAY_<OVERLAY.NAME>_END      - SDK_OVERLAY_<OVERLAY.NAME>_START;

	} > <OVERLAY.NAME>

	.<OVERLAY.NAME>_bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
	
	#
	#  BSS BLOCK
	#
	SDK_OVERLAY_<OVERLAY.NAME>_BSS_START	= .;
						#:::::::::: bss
						<FOREACH.OVERLAY.OBJECTS=.bss>
						<OVERLAY.OBJECT=.bss:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.bss>
						<OVERLAY.LIBRARY=.bss:t>
						<END.OVERLAY.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.OVERLAY.OBJECTS=.sbss>
						<OVERLAY.OBJECT=.sbss:t>
						<END.OVERLAY.OBJECTS>
						<FOREACH.OVERLAY.LIBRARIES=.sbss>
						<OVERLAY.LIBRARY=.sbss:t>
						<END.OVERLAY.LIBRARIES>
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_OVERLAY_<OVERLAY.NAME>_BSS_END	= .;

	SDK_OVERLAY_<OVERLAY.NAME>_BSS_SIZE	= SDK_OVERLAY_<OVERLAY.NAME>_BSS_END - SDK_OVERLAY_<OVERLAY.NAME>_BSS_START;
	
	} >> <OVERLAY.NAME>

<END.OVERLAYS>
	
	############################ MAIN EX ##################################
	# MAIN EX Area
	.MAIN_EX__:
	{
		. = ALIGN(32);
	} > MAIN_EX__
	
	############################ ARENA ##################################
	.ARENA__:
	{
						. = ALIGN(32);
		SDK_SECTION_ARENA_START		=.;
	} > ARENA__
	
	.ARENA_EX__:
	{
						. = ALIGN(32);
		SDK_SECTION_ARENA_EX_START	=.;
	} > ARENA_EX__
	
	.ARENA_ITCM__:
	{
						. = ALIGN(32);
		SDK_SECTION_ARENA_ITCM_START	=.;
	} > ARENA_ITCM__

	.ARENA_DTCM__:
	{
						. = ALIGN(32);
		SDK_SECTION_ARENA_DTCM_START	=.;
	} > ARENA_DTCM__
	
	############################ OVERLAYDEFS ############################
	.<PROPERTY.OVERLAYDEFS>:
	{
		###  <STATIC.NAME> module information 
		WRITEW ADDR(.<STATIC.NAME>);			# load address
		WRITEW _start;					# entry address
		WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE;	# size of module
		WRITEW _start_AutoloadDoneCallback;		# callback autoload done
		
		###  overlay filename
		<FOREACH.OVERLAYS>
		WRITES ("<OVERLAY.NAME><PROPERTY.SUFFIX>");	# Overlay <OVERLAY.ID>
		<END.OVERLAYS>
	
	} > <PROPERTY.OVERLAYDEFS>


	############################ OVERLAYTABLE ###########################
	.<PROPERTY.OVERLAYTABLE>:
	{
		<FOREACH.OVERLAYS>
		#	 Overlay <OVERLAY.ID>
		WRITEW <OVERLAY.ID>;				# overlay ID
		WRITEW ADDR(.<OVERLAY.NAME>);			# load address
		WRITEW SDK_OVERLAY_<OVERLAY.NAME>_SIZE;		# size of module
		WRITEW SDK_OVERLAY_<OVERLAY.NAME>_BSS_SIZE;	# size of bss
		WRITEW SDK_OVERLAY_<OVERLAY.NAME>_SINIT_START;	# start address of static init
		WRITEW SDK_OVERLAY_<OVERLAY.NAME>_SINIT_END;	# end address of static init
		WRITEW <OVERLAY.ID>;				# ROM file ID
		WRITEW 0;					# Reserved
		
		<END.OVERLAYS>
		
	} > <PROPERTY.OVERLAYTABLE>
	
	
	############################ OTHERS #################################
	SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START;
	SDK_IRQ_STACKSIZE = <STATIC.IRQSTACKSIZE>;	# allocated in DTCM
	SDK_SYS_STACKSIZE = <STATIC.STACKSIZE>;		# when 0 means all remains of DTCM
	
	# Module filelist
	.MODULE_FILES__:
	{
		WRITES ("<STATIC.NAME><PROPERTY.SUFFIX>");
		WRITES ("<PROPERTY.OVERLAYDEFS><PROPERTY.SUFFIX>");
		WRITES ("<PROPERTY.OVERLAYTABLE><PROPERTY.SUFFIX>");
	} > MODULE_FILES__

	# ITCM/DTCM size checker => check AUTOLOAD_ITCM/DTCM
	.ITCM__:
	{
		. = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE;
<FOREACH.OVERLAYS=ITCM>
		. = . + SDK_OVERLAY_<OVERLAY.NAME>_SIZE + SDK_OVERLAY_<OVERLAY.NAME>_BSS_SIZE;
<END.OVERLAYS>
	} > ITCM__
	
	SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1;
	.DTCM__:
	{
		. = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE;
<FOREACH.OVERLAYS=DTCM>
		. = . + SDK_OVERLAY_<OVERLAY.NAME>_SIZE + SDK_OVERLAY_<OVERLAY.NAME>_BSS_SIZE;
<END.OVERLAYS>
		. = . + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN;
	} > DTCM__

}
