Skip to content

Instantly share code, notes, and snippets.

@ntavish
Created September 10, 2018 04:56
Show Gist options
  • Save ntavish/1a6f8c1e670d746b36629f051d4e1921 to your computer and use it in GitHub Desktop.
Save ntavish/1a6f8c1e670d746b36629f051d4e1921 to your computer and use it in GitHub Desktop.
/* details on syntax can be found in GCC linker manual */
MEMORY {
RAM (xrw): ORIGIN = 0x20000000, LENGTH = 20K
FLASH (rx) : ORIGIN = 0x0, LENGTH = 256K
}
SECTIONS {
.isr_vector : {
. = ALIGN(4);
KEEP(*(.isr_vector)) /* vector table */
. = ALIGN(4);
} >FLASH
.text : {
. = ALIGN(4);
*(.text) /* Program code */
*(.text.*)
*(.rodata) /* read only data */
*(.rodata*)
. = ALIGN(4);
_etext = .; /* _etext is end of program code */
} >FLASH /* this section is code, hence gos to FLASH */
.data : AT ( _etext ) { /* AT specifies the LMA (load memory address) */
. = ALIGN(4); /* also, this section is for initialized
global/static variables */
_sdata = .;
*(.data)
*(.data.*)
. = ALIGN(4);
_edata = .;
} >RAM /* this section go into this RAM */
.bss : { /* this section is for uninitialized global/static
variables, which we set to zero */
. = ALIGN(4);
_sbss = .; /* the . sets the symbol to value of current counter */
*(.bss)
*(COMMON)
. = ALIGN(4);
_ebss = .;
} >RAM
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment