lkml.org 
[lkml]   [2010]   [Jan]   [8]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] Allow linker to eliminate unused functions in lib/*
On Tue, 5 Jan 2010 15:59:18 +0100
Andi Kleen <andi@firstfloor.org> wrote:

> Allow linker to eliminate unused functions in lib/*
>
> Right now a lot of code in lib/* is obj-y and always linked
> in. The reason is that there is no other way to ensure the EXPORT_SYMBOLs
> get included.
>
> This patch moves the EXPORT_SYMBOLs into separate files instead. This
> way the files actually implementing the code can be made lib-y again,
> and the separate export symbols pull them in for modular kernels.
>
> For non modular kernels the linker can decide whether to use them
> or not.
>
> This shrinks a allnoconfig+CONFIG_EMBEDDED=y+all options disabled
> kernel by about 1k on x86. Not much, but also not too shabby.
>
> In some ways that's similar to the old ksyms.c files, but
> not as centralized.
>
> I didn't do this for the functions in lib/* which already have
> Kconfig symbol. Presumably that is usually only set on demand
> when they are actually needed (although I'm not sure it's true
> for all cases).
>

Sneaky.

It's a bit sad to reduce the code cleanliness and maintainability in
this way, but 1k is 1k.

Removing the module.h include from the .c files will hopefully help
people realise that new exports shouldn't be added to the .c files.

> --- linux-2.6.33-rc2-ak.orig/lib/lib-syms.c
> +++ linux-2.6.33-rc2-ak/lib/lib-syms.c
> @@ -5,9 +5,13 @@
> * On modular kernels it keeps a reference to all the lib files with
> * exports so that they can be used by modules. On non modular
> * kernels it does nothing and the linker can decide whether a lib
> - * object file is needed or not.
> + * object file is needed or not. This way unneeded library functions
> + * can be eliminated.
> */

The patch assumes a pre-existing lib-syms.c. Confused.


\
 
 \ /
  Last update: 2010-01-09 01:33    [from the cache]
©2003-2011 Jasper Spaans