-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Description
Hi,
I'm trying to test the -mcmodel=large
option. When I compiled a simple C code program, I received a linker error. Here are the steps to reproduce the issue:
• Riscv-gnu-toochain compilation:
configure --with-arch=rv64imafc --with-abi=lp64f --with-cmodel=large --prefix=/toolchain/gnu-workspace/install-gnu-toolchain-upstream MAKEINFO=true
make MAKEINFO=true -j 8
• C code file(main.c):
#include <string.h>
__attribute__((section(".far_dccm"))) const char* G_s1 = "Str1";
__attribute__((section(".far_dccm"))) const char* G_s2 = "Str2";
void main()
{
if(strcmp(G_s1,G_s2)) return;
}
• Linker script file(link.ld):
ENTRY(main)
MEMORY
{
BRAM (rx) : ORIGIN = 0x00000000, LENGTH = 256K
DCCM (rw) : ORIGIN = 0xAA00000000, LENGTH = 256K
}
SECTIONS
{
.text :
{
*(.text*)
} > BRAM
.far_dccm :
{
*(.srodata .srodata.*)
} > DCCM
}
• Compilation command:
riscv64-unknown-elf-gcc main.c -o main.elf -T link.ld -mabi=lp64f -march=rv64imafc -mcmodel=large -nostartfiles
• Compilation error:
repos/cmodel-demo/toolchains/install-gnu-toolchain-upstream/bin/../lib/gcc/riscv64-unknown-elf/14.2.0/../../../../riscv64-unknown-elf/lib/libc.a(libc_a-strcmp.o): in function strcmp': (.text+0xa): relocation truncated to fit: R_RISCV_PCREL_HI20 against
mask'
collect2: error: ld returned 1 exit status