Problem with shared library

Naveen H. S Naveen.S at kpitcummins.com
Thu Jan 5 06:34:13 UTC 2012


>> We are implementing uclibc port for CR16 target with shared library 
>> support. However, there was an issue observed during testing the port 
>> with shared library.

> and what changes did you make how do we know ?

Hi,

Thanks for reviewing the mail and sending your feedback.

We are working on the uClibc port for CR16 architecture. Please find
attached the patch "uclibc-cr16.patch" for CR16 port. It has some 
target specific changes in generic files. However, we are working on
stabilizing the port first. The version of the uClibc used is
0.9.30.1 and uClinux Kernel- 2.6.19-uc1.

Currently we are facing a problem with the ID shared library routines
declared with __attribute__ ((constructor)). These routines are not 
getting called before user main function, as expected.

e.g. A shared library with ID 3 is created from the following source
code. 
=======================================================================
static int val = 1 ;

void lib_init ( void ) __attribute__((constructor)); 
void lib_init( void )
{        printf(“\n Entering constructor…”);
         val = 13 ;       }

int lib_func ( const char* s )
{  printf( "\t Entering %s, called from %s\n\n", __FUNCTION__, s ) ;
   return val ; 
}
=======================================================================

From the user main() application, lib_func() is called.
When user application is executed on hardware, lib_func() is expected 
to return value 13 here. However, it returns value 1. This is happening 
because the constructor routine lib_init() is not getting called before
user main().

In the map file generated while compiling library source code, I can
see a correct entry under the “.ctors” section. I even tried placing
an entry under ‘__init_array_start’ manually. Still it failed.

With some fprintf statements, I can see ‘__shared_flat_init()’ is
getting called before user main(). However, I can't see which
initialization routine this function is calling for my test library.
How can I see it?

I got one more doubt. In file shared_flat_add_library.c, I can see a
structure ‘this_lib’ (of type struct shared_flat_lib) is associated
with each shared library being used. I think ‘_init’ element of this
structure should get populated with lib_init() address in my test case. 
Is it correct? 
In that case, who is expected to assign this value to this element?

Thanks & Regards,
Naveen


-------------- next part --------------
A non-text attachment was scrubbed...
Name: uclibc-cr16.patch.tar.gz
Type: application/x-gzip
Size: 25242 bytes
Desc: uclibc-cr16.patch.tar.gz
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20120105/b132a3b5/attachment-0001.bin>


More information about the uClibc mailing list