Based on riscv GNU toolchain.
I suggest you to use the default link script, and add your memory & stack & heap defination.
But remember, add a ".other: { (.) }", in case of there's some of the sections are not defined in the default script.
This is an example:
/* Copyright (C) 2014-2025 Free Software Foundation, Inc.
Copying and distribution of this script, with or without modification,
are permitted in any medium without royalty provided the copyright
notice and this notice are preserved. */
OUTPUT_FORMAT("elf32-littleriscv", "elf32-littleriscv", "elf32-littleriscv")