Reputation: 19
I am using a linker script to compile a program in riscv64 .I need my ram start address to be higher than 32 bits but whenever i try to modify the address in the linker script i get the following errors:
(.text._start+0x0): relocation truncated to fit: R_RISCV_PCREL_HI20 against symbol
__global_pointer$' defined in *ABS* section in build/bm_uart_test.qemu.elf /tmp/ccU40vjX.o: in function
.L0 ': uart.c:(.text.uart_init+0x14): relocation truncated to fit: R_RISCV_PCREL_HI20 againstuart_base' /tmp/ccU40vjX.o: in function
uart_putc': uart.c:(.text.uart_putc+0xa): relocation truncated to fit: R_RISCV_PCREL_HI20 against `uart_base' collect2: error: ld returned 1 exit status
The make flags are :
AOPS = -march=rv64gc -mabi=lp64d -mcmodel=medany
COPS = -Wall -O2 -static -nostdlib -nostartfiles -ffreestanding -mstrict-align
CFLAGS += $(AOPS) $(COPS) -I include/
LOPTS = -lgcc -Wl,--relax,--orphan-handling=warn,--no-dynamic-linker,--gc-sections,--print-gc-sections,--strip-discarded
LOPTS_QEMU = $(LOPTS) -T bmmap.qemu.ld
CPOPS = -O binary --gap-fil 0
From what i understand up to this point the model medany requires that all global symbols must reside in a -+2GiB window .Since my address is higher than 32 bit ,the linker can't generate an address to reach those symbols and that's why i get the error.Is there any way to fix this ? Please correct my assumptions if they are wrong.I would deeply appreciate any help!
Upvotes: 0
Views: 144