From ca94b1ef1bbe005772ff79cdabd9280aa833a26c Mon Sep 17 00:00:00 2001 From: Stephan Date: Mon, 3 Jul 2023 21:27:02 +0200 Subject: [PATCH] add linker script --- mips-rt/Cargo.toml | 2 +- mips-rt/build.rs | 1 + mips-rt/link.x | 458 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 460 insertions(+), 1 deletion(-) create mode 100644 mips-rt/link.x diff --git a/mips-rt/Cargo.toml b/mips-rt/Cargo.toml index 766044f..0946451 100644 --- a/mips-rt/Cargo.toml +++ b/mips-rt/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mips-rt" -version = "0.3.1" +version = "0.3.2" authors = ["Stephan bootloader_mem + + /* ## PIC32MX configuration registers */ + .configsfrs : { + KEEP(*(.configsfrs)); + } > configsfrs + + /* Reset Sections */ + .reset : + { + KEEP(*(.reset)) + KEEP(*(.reset.startup)) + } > reset_mem + /* .bev_excpt _BEV_EXCPT_ADDR : + { + KEEP(*(.bev_handler)) + } > kseg1_boot_mem */ + /* Debug exception vector */ + /* Space reserved for the debug executive */ +/* .dbg_code _DBG_CODE_ADDR (NOLOAD) : + { + . += (DEFINED (_DEBUGGER) ? _DBG_CODE_SIZE : 0x0); + } > debug_exec_mem */ + + /* Exception handlers */ + .app_excpt _ebase_address + 0x180: + { + KEEP(*(.gen_handler)) + } > exception_mem + + .vector_0 _ebase_address + 0x200 + ((_vector_spacing << 5) * 0) : + { + KEEP(*(.vector_0)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_0) <= (_vector_spacing << 5), "function at exception vector 0 too large") + .vector_1 _ebase_address + 0x200 + ((_vector_spacing << 5) * 1) : + { + KEEP(*(.vector_1)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_1) <= (_vector_spacing << 5), "function at exception vector 1 too large") + .vector_2 _ebase_address + 0x200 + ((_vector_spacing << 5) * 2) : + { + KEEP(*(.vector_2)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_2) <= (_vector_spacing << 5), "function at exception vector 2 too large") + .vector_3 _ebase_address + 0x200 + ((_vector_spacing << 5) * 3) : + { + KEEP(*(.vector_3)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_3) <= (_vector_spacing << 5), "function at exception vector 3 too large") + .vector_4 _ebase_address + 0x200 + ((_vector_spacing << 5) * 4) : + { + KEEP(*(.vector_4)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_4) <= (_vector_spacing << 5), "function at exception vector 4 too large") + .vector_5 _ebase_address + 0x200 + ((_vector_spacing << 5) * 5) : + { + KEEP(*(.vector_5)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_5) <= (_vector_spacing << 5), "function at exception vector 5 too large") + .vector_6 _ebase_address + 0x200 + ((_vector_spacing << 5) * 6) : + { + KEEP(*(.vector_6)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_6) <= (_vector_spacing << 5), "function at exception vector 6 too large") + .vector_7 _ebase_address + 0x200 + ((_vector_spacing << 5) * 7) : + { + KEEP(*(.vector_7)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_7) <= (_vector_spacing << 5), "function at exception vector 7 too large") + .vector_8 _ebase_address + 0x200 + ((_vector_spacing << 5) * 8) : + { + KEEP(*(.vector_8)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_8) <= (_vector_spacing << 5), "function at exception vector 8 too large") + .vector_9 _ebase_address + 0x200 + ((_vector_spacing << 5) * 9) : + { + KEEP(*(.vector_9)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_9) <= (_vector_spacing << 5), "function at exception vector 9 too large") + .vector_10 _ebase_address + 0x200 + ((_vector_spacing << 5) * 10) : + { + KEEP(*(.vector_10)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_10) <= (_vector_spacing << 5), "function at exception vector 10 too large") + .vector_11 _ebase_address + 0x200 + ((_vector_spacing << 5) * 11) : + { + KEEP(*(.vector_11)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_11) <= (_vector_spacing << 5), "function at exception vector 11 too large") + .vector_12 _ebase_address + 0x200 + ((_vector_spacing << 5) * 12) : + { + KEEP(*(.vector_12)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_12) <= (_vector_spacing << 5), "function at exception vector 12 too large") + .vector_13 _ebase_address + 0x200 + ((_vector_spacing << 5) * 13) : + { + KEEP(*(.vector_13)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_13) <= (_vector_spacing << 5), "function at exception vector 13 too large") + .vector_14 _ebase_address + 0x200 + ((_vector_spacing << 5) * 14) : + { + KEEP(*(.vector_14)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_14) <= (_vector_spacing << 5), "function at exception vector 14 too large") + .vector_15 _ebase_address + 0x200 + ((_vector_spacing << 5) * 15) : + { + KEEP(*(.vector_15)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_15) <= (_vector_spacing << 5), "function at exception vector 15 too large") + .vector_16 _ebase_address + 0x200 + ((_vector_spacing << 5) * 16) : + { + KEEP(*(.vector_16)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_16) <= (_vector_spacing << 5), "function at exception vector 16 too large") + .vector_17 _ebase_address + 0x200 + ((_vector_spacing << 5) * 17) : + { + KEEP(*(.vector_17)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_17) <= (_vector_spacing << 5), "function at exception vector 17 too large") + .vector_18 _ebase_address + 0x200 + ((_vector_spacing << 5) * 18) : + { + KEEP(*(.vector_18)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_18) <= (_vector_spacing << 5), "function at exception vector 18 too large") + .vector_19 _ebase_address + 0x200 + ((_vector_spacing << 5) * 19) : + { + KEEP(*(.vector_19)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_19) <= (_vector_spacing << 5), "function at exception vector 19 too large") + .vector_20 _ebase_address + 0x200 + ((_vector_spacing << 5) * 20) : + { + KEEP(*(.vector_20)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_20) <= (_vector_spacing << 5), "function at exception vector 20 too large") + .vector_21 _ebase_address + 0x200 + ((_vector_spacing << 5) * 21) : + { + KEEP(*(.vector_21)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_21) <= (_vector_spacing << 5), "function at exception vector 21 too large") + .vector_22 _ebase_address + 0x200 + ((_vector_spacing << 5) * 22) : + { + KEEP(*(.vector_22)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_22) <= (_vector_spacing << 5), "function at exception vector 22 too large") + .vector_23 _ebase_address + 0x200 + ((_vector_spacing << 5) * 23) : + { + KEEP(*(.vector_23)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_23) <= (_vector_spacing << 5), "function at exception vector 23 too large") + .vector_24 _ebase_address + 0x200 + ((_vector_spacing << 5) * 24) : + { + KEEP(*(.vector_24)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_24) <= (_vector_spacing << 5), "function at exception vector 24 too large") + .vector_25 _ebase_address + 0x200 + ((_vector_spacing << 5) * 25) : + { + KEEP(*(.vector_25)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_25) <= (_vector_spacing << 5), "function at exception vector 25 too large") + .vector_26 _ebase_address + 0x200 + ((_vector_spacing << 5) * 26) : + { + KEEP(*(.vector_26)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_26) <= (_vector_spacing << 5), "function at exception vector 26 too large") + .vector_27 _ebase_address + 0x200 + ((_vector_spacing << 5) * 27) : + { + KEEP(*(.vector_27)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_27) <= (_vector_spacing << 5), "function at exception vector 27 too large") + .vector_28 _ebase_address + 0x200 + ((_vector_spacing << 5) * 28) : + { + KEEP(*(.vector_28)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_28) <= (_vector_spacing << 5), "function at exception vector 28 too large") + .vector_29 _ebase_address + 0x200 + ((_vector_spacing << 5) * 29) : + { + KEEP(*(.vector_29)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_29) <= (_vector_spacing << 5), "function at exception vector 29 too large") + .vector_30 _ebase_address + 0x200 + ((_vector_spacing << 5) * 30) : + { + KEEP(*(.vector_30)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_30) <= (_vector_spacing << 5), "function at exception vector 30 too large") + .vector_31 _ebase_address + 0x200 + ((_vector_spacing << 5) * 31) : + { + KEEP(*(.vector_31)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_31) <= (_vector_spacing << 5), "function at exception vector 31 too large") + .vector_32 _ebase_address + 0x200 + ((_vector_spacing << 5) * 32) : + { + KEEP(*(.vector_32)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_32) <= (_vector_spacing << 5), "function at exception vector 32 too large") + .vector_33 _ebase_address + 0x200 + ((_vector_spacing << 5) * 33) : + { + KEEP(*(.vector_33)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_33) <= (_vector_spacing << 5), "function at exception vector 33 too large") + .vector_34 _ebase_address + 0x200 + ((_vector_spacing << 5) * 34) : + { + KEEP(*(.vector_34)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_34) <= (_vector_spacing << 5), "function at exception vector 34 too large") + .vector_35 _ebase_address + 0x200 + ((_vector_spacing << 5) * 35) : + { + KEEP(*(.vector_35)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_35) <= (_vector_spacing << 5), "function at exception vector 35 too large") + .vector_36 _ebase_address + 0x200 + ((_vector_spacing << 5) * 36) : + { + KEEP(*(.vector_36)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_36) <= (_vector_spacing << 5), "function at exception vector 36 too large") + .vector_37 _ebase_address + 0x200 + ((_vector_spacing << 5) * 37) : + { + KEEP(*(.vector_37)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_37) <= (_vector_spacing << 5), "function at exception vector 37 too large") + .vector_38 _ebase_address + 0x200 + ((_vector_spacing << 5) * 38) : + { + KEEP(*(.vector_38)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_38) <= (_vector_spacing << 5), "function at exception vector 38 too large") + .vector_39 _ebase_address + 0x200 + ((_vector_spacing << 5) * 39) : + { + KEEP(*(.vector_39)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_39) <= (_vector_spacing << 5), "function at exception vector 39 too large") + .vector_40 _ebase_address + 0x200 + ((_vector_spacing << 5) * 40) : + { + KEEP(*(.vector_40)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_40) <= (_vector_spacing << 5), "function at exception vector 40 too large") + .vector_41 _ebase_address + 0x200 + ((_vector_spacing << 5) * 41) : + { + KEEP(*(.vector_41)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_41) <= (_vector_spacing << 5), "function at exception vector 41 too large") + .vector_42 _ebase_address + 0x200 + ((_vector_spacing << 5) * 42) : + { + KEEP(*(.vector_42)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_42) <= (_vector_spacing << 5), "function at exception vector 42 too large") + .vector_43 _ebase_address + 0x200 + ((_vector_spacing << 5) * 43) : + { + KEEP(*(.vector_43)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_43) <= (_vector_spacing << 5), "function at exception vector 43 too large") + .vector_44 _ebase_address + 0x200 + ((_vector_spacing << 5) * 44) : + { + KEEP(*(.vector_44)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_44) <= (_vector_spacing << 5), "function at exception vector 44 too large") + .vector_45 _ebase_address + 0x200 + ((_vector_spacing << 5) * 45) : + { + KEEP(*(.vector_45)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_45) <= (_vector_spacing << 5), "function at exception vector 45 too large") + .vector_46 _ebase_address + 0x200 + ((_vector_spacing << 5) * 46) : + { + KEEP(*(.vector_46)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_46) <= (_vector_spacing << 5), "function at exception vector 46 too large") + .vector_47 _ebase_address + 0x200 + ((_vector_spacing << 5) * 47) : + { + KEEP(*(.vector_47)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_47) <= (_vector_spacing << 5), "function at exception vector 47 too large") + .vector_48 _ebase_address + 0x200 + ((_vector_spacing << 5) * 48) : + { + KEEP(*(.vector_48)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_48) <= (_vector_spacing << 5), "function at exception vector 48 too large") + .vector_49 _ebase_address + 0x200 + ((_vector_spacing << 5) * 49) : + { + KEEP(*(.vector_49)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_49) <= (_vector_spacing << 5), "function at exception vector 49 too large") + .vector_50 _ebase_address + 0x200 + ((_vector_spacing << 5) * 50) : + { + KEEP(*(.vector_50)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_50) <= (_vector_spacing << 5), "function at exception vector 50 too large") + .vector_51 _ebase_address + 0x200 + ((_vector_spacing << 5) * 51) : + { + KEEP(*(.vector_51)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_51) <= (_vector_spacing << 5), "function at exception vector 51 too large") + .vector_52 _ebase_address + 0x200 + ((_vector_spacing << 5) * 52) : + { + KEEP(*(.vector_52)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_52) <= (_vector_spacing << 5), "function at exception vector 52 too large") + .vector_53 _ebase_address + 0x200 + ((_vector_spacing << 5) * 53) : + { + KEEP(*(.vector_53)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_53) <= (_vector_spacing << 5), "function at exception vector 53 too large") + .vector_54 _ebase_address + 0x200 + ((_vector_spacing << 5) * 54) : + { + KEEP(*(.vector_54)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_54) <= (_vector_spacing << 5), "function at exception vector 54 too large") + .vector_55 _ebase_address + 0x200 + ((_vector_spacing << 5) * 55) : + { + KEEP(*(.vector_55)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_55) <= (_vector_spacing << 5), "function at exception vector 55 too large") + .vector_56 _ebase_address + 0x200 + ((_vector_spacing << 5) * 56) : + { + KEEP(*(.vector_56)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_56) <= (_vector_spacing << 5), "function at exception vector 56 too large") + .vector_57 _ebase_address + 0x200 + ((_vector_spacing << 5) * 57) : + { + KEEP(*(.vector_57)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_57) <= (_vector_spacing << 5), "function at exception vector 57 too large") + .vector_58 _ebase_address + 0x200 + ((_vector_spacing << 5) * 58) : + { + KEEP(*(.vector_58)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_58) <= (_vector_spacing << 5), "function at exception vector 58 too large") + .vector_59 _ebase_address + 0x200 + ((_vector_spacing << 5) * 59) : + { + KEEP(*(.vector_59)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_59) <= (_vector_spacing << 5), "function at exception vector 59 too large") + .vector_60 _ebase_address + 0x200 + ((_vector_spacing << 5) * 60) : + { + KEEP(*(.vector_60)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_60) <= (_vector_spacing << 5), "function at exception vector 60 too large") + .vector_61 _ebase_address + 0x200 + ((_vector_spacing << 5) * 61) : + { + KEEP(*(.vector_61)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_61) <= (_vector_spacing << 5), "function at exception vector 61 too large") + .vector_62 _ebase_address + 0x200 + ((_vector_spacing << 5) * 62) : + { + KEEP(*(.vector_62)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_62) <= (_vector_spacing << 5), "function at exception vector 62 too large") + .vector_63 _ebase_address + 0x200 + ((_vector_spacing << 5) * 63) : + { + KEEP(*(.vector_63)) + } > exception_mem + ASSERT (_vector_spacing == 0 || SIZEOF(.vector_63) <= (_vector_spacing << 5), "function at exception vector 63 too large") + + /* ### .text */ + .text : + { + *(.text .text.*); + } > program_mem + + /* ### .rodata */ + .rodata : ALIGN(4) + { + *(.rodata .rodata.*); + + /* 4-byte align the end (VMA) of this section. + This is required by LLD to ensure the LMA of the following .data + section will have the correct alignment. */ + . = ALIGN(4); + } > program_mem + + /* ## Sections in RAM */ + /* ### .data */ + .data : ALIGN(4) + { + *(.data .data.*); + + . = ALIGN(4); /* 4-byte align the end (VMA) of this section */ + } > data_mem AT > program_mem + + /* VMA of .data */ + __sdata = ADDR(.data); + __edata = ADDR(.data) + SIZEOF(.data); + + /* LMA of .data */ + __sidata = LOADADDR(.data); + + /* ### .bss */ + .bss (NOLOAD) : ALIGN(4) + { + . = ALIGN(4); + __sbss = .; + *(.bss .bss.*); + *(COMMON); /* Uninitialized C statics */ + . = ALIGN(4); /* 4-byte align the end (VMA) of this section */ + } > data_mem + /* Allow sections from user `memory.x` injected using `INSERT AFTER .bss` to + * use the .bss zeroing mechanism by pushing __ebss. Note: do not change + * output region or load region in those user sections! */ + . = ALIGN(4); + __ebss = .; + + /* ### .uninit */ + .uninit (NOLOAD) : ALIGN(4) + { + . = ALIGN(4); + __suninit = .; + *(.uninit .uninit.*); + . = ALIGN(4); + __euninit = .; + } > data_mem + + /* Place the heap right after `.uninit` in RAM */ + PROVIDE(__sheap = __euninit); + + /* Stack usage metadata emitted by LLVM */ + .stack_sizes (INFO) : + { + KEEP(*(.stack_sizes)); + } + + /* ## Discarded sections */ + /DISCARD/ : + { + *(.reginfo); + *(.MIPS.abiflags); + *(.eh_frame_hdr); + *(.eh_frame); + *(.got); + } +}