[buildroot] $(STRIP) --strip-unneeded on a SHARED library...WHY?

John Z. Bohach jzb at aexorsyst.com
Tue Dec 6 19:46:08 UTC 2005


On Tuesday 06 December 2005 10:21, Mike Frysinger wrote:
> On Tue, Dec 06, 2005 at 09:20:01AM -0800, John Z. Bohach wrote:
> > On Tuesday 06 December 2005 08:44, Paul Fox wrote:
> > > we use --strip-unneeded too, and it's fine.  but it's fine for
> > > runtime.  is it perhaps the case that libraries stripped like
> > > that can no longer be used in development?
> >
> > BINGO.  Executables that have been linked have addresses hardwired where
> > the symbols were.
>
> no, that isnt how linking works
>
> executables store a list of all needed external symbols and a list of
> all needed libraries
>
> for example:
> $ echo 'int foo() { return 123; }' > libfoo.c
> $ gcc -fPIC -shared -s libfoo.c -o libfoo.so
> $ strip --strip-unneeded libfoo.so
> $ readelf -s libfoo.so | grep foo
>     16: 0000000000000678    11 FUNC    GLOBAL DEFAULT   10 foo
>
> $ cat << EOF > striptest.c
> #include <stdio.h>
> extern int foo(void);
> int main() { printf("%i\n", foo()); return 0; }
> EOF
> $ gcc striptest.c -L. -Wl,-rpath,. -lfoo -o striptest
> $ readelf -a striptest | grep foo
>  0x0000000000000001 (NEEDED)             Shared library: [libfoo.so]
>      7: 0000000000000000    11 FUNC    GLOBAL DEFAULT  UND foo
> $ ./striptest
> 123
>1
> seems to me it worked just fine
> -mike

Well, thanks for the comments.  What you all are saying is true, I'll focus in 
on the cross-toolchain, which is what its looking like, since STRIP gets 
defined as i486-linux-strip in my buildroot...What I do know is that if I 
don't STRIP the shared libs, then all is fine even for the cross-toolchain.

Thanks again...

(P.S.:  stripping --strip-unneeded natively is working fine, so I guess its 
just the cross-toolchain stripper that causes problems for me).




More information about the busybox mailing list