I tried this recipe : How to run a bare metal ELF file on QEMU? to run bare metal AArch64 executables on QEMU (and it worked). I'd like to do the same for 64-bit SPARCv9 executables (preferably starting from C/C++, not assembly) - I tried the examples in this link : Run SPARC assembly in QEMU, but that one runs in user-mode Linux, does syscall translation to the host system, etc.
Example :
int main(int argc, char **argv) {
volatile int a = 11, b = 13, c = 7, d = 5;
return a + b - c - d;
}
How do I run this example as a bare metal Sparcv9 executable AND connect gdb to it ?
Any of the available 64-bit boards in qemu/hw/sparc64/ would be fine. Thank you.
I believe what you are after is the
qemu-system-sparc64command. Just something to note is that the general form for bare-metal emulation isqemu-system-{ARCH}and the general command for user mode emulation isqemu-{ARCH}.An example from the qemu docs.
As for building your own c/c++ bare-metal executables, that's a relatively broad topic, but I'd recommend starting with GCC and newlib-nano (for libc).