[PATCH] RFC: reduce static data usage

Denis Vlasenko vda.linux at googlemail.com
Sun Jul 29 14:26:07 UTC 2007

On 7/23/07, Bernhard Fischer <rep.dot.nop at gmail.com> wrote:
> >These six patches make uclibc malloc big(ger) buffers instead of
> >keeping them in data/bss - should help NOMMU people.
> >
> >patch #1: introduce __uc_malloc, so that users can intercept OOM.
> >patch #2: convert des.c to use __uc_malloc (-70 kbytes of bss)
> >patch #3: convert resolv.c
> >patch #4: convert pwd_grp.c
> >patch #5: convert utent.c, getpass.c
> >patch #6: convert getnetent.c, md5.c
> >
> >This deals with almost all buffers bigger than 100 bytes.
> >We pay in code size for that (+20 - +40 bytes per module
> >on i386):
> Sounds like a good idea to me, fwiw.
> The '//' comments should be converted to '/**/' imo, but that's just
> cosmetics. Also, i think that you should hide all stuff that is exported
> in __uc_malloc.c (see hidden_proto/hidden_def et al).
> Care to take this into account?

Will do. Things slowed down here due to dead ISP link at home.

I was looking into ways of building smallest static busybox and
I found out that -fomit-stack-pointer isn't added by uclibc
Makefile machinery even for static lib build - would be nice to fix.
So far, I added that to UCLIBC_EXTRA_CFLAGS and gained ~1k, I think.

But the biggest thing was adding -ffunction-sections -fdata-sections -
linker found and threw out around ~6k of unused objects!

Another nice side effect is that in this mode (when you have
code in .text.function, not just in .text) default .text alignment of 4 bytes
doesn't apply and code has no NOPs inserted between every two functions.

BTW, any idea how to make .text byte-aligned? I mean:

$ objdump -x crt1.o
crt1.o:     file format elf32-i386
architecture: i386, flags 0x00000011:
start address 0x00000000
Idx Name          Size      VMA       LMA       File off  Algn
  0 .text         00000022  00000000  00000000  00000034  2**2 <=== THIS ONE

I'd like to see 2**0 there.

Anyway. with -ffunction-sections -fdata-sections amount of padding went down
so far that smaller sources of useless padding become visible:
1. int global_n; char global_c, int global_m;
   -- how to make linker sort .bss.global_XXX according to alignment
   (or at least by size)
2. some .align 16 / .align 4 in uclibc code. I believe these are some kind
   of leftovers and I will remove them in svn. (Revert if I'm wrong).


More information about the uClibc mailing list