I designed RISCV32IM processor, and i used "riscv32/64-unknown-elf-gcc" to generate code for test.
I am testing on a system without an OS, and when I use the compile option (-O0) below, I am reluctant because there is a lot of unnecessary code generation.
riscv64-unknown-elf-gcc -march=rv32im -mabi=ilp32 -nostartfiles -O0 -x c -Ttext 40000000 -Tdata 50000000 -Tbss 60000000 -o main.o main.c
When the compile option (-O1 or -O2) is used, only the necessary code is generated, but depending on the C code, the instruction code location of the main() or _start() function may not be the first part of the instruction memory.
Due to the nature of the system, the code location of main() or _start() must be located at the beginning of the instruction memory.
What are the compiler options to solve the above problem?
riscv64-unknown-elf-gcc -march=rv32im -mabi=ilp32 -nostartfiles -O2 -x c -Ttext 40000000 -Tdata 50000000 -Tbss 60000000 -o main.o main.c