SoftFloat using -march=rv32i and -mabi=ilp32

349 views
Skip to first unread message

Waleed Bin Ehsan

unread,
Jan 26, 2021, 11:33:46 PM1/26/21
to RISC-V SW Dev
I have downloaded and installed a newer tool-chain. By using the following commands

./configure --prefix=/opt/riscv --enable-multilib
sudo make

After that i ran the
/opt/riscv/bin/riscv64-unknown-elf-gcc /home/waleedbinehsan/Desktop/main.c -lm -lgcc -march=rv32i -mabi=ilp32 -o main

Yet still its calling the __adddf3 routines how can i get the asm file that have been linked the respective libraries call

Waleed Bin Ehsan

unread,
Jan 27, 2021, 3:02:59 AM1/27/21
to RISC-V SW Dev, Waleed Bin Ehsan

I actually want to run the code on a core, so I made object file using the following command
''/opt/riscv/bin/riscv64-unknown-elf-gcc -I SweRV-Original/SweRV-EL2_older_release/snapshots/default/ -g -O3 -funroll-all-loops -mabi=ilp32 -march=rv32imc -nostdlib -c main.c -o main.o''

After that to make the exe file i used the following command
''/opt/riscv/bin/riscv64-unknown-elf-ld -m elf32lriscv --discard-none -T SweRV-Original/SweRV-EL2_older_release/testbench/link.ld -o main.exe main.o''

But now I am getting errors such as:
/opt/riscv/bin/riscv64-unknown-elf-ld: /home/waleedbinehsan/Desktop/main.c:118: undefined reference to `__adddf3'

Tommy Murphy

unread,
Jan 27, 2021, 5:02:00 AM1/27/21
to RISC-V SW Dev, waleed...@lampromellon.com
A list or map file will tell you where/why such symbols are being sought.

thomas.h...@googlemail.com

unread,
Jan 28, 2021, 2:18:58 AM1/28/21
to RISC-V SW Dev, waleed...@lampromellon.com
You may need to add the -lm to your linker command line to add libm (math library) 

Waleed Bin Ehsan

unread,
Jan 28, 2021, 2:21:14 AM1/28/21
to thomas.h...@googlemail.com, RISC-V SW Dev

I tried these commands too
To generate the object file
/opt/riscv/bin/riscv64-unknown-elf-gcc -I SweRV-Original/SweRV-EL2_older_release/snapshots/default/ -g -O3 -funroll-all-loops -lgcc -lm -mabi=ilp32 -march=rv32imc -c main.c -o main.o

To generate exe file
/opt/riscv/bin/riscv64-unknown-elf-ld -m elf32lriscv -lgcc -lm --discard-none -T SweRV-Original/SweRV-EL2_older_release/testbench/link.ld -o main.exe main.o

After this command i am getting the following error:
image

Regards,
Waleed Bin Ehsan
Associate Design Engineer
Lampro Mellon

thomas.h...@googlemail.com

unread,
Jan 28, 2021, 2:43:04 AM1/28/21
to RISC-V SW Dev, waleed...@lampromellon.com, RISC-V SW Dev, thomas.h...@googlemail.com

For the second error I‘m not entirely sure, but calling the linker directly with ld is a bit unusual. I‘m always using gcc also for invoking the linker step. It is an universal frontend which automatically call all the tools. In your case (one source file) you can even run compile and link in one step: Just replace the last part ofriscv64-unknown-elf-ld with -gcc and replace main.o with main.c.
Move the -l options to the end of your command line (behind main.c)

Waleed Bin Ehsan

unread,
Jan 28, 2021, 4:01:34 AM1/28/21
to thomas.h...@googlemail.com, RISC-V SW Dev
Thanks Now i'm getting this warning, is it ok?
image.png


Regards,
Waleed Bin Ehsan
Associate Design Engineer
Lampro Mellon

thomas.h...@googlemail.com

unread,
Jan 28, 2021, 6:14:52 AM1/28/21
to RISC-V SW Dev, waleed...@lampromellon.com, RISC-V SW Dev, thomas.h...@googlemail.com
The warning is expected as you have set the option --nostartfiles and did not provide an own start up file. 
You can remove the --nostartfiles option, than your program should link correctly, and would run on e.g. QEMU or Spike.
When you want to use in some "bare-metal" environment (I assume that your are trying to run it on a simulation or FPGA implementation of the SweRV core) you need a start-up code which initialized the environment in the correct way. You may also need newlib stub implementations for i/o in case your program intends to sent some output over e.g. an UART.
I think there are example programs for your processor core which contain startup code, etc. 

Waleed Bin Ehsan

unread,
Jan 28, 2021, 7:01:26 AM1/28/21
to thomas.h...@googlemail.com, RISC-V SW Dev
Thank you for the clarification. Fixed by writing asm in the c-file by declaring start and finish in asm. Again thanks very much

Regards,
Waleed Bin Ehsan
Associate Design Engineer
Lampro Mellon

Reply all
Reply to author
Forward
0 new messages