| /* Copyright 2023 Google LLC. */ |
| /* Licensed under the Apache License, Version 2.0, see LICENSE for details. */ |
| /* SPDX-License-Identifier: Apache-2.0 */ |
| |
| /** |
| * A simple linker script for kelvin core. |
| */ |
| |
| INCLUDE hw/top_matcha/sw/autogen/top_matcha_memory.ld |
| |
| /** |
| * Define a new memory since kelvin core memory address offset does not use |
| * top_matcha's definition. However, the length of the memory is pulled from |
| * top_matcha_memory.ld. |
| */ |
| |
| MEMORY { |
| TCM(rwx): ORIGIN = 0x00000000, LENGTH = LENGTH(ram_ml_dmem) |
| } |
| |
| _stack_size = 0x4000; |
| __heap_size__ = 0x1000; |
| |
| ENTRY(_start) |
| |
| SECTIONS { |
| . = ORIGIN(TCM); |
| .text : ALIGN(4) { |
| *(._init) |
| *(.text) |
| *(.text.*) |
| . = ALIGN(4); |
| __etext = .; |
| } > TCM |
| |
| .init.array : ALIGN(4) { |
| __init_array_start = .; |
| *(.init_array) |
| *(.init_array.*) |
| . = ALIGN(4); |
| __init_array_end = .; |
| } > TCM |
| |
| .rodata : ALIGN(4) { |
| *(.srodata) |
| *(.srodata.*) |
| *(.rodata) |
| *(.rodata.*) |
| . = ALIGN(4); |
| } > TCM |
| |
| .data : ALIGN(4) { |
| __data_start__ = .; |
| /** |
| * This will get loaded into `gp`, and the linker will use that register for |
| * accessing data within [-2048,2047] of `__global_pointer$`. |
| * |
| * This is much cheaper (for small data) than materializing the |
| * address and loading from that (which will take one extra instruction). |
| */ |
| _global_pointer = . + 0x800; |
| *(.sdata) |
| *(.sdata.*) |
| *(.data) |
| *(.data.*) |
| /* Align on 256 width. */ |
| . = ALIGN(256); |
| __data_end__ = .; |
| } > TCM |
| |
| .bss : ALIGN(4) { |
| __bss_start__ = .; |
| *(.sbss) |
| *(.sbss.*) |
| *(.bss) |
| *(.bss.*) |
| __bss_end__ = .; |
| } > TCM |
| |
| .heap : ALIGN(4) { |
| __heap_start__ = .; |
| . += __heap_size__; |
| __heap_end__ = .; |
| } > TCM |
| |
| .stack : ALIGN(4) { |
| __stack_start__ = .; |
| . += _stack_size; |
| __stack_end__ = .; |
| } > TCM |
| } |