WitchCraft
September 25th, 2010, 05:18 PM
Question: I want to load a shared library from within an attached process in gdb.
example:
gdb
attach <pid>
call dlopen("/path/to/my/dll/libxy.so", 2)
detach
It works fine when the application has been linked with -ldl.
that is to say when the linker added libdl.so in the address space...
libdl.so.2 => /lib/tls/i686/cmov/libdl.so.2 (0x00dff000)
My question now:
How can I load libdl.so when the linker has not loaded it ?
WitchCraft
October 2nd, 2010, 11:37 AM
bump.
WitchCraft
October 3rd, 2010, 03:25 PM
bump.
johnl
October 3rd, 2010, 05:36 PM
You can use the LD_PRELOAD environmental variable to cause the loader to load any shared object into the process. To do it with GDB, you use the "set environment" command before running the executable. This might even accomplish what you want to do without using GDB.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) set environment LD_PRELOAD /usr/lib/libdl.so
(gdb) file ./mem
Reading symbols from /home/ledbettj/Projects/mem/mem...done.
(gdb) break main
Breakpoint 1 at 0x4007d3: file mem_main.c, line 9.
(gdb) run
Starting program: /home/ledbettj/Projects/mem/mem
Breakpoint 1, main (argc=1, argv=0x7fffffffe328) at mem_main.c:9
9 if (mempool_init(&pool, 4096, 4096)) {
(gdb) shared
Symbols already loaded for /lib64/ld-linux-x86-64.so.2
Symbols already loaded for /usr/lib/libdl.so
Symbols already loaded for /lib/libc.so.6
(gdb) call dlopen("/path/to/foo.so", 2)
$1 = 0
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.