How to properly link libgcc in -ffreestanding mode?
Alexander Monakov
amonakov@ispras.ru
Wed Jan 27 12:07:45 GMT 2021
On Wed, 27 Jan 2021, Josef Wolf wrote:
> $ 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`
>
[...]
> What am I missinghere? Any help?
On the command line, libraries need to come after object files that need them,
because when inspecting the library, the linker unpacks only those archived
object files that would satisfy some undefined symbol already required by
previously linked .o files.
Therefore, in your command line above, -lgcc needs to come after `cat
file.objs`, not before.
Alexander
More information about the Gcc-help
mailing list