#---------------------------------------------------------------------------
#  Project:  TwlSDK - tools - makelcf
#  File:     ARM9-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.
#
#  $Date:: 2008-09-18#$
#  $Rev: 8573 $
#  $Author: okubata_ryoma $
#---------------------------------------------------------------------------
MEMORY
{
	main		(RWX) : ORIGIN = 0x02000000,   LENGTH = 0x0 >  main.sbin
	ITCM		(RWX) : ORIGIN = 0x01ff8000, LENGTH = 0x0 >> main.sbin
	DTCM		(RWX) : ORIGIN = 0x023e0000, LENGTH = 0x0 >> main.sbin
	binary.AUTOLOAD_INFO		(RWX) : ORIGIN = 0, LENGTH = 0x0 >> main.sbin
	binary.STATIC_FOOTER		(RWX) : ORIGIN = 0, LENGTH = 0x0 >> main.sbin
	
	main_defs	(RW)  : ORIGIN = AFTER(main), LENGTH = 0x0 > main_defs.sbin
	main_table	(RW)  : ORIGIN = AFTER(main), LENGTH = 0x0 > main_table.sbin
	main_overlay_1		(RWXO): ORIGIN = AFTER(main), LENGTH = 0x0 > main_overlay_1.sbin
	main_overlay_2		(RWXO): ORIGIN = AFTER(main), LENGTH = 0x0 > main_overlay_2.sbin
	main_itcm_1		(RWXO): ORIGIN = AFTER(ITCM), LENGTH = 0x0 > main_itcm_1.sbin
	main_dtcm_1		(RWXO): ORIGIN = AFTER(DTCM), LENGTH = 0x0 > main_dtcm_1.sbin
	main_dtcm_2		(RWXO): ORIGIN = AFTER(DTCM), LENGTH = 0x0 > main_dtcm_2.sbin
	MAIN_EX		(RWXO): ORIGIN = 0x02400000, LENGTH = 0x0 > MAIN_EX.sbin
	MAIN_EX_2		(RWXO): ORIGIN = AFTER(MAIN_EX), LENGTH = 0x0 > MAIN_EX_2.sbin
	dummy.MAIN_EX		(RW)  : ORIGIN = 0x023e0000, LENGTH = 0x0
	arena.MAIN			(RW)  : ORIGIN = AFTER(main,main_overlay_1,main_overlay_2), LENGTH = 0x0
	arena.MAIN_EX		(RW)  : ORIGIN = AFTER(dummy.MAIN_EX,MAIN_EX,MAIN_EX_2), LENGTH = 0x0
	arena.ITCM		(RW)  : ORIGIN = AFTER(ITCM,main_itcm_1), LENGTH = 0x0
	arena.DTCM		(RW)  : ORIGIN = AFTER(DTCM,main_dtcm_1,main_dtcm_2), LENGTH = 0x0
	binary.MODULE_FILES		(RW)  : ORIGIN = 0x0, LENGTH = 0x0     > component.files
	check.ITCM			(RWX) : ORIGIN = 0x0, LENGTH = 0x08000 > itcm.check
	check.DTCM			(RW)  : ORIGIN = 0x0, LENGTH = 0x04000 > dtcm.check
}

FORCE_ACTIVE
{
	SVC_SoftReset
}

KEEP_SECTION
{
	.sinit
}

