openhwgroup/corev-binutils-gdb

ld segfault when linking .S assembly file

silabs-hfegran opened this issue · 5 comments

Hi,
Running the following sequence of commands with binutils corev-openhw-gcc-centos7-20230310 results in a segfault. This appear to only happen when the source file for the compile and link command to gcc is a file written in assembly, I have not yet observed this error when the source file is a C-file.

collect2: fatal error: ld terminated with signal 11 [Segmentation fault], core dumped
compilation terminated.

Code located here and is reproducible on my end with the following commands:

riscv32-corev-elf-gcc -Os -g -static -mabi=ilp32 -march=rv32im_zba1p00_zbb1p00_zbc1p00_zbs1p00_zicsr_zca_zcb_zcmp_zcmt_zifencei -Wall -pedantic -mno-relax  -c ./bsp/crt0.S -o ./bsp/crt0.o
riscv32-corev-elf-gcc -Os -g -static -mabi=ilp32 -march=rv32im_zba1p00_zbb1p00_zbc1p00_zbs1p00_zicsr_zca_zcb_zcmp_zcmt_zifencei -Wall -pedantic -mno-relax  -c ./bsp/handlers.S -o ./bsp/handlers.o
riscv32-corev-elf-gcc -Os -g -static -mabi=ilp32 -march=rv32im_zba1p00_zbb1p00_zbc1p00_zbs1p00_zicsr_zca_zcb_zcmp_zcmt_zifencei -Wall -pedantic -mno-relax  -c ./bsp/syscalls.c -o ./bsp/syscalls.o
riscv32-corev-elf-gcc -Os -g -static -mabi=ilp32 -march=rv32im_zba1p00_zbb1p00_zbc1p00_zbs1p00_zicsr_zca_zcb_zcmp_zcmt_zifencei -Wall -pedantic -mno-relax  -c ./bsp/vectors.S -o ./bsp/vectors.o

riscv32-corev-elf-ar rcs ./bsp/libcv-verif.a ./bsp/crt0.o ./bsp/handlers.o ./bsp/syscalls.o ./bsp/vectors.o

// The following gcc invocations both result in segmentation faults:
riscv32-corev-elf-gcc -Os -g -static -mabi=ilp32 -march=rv32im_zba1p00_zbb1p00_zbc1p00_zbs1p00_zicsr_zca_zcb_zcmp_zcmt_zifencei -Wall -pedantic  -I ./bsp  -o generic_exception_test.elf -nostartfiles ./generic_exception_test.S -T ./link.ld -L ./bsp -lcv-verif
riscv32-corev-elf-gcc -Os -g -static -mabi=ilp32 -march=rv32im_zba1p00_zbb1p00_zbc1p00_zbs1p00_zicsr_zca_zcb_zcmp_zcmt_zifencei -Wall -pedantic  -I ./bsp  -o cv32e40s_readonly_csr_access_test.elf -nostartfiles ./cv32e40s_readonly_csr_access_test.S -T ./link.ld -L ./bsp -lcv-verif

@MaryBennett since you are working on the linker just now, could you investigate this one. You may need to consult with @pz9115

@jeremybennett Any updates on this?

Hi @silabs-hfegran, we are currently looking into this fix. We think we have a solution to this issue but we have yet to try it. We are doing a roll-forward with upstream GCC and Binutils for CORE-V. We have got these branches set aside but we are waiting on the clean up patches for Zc*. The GCC patches are ready and currently being reviewed but we are waiting on the patches for Binutils. However, we will release the fix for issue above ASAP but it will not be merged in until we have the Zc* patches.

AP: (MARY) check that this still produces an error with current toolchain release

With the current toolchain release, corev-openhw-gcc-centos7-20231205, this error is not present. Therefore, I am closing this issue and marking it fixed!