Files
microchip-application-pec93…/Drivers/PEC930/gcc_flashxip.ld
T

259 lines
7.2 KiB
Plaintext

/******************************************************************************
* @file gcc_flashxip.ld
* @brief GNU Linker Script for RISC-V device in FlashXIP Download Mode
* @date 10. March 2022
******************************************************************************/
/*********** Use Configuration Wizard in Context Menu *************************/
OUTPUT_ARCH( "riscv" )
/********************* Stack / neap Configuration ****************************
* <h> Stack / Heap Configuration
* <o0> Stack Size (in Bytes) <0x0-0xFFFFFFFF:8>
* <o1> Heap Size (in Bytes) <0x0-0xFFFFFFFF:8>
* </h>
*/
__STACK_SIZE = 0x00000200;
__HEAP_SIZE = 0x00000000;
/**************************** end of configuration section ********************/
ENTRY(_start)
/* Define base address and length of flash and sram */
MEMORY
{
flash (rxa!w) : ORIGIN = 0x00000000, LENGTH = 0x8000
sram (wxa!r) : ORIGIN = 0x20000000, LENGTH = 0x1000
}
REGION_ALIAS("ROM", flash)
REGION_ALIAS("RAM", sram)
SECTIONS
{
/* To provide symbol __STACK_SIZE, __HEAP_SIZE */
PROVIDE(__STACK_SIZE = 512);
PROVIDE(__HEAP_SIZE = 256);
__TOT_STACK_SIZE = __STACK_SIZE;
.init :
{
__exec_base_start = .;
/* vector table locate at ROM */
*(.text.vtable)
KEEP (*(SORT_NONE(.text.init)))
. = ALIGN(4);
} >flash AT>flash
. = ALIGN(4);
__fastcode_lma_start = .;
.fastcode : ALIGN(4)
{
/* fast code, execute code at SRAM */
__fastcode_vma_start = ALIGN(4);
PROVIDE( __fastcode_start = . );
*(.fastcode)
__fastcode_vma_end = .;
PROVIDE( __fastcode_end = . );
} >sram AT>flash
/* Code section located at flash */
.text :
{
*(.text.unlikely .text.unlikely.*)
*(.text.startup .text.startup.*)
. = ALIGN(8);
PROVIDE( __jvt_base$ = . );
*(.text.tbljal .text.tbljal.*)
*(.text .text.*)
*(.gnu.linkonce.t.*)
/* readonly data placed in flash */
. = ALIGN(8);
*(.srodata.cst16)
*(.srodata.cst8)
*(.srodata.cst4)
*(.srodata.cst2)
*(.srodata .srodata.*)
*(.rdata)
*(.rodata .rodata.*)
*(.gnu.linkonce.r.*)
/* below sections are used for rt-thread */
. = ALIGN(4);
__rt_init_start = .;
KEEP(*(SORT(.rti_fn*)))
__rt_init_end = .;
. = ALIGN(4);
__fsymtab_start = .;
KEEP(*(FSymTab))
__fsymtab_end = .;
. = ALIGN(4);
__vsymtab_start = .;
KEEP(*(VSymTab))
__vsymtab_end = .;
} >flash AT>flash
.fini :
{
KEEP (*(SORT_NONE(.fini)))
} >flash AT>flash
.preinit_array :
{
PROVIDE_HIDDEN (__preinit_array_start = .);
KEEP (*(.preinit_array))
PROVIDE_HIDDEN (__preinit_array_end = .);
} >flash AT>flash
.init_array :
{
PROVIDE_HIDDEN (__init_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
KEEP (*(.init_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
PROVIDE_HIDDEN (__init_array_end = .);
} >flash AT>flash
.fini_array :
{
PROVIDE_HIDDEN (__fini_array_start = .);
KEEP (*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
KEEP (*(.fini_array EXCLUDE_FILE (*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
PROVIDE_HIDDEN (__fini_array_end = .);
} >flash AT>flash
.ctors :
{
/* gcc uses crtbegin.o to find the start of
* the constructors, so we make sure it is
* first. Because this is a wildcard, it
* doesn't matter if the user does not
* actually link against crtbegin.o; the
* linker won't look for a file to match a
* wildcard. The wildcard also means that it
* doesn't matter which directory crtbegin.o
* is in.
*/
KEEP (*crtbegin.o(.ctors))
KEEP (*crtbegin?.o(.ctors))
/* We don't want to include the .ctor section from
* the crtend.o file until after the sorted ctors.
* The .ctor section from the crtend file contains the
* end of ctors marker and it must be last
*/
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .ctors))
KEEP (*(SORT(.ctors.*)))
KEEP (*(.ctors))
} >flash AT>flash
.dtors :
{
KEEP (*crtbegin.o(.dtors))
KEEP (*crtbegin?.o(.dtors))
KEEP (*(EXCLUDE_FILE (*crtend.o *crtend?.o ) .dtors))
KEEP (*(SORT(.dtors.*)))
KEEP (*(.dtors))
} >flash AT>flash
PROVIDE( _text_lma = LOADADDR(.text) );
PROVIDE( _text = ADDR(.text) );
PROVIDE (_etext = .);
PROVIDE (__etext = .);
PROVIDE (etext = .);
.data : ALIGN(8)
{
KEEP(*(.data.ctest*))
*(.data .data.*)
*(.gnu.linkonce.d.*)
. = ALIGN(8);
PROVIDE( __global_pointer$ = . + 0x800 );
*(.sdata .sdata.* .sdata*)
*(.gnu.linkonce.s.*)
/* Fix undefined symbol: __eh_frame_start/__eh_frame_hdr_start/__eh_frame_end/__eh_frame_hdr_end */
PROVIDE_HIDDEN (__eh_frame_hdr_start = .);
*(.eh_frame_hdr)
PROVIDE_HIDDEN (__eh_frame_hdr_end = .);
PROVIDE_HIDDEN (__eh_frame_start = .);
*(.eh_frame)
PROVIDE_HIDDEN (__eh_frame_end = .);
. = ALIGN(8);
/* table real-usage */
. = ALIGN(256);
KEEP (*(.mintvec))
. = ALIGN(64);
KEEP (*(.mexcptrap))
} >sram AT>flash
.tdata : ALIGN(8)
{
PROVIDE( __tls_base = . );
*(.tdata .tdata.* .gnu.linkonce.td.*)
} >sram AT>flash
PROVIDE( _data_lma = LOADADDR(.data) );
PROVIDE( _data = ADDR(.data) );
PROVIDE( _edata = . );
PROVIDE( edata = . );
PROVIDE( _fbss = . );
PROVIDE( __bss_start = . );
__end_lma__ = LOADADDR(.tdata);
.tbss (NOLOAD) : ALIGN(8)
{
*(.tbss .tbss.* .gnu.linkonce.tb.*)
*(.tcommon)
PROVIDE( __tls_end = . );
} >sram AT>sram
.tbss_space (NOLOAD) : ALIGN(8)
{
. = . + SIZEOF(.tbss);
} >sram AT>sram
.bss (NOLOAD) : ALIGN(8)
{
*(.sbss*)
*(.gnu.linkonce.sb.*)
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
. = ALIGN(4);
} >sram AT>sram
PROVIDE( _end = . );
PROVIDE( end = . );
/**
* 1. heap need to be align at 16 bytes
* 2. __heap_start and __heap_end symbol need to be defined
* 3. reserved at least __HEAP_SIZE space for heap
*/
.heap (NOLOAD) : ALIGN(16)
{
. = ALIGN(16);
PROVIDE( __heap_start = . );
. += __HEAP_SIZE;
. = ALIGN(16);
PROVIDE( __heap_limit = . );
} >sram AT>sram
.stack ORIGIN(sram) + LENGTH(sram) - __TOT_STACK_SIZE (NOLOAD) :
{
. = ALIGN(16);
PROVIDE( _heap_end = . );
PROVIDE( __heap_end = . );
PROVIDE( __StackLimit = . );
PROVIDE( __StackBottom = . );
. += __TOT_STACK_SIZE;
. = ALIGN(16);
PROVIDE( __StackTop = . );
PROVIDE( _sp = . );
} >sram AT>sram
}