summaryrefslogtreecommitdiff
path: root/linker_script.ld
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2022-12-12 20:38:24 -0700
committerJosh Rahm <joshuarahm@gmail.com>2022-12-12 20:38:54 -0700
commitef3a1919ce5c87179e8f1d7a3b1b835151fdf50f (patch)
tree600a70a334df03ebbaa2c7928ff0863e3ca614a0 /linker_script.ld
downloadstm32l4-rust-ef3a1919ce5c87179e8f1d7a3b1b835151fdf50f.tar.gz
stm32l4-rust-ef3a1919ce5c87179e8f1d7a3b1b835151fdf50f.tar.bz2
stm32l4-rust-ef3a1919ce5c87179e8f1d7a3b1b835151fdf50f.zip
Start writing bare-metal stm32 kernel in rust
Diffstat (limited to 'linker_script.ld')
-rw-r--r--linker_script.ld58
1 files changed, 58 insertions, 0 deletions
diff --git a/linker_script.ld b/linker_script.ld
new file mode 100644
index 0000000..37b90a4
--- /dev/null
+++ b/linker_script.ld
@@ -0,0 +1,58 @@
+MEMORY
+{
+ flash : org = 0x08000000, len = 256k
+ sram1 : org = 0x20000000, len = 48k
+ sram2 : org = 0x10000000, len = 16k
+}
+
+SECTIONS
+{
+ /* By default the start of the stack is at the top of sram1. */
+ PROVIDE(_stack_start = ORIGIN(sram1) + LENGTH(sram1));
+
+ /* Vector-offset table. */
+ .vectors ORIGIN(flash) : ALIGN(0x04) {
+ LONG(_stack_start); /* Store the start of the stack. */
+ KEEP(*(.on_reset));
+
+ . = ORIGIN(flash) + 0x0dc;
+ } >flash
+
+ /** Text data is stored after the vector table. */
+ PROVIDE(_stext = ADDR(.vectors) + SIZEOF(.vectors));
+ .text _stext : ALIGN(0x04) {
+ *(.text .text.*);
+ . = ALIGN(0x04);
+ _etext = .;
+
+ /* Readonly data should be stored in flash. */
+ *(.rodata .rodata.*)
+ } >flash
+
+ /* the data segment where static data is stored. This is linked to reference
+ * variables in sram2, but the data is stored persistently in the flash.
+ *
+ * The Application has to load the data from the flash to */
+ .data : ALIGN(0x04) {
+ __data_load = LOADADDR(.data);
+ __data_store_start = .;
+ *(.data .data.*);
+ __data_store_end = .;
+ } > sram2 AT > flash
+
+ /* block starting symbol (bss). This is data initialized to 0. The application
+ * is responsible for zeroing out this data. */
+ .bss : ALIGN(0x04) {
+ __bss_start = .;
+ *(.bss .bss.*);
+ __bss_end = .;
+ } > sram2
+
+ /* Sections that should be discarded. */
+ /DISCARD/ :
+ {
+ *(.ARM.exidx);
+ *(.ARM.exidx.*);
+ *(.ARM.extab.*);
+ }
+}