Skip to content

Compiling a program for RISC V TLM

Màrius Montón edited this page Sep 10, 2019 · 1 revision

RISC-V-TLM can simulate a standard binary compiled for 32 bits RISC-V. Using GCC compiler, it is necessary the following options:

-static -march=rv32imac -mabi=ilp32 --specs=nosys.specs

  • -static : to add all necessary libraries to the binary file (not shared libraries used)
  • -march=rv32imac : sets the architecture, in this case risc-v 32 bits, with I, M, A & C extensions.
  • -mabi=ilp32 : ABI (Application Binary Interface) set to use integers, longs and pointers to be 32 bits long (long long will be 64 bits, char is 8 bits and short is 16 bits long), soft-floating point (see this link for more information).
  • --specs=nosys.specs : inform GCC to use newlib-nano system library (the most used library in embedded). This library offers empty implementations of POSIX system calls.

No more options are required to obtain a runnable binary for RISC-V-TLM simulator. You can add your typical flags (-Wall, -O2/3/s, etc.).

No special linker scripts required, RISC-V-TLM automatically remaps executable segment to memory address 0x0000_0000.

Clone this wiki locally