SECTIONS
{
	############################ STATIC #################################
	.main:
	{
	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 セクションを追加しています。
					# このセクションに含まれる情報はロットチェックの際に
					# 必要となりますので、必ずこの位置に残すようにして下さい。
					#
					* (.version)
					OBJECT(NitroMain,*)
					main_a.o (.text)
					main_b.o (.text)
					main_c.o (.text)
					main_a.a (.text)
					main_b.a (.text)
					main_c.a (.text)
					. = ALIGN(4);
					* (.exception)
					. = ALIGN(4);
	SDK_STATIC_ETABLE_START		=.;
					EXCEPTION
	SDK_STATIC_ETABLE_END		=.;
					. = ALIGN(4);
					main_a.o (.init)
					main_b.o (.init)
					main_c.o (.init)
					main_a.a (.init)
					main_b.a (.init)
					main_c.a (.init)
					. = ALIGN(4);
					main_a.o (.rodata)
					main_b.o (.rodata)
					main_c.o (.rodata)
					main_a.a (.rodata)
					main_b.a (.rodata)
					main_c.a (.rodata)
					. = ALIGN(4);

	SDK_STATIC_SINIT_START		=.;
					#:::::::::: ctor
					main_a.o (.ctor)
					main_b.o (.ctor)
					main_c.o (.ctor)
					main_a.a (.ctor)
					main_b.a (.ctor)
					main_c.a (.ctor)
					main_a.o (.sinit)
					main_b.o (.sinit)
					main_c.o (.sinit)
					main_a.a (.sinit)
					main_b.a (.sinit)
					main_c.a (.sinit)
					WRITEW	0;
					#:::::::::: ctor
	SDK_STATIC_SINIT_END		=.;

					#:::::::::: text/rodata
					. = ALIGN(32);
	SDK_STATIC_TEXT_END		=.;
	
	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_STATIC_DATA_START		=.;
					#:::::::::: data
					main_a.o (.sdata)
					main_b.o (.sdata)
					main_c.o (.sdata)
					main_a.a (.sdata)
					main_b.a (.sdata)
					main_c.a (.sdata)
					. = ALIGN(4);
					main_a.o (.data)
					main_b.o (.data)
					main_c.o (.data)
					main_a.a (.data)
					main_b.a (.data)
					main_c.a (.data)
					. = 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
	} > main

	.main.bss:
	{
	ALIGNALL(4);			. = ALIGN(32);
					
	#
	#  BSS BLOCK
	#
	SDK_STATIC_BSS_START		=.;
					#:::::::::: bss
					main_a.o (.sbss)
					main_b.o (.sbss)
					main_c.o (.sbss)
					main_a.a (.sbss)
					main_b.a (.sbss)
					main_c.a (.sbss)
					. = ALIGN(4);
					main_a.o (.bss)
					main_b.o (.bss)
					main_c.o (.bss)
					main_a.a (.bss)
					main_b.a (.bss)
					main_c.a (.bss)
					. = ALIGN(4);
					#:::::::::: bss
					. = ALIGN(32);
	SDK_STATIC_BSS_END		= .;
	SDK_STATIC_BSS_SIZE		= SDK_STATIC_BSS_END - SDK_STATIC_BSS_START;

	} >> main
	
	
	############################ 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.ITCM.SIZE			= 0;
	SDK_AUTOLOAD.ITCM.BSS_SIZE		= 0;
	SDK_AUTOLOAD.DTCM.START			= 0x027e0000;
	SDK_AUTOLOAD.DTCM.END			= SDK_AUTOLOAD.DTCM.START;
	SDK_AUTOLOAD.DTCM.BSS_END		= SDK_AUTOLOAD.DTCM.START;
	SDK_AUTOLOAD.DTCM.SIZE			= 0;
	SDK_AUTOLOAD.DTCM.BSS_SIZE		= 0;
	SDK_AUTOLOAD_START			= SDK_STATIC_END;
	SDK_AUTOLOAD_SIZE			= 0;
	SDK_AUTOLOAD_NUMBER			= 2;

	.ITCM:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_AUTOLOAD_ITCM_ID		=0;
	SDK_AUTOLOAD.ITCM.ID		=0;
	SDK_AUTOLOAD.ITCM.START	=.;
	SDK_AUTOLOAD.ITCM.TEXT_START	=.;
						#:::::::::: text/rodata
						. = ALIGN(4);
						* (.itcm)
						. = ALIGN(4);
						. = ALIGN(4);
						#:::::::::: text/rodata
	SDK_AUTOLOAD.ITCM.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE BLOCK
	#
	SDK_AUTOLOAD.ITCM.DATA_START	=.;
						#:::::::::: data
						. = ALIGN(4);
						. = ALIGN(4);
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_AUTOLOAD.ITCM.DATA_END	=.;
	SDK_AUTOLOAD.ITCM.END	=.;
	
	SDK_AUTOLOAD.ITCM.TEXT_SIZE	= SDK_AUTOLOAD.ITCM.TEXT_END - SDK_AUTOLOAD.ITCM.TEXT_START;
	SDK_AUTOLOAD.ITCM.DATA_SIZE	= SDK_AUTOLOAD.ITCM.DATA_END - SDK_AUTOLOAD.ITCM.DATA_START;
	SDK_AUTOLOAD.ITCM.SIZE	= SDK_AUTOLOAD.ITCM.END	- SDK_AUTOLOAD.ITCM.START;
	SDK_AUTOLOAD_SIZE			= SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD.ITCM.SIZE;

	} > ITCM

	.ITCM.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_AUTOLOAD.ITCM.BSS_START	= .;
						#:::::::::: bss
						. = ALIGN(4);
						. = ALIGN(4);
						. = ALIGN(4);
						* (.itcm.bss)
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_AUTOLOAD.ITCM.BSS_END	= .;

	SDK_AUTOLOAD.ITCM.BSS_SIZE	= SDK_AUTOLOAD.ITCM.BSS_END - SDK_AUTOLOAD.ITCM.BSS_START;

	} >> ITCM

	.DTCM:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_AUTOLOAD_DTCM_ID		=1;
	SDK_AUTOLOAD.DTCM.ID		=1;
	SDK_AUTOLOAD.DTCM.START	=.;
	SDK_AUTOLOAD.DTCM.TEXT_START	=.;
						#:::::::::: text/rodata
						. = ALIGN(4);
						. = ALIGN(4);
						. = ALIGN(4);
						#:::::::::: text/rodata
	SDK_AUTOLOAD.DTCM.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE BLOCK
	#
	SDK_AUTOLOAD.DTCM.DATA_START	=.;
						#:::::::::: data
						. = ALIGN(4);
						. = ALIGN(4);
						* (.dtcm)
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_AUTOLOAD.DTCM.DATA_END	=.;
	SDK_AUTOLOAD.DTCM.END	=.;
	
	SDK_AUTOLOAD.DTCM.TEXT_SIZE	= SDK_AUTOLOAD.DTCM.TEXT_END - SDK_AUTOLOAD.DTCM.TEXT_START;
	SDK_AUTOLOAD.DTCM.DATA_SIZE	= SDK_AUTOLOAD.DTCM.DATA_END - SDK_AUTOLOAD.DTCM.DATA_START;
	SDK_AUTOLOAD.DTCM.SIZE	= SDK_AUTOLOAD.DTCM.END	- SDK_AUTOLOAD.DTCM.START;
	SDK_AUTOLOAD_SIZE			= SDK_AUTOLOAD_SIZE + SDK_AUTOLOAD.DTCM.SIZE;

	} > DTCM

	.DTCM.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_AUTOLOAD.DTCM.BSS_START	= .;
						#:::::::::: bss
						. = ALIGN(4);
						. = ALIGN(4);
						* (.dtcm.bss)
						. = ALIGN(4);
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_AUTOLOAD.DTCM.BSS_END	= .;

	SDK_AUTOLOAD.DTCM.BSS_SIZE	= SDK_AUTOLOAD.DTCM.BSS_END - SDK_AUTOLOAD.DTCM.BSS_START;

	} >> DTCM


	SDK_AUTOLOAD_ITCM_START			= SDK_AUTOLOAD.ITCM.START;
	SDK_AUTOLOAD_ITCM_END			= SDK_AUTOLOAD.ITCM.END;
	SDK_AUTOLOAD_ITCM_BSS_END		= SDK_AUTOLOAD.ITCM.BSS_END;
	SDK_AUTOLOAD_ITCM_SIZE			= SDK_AUTOLOAD.ITCM.SIZE;
	SDK_AUTOLOAD_ITCM_BSS_SIZE		= SDK_AUTOLOAD.ITCM.BSS_SIZE;
	SDK_AUTOLOAD_DTCM_START			= SDK_AUTOLOAD.DTCM.START;
	SDK_AUTOLOAD_DTCM_END			= SDK_AUTOLOAD.DTCM.END;
	SDK_AUTOLOAD_DTCM_BSS_END		= SDK_AUTOLOAD.DTCM.BSS_END;
	SDK_AUTOLOAD_DTCM_SIZE			= SDK_AUTOLOAD.DTCM.SIZE;
	SDK_AUTOLOAD_DTCM_BSS_SIZE		= SDK_AUTOLOAD.DTCM.BSS_SIZE;

	############################ AUTOLOAD_INFO ##########################
	.binary.AUTOLOAD_INFO:
	{
		WRITEW ADDR(.ITCM);
		WRITEW SDK_AUTOLOAD.ITCM.SIZE;
		WRITEW SDK_AUTOLOAD.ITCM.BSS_SIZE;
		WRITEW ADDR(.DTCM);
		WRITEW SDK_AUTOLOAD.DTCM.SIZE;
		WRITEW SDK_AUTOLOAD.DTCM.BSS_SIZE;
	} > 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);
	
	############################ STATIC_FOOTER ##########################
	.binary.STATIC_FOOTER:
	{
		WRITEW 0xdec00621;		# LE(0x2106C0DE) = NITRO CODE
		WRITEW _start_ModuleParams - ADDR(.main);
		WRITEW 0;			# NO DIGEST
	} > binary.STATIC_FOOTER
	
	############################ OVERLAYS ###############################
	SDK_OVERLAY_NUMBER			= 7;

	.main_overlay_1:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_main_overlay_1_ID		=0;	### SEGMENT main_overlay_1 OVERLAY ID
	SDK_OVERLAY.main_overlay_1.ID		=0;
	SDK_OVERLAY.main_overlay_1.START	=.;
	SDK_OVERLAY.main_overlay_1.TEXT_START	=.;
						#:::::::::: text/rodata
						func_1.o (.text)
						. = ALIGN(4);
						func_1.o (.rodata)
						. = ALIGN(4);
						func_1.o (.init)
						. = ALIGN(4);
	SDK_OVERLAY.main_overlay_1.SINIT_START	=.;
						#:::::::::: ctor
						func_1.o (.ctor)
						func_1.o (.sinit)
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY.main_overlay_1.SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(32);
	SDK_OVERLAY.main_overlay_1.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_OVERLAY.main_overlay_1.DATA_START	=.;
						#:::::::::: data
						func_1.o (.sdata)
						. = ALIGN(4);
						func_1.o (.data)
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_OVERLAY.main_overlay_1.DATA_END	=.;
	SDK_OVERLAY.main_overlay_1.END		=.;

	SDK_OVERLAY.main_overlay_1.TEXT_SIZE	= SDK_OVERLAY.main_overlay_1.TEXT_END - SDK_OVERLAY.main_overlay_1.TEXT_START;
	SDK_OVERLAY.main_overlay_1.DATA_SIZE	= SDK_OVERLAY.main_overlay_1.DATA_END - SDK_OVERLAY.main_overlay_1.DATA_START;
	SDK_OVERLAY.main_overlay_1.SIZE		= SDK_OVERLAY.main_overlay_1.END      - SDK_OVERLAY.main_overlay_1.START;

	} > main_overlay_1

	.main_overlay_1.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_OVERLAY.main_overlay_1.BSS_START	= .;
						#:::::::::: bss
						func_1.o (.bss)
						. = ALIGN(4);
						func_1.o (.sbss)
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_OVERLAY.main_overlay_1.BSS_END	= .;

	SDK_OVERLAY.main_overlay_1.BSS_SIZE	= SDK_OVERLAY.main_overlay_1.BSS_END - SDK_OVERLAY.main_overlay_1.BSS_START;
	
	} >> main_overlay_1

	.main_overlay_2:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_main_overlay_2_ID		=1;	### SEGMENT main_overlay_2 OVERLAY ID
	SDK_OVERLAY.main_overlay_2.ID		=1;
	SDK_OVERLAY.main_overlay_2.START	=.;
	SDK_OVERLAY.main_overlay_2.TEXT_START	=.;
						#:::::::::: text/rodata
						func_2.o (.text)
						. = ALIGN(4);
						func_2.o (.rodata)
						. = ALIGN(4);
						func_2.o (.init)
						. = ALIGN(4);
	SDK_OVERLAY.main_overlay_2.SINIT_START	=.;
						#:::::::::: ctor
						func_2.o (.ctor)
						func_2.o (.sinit)
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY.main_overlay_2.SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(32);
	SDK_OVERLAY.main_overlay_2.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_OVERLAY.main_overlay_2.DATA_START	=.;
						#:::::::::: data
						func_2.o (.sdata)
						. = ALIGN(4);
						func_2.o (.data)
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_OVERLAY.main_overlay_2.DATA_END	=.;
	SDK_OVERLAY.main_overlay_2.END		=.;

	SDK_OVERLAY.main_overlay_2.TEXT_SIZE	= SDK_OVERLAY.main_overlay_2.TEXT_END - SDK_OVERLAY.main_overlay_2.TEXT_START;
	SDK_OVERLAY.main_overlay_2.DATA_SIZE	= SDK_OVERLAY.main_overlay_2.DATA_END - SDK_OVERLAY.main_overlay_2.DATA_START;
	SDK_OVERLAY.main_overlay_2.SIZE		= SDK_OVERLAY.main_overlay_2.END      - SDK_OVERLAY.main_overlay_2.START;

	} > main_overlay_2

	.main_overlay_2.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_OVERLAY.main_overlay_2.BSS_START	= .;
						#:::::::::: bss
						func_2.o (.bss)
						. = ALIGN(4);
						func_2.o (.sbss)
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_OVERLAY.main_overlay_2.BSS_END	= .;

	SDK_OVERLAY.main_overlay_2.BSS_SIZE	= SDK_OVERLAY.main_overlay_2.BSS_END - SDK_OVERLAY.main_overlay_2.BSS_START;
	
	} >> main_overlay_2

	.main_itcm_1:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_main_itcm_1_ID		=2;	### SEGMENT main_itcm_1 OVERLAY ID
	SDK_OVERLAY.main_itcm_1.ID		=2;
	SDK_OVERLAY.main_itcm_1.START	=.;
	SDK_OVERLAY.main_itcm_1.TEXT_START	=.;
						#:::::::::: text/rodata
						func_3.o (.text)
						. = ALIGN(4);
						func_3.o (.rodata)
						. = ALIGN(4);
						func_3.o (.init)
						. = ALIGN(4);
	SDK_OVERLAY.main_itcm_1.SINIT_START	=.;
						#:::::::::: ctor
						func_3.o (.ctor)
						func_3.o (.sinit)
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY.main_itcm_1.SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(32);
	SDK_OVERLAY.main_itcm_1.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_OVERLAY.main_itcm_1.DATA_START	=.;
						#:::::::::: data
						func_3.o (.sdata)
						. = ALIGN(4);
						func_3.o (.data)
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_OVERLAY.main_itcm_1.DATA_END	=.;
	SDK_OVERLAY.main_itcm_1.END		=.;

	SDK_OVERLAY.main_itcm_1.TEXT_SIZE	= SDK_OVERLAY.main_itcm_1.TEXT_END - SDK_OVERLAY.main_itcm_1.TEXT_START;
	SDK_OVERLAY.main_itcm_1.DATA_SIZE	= SDK_OVERLAY.main_itcm_1.DATA_END - SDK_OVERLAY.main_itcm_1.DATA_START;
	SDK_OVERLAY.main_itcm_1.SIZE		= SDK_OVERLAY.main_itcm_1.END      - SDK_OVERLAY.main_itcm_1.START;

	} > main_itcm_1

	.main_itcm_1.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_OVERLAY.main_itcm_1.BSS_START	= .;
						#:::::::::: bss
						func_3.o (.bss)
						. = ALIGN(4);
						func_3.o (.sbss)
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_OVERLAY.main_itcm_1.BSS_END	= .;

	SDK_OVERLAY.main_itcm_1.BSS_SIZE	= SDK_OVERLAY.main_itcm_1.BSS_END - SDK_OVERLAY.main_itcm_1.BSS_START;
	
	} >> main_itcm_1

	.main_dtcm_1:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_main_dtcm_1_ID		=3;	### SEGMENT main_dtcm_1 OVERLAY ID
	SDK_OVERLAY.main_dtcm_1.ID		=3;
	SDK_OVERLAY.main_dtcm_1.START	=.;
	SDK_OVERLAY.main_dtcm_1.TEXT_START	=.;
						#:::::::::: text/rodata
						func_4.o (.text)
						. = ALIGN(4);
						func_4.o (.rodata)
						. = ALIGN(4);
						func_4.o (.init)
						. = ALIGN(4);
	SDK_OVERLAY.main_dtcm_1.SINIT_START	=.;
						#:::::::::: ctor
						func_4.o (.ctor)
						func_4.o (.sinit)
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY.main_dtcm_1.SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(32);
	SDK_OVERLAY.main_dtcm_1.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_OVERLAY.main_dtcm_1.DATA_START	=.;
						#:::::::::: data
						func_4.o (.sdata)
						. = ALIGN(4);
						func_4.o (.data)
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_OVERLAY.main_dtcm_1.DATA_END	=.;
	SDK_OVERLAY.main_dtcm_1.END		=.;

	SDK_OVERLAY.main_dtcm_1.TEXT_SIZE	= SDK_OVERLAY.main_dtcm_1.TEXT_END - SDK_OVERLAY.main_dtcm_1.TEXT_START;
	SDK_OVERLAY.main_dtcm_1.DATA_SIZE	= SDK_OVERLAY.main_dtcm_1.DATA_END - SDK_OVERLAY.main_dtcm_1.DATA_START;
	SDK_OVERLAY.main_dtcm_1.SIZE		= SDK_OVERLAY.main_dtcm_1.END      - SDK_OVERLAY.main_dtcm_1.START;

	} > main_dtcm_1

	.main_dtcm_1.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_OVERLAY.main_dtcm_1.BSS_START	= .;
						#:::::::::: bss
						func_4.o (.bss)
						. = ALIGN(4);
						func_4.o (.sbss)
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_OVERLAY.main_dtcm_1.BSS_END	= .;

	SDK_OVERLAY.main_dtcm_1.BSS_SIZE	= SDK_OVERLAY.main_dtcm_1.BSS_END - SDK_OVERLAY.main_dtcm_1.BSS_START;
	
	} >> main_dtcm_1

	.main_dtcm_2:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_main_dtcm_2_ID		=4;	### SEGMENT main_dtcm_2 OVERLAY ID
	SDK_OVERLAY.main_dtcm_2.ID		=4;
	SDK_OVERLAY.main_dtcm_2.START	=.;
	SDK_OVERLAY.main_dtcm_2.TEXT_START	=.;
						#:::::::::: text/rodata
						func_5.o (.text)
						. = ALIGN(4);
						func_5.o (.rodata)
						. = ALIGN(4);
						func_5.o (.init)
						. = ALIGN(4);
	SDK_OVERLAY.main_dtcm_2.SINIT_START	=.;
						#:::::::::: ctor
						func_5.o (.ctor)
						func_5.o (.sinit)
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY.main_dtcm_2.SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(32);
	SDK_OVERLAY.main_dtcm_2.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_OVERLAY.main_dtcm_2.DATA_START	=.;
						#:::::::::: data
						func_5.o (.sdata)
						. = ALIGN(4);
						func_5.o (.data)
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_OVERLAY.main_dtcm_2.DATA_END	=.;
	SDK_OVERLAY.main_dtcm_2.END		=.;

	SDK_OVERLAY.main_dtcm_2.TEXT_SIZE	= SDK_OVERLAY.main_dtcm_2.TEXT_END - SDK_OVERLAY.main_dtcm_2.TEXT_START;
	SDK_OVERLAY.main_dtcm_2.DATA_SIZE	= SDK_OVERLAY.main_dtcm_2.DATA_END - SDK_OVERLAY.main_dtcm_2.DATA_START;
	SDK_OVERLAY.main_dtcm_2.SIZE		= SDK_OVERLAY.main_dtcm_2.END      - SDK_OVERLAY.main_dtcm_2.START;

	} > main_dtcm_2

	.main_dtcm_2.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_OVERLAY.main_dtcm_2.BSS_START	= .;
						#:::::::::: bss
						func_5.o (.bss)
						. = ALIGN(4);
						func_5.o (.sbss)
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_OVERLAY.main_dtcm_2.BSS_END	= .;

	SDK_OVERLAY.main_dtcm_2.BSS_SIZE	= SDK_OVERLAY.main_dtcm_2.BSS_END - SDK_OVERLAY.main_dtcm_2.BSS_START;
	
	} >> main_dtcm_2

	.MAIN_EX:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_MAIN_EX_ID		=5;	### SEGMENT MAIN_EX OVERLAY ID
	SDK_OVERLAY.MAIN_EX.ID		=5;
	SDK_OVERLAY.MAIN_EX.START	=.;
	SDK_OVERLAY.MAIN_EX.TEXT_START	=.;
						#:::::::::: text/rodata
						ex_1.o (.text)
						. = ALIGN(4);
						ex_1.o (.rodata)
						. = ALIGN(4);
						ex_1.o (.init)
						. = ALIGN(4);
	SDK_OVERLAY.MAIN_EX.SINIT_START	=.;
						#:::::::::: ctor
						ex_1.o (.ctor)
						ex_1.o (.sinit)
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY.MAIN_EX.SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(32);
	SDK_OVERLAY.MAIN_EX.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_OVERLAY.MAIN_EX.DATA_START	=.;
						#:::::::::: data
						ex_1.o (.sdata)
						. = ALIGN(4);
						ex_1.o (.data)
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_OVERLAY.MAIN_EX.DATA_END	=.;
	SDK_OVERLAY.MAIN_EX.END		=.;

	SDK_OVERLAY.MAIN_EX.TEXT_SIZE	= SDK_OVERLAY.MAIN_EX.TEXT_END - SDK_OVERLAY.MAIN_EX.TEXT_START;
	SDK_OVERLAY.MAIN_EX.DATA_SIZE	= SDK_OVERLAY.MAIN_EX.DATA_END - SDK_OVERLAY.MAIN_EX.DATA_START;
	SDK_OVERLAY.MAIN_EX.SIZE		= SDK_OVERLAY.MAIN_EX.END      - SDK_OVERLAY.MAIN_EX.START;

	} > MAIN_EX

	.MAIN_EX.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_OVERLAY.MAIN_EX.BSS_START	= .;
						#:::::::::: bss
						ex_1.o (.bss)
						. = ALIGN(4);
						ex_1.o (.sbss)
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_OVERLAY.MAIN_EX.BSS_END	= .;

	SDK_OVERLAY.MAIN_EX.BSS_SIZE	= SDK_OVERLAY.MAIN_EX.BSS_END - SDK_OVERLAY.MAIN_EX.BSS_START;
	
	} >> MAIN_EX

	.MAIN_EX_2:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#   TEXT BLOCK: READ ONLY
	#
	SDK_OVERLAY_MAIN_EX_2_ID		=6;	### SEGMENT MAIN_EX_2 OVERLAY ID
	SDK_OVERLAY.MAIN_EX_2.ID		=6;
	SDK_OVERLAY.MAIN_EX_2.START	=.;
	SDK_OVERLAY.MAIN_EX_2.TEXT_START	=.;
						#:::::::::: text/rodata
						ex_2.o (.text)
						. = ALIGN(4);
						ex_2.o (.rodata)
						. = ALIGN(4);
						ex_2.o (.init)
						. = ALIGN(4);
	SDK_OVERLAY.MAIN_EX_2.SINIT_START	=.;
						#:::::::::: ctor
						ex_2.o (.ctor)
						ex_2.o (.sinit)
						WRITEW	0;
						#:::::::::: ctor
	SDK_OVERLAY.MAIN_EX_2.SINIT_END	=.;

						#:::::::::: text/rodata
						. = ALIGN(32);
	SDK_OVERLAY.MAIN_EX_2.TEXT_END	=.;

	#
	#  DATA BLOCK: READ WRITE
	#
	SDK_OVERLAY.MAIN_EX_2.DATA_START	=.;
						#:::::::::: data
						ex_2.o (.sdata)
						. = ALIGN(4);
						ex_2.o (.data)
						. = ALIGN(4);
						#:::::::::: data
						. = ALIGN(32);
	SDK_OVERLAY.MAIN_EX_2.DATA_END	=.;
	SDK_OVERLAY.MAIN_EX_2.END		=.;

	SDK_OVERLAY.MAIN_EX_2.TEXT_SIZE	= SDK_OVERLAY.MAIN_EX_2.TEXT_END - SDK_OVERLAY.MAIN_EX_2.TEXT_START;
	SDK_OVERLAY.MAIN_EX_2.DATA_SIZE	= SDK_OVERLAY.MAIN_EX_2.DATA_END - SDK_OVERLAY.MAIN_EX_2.DATA_START;
	SDK_OVERLAY.MAIN_EX_2.SIZE		= SDK_OVERLAY.MAIN_EX_2.END      - SDK_OVERLAY.MAIN_EX_2.START;

	} > MAIN_EX_2

	.MAIN_EX_2.bss:
	{
	ALIGNALL(4);				. = ALIGN(32);
						
	#
	#  BSS BLOCK
	#
	SDK_OVERLAY.MAIN_EX_2.BSS_START	= .;
						#:::::::::: bss
						ex_2.o (.bss)
						. = ALIGN(4);
						ex_2.o (.sbss)
						. = ALIGN(4);
						#:::::::::: bss
						. = ALIGN(32);
	SDK_OVERLAY.MAIN_EX_2.BSS_END	= .;

	SDK_OVERLAY.MAIN_EX_2.BSS_SIZE	= SDK_OVERLAY.MAIN_EX_2.BSS_END - SDK_OVERLAY.MAIN_EX_2.BSS_START;
	
	} >> MAIN_EX_2

	
	############################ MAIN EX ##################################
	# MAIN EX Area
	.dummy.MAIN_EX:
	{
		. = ALIGN(32);
	} > dummy.MAIN_EX
	
	############################ ARENA ##################################
	.arena.MAIN:
	{
						. = ALIGN(32);
		SDK_SECTION_ARENA_START		=.;
	} > arena.MAIN
	
	.arena.MAIN_EX:
	{
						. = ALIGN(32);
		SDK_SECTION_ARENA_EX_START	=.;
	} > arena.MAIN_EX
	
	.arena.ITCM:
	{
						. = ALIGN(32);
		SDK_SECTION_ARENA_ITCM_START	=.;
	} > arena.ITCM

	.arena.DTCM:
	{
						. = ALIGN(32);
		SDK_SECTION_ARENA_DTCM_START	=.;
	} > arena.DTCM
	
	############################ OVERLAYDEFS ############################
	.main_defs:
	{
		###  main module information 
		WRITEW ADDR(.main);			# load address
		WRITEW _start;					# entry address
		WRITEW SDK_STATIC_SIZE + SDK_AUTOLOAD_SIZE;	# size of module
		WRITEW _start_AutoloadDoneCallback;		# callback autoload done
		
		###  overlay filename 
		WRITES ("main_overlay_1.sbin");	# Overlay 0
		WRITES ("main_overlay_2.sbin");	# Overlay 1
		WRITES ("main_itcm_1.sbin");	# Overlay 2
		WRITES ("main_dtcm_1.sbin");	# Overlay 3
		WRITES ("main_dtcm_2.sbin");	# Overlay 4
		WRITES ("MAIN_EX.sbin");	# Overlay 5
		WRITES ("MAIN_EX_2.sbin");	# Overlay 6
	
	} > main_defs


	############################ OVERLAYTABLE ###########################
	.main_table:
	{
		#	 Overlay 0
		WRITEW 0;				# overlay ID
		WRITEW ADDR(.main_overlay_1);			# load address
		WRITEW SDK_OVERLAY.main_overlay_1.SIZE;		# size of module
		WRITEW SDK_OVERLAY.main_overlay_1.BSS_SIZE;	# size of bss
		WRITEW SDK_OVERLAY.main_overlay_1.SINIT_START;	# start address of static init
		WRITEW SDK_OVERLAY.main_overlay_1.SINIT_END;	# end address of static init
		WRITEW 0;				# ROM file ID
		WRITEW 0;					# Reserved
		
		#	 Overlay 1
		WRITEW 1;				# overlay ID
		WRITEW ADDR(.main_overlay_2);			# load address
		WRITEW SDK_OVERLAY.main_overlay_2.SIZE;		# size of module
		WRITEW SDK_OVERLAY.main_overlay_2.BSS_SIZE;	# size of bss
		WRITEW SDK_OVERLAY.main_overlay_2.SINIT_START;	# start address of static init
		WRITEW SDK_OVERLAY.main_overlay_2.SINIT_END;	# end address of static init
		WRITEW 1;				# ROM file ID
		WRITEW 0;					# Reserved
		
		#	 Overlay 2
		WRITEW 2;				# overlay ID
		WRITEW ADDR(.main_itcm_1);			# load address
		WRITEW SDK_OVERLAY.main_itcm_1.SIZE;		# size of module
		WRITEW SDK_OVERLAY.main_itcm_1.BSS_SIZE;	# size of bss
		WRITEW SDK_OVERLAY.main_itcm_1.SINIT_START;	# start address of static init
		WRITEW SDK_OVERLAY.main_itcm_1.SINIT_END;	# end address of static init
		WRITEW 2;				# ROM file ID
		WRITEW 0;					# Reserved
		
		#	 Overlay 3
		WRITEW 3;				# overlay ID
		WRITEW ADDR(.main_dtcm_1);			# load address
		WRITEW SDK_OVERLAY.main_dtcm_1.SIZE;		# size of module
		WRITEW SDK_OVERLAY.main_dtcm_1.BSS_SIZE;	# size of bss
		WRITEW SDK_OVERLAY.main_dtcm_1.SINIT_START;	# start address of static init
		WRITEW SDK_OVERLAY.main_dtcm_1.SINIT_END;	# end address of static init
		WRITEW 3;				# ROM file ID
		WRITEW 0;					# Reserved
		
		#	 Overlay 4
		WRITEW 4;				# overlay ID
		WRITEW ADDR(.main_dtcm_2);			# load address
		WRITEW SDK_OVERLAY.main_dtcm_2.SIZE;		# size of module
		WRITEW SDK_OVERLAY.main_dtcm_2.BSS_SIZE;	# size of bss
		WRITEW SDK_OVERLAY.main_dtcm_2.SINIT_START;	# start address of static init
		WRITEW SDK_OVERLAY.main_dtcm_2.SINIT_END;	# end address of static init
		WRITEW 4;				# ROM file ID
		WRITEW 0;					# Reserved
		
		#	 Overlay 5
		WRITEW 5;				# overlay ID
		WRITEW ADDR(.MAIN_EX);			# load address
		WRITEW SDK_OVERLAY.MAIN_EX.SIZE;		# size of module
		WRITEW SDK_OVERLAY.MAIN_EX.BSS_SIZE;	# size of bss
		WRITEW SDK_OVERLAY.MAIN_EX.SINIT_START;	# start address of static init
		WRITEW SDK_OVERLAY.MAIN_EX.SINIT_END;	# end address of static init
		WRITEW 5;				# ROM file ID
		WRITEW 0;					# Reserved
		
		#	 Overlay 6
		WRITEW 6;				# overlay ID
		WRITEW ADDR(.MAIN_EX_2);			# load address
		WRITEW SDK_OVERLAY.MAIN_EX_2.SIZE;		# size of module
		WRITEW SDK_OVERLAY.MAIN_EX_2.BSS_SIZE;	# size of bss
		WRITEW SDK_OVERLAY.MAIN_EX_2.SINIT_START;	# start address of static init
		WRITEW SDK_OVERLAY.MAIN_EX_2.SINIT_END;	# end address of static init
		WRITEW 6;				# ROM file ID
		WRITEW 0;					# Reserved
		
		
	} > main_table
	
	
	############################ OTHERS #################################
	SDK_MAIN_ARENA_LO = SDK_SECTION_ARENA_START;
	SDK_IRQ_STACKSIZE = 1024;	# allocated in DTCM
	SDK_SYS_STACKSIZE = 0;		# when 0 means all remains of DTCM
	
	# Module filelist
	.binary.MODULE_FILES:
	{
		WRITES ("main.sbin");
		WRITES ("main_defs.sbin");
		WRITES ("main_table.sbin");
	} > binary.MODULE_FILES

	# ITCM/DTCM size checker => check AUTOLOAD_ITCM/DTCM
	.check.ITCM:
	{
		. = . + SDK_AUTOLOAD_ITCM_SIZE + SDK_AUTOLOAD_ITCM_BSS_SIZE;
	} > check.ITCM
	
	SDK_SYS_STACKSIZE_SIGN = (SDK_SYS_STACKSIZE < 0x80000000) * 2 - 1;
	.check.DTCM:
	{
		. = . + SDK_AUTOLOAD_DTCM_SIZE + SDK_AUTOLOAD_DTCM_BSS_SIZE;
		. = . + SDK_IRQ_STACKSIZE + SDK_SYS_STACKSIZE * SDK_SYS_STACKSIZE_SIGN;
	} > check.DTCM

}
