[haiku-bugs] [Haiku] #8064: dladdr doesn't work for local symbols

  • From: "unitedroad" <trac@xxxxxxxxxxxx>
  • Date: Sun, 30 Oct 2011 08:18:57 -0000

#8064: dladdr doesn't work for local symbols
-----------------------------------------------+-------------------------
 Reporter:  unitedroad                         |        Owner:  axeld
     Type:  bug                                |       Status:  new
 Priority:  normal                             |    Milestone:  R1
Component:  System/libroot.so                  |      Version:  R1/alpha3
 Keywords:  dladdr, shared library, so, dlfcn  |   Blocked By:
 Blocking:                                     |  Has a Patch:  0
 Platform:  All                                |
-----------------------------------------------+-------------------------
 Hi,
    the dladdr function doesn't resolve the library location for for the
 symbols that are not exposed by the library to outside. This used to work
 in a previous revision from Haiku from last year.
 This is my code:

 main.c:
 {{{
 #include <stdio.h>
 #include <dlfcn.h>
 #include <unistd.h>
 #include <string.h>

 int main(){
         void (*dladdrerp)();
         char liblocation[1024];
         getcwd(liblocation,1024);
         strcat(liblocation,"/liblso.so");
         void *handle = dlopen(liblocation, RTLD_LAZY);
         dladdrerp = (void(*)())dlsym(handle,"dladdrer");
         dladdrerp();
 }

 }}}

 lso.c (where the dladdr function is called):

 {{{
 #include <stdio.h>
 #include <dlfcn.h>

 int dladdree(){

 }

 int dladdrer(){
         Dl_info info;
         if (dladdr(dladdree,&info)==0){
                 printf("dladdree not found\n");
         } else {
                 printf("%s\n",info.dli_fname);
         }
 }
 }}}

 lso.exp used to create th shared library:

 {{{
 LSO_1.1 {
         global:
                 dladdrer;
         local :*;
 };
 }}}


 I have created function called '''"dladdree"''' that is resolved through
 dladdr function by '''"dladdrer"'''.
 dladdrer prints the location of the shared library containing dladdree in
 Ubuntu Linux 10.10, FreeBSD 8.1 and a Haiku revision from last year (I
 can't find the revision number since my nightly doesn't show it in Haiku
 nightly). However, in the Haiku revision 42917, it prints out "dladdree
 not found".

 I have also attached all the code files with version script and Makefile
 with this report.

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

Other related posts: