From owner-freebsd-hackers Sun Sep 13 16:17:51 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id QAA19141 for freebsd-hackers-outgoing; Sun, 13 Sep 1998 16:17:51 -0700 (PDT) (envelope-from owner-freebsd-hackers@FreeBSD.ORG) Received: from smtp03.primenet.com (smtp03.primenet.com [206.165.6.133]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id QAA19127 for ; Sun, 13 Sep 1998 16:17:47 -0700 (PDT) (envelope-from tlambert@usr04.primenet.com) Received: (from daemon@localhost) by smtp03.primenet.com (8.8.8/8.8.8) id QAA19220; Sun, 13 Sep 1998 16:17:17 -0700 (MST) Received: from usr04.primenet.com(206.165.6.204) via SMTP by smtp03.primenet.com, id smtpd019211; Sun Sep 13 16:17:12 1998 Received: (from tlambert@localhost) by usr04.primenet.com (8.8.5/8.8.5) id QAA22419; Sun, 13 Sep 1998 16:17:11 -0700 (MST) From: Terry Lambert Message-Id: <199809132317.QAA22419@usr04.primenet.com> Subject: Re: Unused functions To: graphix@iastate.edu (Kent A Vander Velden) Date: Sun, 13 Sep 1998 23:17:10 +0000 (GMT) Cc: freebsd-hackers@FreeBSD.ORG In-Reply-To: <199809132056.PAA01179@isua3.iastate.edu> from "Kent A Vander Velden" at Sep 13, 98 03:56:16 pm X-Mailer: ELM [version 2.4 PL25] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > 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