[RFC] shared busybox as library drop-in replacement

Bernhard Fischer rep.nop at aon.at
Fri Apr 7 14:12:48 UTC 2006


Hi,

I was playing with a different approach of busybox and shared objects.

The previous approach was to build all internally used library functions
into a .so.

In order to use busybox (the binary) as drop-in replacement for e.g. 
-lz, we'd perhaps be better off to build busybox as shared object and
add proper entry-points (e.g. uncompress(), zcalloc(), zcfree(), etc)
to mimic the libs we want to replace. We will of course still work as
an executable, so if we're executed, we run the normal applet-dispatcher
like we currently do.

Would this be an acceptable approach?



PS:
My first quick proposal is currently only tested with elf.

$ ldd busybox
        linux-gate.so.1 =>  (0xffffe000)
        libc.so.6 => /lib/tls/i686/cmov/libc.so.6 (0xb7e82000)
        /lib/ld-linux.so.2 (0xb7fbd000)
$ file busybox
busybox: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV),
stripped
$ ln -sf busybox libx.so
$ cat standalone-app.c 
#include <stdio.h>
#include "busybox.h"
int main (int argc, char **argv)
{
        int ret;
        printf("calling basename_main(%d,%s)\n", 1, argv[1]);
        ret = basename_main(argc, argv);
        printf("return %d\n", ret);
        return ret;
}
$ make -f M
gcc -o bar standalone-app.c -I/home/b/src/bb.lib/include
-I/home/b/obj/bb.lib/include -L. -lx
$ ./bar ././libx.so
calling basename_main(1,././libx.so)
libx.so
$ 



More information about the busybox mailing list