2017-02-17 156 views
0

dlopen的我想加载从gdb的共享库(的.so),我发现这个命令:呼叫从GDB

(gdb) call dlopen("path/to/lib.so",..) 

但它不工作,我联系我的程序与-ldl。

我得到的错误是:

No symbol "dlopen" in current context 

我错过了什么?

+1

你没有提及它是如何失败的。 –

+0

对,我得到这个:没有符号“dlopen”在当前的情况下 – wolfgunner

+1

你*开始*程序? 'info shared'和'info func dlopen'说什么? –

回答

0

我找到了解决这个问题的一半的命令。我解释一下: 首先,你应该共享对象加载到进程:

(gdb) set environment LD_PRELOAD /usr/lib/libdl.so 

在那之后,我们定义的文件debbuging

(gdb) file pgm 

为了进行测试,我们把断点在主即

(gdb) break main 

现在,我们运行程序

(gdb) run 

,我们呼吁的dlopen

(gdb) call dlopen("/path/to/lib.so",2) 

到现在为止它的工作,但是当我把最后一个命令,我:当我修改“unwindonsignal到

Program received signal SIGSEGV, Segmentation fault. 
0x00007ffff7de7f09 in ??() from /lib64/ld-linux-x86-64.so.2 
The program being debugged was signaled while in a function called from GDB. 
GDB remains in the frame where the signal was received. 
To change this behavior use "set unwindonsignal on". 
Evaluation of the expression containing the function 
(_gdb_expr) will be abandoned. 
When the function is done executing, GDB will silently stop. 

没有什么变化(开/关) '

这次我忘了什么?

useful