From https://github.com/riscv/riscv-llvm,
Using the llvm-riscv is fairly simple to build a full executable however you need riscv64-unknown-*-gcc to do the assembling and linking. An example of compiling hello world:
$ clang -target riscv64 -mriscv=RV64IAMFD -S hello.c -o hello.S
$ riscv64-unknown-elf-gcc -o hello.riscv hello.S
My question is: if I change the LLVM backend and get it to emit a new instruction in the hello.S file, how will riscv64-unknown-elf-gcc
know how to convert it into object code? Do I also need to make changes in riscv64-unknown-elf-gcc
so that it knows the format of the new instruction?
riscv64-unknown-elf-gcc
callsas
, i.e. usually GNUas
from the binutils to assemble assembly code (i.e.hello.S
in your snippet) into executable machine code. Thus you would have to modify the binutils if you want to assemble a new instruction.