#---------------------------------------------------------------------------
#  Project:  NitroSDK - tools - makelcf
#  File:     ARM7-TS.lcf.template
#
#  Copyright 2003-2008 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: ARM7-TS.lcf.template,v $
#  Revision 1.24  2006/05/10 03:19:47  yasu
#  Added support for the CodeWarrior 2.x overlay expansion
#
#  Revision 1.23  2006/04/07 04:45:14  kitase_hirotake
#  Added .wram.bss
#
#  Revision 1.22  2006/03/30 00:43:20  yasu
#  Updated copyright year
#
#  Revision 1.21  2006/03/29 13:19:14  yasu
#  NUMBER_OVERLAYS revised to NUMBER.OVERLAYS
#
#  Revision 1.20  2005/09/02 04:14:22  yasu
#  Old symbols were redefined so they can be used even under SDK2.2
#
#  Revision 1.19  2005/08/31 09:34:57  yasu
#  Corrected a problem where code would not function normally when using section names such as section_BSS
#
#  Revision 1.18  2005/06/20 12:29:20  yasu
#  Changed Surffix to Suffix
#
#  Revision 1.17  2005/06/14 09:03:42  yada
#  Fix specific to negative value of SDK_STACKSIZE
#
#  Revision 1.16  2005/04/14 00:04:17  terui
#  Updated copyright.
#
#  Revision 1.15  2005/04/13 12:52:50  terui
#  Changed SDK_AUTOLOAD.MAIN.START 0x027c0000 to 0x027e0000
#
#  Revision 1.14  2004/09/08 01:27:18  yasu
#  Added * (.wram) on static segment
#
#  Revision 1.13  2004/08/18 01:50:40  yasu
#  Support for SDK_SUBPRIV_ARENA_LO
#
#  Revision 1.12  2004/08/02 10:38:53  yasu
#  Added autoload-done callback address in overlaydefs
#
#  Revision 1.11  2004/07/26 00:08:27  yasu
#  Fixed label of exception table
#
#  Revision 1.10  2004/07/24 05:42:25  yasu
#  Set default values for SDK_AUTOGEN_xTCM_START
#
#  Revision 1.9  2004/07/23 11:32:14  yasu
#  Defined labels for __exception_table_start__ and _end__
#
#  Revision 1.8  2004/07/12 12:24:12  yasu
#  Fixed checking WRAM
#
#  Revision 1.7  2004/07/10 04:10:26  yasu
#  Added support for command 'Library'
#
#  Revision 1.6  2004/07/02 08:13:02  yasu
#  Added support for OBJECT()
#
#  Revision 1.5  2004/07/01 12:54:38  yasu
#  Added support for ITCM/DTCM/WRAM autoload
#
#  Revision 1.4  2004/07/01 10:41:46  yasu
#  Added support for autoload
#
#  Revision 1.3  2004/05/28 02:11:15  yasu
#  Set WRAM arena region correctly
#
#  Revision 1.2  2004/04/26 12:17:49  yasu
#  Added KEEP_SECTIONS
#
#  Revision 1.1  2004/04/06 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>
	binary.AUTOLOAD_INFO		(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>
	arena.MAIN                 (RW)  : ORIGIN = AFTER(<STATIC.NAME><FOREACH.OVERLAYS>,<OVERLAY.NAME><END.OVERLAYS>), LENGTH = 0x0
	check.WORKRAM		(RWX) : ORIGIN = 0x037f8000, LENGTH = 0x18000 > workram.check
	check.MAIN			(RWX) : ORIGIN = 0x027e0000, LENGTH = 0x1c000 > main.check
}

