This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug libc/20109] dlsym(0,any) can't resolved the symbol


https://sourceware.org/bugzilla/show_bug.cgi?id=20109

rm beer <rmbeer2 at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---

--- Comment #2 from rm beer <rmbeer2 at gmail dot com> ---
Sorry, i forget remark with bold and underline that the problem is with
dlsym(), ok, i have a other example:

================================================================
OBJ.CPP:
#include "obj.h"

int func(int a){
        return a+a;
}

================================================================
OBJ.H:
int func(int);

================================================================
PRUEBA.CPP:
#include <stdio.h>
#include <dlfcn.h>
#include <stdlib.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include "obj.h"

//#define FUNC "func"
#define FUNC "_Z4funci"

int main(){
  long ptr=(long)dlsym(0,FUNC);
        int fl,cn;
        printf("Puntero: %x\n",ptr);
        char msg[2000];
        for(cn=0;cn<2000;cn++){
                sprintf(msg,"%d",rand()%20000);
                fl=open(msg,O_WRONLY|O_CREAT,S_IRUSR|S_IWUSR);
                if(fl){
                        sprintf(msg,"Puntero: %x\n",dlsym(0,FUNC));
                        write(fl,msg,strlen(msg)+1);
                        close(fl);
                }
        }
        for(cn=0;cn<20;cn++){
                sprintf(msg,"/dev/tty%d",cn);
                fl=open(msg,O_WRONLY);
                if(fl){
                        sprintf(msg,"Puntero: %x\n",dlsym(0,FUNC));
                        write(fl,msg,strlen(msg)+1);
                        close(fl);
                }
        }
        for(cn=0;cn<20;cn++){
                if(dlsym(0,FUNC)==0)printf("NOT HAVE A POINTER!!!\n");
        }
        return ptr;
}
================================================================


Lines for compiling:
# g++ -c obj.cpp -o obj.o
# g++ prueba.cpp obj.o -o prueba -ldl

For best work, executing in the root user. THIS EXAMPLE IS TESTING 100%
VERIFIED!

With this, you view that not work in dlsym() function. Showing with objdump and
other app for view objects files, the obj.o show a _Z4funci string. This bug
not show the pointer of _Z4funci, this problem is obviously that dlsym() not
search a symbol in the executable binary file.

Now can you find a problem in all outputs of example? or definitely the problem
is in dlsym()?

that you have a nice day.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]