I want to create a very small (preferably ~20KB) statically linked
application, which is used during boot sequence. This application will
be on a minimal distribution of a Linux system.
When I linked my application with -static and -s parameters, the size
was around 120KB. Of those, my application consists of around 20KB, and
uses exit(), malloc() and free(). Of those, I can do without malloc()
and free() with a little re-design.
But somehow, I doubt that the code for exit(), malloc() and free() is
100KB big! So I made a map file to see what happens. Well, the entry and
exit code needs the hole file library (which I don't use) and also
printf() with all the things that takes with it!!
I looked at the sources for the library (glibc-2.1.1pre3) and tried to
see if I could do my own version, with just the entry and exit code. But
I don't understand the code.
As for entry code, it seems to be like this:
ctr0.o -> _start (/sysdeps/i386/elf/start.S)
_start -> __libc_start_main (/sysdeps/generic/libc_start.c)
__libc_start_main -> __libc_init_first (/sysdeps/i386/init-first.c)
__libc_start_main -> (*init)()
__libc_start_main -> (*main)()
__libc_start_main -> exit()
exit() -> _cleanup()
exit() -> _exit()
As far as I can see, I could redefine __libc_start_main to make it skip
the call to __libc_init_first, as I do not have any use of argc, argv or
argp. So far so good.
But I cannot find _exit()!! I'm running on a elf i386 Linux platform,
and there seems to be _exit() defined for all other platforms except
i386...
So my questions are:
1) Is there something bad about skipping __libc_init_first in my case?
2) Where is i386 version of _exit()?
Thanks in advance for any help!
/Mats