Generating executable for Rocket Chip

Hello everyone,

I’m trying to generate an executable to do the emulation with Rocket Chip.
According to page (in section 2 of Debugging with GDB)

I have to generate the .run file with these 3 commands:

% riscv-gcc -c common/crt.S -o crt.o
% riscv-gcc -c hello.c -o hello.o
% riscv-gcc -T common/test.ld common/syscalls.c -lc hello.o -o

The last command doesn’t work and I receive these errors:

/tmp/ccJNVZKj.o: In function _init': syscalls.c:(.text+0x63c): multiple definition of_init’

/riscv-tools/lib/gcc/riscv64-unknown-elf/7.2.0/…/…/…/…/riscv64-unknown-elf/lib/crt0.o:(.text+0x52): first defined here

/riscv-tools/lib/gcc/riscv64-unknown-elf/7.2.0/…/…/…/…/riscv64-unknown-elf/lib/crt0.o: In function .L0 ': (.text+0x8): undefined reference to_edata’

/riscv-tools/lib/gcc/riscv64-unknown-elf/7.2.0/crtbegin.o: In function deregister_tm_clones': crtstuff.c:(.text+0x0): relocation truncated to fit: R_RISCV_HI20 againstTMC_LIST

/riscv-tools/lib/gcc/riscv64-unknown-elf/7.2.0/…/…/…/…/riscv64-unknown-elf/bin/ld: final link failed: Symbol needs debug section which does not exist
collect2: error: ld returned 1 exit status

In addition I have tried to add the “-mcmodel=medany” option but is the same.

Where is the problem??

Thank you all!