/* * Linker script for a RISC-V based System-on-Chip * * This version is an FPGA version with RAM for code and data */ /* * Declare the memory units supported in this system. */ MEMORY { RAM (rwx) : ORIGIN = 0x00000000, LENGTH = 16K } /* * Map 'sections' generated by the compiler into the memory * units declared above. * * The standard sections are: * * .text : for code * .data : for initialised data * .bss : for uninitialised data * * Other sections may also exist dependent on the particular * compiler and even in response to compiler directives in the * source code. */ SECTIONS { /* * The '.text' section contains code and read-only data * this can go straight into the RAM in an FPGA based system */ .text : { _stext = .; /* Provide the name for the start of this section */ CREATE_OBJECT_SYMBOLS *(.reset.text) /* Include the startup assembly code first */ *(.text) *(.text.*) . = ALIGN(4); /* Align the start of the rodata part */ *(.rodata) *(.rodata.*) . = ALIGN(4); /* Align the start of the small rodata part */ *(.srodata) *(.srodata.*) . = ALIGN(4); /* Align the end of the section */ _etext = .; /* Provide the name for the end of this section */ } > RAM = 0 /* * The '.data' section contains initialised data * this can go straight into the RAM in an FPGA based system */ .data : { . = ALIGN(4); /* Align the start of the section */ _sdata = .; /* Provide the name for the start of this section */ *(.data) *(.data.*) . = ALIGN(4); /* Align the start of the small data part */ _small_data = .; /* Provide the name for the start of this section */ *(.sdata) *(.sdata.*) . = ALIGN(4); /* Align the end of the section */ _edata = .; /* Provide the name for the end of this section */ } > RAM /* * The '.bss' section contains uninitialised data * we would like this to go into RAM * * In spite of the "uninitialised" description, it is * usual to initialise this data to zero - * this is a job for the Reset Handler code. */ .bss : { . = ALIGN(4); /* Align the start of the section */ _sbss = .; /* Provide the name for the start of this section */ *(.sbss) *(.sbss.*) . = ALIGN(4); /* Align the start of bss part */ *(.bss) *(.bss.*) . = ALIGN(4); /* Align the end of the section */ _ebss = .; /* Provide the name for the end of this section */ } > RAM /* * The following line assigns a symbol for the "bottom" of * the the stack. This symbol is used by the startup code in * order to initialise the stack pointer */ _estack = ORIGIN(RAM) + LENGTH(RAM); /* * Assigning the special "__global_pointer$" symbol allows the * compiler to use gp relative addresses in the range: * (__global_pointer$ - 0x800) - (__global_pointer$ + 0x7FF) * * The symbol is used by the startup code in order to initialise * the gp register. * * Here the _small_data symbol is used to indicate the start of the * .sdata section */ __global_pointer$ = _small_data + 0x800; /* * Exception frames are not supported by this embedded system * so we will discard the 'eh_frame' section */ /DISCARD/ : { *(.eh_frame) } } /* * The ENTRY section can be used to tell an emulator where * to start executing the code */ ENTRY(_start)