On 02/11/2012 14.54, 风涯 wrote: > first an example > > libmya.c > [code] > #include<stdio.h> > void PrintA() > { > printf("A\n"); > } > > __attribute__ ((weak)) > void myfunc() > { > printf("myfunc in libmya\n"); > } > [/code] > > > libmyb.c > [code] > #include<stdio.h> > void PrintB() > { > printf("B\n"); > } > void myfunc() > { > printf("myfunc in libmyb\n"); > } > [/code] > > main.c > > [code] > void main() > { > PrintA(); > PrintB(); > myfunc(); > } > [/code] > > > Makefile > [code] > > CC=gcc > ALL:main > main:main.c libmya.so libmyb.so > ${CC} main.c -L. -Wl,-rpath,. libmya.so libmyb.so -o main -g > libmya.so:libmya.c > ${CC} libmya.c -shared -fPIC -o libmya.so > libmyb.so:libmyb.c > ${CC} libmyb.c -shared -fPIC -o libmyb.so > clean: > rm main *.so *.o *.s > [/code] > > the result is: > A > B > myfunc in libmya > > why the strong symbal int libmyb.so didn't cover the weak one in libmya.so? > > I know it is becuase the _function dl_find_hash in the dl-hash.c do nothing > with the weak symbal . But I think if there is a strong one,we should > choose it rather than weak one.
And this is the correct behaviour, and the only one supported in uClibc. glibc behaves similarly, except if you set LD_DYNAMIC_WEAK. weak are meaningful only for static libraries, not shared. See, for example: http://sourceware.org/bugzilla/show_bug.cgi?id=3946. Regards, Carmelo > > sorry for my bad English... > _______________________________________________ > uClibc mailing list > uClibc@uclibc.org > http://lists.busybox.net/mailman/listinfo/uclibc > > _______________________________________________ uClibc mailing list uClibc@uclibc.org http://lists.busybox.net/mailman/listinfo/uclibc