Truncation of relocation to fit: R_RISCV_PCREL_L012_I against '.L0
riffraffff opened this issue · 1 comments
when I execute the command 'make qemu'
I meet the error is that "Truncation of relocation to fit: R_RISCV_PCREL_L012_I against '.L0"
I've commented out the code in the corresponding file, but similar errors still occur in other files. Can someone help me?
I deployed the project on the Linux virtual machine(Ubuntu 18.04.6)
Hi there, I resolved it last year, and I finally added "mcmodel=medany," and it worked. Simply put, "mcmodel" is an instruction that guides the compiler on how to produce the access instructions for global variables. As you may know, the accessible address of a variable is PC-relative (PC ± 2G), so using "medany" instructs the compiler to generate Position Independent Code.
You might be confused about why your variables have exceeded 2G. That's because the .text is at 0x8000_0000, which is 2^(32-1) = 2G. You can test this by modifying the number in the linker script, changing it to 0x4000_0000. It compiles successfully, but RISC-V64 won't actually run it.