-
Notifications
You must be signed in to change notification settings - Fork 115
Closed
Description
Consider the following code to calculate fibonacci sequences:
long fib(int n)
{
if (n == 0 || n == 1) {
return n;
}
return fib(n - 1) + fib(n - 2);
}
int main()
{
return fib(30);
}
and build it with the linker script and commands:
OUTPUT_ARCH("riscv")
ENTRY(main)
SECTIONS
{
. = 0x10000;
}
$ make clean ENABLE_JIT=1 all
$ riscv32-unknown-elf-gcc -S -O2 -o fib.s fib.c
$ riscv32-unknown-elf-gcc -c -o fib.o fib.s
$ riscv32-unknown-elf-ld -T script.ld -o fib fib.o
$ build/rv32emu fib
It will fall into the infinite loop when executed by the rv32emu.
The problem only happens when the -O2
option enabled.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working