Problem with shared_flat_add_library

Jayant R. Sonar Jayant.Sonar at kpitcummins.com
Wed Jan 25 13:07:15 UTC 2012


Hi,

I am working on National Semiconductor’s CR16 architecture. 
I am facing a problem with 'shared_flat_add_library' function. 

My application uses C library (lib1.so) and user library (lib3.so).
As I understand, shared library initialization inside uClibc proceeds as:
1. shared_flat_add_library(): 
     a. adding lib1.so into the linked list
     b. adding lib3.so into the linked list
     c. adding app.out into the linked list
2. shared_flat_init()
     a. Calling initialization routines of lib1.so 
     b. Calling initialization routines of lib3.so 
     c. Calling initialization routines of app.out 

'shared_flat_add_library()' does the part of adding each loaded library into 
the linked list. It adds application binary as well. 

I believe, in my case it is failing to add user library in this list. 
This further results it's init routines not being called at all.

Please refer the application execution dump given below.
This is taken with the help of various fprintfs placed inside 2 files- 
'shared_flat_add _library.c' and 'shared_flat_initfini.c'.

============================================================================
Entering shared_flat_add_library
                                       << Lib1.so >>
Initial first_shared_lib 0, 
Initial last_shared_lib 0
&this_lib e65254
Update first_shared_lib e65254
Updated last_shared_lib e65254
                                        << Lib3.so >>
Initial first_shared_lib 0    ⇐⇐⇐⇐⇐⇐⇐<< PROBLEM >>
Initial last_shared_lib 0
&this_lib 7c9990
Update first_shared_lib 7c9990
Updated last_shared_lib 7c9990
                                        << App.out >>
Initial first_shared_lib e65254
Initial last_shared_lib e65254
this_lib 79d3cc
Update first_shared_lib e65254
Updated last_shared_lib 79d3cc


Entering shared_flat_init 

calling init routine no 0                 << Lib1.so initialization >>
calling init routine addr de139
init_array_start e65c18
init_array_end e65c18

calling init routine no 1                 << App.out initialization >>
calling init routine addr 3cd4e6
init_array_start 79d418
init_array_end 79d42C
From the init_array_start, calling routine no 0

Leaving shared_flat_init

                                          << Application output dump >>
In user main(), Starting ./app.out... 
In user_lib_func, called from user main
In user main(), user_lib_func() returned 1


Entering shared_flat_fini
calling fini routine no 0                 << lib1.so fini code >>
calling fini routine no 1                 << app.out fini code >>
============================================================================

As can be seen above 'shared_flat_add_library()' iterates in loop thrice.
Whereas 'shared_flat_init()' iterates only twice.

During addition of lib1.so in linked list:
Values of 3 variables - 'first_shared_lib', 'last_shared_lib' and 
'this_lib', are zero which are default ones. 

During addition of app.out in linked list:
Value of 'first_shared_lib' is e65254 i.e. address of lib1.so’s 'this_lib'. 
That means these 2 binaries – 'lib1.so' and 'app.out' - are properly joined 
in linked list. 

During addition of lib3.so:
Value of 'first_shared_lib' is still zero which is improper. That means this 
does not become part of the linked list at all.

Is this an expected behavior?
Or user lib should also get added into this linked list?
In that case, any clue why it would be failing to register 'lib3.so' into 
the linked list?

Further 'shared_flat_init()' iterates through elements of this linked list. 
Hence init routines of 'lib1.so' and 'app.out' get called. 
However, those of 'lib3.so' never get called.

PFA, compilation commands used for compiling the application and library. 

Thanks and Regards,
Jayant Sonar
[KPIT Cummins]






-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: compilation-commands.txt
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20120125/03cd5931/attachment.txt>


More information about the uClibc mailing list