Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 13 Sep 1998 23:17:10 +0000 (GMT)
From:      Terry Lambert <tlambert@primenet.com>
To:        graphix@iastate.edu (Kent A Vander Velden)
Cc:        freebsd-hackers@FreeBSD.ORG
Subject:   Re: Unused functions
Message-ID:  <199809132317.QAA22419@usr04.primenet.com>
In-Reply-To: <199809132056.PAA01179@isua3.iastate.edu> from "Kent A Vander Velden" at Sep 13, 98 03:56:16 pm

next in thread | previous in thread | raw e-mail | index | archive | help
>   Is the code associated with unused functions of a used archive ever removed
> from the executable that uses the archive?  After linking I see with 'nm'
> there are many functions in the executable that are never called.  This is
> making my executable rather large since the archive is huge.  Would elf
> help in anyway with this?

Functions that are called by functions you call will cause code
to be drug in, even if you don't call them directly.

For shared libraries, the symbols are used to look up the
code addresses, and called through a table.  Since the pages
aren't there unless they are used, this is good enough.

For statically linked images, only the functions that are actually
used are linked in.

For static linkage, the smalled chunk you can pull in during the
link is one ".o" file from the archive (library).  So if you have
one ".o" file that resulted from a ".c" file that implements the
functions "bob" and "superbob", you will get both these functions
code, even if you only call one of them.

If this is a problem for you, then consider breaking the file
into two (or more) files to make them seperate compilation units,
and therefore seperate ".o" files, and therefore seperately
linked from the archive (library) file (".a").


					Terry Lambert
					terry@lambert.org
---
Any opinions in this posting are my own and not those of my present
or previous employers.

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199809132317.QAA22419>