Re: [PATCH] Re: crc32 and lib.a (was Re: [PATCH] nbd in 2.5.3 does

From: Daniel Jacobowitz (dan@debian.org)
Date: Sat Feb 02 2002 - 02:42:36 EST


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/



This archive was generated by hypermail 2b29 : Thu Feb 07 2002 - 21:00:21 EST