blob: 076aa680583b61599e895b2168b47b4440462052 [file] [log] [blame]
/* 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 = 3M
MODEL_DATA(rw): ORIGIN = LENGTH(TCM), LENGTH = LENGTH(ram_ml_dmem) - LENGTH(TCM)
}
STACK_SIZE = DEFINED(__stack_size__) ? __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
}
SECTIONS {
. = ORIGIN(MODEL_DATA);
.model_data (NOLOAD) : ALIGN(4) {
__model_data_start__ = .;
*(.model_data)
__model_data_end__ = .;
} > MODEL_DATA
/*
* Model header information (model input/output addresses) is
* always at the end of DMEM.
*/
.model_header LENGTH(ram_ml_dmem) - 4096 (NOLOAD) : ALIGN(4) {
__model_header_start__ = .;
*(.model_header*)
__model_header_end__ = .;
} > MODEL_DATA
}