From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7591 invoked by alias); 28 Jun 2006 21:20:24 -0000 Received: (qmail 7583 invoked by uid 22791); 28 Jun 2006 21:20:24 -0000 X-Spam-Check-By: sourceware.org Received: from dessent.net (HELO dessent.net) (69.60.119.225) by sourceware.org (qpsmtpd/0.31) with ESMTP; Wed, 28 Jun 2006 21:20:22 +0000 Received: from localhost ([127.0.0.1] helo=dessent.net) by dessent.net with esmtp (Exim 4.61) (envelope-from ) id 1FvhSN-0006Mb-QD for gcc-help@gcc.gnu.org; Wed, 28 Jun 2006 21:20:19 +0000 Message-ID: <44A2F293.7353A1FF@dessent.net> Date: Wed, 28 Jun 2006 21:20:00 -0000 From: Brian Dessent Reply-To: gcc-help@gcc.gnu.org X-Mailer: Mozilla 4.79 [en] (Windows NT 5.0; U) MIME-Version: 1.0 To: gcc-help@gcc.gnu.org Subject: Re: Symbols which were not used, still in binary References: <44A2DF65.8010704@web.de> <44A2E3C9.90201@eagercon.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact gcc-help-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Archive: List-Post: List-Help: Sender: gcc-help-owner@gcc.gnu.org X-SW-Source: 2006-06/txt/msg00266.txt.bz2 Michael Eager wrote: > Arguably, the linker should know > that add is not referenced and could remove it, but linkers are not > usually able to slice and dice object files. You address this limitation by compiling with "-ffunction-sections -fdata-sections -Wl,--gc-sections". However, it's still better to use "static" on these kinds of local functions that are only used from the same .o file. This has a number of benefits: - it ensures that internal functions of a library are not exported for use by other code when they are not part of the defined ABI/API - it prevents them from taking up needless relocations, which can slow linking - when compiled -fpic (as in a shared library) it allows for direct calls to the function instead of having to go through the PLT which is slower - it allows the compiler freedom to inline Brian