SECTIONS
{
	############################ STATIC #################################
	.<STATIC.NAME>:
	{
	ALIGNALL(4);			. = ALIGN(4);	# Fit to cache line
					<IF.NITRO_LCFSPEC.GE.2>
					<FOREACH.STATIC.SEARCHSYMBOLS>
					SEARCH_SYMBOL <STATIC.SEARCHSYMBOL>;
					<END.STATIC.SEARCHSYMBOLS>
					<ENDIF>
	#
	#  TEXT BLOCK: READ ONLY
	#
	SDK_STATIC_START		=.;
	SDK_STATIC_TEXT_START		=.;
					#:::::::::: text/rodata
					OBJECT(_start,*)
					crt0.o (.text)
					<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>
					WRITEW	0;
					#:::::::::: ctor
	SDK_STATIC_SINIT_END		=.;

					#:::::::::: text/rodata
					. = ALIGN(4);
	SDK_STATIC_TEXT_END		=.;
	
	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_STATIC_DATA_START		=.;
					#:::::::::: Data
					<FOREACH.STATIC.OBJECTS=.wram>
					<STATIC.OBJECT=.wram:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.wram>
					<STATIC.LIBRARY=.wram:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);
					<FOREACH.STATIC.OBJECTS=.main>
					<STATIC.OBJECT=.main:t>
					<END.STATIC.OBJECTS>
					<FOREACH.STATIC.LIBRARIES=.main>
					<STATIC.LIBRARY=.main:t>
					<END.STATIC.LIBRARIES>
					. = ALIGN(4);
					<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);
					#:::::::::: Data
					. = ALIGN(4);
	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(4);
					<IF.NITRO_LCFSPEC.GE.2>
					<FOREACH.STATIC.SEARCHSYMBOLS>
					SEARCH_SYMBOL <STATIC.SEARCHSYMBOL>;
					<END.STATIC.SEARCHSYMBOLS>
					<ENDIF>
	#
	#  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(4);
	SDK_STATIC_BSS_END		= .;
	SDK_STATIC_BSS_SIZE		= SDK_STATIC_BSS_END - SDK_STATIC_BSS_START;

	} >> <STATIC.NAME>
	
	
	############################ AUTOLOADS ##############################
	SDK_AUTOLOAD.MAIN.START			= 0x027e0000;
	SDK_AUTOLOAD.MAIN.END			= SDK_AUTOLOAD.MAIN.START;
	SDK_AUTOLOAD.MAIN.BSS_END		= SDK_AUTOLOAD.MAIN.START;
	SDK_AUTOLOAD.MAIN.SIZE			= 0;
	SDK_AUTOLOAD.MAIN.BSS_SIZE		= 0;
	SDK_AUTOLOAD.WRAM.START			= 0x037f8000;
	SDK_AUTOLOAD.WRAM.END			= SDK_AUTOLOAD.WRAM.START;
	SDK_AUTOLOAD.WRAM.BSS_END		= SDK_AUTOLOAD.WRAM.START;
	SDK_AUTOLOAD.WRAM.SIZE			= 0;
	SDK_AUTOLOAD.WRAM.BSS_SIZE		= 0;
	SDK_AUTOLOAD_START			= SDK_STATIC_END;
	SDK_AUTOLOAD_SIZE			= 0;
	SDK_AUTOLOAD_NUMBER			= <NUMBER.AUTOLOADS>;

<FOREACH.AUTOLOADS>
	.<AUTOLOAD.NAME>:
	{
	ALIGNALL(4);				. = ALIGN(4);
						<IF.NITRO_LCFSPEC.GE.2>
						<FOREACH.AUTOLOAD.SEARCHSYMBOLS>
						SEARCH_SYMBOL <AUTOLOAD.SEARCHSYMBOL>;
						<END.AUTOLOAD.SEARCHSYMBOLS>
						<ENDIF>
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_AUTOLOAD_<AUTOLOAD.NAME>_ID		=<AUTOLOAD.ID>;
	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=.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=.wram>
						<AUTOLOAD.OBJECT=.wram:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.wram>
						<AUTOLOAD.LIBRARY=.wram:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.AUTOLOAD.OBJECTS=.main>
						<AUTOLOAD.OBJECT=.main:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.main>
						<AUTOLOAD.LIBRARY=.main:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						<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);
						#:::::::::: Data
	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(4);
						<IF.NITRO_LCFSPEC.GE.2>
						<FOREACH.AUTOLOAD.SEARCHSYMBOLS>
						SEARCH_SYMBOL <AUTOLOAD.SEARCHSYMBOL>;
						<END.AUTOLOAD.SEARCHSYMBOLS>
						<ENDIF>
	#
	#  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);
						<FOREACH.AUTOLOAD.OBJECTS=.wram>
						<AUTOLOAD.OBJECT=.wram.bss:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.wram>
						<AUTOLOAD.LIBRARY=.wram.bss:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						<FOREACH.AUTOLOAD.OBJECTS=.main>
						<AUTOLOAD.OBJECT=.main.bss:t>
						<END.AUTOLOAD.OBJECTS>
						<FOREACH.AUTOLOAD.LIBRARIES=.main>
						<AUTOLOAD.LIBRARY=.main.bss:t>
						<END.AUTOLOAD.LIBRARIES>
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(4);
	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>

	SDK_AUTOLOAD_MAIN_START			= SDK_AUTOLOAD.MAIN.START;
	SDK_AUTOLOAD_MAIN_END			= SDK_AUTOLOAD.MAIN.END;
	SDK_AUTOLOAD_MAIN_BSS_END		= SDK_AUTOLOAD.MAIN.BSS_END;
	SDK_AUTOLOAD_MAIN_SIZE			= SDK_AUTOLOAD.MAIN.SIZE;
	SDK_AUTOLOAD_MAIN_BSS_SIZE		= SDK_AUTOLOAD.MAIN.BSS_SIZE;
	SDK_AUTOLOAD_WRAM_START			= SDK_AUTOLOAD.WRAM.START;
	SDK_AUTOLOAD_WRAM_END			= SDK_AUTOLOAD.WRAM.END;
	SDK_AUTOLOAD_WRAM_BSS_END		= SDK_AUTOLOAD.WRAM.BSS_END;
	SDK_AUTOLOAD_WRAM_SIZE			= SDK_AUTOLOAD.WRAM.SIZE;
	SDK_AUTOLOAD_WRAM_BSS_SIZE		= SDK_AUTOLOAD.WRAM.BSS_SIZE;

	############################ AUTOLOAD_INFO ##########################
	.binary.AUTOLOAD_INFO:
	{
<FOREACH.AUTOLOADS>
		WRITEW ADDR(.<AUTOLOAD.NAME>);
		WRITEW SDK_AUTOLOAD.<AUTOLOAD.NAME>.SIZE;
		WRITEW SDK_AUTOLOAD.<AUTOLOAD.NAME>.BSS_SIZE;
<END.AUTOLOADS>
	} > binary.AUTOLOAD_INFO
	
	SDK_AUTOLOAD_LIST			= SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE;
	SDK_AUTOLOAD_LIST_END			= SDK_AUTOLOAD_START + SDK_AUTOLOAD_SIZE + SIZEOF(.binary.AUTOLOAD_INFO);
	SDK_AUTOLOAD_SIZE			= SDK_AUTOLOAD_SIZE  + SIZEOF(.binary.AUTOLOAD_INFO);

	############################ OVERLAYS ###############################
	SDK_OVERLAY_NUMBER 			= <NUMBER.OVERLAYS>;

