Hi,
I am trying to build an image which has a VMA of 0x8000_0000, but I get the following error.
c_test_riscv/high_c.cpp:7:(.text+0x30): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
The code is as follows:
#->cat high_c.cpp
void something_something(const char *str)
{
}
extern "C" void c_high()
{
something_something("and something");
}
#->cat linker.script
ENTRY(c_high)
SECTIONS
{
HIGH 0x80000000 : AT(0x1000){
high_c.o (*)
}
}
The commands to build the code is:
#->cat compile.sh
riscv64-unknown-elf-g++ -ggdb -c high_c.cpp -o high_c.o
riscv64-unknown-elf-g++ -g -o test.elf -T linker.script -nostdlib high_c.o
Running this, give me the eror:
c_test_riscv/high_c.cpp:7:(.text+0x30): relocation truncated to fit: R_RISCV_HI20 against `.LC0'
Looks like the linker thinks that the symbol `.LC0' which I think points to the sting can be linked with a immediate load, but fails when the pointer is at a high address
Any pointers to fix this would be helpful
TIA,
sthiruva
PS: I do realise that this code will fail badly when run, but this is simplified code to demonstrate the issue