Relocation truncated to fit

Hi,

I tried to link applications to non-standard locations, got error messages like:

$ riscv-gaisler-elf-gcc -I. -I../../software/noelv/systest/sw -static -std=gnu99 -O3 -march=rv64ima -mabi=lp64 -DNOELV_SYSTEST  ./obj/*.o -L./ libnoeltests.a -qbsp=2020q4 \
-mcmodel=medany -Tlinkcmds-any -Wl,-Ttext=80000000,-Map=systest.map systest.c -o systest.elf
c:/opt/ncc-1.0.4-gcc/bin/../lib/gcc/riscv-gaisler-elf/10.2.0/rv64ima/lp64/crtbegin.o: in function `deregister_tm_clones':
crtstuff.c:(.text+0x0): relocation truncated to fit: R_RISCV_HI20 against `__TMC_LIST__'
c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(copy_data.c.o): in function `__bcc_copy_data':
/opt/ncc-1.0.4-gcc/src/libbcc/shared/copy_data.c:49:(.text+0x0): relocation truncated to fit: R_RISCV_HI20 against symbol `__data_start_lma' defined in .data section in systest.elf
c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(handle_interrupt.c.o): in function `__bcc_handle_interrupt':
/opt/ncc-1.0.4-gcc/src/libbcc/shared/handle_interrupt.c:41:(.text+0x3c): relocation truncated to fit: R_RISCV_HI20 against symbol `__bcc_isr_list' defined in .bss section in c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(isr.c.o)
c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(int_irqmp_init.c.o): in function `findplic':
/opt/ncc-1.0.4-gcc/src/libbcc/shared/interrupt/int_irqmp_init.c:36:(.text+0x34): relocation truncated to fit: R_RISCV_HI20 against symbol `__bcc_ioarea' defined in .sdata section in c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(ioarea.c.o)
c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(con_apbuart_init.c.o): in function `__bcc_con_init':
/opt/ncc-1.0.4-gcc/src/libbcc/shared/console/con_apbuart_init.c:45:(.text+0x18): relocation truncated to fit: R_RISCV_HI20 against symbol `__bcc_ioarea' defined in .sdata section in c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(ioarea.c.o)
c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(timer_gptimer_init.c.o): in function `__bcc_timer_init':
/opt/ncc-1.0.4-gcc/src/libbcc/shared/timer/timer_gptimer_init.c:68:(.text+0x28): relocation truncated to fit: R_RISCV_HI20 against symbol `__bcc_ioarea' defined in .sdata section in c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(ioarea.c.o)
c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(isr_register_node.c.o): in function `bcc_isr_register_node':
/opt/ncc-1.0.4-gcc/src/libbcc/shared/isr_register_node.c:63:(.text+0x18): relocation truncated to fit: R_RISCV_HI20 against symbol `__bcc_isr_list' defined in .bss section in c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(isr.c.o)
c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(isr_unregister_node.c.o): in function `bcc_isr_unregister_node':
/opt/ncc-1.0.4-gcc/src/libbcc/shared/isr_unregister_node.c:58:(.text+0x4): relocation truncated to fit: R_RISCV_HI20 against symbol `__bcc_isr_list' defined in .bss section in c:/opt/ncc-1.0.4-gcc/bin/../riscv-gaisler-elf/bsp/2020q4/rv64ima/lp64\libbcc.a(isr.c.o)
c:/opt/ncc-1.0.4-gcc/bin/../lib/gcc/riscv-gaisler-elf/10.2.0/../../../../riscv-gaisler-elf/lib/rv64ima/lp64\libc.a(lib_a-exit.o): in function `exit':
/opt/ncc-1.0.4-gcc/src/ncc-1.0.4/newlib/newlib/libc/stdlib/exit.c:60:(.text+0x18): relocation truncated to fit: R_RISCV_HI20 against symbol `_global_impure_ptr' defined in .srodata section in c:/opt/ncc-1.0.4-gcc/bin/../lib/gcc/riscv-gaisler-elf/10.2.0/../../../../riscv-gaisler-elf/lib/rv64ima/lp64\libc.a(lib_a-impure.o)
c:/opt/ncc-1.0.4-gcc/bin/../lib/gcc/riscv-gaisler-elf/10.2.0/../../../../riscv-gaisler-elf/lib/rv64ima/lp64\libc.a(lib_a-fini.o): in function `__libc_fini_array':
/opt/ncc-1.0.4-gcc/src/ncc-1.0.4/newlib/newlib/libc/misc/fini.c:31:(.text+0x8): relocation truncated to fit: R_RISCV_HI20 against symbol `__fini_array_end' defined in .fini_array section in systest.elf
c:/opt/ncc-1.0.4-gcc/bin/../lib/gcc/riscv-gaisler-elf/10.2.0/../../../../riscv-gaisler-elf/lib/rv64ima/lp64\libc.a(lib_a-init.o): in function `__libc_init_array':
/opt/ncc-1.0.4-gcc/src/ncc-1.0.4/newlib/newlib/libc/misc/init.c:35:(.text+0xc): additional relocation overflows omitted from the output
collect2.exe: error: ld returned 1 exit status

how can I avoid it?

Thanks

In addition, the new version of GRLIB relies on NCC that require ‘_Zicsr_Zifencei’ extension support (software/noelv/systest/Makefile, RISCV_ARCH ?= rv$(XLEN)ima_zicsr_zifencei), currently I have temporarily disabled this extension. Do you have any plans to release a new version of NCC ?

Sorry to go back to this issue.

To support a load address of 0x80000000 on a 64-bit target, I need to rebuild the NCC that defaults to medany cmodel, is there any relevant guidance or script available ?

I am trying to port the bcc-2.3.0/ubuild.sh script.

The issue was solved by using the rebuilding version of NCC.