How to properly link libgcc in -ffreestanding mode?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I am trying to follow the steps described in
http://cs107e.github.io/guides/gcc/
to build a freestanding application which is using functions from libgcc

The code I am trying to compile can be found at
https://github.com/ESultanik/mtwister

I guess the problem comes from the usage of the "double" type in thise code.

This is how I invoke compileer and linker:

$ m68k-unknown-elf-gcc -ansi -std=c89 -pedantic -Wall -Wcast-align \
                       -Wstrict-prototypes \
                       -Wmissing-prototypes -Wnull-dereference \
                       -O2 -g -fno-toplevel-reorder -mcpu32 \
                       -ffreestanding -static-libgcc -lgcc \
                       -c -o mtwister.o mtwister.c

$ m68k-unknown-elf-gcc -ansi -std=c89 -pedantic -Wall -Wcast-align \
                       -Wstrict-prototypes \
                       -Wmissing-prototypes -Wnull-dereference \
                       -O2 -g -fno-toplevel-reorder -mcpu32 \
                       -ffreestanding -static-libgcc -lgcc \
                       -Wl,--cref,--section-start=vectors=0 \
                       -nostdlib -Wl,-Ttext=0x400,--entry=entry \
                       -Wl,--oformat,elf32-m68k \
                       -Wl,--cref,-Map,bestd.map \
                       -Wl,-T,ldscript.ld \
                       -o output.elf `cat file.objs`

The linker complains that it can't find __floatunsidf and __divdf3

I have tried to use -Wl,-lgcc instead, but this did not help.

The map file says that libgcc is loaded:

$ grep libgcc *.map
LOAD /m68k-unknown-elf/lib/gcc/m68k-unknown-elf/9.3.0/mcpu32/libgcc.a
LOAD /m68k-unknown-elf/lib/gcc/m68k-unknown-elf/9.3.0/mcpu32/libgcc.a


And I can see that those functions are provided by libgcc:

$ nm /m68k-unknown-elf/lib/gcc/m68k-unknown-elf/9.3.0/mcpu32/libgcc.a|egrep '(__divdf3|__floatunsidf)'
000005a4 T __divdf3
         U __divdf3
         U __divdf3
         U __floatunsidf
         U __floatunsidf
         U __floatunsidf
         U __floatunsidf
         U __floatunsidf
         U __floatunsidf
000000ba T __floatunsidf
         U __divdf3
         U __floatunsidf

What am I missinghere? Any help?

BTW: This is gcc-9.3.0 and binutils-2.34

-- 
Josef Wolf
jw@xxxxxxxxxxxxx



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux