linux-c-programming.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hendrik Visage <hvjunk@gmail.com>
To: Glynn Clements <glynn@gclements.plus.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 07:17:31 +0200	[thread overview]
Message-ID: <d93f04c70602012117v6998ef94k3e87a9a3820a45f9@mail.gmail.com> (raw)
In-Reply-To: <17373.1722.484465.747500@cerise.gclements.plus.com>

On 1/29/06, Glynn Clements <glynn@gclements.plus.com> wrote:
>
> Shriramana Sharma 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?
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(). that's the reason why static
libraries makes use of small objects to minimize the stuff linked in.

obj1.c:
int a(){return 1;}
int b(){return 2;}

obj2.c
int c(){return 3;}
int d(){return 4;}

main.c
int main(){
 return a();
}

--
Hendrik Visage

  reply	other threads:[~2006-02-02  5:17 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 [this message]
2006-02-02 16:39     ` Glynn Clements

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=d93f04c70602012117v6998ef94k3e87a9a3820a45f9@mail.gmail.com \
    --to=hvjunk@gmail.com \
    --cc=glynn@gclements.plus.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).