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.
Basically it's similar to running an AArch64 bare-metal ELF:
or
Both -kernel and -bios options in sun4u emulation may load ELF files, the difference is that in the first example the hardware is initialized by OpenBIOS, and in the second example you are running in a PROM right after the cold start. The -s option will make QEMU listen for an incoming connection from gdb on TCP port 1234.
In the second example you probably also would like to add the -S option in oder to make QEMU not to start the execution of your ELF file until you tell it to from gdb. In gdb you do the following: