Simulation problem with stdlib


I want to implement some programs using the stdlib library, and then simulating it using modelsim. It compil just fine with the gaisler toolchain, but when i run the simulation, malloc() always return NULL and rand( return the following error message :

assertion "REENT malloc succeeded" failed: file "/opt/ncc-1.0.0-gcc/src/ncc-1.0.0/newlib/newlib/libc/stdlib/random.c", line 76

I haven’t tested all the fonction included from stdlib.h, but some seem to function, like atoi().

I think I do not use the right option when compiling, but I do not know which option I am not using correctly. When compiling, I use the same option as the example program (when using make soft) :

riscv-gaisler-elf-gcc -I./../../software/noelv/systest -Isw -mcmodel=medany -static -std=gnu99 -O2 -march=rv64imafd -mabi=lp64d -Wl,--no-gc-sections -nostdlib -T./../../software/noelv/systest/ ./../../software/noelv/systest/prom.S -o prom.elf
riscv-gaisler-elf-objcopy --srec-len=16 --srec-forceS3 --gap-fill=0 --remove-section=.comment --remove-section=.riscv.attributes -O srec prom.elf prom.srec
riscv-gaisler-elf-gcc -I./../../software/noelv/systest -Isw -mcmodel=medany -static -std=gnu99 -O2 -march=rv64imafd -mabi=lp64d -Wl,--no-gc-sections -c ./../../software/noelv/systest/report_device.c
riscv-gaisler-elf-ar -cr libnoeltests.a
riscv-gaisler-elf-gcc -I./../../software/noelv/systest -Isw -mcmodel=medany -static -std=gnu99 -O0 -march=rv64imafd -mabi=lp64d -Wl,--no-gc-sections report_device.o -L./ libnoeltests.a -qbsp=2020q4 test_perso/hello.c -o systest.elf
riscv-gaisler-elf-objcopy --srec-len=16 --srec-forceS3 --gap-fill=0 --remove-section=.comment --remove-section=.riscv.attributes -O srec systest.elf ram.srec

If you have compiled programs using stdlib, especially function like malloc() or rand(), could you tell me the way to make it work for me ? For information, I use the noelv_generic design with the single-issued GPP64 configuration.