-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
On 11/11/19 10:11, MD. Nazimuddowla wrote:
> Hello all, I am facing a problem while generating binary file from
> .c file. I have used this command
>
> " riscv64-unknown-elf-gcc -o reverse_number -static -std=gnu99
> -fno-common -march=rv32i -mabi=ilp32 -Wa,-march=rv32i
> -nostartfiles -nostdlib -lgcc -Tlink.ld start.s reverse_number.c "
>
> and getting the message,
>
> "reverse_number.c:(.text+0x34): undefined reference to `__modsi3'
> "
Hi MD. Nazimuddowla
You have specified RV32I as your achitecture, so no hardware
multiplication support. This means multiplication related functions
(such as modulo) need to be emulated. This emulation is in the libgcc
library, and includes __modsi3 (modulo of two ints returning an int).
You have specified -nostdlib (no standard libraries), although you
have then manually specified -lgcc. However I am guessing you have
specified it before the code which uses it (reverse_number.c).
The linker takes all its command line items in order, resolving
references in earlier code with libraries provided later on the
command line. In this case the attempt to resolve __modsi3 fails
because its use comes after the provision of -lgcc.
You can either specify the library later in the command line, or
consider whether you need to specify -nostdlib.
HTH,
Jeremy
>
>
> I have installed the toolchain from "
>
https://github.com/riscv/riscv-gnu-toolchain/blob/master/README.md
> " and installed as multilib in my ubuntu 18.04. Only the
> difference, they told to "make linux" but I did "sudo make".
>
> All other things are remain same.
>
> Anyone please tell what did I wrong or what should I do now?
>
>
>
> -- You received this message because you are subscribed to the
> Google Groups "RISC-V Teach" group. To unsubscribe from this group
> and stop receiving emails from it, send an email to
>
riscv-teach...@groups.riscv.org
> <mailto:
riscv-teach...@groups.riscv.org>. To view this
> discussion on the web visit
>
https://groups.google.com/a/groups.riscv.org/d/msgid/riscv-teach/a7976a3d-1963-4e51-be40-8849857a4e92%40groups.riscv.org
>
>
<
https://groups.google.com/a/groups.riscv.org/d/msgid/riscv-teach/a7976a3d-1963-4e51-be40-8849857a4e92%40groups.riscv.org?utm_medium=email&utm_source=footer>.
- --
Tel:
+44 (1590) 610184
Cell:
+44 (7970) 676050
SkypeID: jeremybennett
Twitter: @jeremypbennett
Email:
jeremy....@embecosm.com
Web:
www.embecosm.com
PGP key: 1024D/BEF58172FB4754E1 2009-03-20
-----BEGIN PGP SIGNATURE-----
iEYEARECAAYFAl3JcxwACgkQvvWBcvtHVOG2TACcC3togaS5AyQQ4L3RGhQO6iB5
g6sAn0AxGXRrUefhZc4bXnU+xTkGLsiE
=nvh4
-----END PGP SIGNATURE-----