<FOREACH.OVERLAYS>
	.<OVERLAY.NAME>:<IF.NITRO_LCFSPEC.GE.2><OVERLAY.NAME><ENDIF>
	{
	ALIGNALL(4);				. = ALIGN(4);
						<IF.NITRO_LCFSPEC.GE.2>
						<FOREACH.OVERLAY.SEARCHSYMBOLS>
						SEARCH_SYMBOL <OVERLAY.SEARCHSYMBOL>;
						<END.OVERLAY.SEARCHSYMBOLS>
						<ENDIF>
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_<OVERLAY.NAME>_ID		=<OVERLAY.ID>;	### SEGMENT <OVERLAY.NAME> OVERLAY ID
	SDK_OVERLAY.<OVERLAY.NAME>.ID		=<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>
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY.<OVERLAY.NAME>.SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(4);
	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(4);
	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:<IF.NITRO_LCFSPEC.GE.2><OVERLAY.NAME><ENDIF>
	{
	ALIGNALL(4);				. = ALIGN(4);
						<IF.NITRO_LCFSPEC.GE.2>
						<FOREACH.OVERLAY.SEARCHSYMBOLS>
						SEARCH_SYMBOL <OVERLAY.SEARCHSYMBOL>;
						<END.OVERLAY.SEARCHSYMBOLS>
						<ENDIF>
	#
	#  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(4);
	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>
	
	
	############################ ARENA ##################################
	.arena.MAIN:
	{
						. = ALIGN(4);
		SDK_SECTION_ARENA_START		=.;
	} > arena.MAIN
	
	
	############################ 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_WRAM_ARENA_LO    = SDK_AUTOLOAD.WRAM.BSS_END;
	SDK_SUBPRIV_ARENA_LO = SDK_AUTOLOAD.MAIN.BSS_END;
	SDK_IRQ_STACKSIZE = <STATIC.IRQSTACKSIZE>;	# Allocated in WRAM
	SDK_SYS_STACKSIZE = <STATIC.STACKSIZE>;		# Allocated in WRAM
	
	# Work RAM size checker => check AUTOLOAD_WRAM
	SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1;
	.check.WORKRAM:
	{
#		. = . + SDK_AUTOLOAD.WRAM.BSS_END - 0x037f8000 + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN;
		. = . + SDK_AUTOLOAD.WRAM.BSS_END - 0x037f8000;
		. = ALIGN(32);
		. = . + 0x2100;
		. = . + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN;
	} > check.WORKRAM

	.check.MAIN:
	{
		. = SDK_SUBPRIV_ARENA_LO;
	} > check.MAIN
}
