why strong symbal not cover weak symbal?

风涯 fengya90 at gmail.com
Fri Nov 2 13:54:52 UTC 2012


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.

sorry for my bad English...


More information about the uClibc mailing list