public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: Alexander Monakov <amonakov@ispras.ru>
To: Josef Wolf <jw@raven.inka.de>
Cc: gcc-help@gcc.gnu.org
Subject: Re: How to properly link libgcc in -ffreestanding mode?
Date: Wed, 27 Jan 2021 15:07:45 +0300 (MSK)	[thread overview]
Message-ID: <alpine.LNX.2.20.13.2101271504560.2464@monopod.intra.ispras.ru> (raw)
In-Reply-To: <20210127115423.GA29238@raven.inka.de>

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

  reply	other threads:[~2021-01-27 12:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-27 11:54 Josef Wolf
2021-01-27 12:07 ` Alexander Monakov [this message]
2021-01-27 12:42   ` Jonathan Wakely
2021-01-27 12:43   ` Josef Wolf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LNX.2.20.13.2101271504560.2464@monopod.intra.ispras.ru \
    --to=amonakov@ispras.ru \
    --cc=gcc-help@gcc.gnu.org \
    --cc=jw@raven.inka.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).