There are pthread_create symbols in libphread.so, libthread.so and libc.so.
The following symbols displayed with the nm command:

[Index]        Value    Size    Type  Bind  Other  Shndx     Name

[Index]        Value    Size    Type  Bind  Other  Shndx     Name

libc.so
[5003]     |    637360|      36|FUNC |WEAK |0    |9      |_pthread_create
[2867]     |    637360|      36|FUNC |WEAK |0    |9      |pthread_create

libpthread.so
[291]       |     14964|       8|FUNC |GLOB |0    |7      |_pthread_create
[283]       |     14964|       8|FUNC |WEAK |0    |7      |pthread_create

libthread.so
[658]       |     48640|     712|FUNC |GLOB |0    |9      |_pthread_create
[259]       |     48640|     712|FUNC |LOCL |0    |9      |_ti_pthread_create
[662]       |     48640|     712|FUNC |WEAK |0    |9      |pthread_create


The pthread_create() returns -1 linking only libc.so, and work properly 
linking both libc.so and libpthread.so in spite of link's ordering.
I understand it is realized using "#pragma weak", so I tried to make a program
to do the same in the following programs, but I can't. 
The foo() returns 0 in main.c when linking libfoo.so before libdummy.so, 
that is to say, "cc main.c -lfoo -ldummy", but foo() returns -1 when linking 
libdummy.so before libfoo.so, that is to say, "cc main.c -ldummy -lfoo".
Could someone tell me about this mechanism?   

---------------------
in main.c
main()
    {
      foo();
    }
---------------------
in libdummy.so
#pragma weak foo
 int foo() 
    {
       return -1;
     } 
---------------------
in libfoo.so
#pragma weak foo = _foo
 int _foo() 
     {
       return 0;
     }
---------------------
 
 
This message posted from opensolaris.org
_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to