| /* Copyright lowRISC contributors. */ |
| /* Licensed under the Apache License, Version 2.0, see LICENSE for details. */ |
| /* SPDX-License-Identifier: Apache-2.0 */ |
| /* |
| |
| OTBN has a pure Harvard architecture, with instruction and data |
| memory both starting at address 0. |
| |
| This linker script template is interpolated by otbn_ld.py after it gets |
| the LMAs and memory sizes from otbn.hjson. |
| |
| */ |
| MEMORY |
| { |
| imem (x) : ORIGIN = 0, LENGTH = ${imem_length} |
| dmem (rw) : ORIGIN = 0, LENGTH = ${dmem_bus_length} |
| dmem_scratch (rw) : ORIGIN = ${dmem_bus_length}, LENGTH = ${dmem_length - dmem_bus_length} |
| |
| /* |
| LMA addresses (for VMAs in imem/dmem, respectively) |
| |
| Note that the DMEM load region is half the size of DMEM itself, |
| to model the fact that OTBN can write to the whole region but |
| only the first ${dmem_length // 2} bytes are bus-accessible. |
| */ |
| imem_load (rw) : ORIGIN = ${imem_lma}, LENGTH = ${imem_length} |
| dmem_load (rw) : ORIGIN = ${dmem_lma}, LENGTH = ${dmem_bus_length} |
| } |
| |
| SECTIONS |
| { |
| .text ORIGIN(imem) : ALIGN(4) |
| { |
| _imem_start = .; |
| KEEP(*(.text.start*)) |
| *(.text*) |
| |
| /* Align section end. Shouldn't really matter, but might make binary |
| blobs a bit easier to work with. */ |
| . = ALIGN(4); |
| |
| _imem_end = .; |
| } >imem AT>imem_load |
| |
| .data ORIGIN(dmem) : ALIGN(32) |
| { |
| _dmem_data_start = .; |
| *(.data*) |
| |
| /* Align section end (see note in .text section) */ |
| . = ALIGN(4); |
| |
| _dmem_data_end = .; |
| } >dmem AT>dmem_load |
| |
| .bss : ALIGN(32) |
| { |
| _dmem_bss_start = .; |
| *(.bss*) |
| |
| /* Align section end (see note in .text section) */ |
| . = ALIGN(4); |
| |
| _dmem_bss_end = .; |
| } >dmem AT>dmem_load |
| |
| /* This matches the offset *in DMEM* of the .bss section. */ |
| _dmem_bss_offset = ADDR(.bss) - ADDR(.data); |
| |
| .scratchpad ORIGIN(dmem_scratch) (NOLOAD) : ALIGN(32) |
| { |
| *(.scratch*) |
| } >dmem |
| } |