[haiku-bugs] [Haiku] #6491: ldsym() / dladdr() work strange

  • From: "Guest One" <trac@xxxxxxxxxxxx>
  • Date: Tue, 24 Aug 2010 05:20:31 -0000

#6491: ldsym() / dladdr() work strange
----------------------------+-----------------------------------------------
   Reporter:  Guest One     |        Owner:  nobody        
       Type:  bug           |       Status:  new           
   Priority:  normal        |    Milestone:  R1            
  Component:  System/POSIX  |      Version:  R1/Development
   Keywords:                |   Blocked By:                
Has a Patch:  0             |     Platform:  All           
   Blocking:                |  
----------------------------+-----------------------------------------------
 I am not sure if it is a real bug or just my improper usage, but attached
 example works different on Linux and Haiku.

 (test.lib.c)
 {{{#!C
 int exoprted_symbol[]= {1, 2, 3, 4, 5, -1};
 }}}

 (test.app.c)
 {{{#!C
 void *ptr;
 void *symbol;
 Dl_info info;

 ptr = dlopen("./test.lib.so", RTLD_LAZY);

 if(ptr==NULL)
 {
     printf( "%s\n", dlerror() );
     return 1;
 }

 symbol = dlsym( ptr,  "exoprted_symbol") ;

 if ( symbol == NULL )
 {
     printf( "%s\n", dlerror() );
     return 1;
 }

 if( ! dladdr( symbol, &info ) )
 {
     printf( "Error mapping address.\n" );
 }

 printf( "fname=%s\n",  info.dli_fname );
 printf( "fbase=%p\n",  info.dli_fbase );
 printf( "sname=%s\n",  info.dli_sname );
 printf( "saddr=%p\n", info.dli_saddr );
 }}}

 On Linux we have:
 {{{
 fname=./test.lib.so
 fbase=0xb78be000
 sname=exoprted_symbol
 saddr=0xb78c000c
 }}}

 On Haiku:
 {{{
 Error mapping address.
 fname=
 fbase=0x7ffeef9c
 sname=
 saddr=(nil)
 }}}

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/6491>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: