lkml.org 
[lkml]   [2002]   [Feb]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Re: crc32 and lib.a (was Re: [PATCH] nbd in 2.5.3 does
On Fri, Feb 01, 2002 at 11:30:20PM -0800, Chris Wedgwood wrote:
> Is there no way to write something like:
>
> --snip-- foo.c --snip--
> void
> blem()
> {
> }
>
> void
> bar()
> {
> blem();
> return 0;
> }
>
> int foo()
> {
> return 1;
> }
>
> int main(...)
> {
> return foo();
> }
> --snip-- foo.c --snip--
>
> compile and link it, have the linker know main or some part of crt0 is
> special, build a graph of the final ELF object, see that bar and blem
> are not connected to 'main' and discard them?
>
> I'm pretty sure (but not 100% certain) that oher compilers can do
> this, maybe someone can test on other platforms?
>
> A really smart linker (if given enough compiler help) could build a
> directional graph and still remove this code even if blem called foo.

One piece of the necessary compiler help would be -ffunction-sections.
If they are in the same section in the same object file, they simply
can not be removed safely. Relocation information for calls to local
functions is not reliably available at link time.


--
Daniel Jacobowitz Carnegie Mellon University
MontaVista Software Debian GNU/Linux Developer
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:23    [from the cache]
©2003-2011 Jasper Spaans