Added an example linker file for ref

Going to use the example linker file for a refernce along with the ld
documentation.
This commit is contained in:
Jake Goodwin 2024-11-10 12:49:15 -08:00
parent c43df6e576
commit 4e6e041073
2 changed files with 79 additions and 5 deletions

63
example.ld Normal file
View File

@ -0,0 +1,63 @@
/* Define the memory regions: Flash and RAM */
MEMORY
{
FLASH (rx) : ORIGIN = 0x08000000, LENGTH = 64K
RAM (rwx) : ORIGIN = 0x20000000, LENGTH = 20K
}
/* Define entry point (usually the reset handler defined in startup code) */
ENTRY(Reset_Handler)
/* Define the sections of the program */
SECTIONS
{
/* Code section, mapped to Flash memory */
.text :
{
KEEP(*(.isr_vector)) /* Vector table, which must be at the beginning of Flash */
*(.text) /* All code goes here */
*(.rodata) /* Read-only data (e.g., const variables) */
_etext = .; /* Mark the end of text section */
} > FLASH
/* Initialized data section, copied from Flash to RAM at startup */
.data :
{
_sdata = .; /* Start of data section */
*(.data) /* Initialized data */
_edata = .; /* End of data section */
} > RAM AT > FLASH
/* Uninitialized data section, placed in RAM but not stored in Flash */
.bss :
{
_sbss = .; /* Start of BSS */
*(.bss) /* Uninitialized data */
*(COMMON) /* Common symbols (zero-initialized) */
_ebss = .; /* End of BSS */
} > RAM
/* Stack section */
._stack :
{
. = ALIGN(8); /* Align to 8-byte boundary */
_estack = .; /* End of stack (top of the stack) */
. = . + 2048; /* Reserve 2 KB for stack */
_sstack = .; /* Start of stack */
} > RAM
/* Heap section */
.heap :
{
_sheap = .; /* Start of heap */
. = . + 2048; /* Reserve 2 KB for heap */
_eheap = .; /* End of heap */
} > RAM
}
/* Provide symbols to be used in the startup code */
PROVIDE(_stack_start = _sstack);
PROVIDE(_stack_end = _estack);
PROVIDE(_heap_start = _sheap);
PROVIDE(_heap_end = _eheap);

View File

@ -37,11 +37,22 @@ MEMORY
floating_point = 0;
SECTIONS
{
. = 0x10000;
.text : { *(.text) }
. = 0x8000000;
.data : { *(.data) }
.bss : { *(.bss) }
/* Code section, mapped to Flash memory */
.tect :
{
KEEP(*(.isr_vector)) /* Vector table, which must be at the beginning of Flash*/
*(.text) /* All code goes here */
*(.rodata) /* Read-only data (e.g., const vars) */
_etext = .; /* Mark the end of text section */
} > FLASH
/* Initialized data section, copied from Flash to RAM on startup. */
.data :
{
_sdata = .; /* Start of data section */
*(.data) /* Initialized data */
_edata = .; /* End of data section */
} > RAM AT > FLASH
}