从gdb调用dlopen

从gdb调用dlopen,gdb,shared-libraries,dlopen,Gdb,Shared Libraries,Dlopen,我想从gdb加载共享库(.so),我发现以下命令: (gdb) call dlopen("path/to/lib.so",..) 但它不起作用,我将我的程序与-ldl链接 我得到的错误是: No symbol "dlopen" in current context 我错过了什么?我找到了一个命令,可以解决这个主题的一半。我解释: 首先,您应该将共享对象加载到流程中: (gdb) set environment LD_PRELOAD /usr/lib/libdl.so 之后,我们将文件定义为

我想从gdb加载共享库(.so),我发现以下命令:

(gdb) call dlopen("path/to/lib.so",..)
但它不起作用,我将我的程序与-ldl链接

我得到的错误是:

No symbol "dlopen" in current context

我错过了什么?

我找到了一个命令,可以解决这个主题的一半。我解释: 首先,您应该将共享对象加载到流程中:

(gdb) set environment LD_PRELOAD /usr/lib/libdl.so
之后,我们将文件定义为debbuging

(gdb) file pgm
对于测试,我们将断点放在main中,即

(gdb) break main
现在,我们运行程序

(gdb) run
我们称之为dlopen

(gdb) call dlopen("/path/to/lib.so",2)
到目前为止,这是可行的,但当我发出最后一个命令时,我有:

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.
当我修改“取消签名为(开/关)”时,没有任何更改

这次我忘了什么


您没有提到它是如何失败的。对,我得到了这样一个信息:当前上下文中没有符号“dlopen”。您启动了该程序吗?
info shared
info func dlopen
说什么呢?当然,对于第一个命令,它正在运行:0x00007ffff7dd7ac0 0x00007ff7df5640 Yes*/lib64/ld-linux-x86-64.so.2 0x00007ff7a2d8b0 0x00007ff7ff14 Yes*/lib/x86\linux-gnu/libc.so.6。第二个不显示结果!!