Re: Stuff taking up kernel space

David Schleef (ds@stm.lbl.gov)
Fri, 4 Jun 1999 18:26:10 -0700


On Fri, Jun 04, 1999 at 07:37:04PM +0200, Artur Skawina wrote:
> Dave Jones. wrote:
> >
> > More disturbingly, I notice in the same image that the strings that
> > are printk'd in the macros from include/linux/time.h seem to be
> > occuring quite a lot.
>
> it's a more general problem with string constants that are used in
> "extern inline" functions etc - they end up in every object that
> includes the definitions.
> iirc, at least; i noticed this happening with parport.h a while ago.
>

This suggests a cool ld hack. gcc apparently uniquizes
strings in the compile stage, so I suppose it could make a list
list of string constants (it probably already can), that could
be uniquized at link stage. See the '-fwritable-strings' option in
the gcc man page. This would be useful in general, not just for
the kernel.

Food for thought:

$ objcopy -O binary -R .note -R .comment -S /usr/src/linux/vmlinux
$ ls -l /usr/src/linux/vmlinux
-rwxrwxr-x 1 ds ds 1128448 Jun 4 18:01 vmlinux
$ strings -n 5 /usr/src/linux/vmlinux |wc
6817 17886 129719
$ strings -n 5 /usr/src/linux/vmlinux |sort|uniq|wc
5819 16180 118741

Savings of about 10k, or about 1%. Not too shabby, since it would
be automatic.

dave...

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/