FW: Problem with shared library

Naveen H. S Naveen.S at kpitcummins.com
Fri Nov 4 12:28:04 UTC 2011


Hi,

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.

The following link was referred to compile the applications with static
and shared libraries:-
http://tldp.org/HOWTO/Program-Library-HOWTO/shared-libraries.html

The application contains a main.c file which calls lib_func function
in lib.c file.
=======================================================================
static int val = 1 ;
static void init( void )
{
        val = 13 ;
}
int lib_func( const char* s )
{
printf( "\tEntering %s, called from %s\n\n", __FUNCTION__, s ) ;
        return val ;
}
=======================================================================

The application with static library generates correct output "13" by 
calling init function init(). However, with shared library; it does
not seem to call init() and generates wrong output "1" as follows:-
==================================================
Starting ./test.out...
        Entering lib_func, called from ./test.out
lib_func() returned 1
==================================================

Please find attached the command file "command" which shows exact
commands used for application and library compilation. On investigation,
the problem seem to be due to the incorrect calling of initialization
routines in crt files. It was observed that the shared library calls
"shared_flat_add_library" in crt1.S file. The same routine is used in
bfin and m68k code. Please find attached the initialization files
crt1.S file present in uClibc/libc/sysdeps/linux/cr16 folder.

Please let us know if anything else should be done for the proper
functioning of initialization code in shared libraries.

Thanks & Regards,
Naveen

-------------- next part --------------
A non-text attachment was scrubbed...
Name: crt1.S
Type: application/octet-stream
Size: 2166 bytes
Desc: crt1.S
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20111104/9c7e9e80/attachment.obj>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: command.txt
URL: <http://lists.busybox.net/pipermail/uclibc/attachments/20111104/9c7e9e80/attachment.txt>


More information about the uClibc mailing list