Hardware loops causes relocation truncated to fit: R_RISCV_CVPCREL_UI12
Reproducer
File test.c.tar.gz:
int *c;
int d[12];
int e;
_start ()
{
volatile a = b ();
}
f ()
{
short g, h;
for (; e;)
{
g = 0;
for (; g < 8; g++)
{
h = 0;
for (; h < 4; h++)
d[h] = c[h] = d[0];
}
}
}
b ()
{
return f;
}
Run with
riscv32-corev-elf-gcc -march=rv32imac_zicsr_xcvhwlp -mabi=ilp32 -Os \
-Wno-implicit-function-declaration -Wno-implicit-int -Wno-int-conversion \
-nostdlib -nostartfiles -o test.exe test.c
Output is
/tmp/ccJN19DD.o: in function `.L9':
test.c:(.text+0x3c): relocation truncated to fit: R_RISCV_CVPCREL_UI12 against `.L3'
collect2: error: ld returned 1 exit status
System information
Using built-in specs.
COLLECT_GCC=riscv32-corev-elf-gcc
COLLECT_LTO_WRAPPER=/home/jeremy/gittrees/dolphin/install/libexec/gcc/riscv32-corev-elf/14.0.0/lto-wrapper
Target: riscv32-corev-elf
Configured with: ../../gcc/configure --target=riscv32-corev-elf --prefix=/home/jeremy/gittrees/dolphin/install --with-sysroot=/home/jeremy/gittrees/dolphin/install/riscv32-corev-elf --with-native-system-header-dir=/include --with-newlib --disable-shared --enable-languages=c,c++ --enable-tls --disable-werror --disable-libmudflap --disable-libssp --disable-quadmath --disable-libgomp --disable-nls --enable-multilib --with-multilib-generator='rv32i-ilp32--c rv32ia-ilp32--m rv32im-ilp32--c rv32if-ilp32f-rv32ifd-c rv32iaf-ilp32f-rv32imaf,rv32iafc-d rv32imf-ilp32f-rv32imfd-c rv32iac-ilp32-- rv32imac-ilp32-- rv32imafc-ilp32f-rv32imafdc- rv32ifd-ilp32d--c rv32imfd-ilp32d--c rv32iafd-ilp32d-rv32imafd,rv32iafdc- rv32imafdc-ilp32d--' --with-arch=rv32imac --with-abi=ilp32 : (reconfigured) ../../gcc/configure --target=riscv32-corev-elf --prefix=/home/jeremy/gittrees/dolphin/install --with-sysroot=/home/jeremy/gittrees/dolphin/install/riscv32-corev-elf --with-native-system-header-dir=/include --with-newlib --disable-shared --enable-languages=c,c++ --enable-tls --disable-werror --disable-libmudflap --disable-libssp --disable-quadmath --disable-libgomp --disable-nls --enable-multilib --with-multilib-generator='rv32i-ilp32--c rv32ia-ilp32--m rv32im-ilp32--c rv32if-ilp32f-rv32ifd-c rv32iaf-ilp32f-rv32imaf,rv32iafc-d rv32imf-ilp32f-rv32imfd-c rv32iac-ilp32-- rv32imac-ilp32-- rv32imafc-ilp32f-rv32imafdc- rv32ifd-ilp32d--c rv32imfd-ilp32d--c rv32iafd-ilp32d-rv32imafd,rv32iafdc- rv32imafdc-ilp32d--' --with-arch=rv32imac --with-abi=ilp32
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 14.0.0 20230928 (experimental) (GCC)