2

I'm currently trying to use the GCC toolchain for RISC-V but i'm running into a few problems.

It looks like the stack pointer doesn't get initialized properly. I know i should initialize it myself, but i can't figure out where. I'm using the default linker script altered with the correct memory addresses and in this script a constant _gp gets set. This constant is used in the default startup code to initialize the gp register.

Unfortunately this doesn't set the sp register. How can i set up the stack pointer without using my own start up code?

4

1 回答 1

2

这是在github上回答的:

在跳转到程序的入口点之前,执行环境(例如,OS 内核)应该已经初始化了 sp。如果您处于具有不同约束的嵌入式域中,则需要使用不同的 crt0 来设置这种东西。gp 是指向小数据部分的 ABI 全局指针。操作系统不会初始化它,因为它是二进制文件的属性,而不是执行环境(与堆栈不同)

于 2015-05-04T19:33:12.470 回答