linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Glynn Clements <glynn@gclements.plus.com>
To: Hendrik Visage <hvjunk@gmail.com>
Cc: Shriramana Sharma <samjnaa@gmail.com>,
	Linux C Programming List <linux-c-programming@vger.kernel.org>
Subject: Re: Does GCC link only used functions?
Date: Thu, 2 Feb 2006 16:39:48 +0000	[thread overview]
Message-ID: <17378.13780.99415.165938@cerise.gclements.plus.com> (raw)
In-Reply-To: <d93f04c70602012117v6998ef94k3e87a9a3820a45f9@mail.gmail.com>


Hendrik Visage wrote:

> > > So does this mean that GCC links only those functions from a library which I
> > > call directly or indirectly through another called function in the course of
> > > my program?
> 
> > For a static library (which is just an archive of object files), the
> > linker will only use those object files which are necessary to satisfy
> > any outstanding references.
> 
> That means that all the functions and everything in that object file
> is included?

Yes. The linker can't include specific portions of an object file.

> thus given the lib.a contains obj1.o and obj2.o compiled from obj1.c &
> obj2.c below,
> the program main from main.c below, linked with lib.a will contain the
> obj1.o part, which
> will also include the superflouos int b() (That's the way I understood
> it too), but not obj2 with c() & d().

Correct.

-- 
Glynn Clements <glynn@gclements.plus.com>

      reply	other threads:[~2006-02-02 16:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-29  9:08 Does GCC link only used functions? Shriramana Sharma
2006-01-29 16:23 ` Steve Graegert
2006-01-29 18:17 ` Glynn Clements
2006-02-02  5:17   ` Hendrik Visage
2006-02-02 16:39     ` Glynn Clements [this message]

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=17378.13780.99415.165938@cerise.gclements.plus.com \
    --to=glynn@gclements.plus.com \
    --cc=hvjunk@gmail.com \
    --cc=linux-c-programming@vger.kernel.org \
    --cc=samjnaa@gmail.com \
    /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 NNTP newsgroup(s).