How to run gdb with LD_PRELOAD?
陳韋任
chenwj@iis.sinica.edu.tw
Thu Jan 20 07:22:00 GMT 2011
Hi, all
I also posted this question on stackoverflow, see the link
below.
http://stackoverflow.com/questions/4703763/how-to-run-gdb-with-ld-preload
It turns out that LD_PRELOAD not only affect qemu-i386 but also
the bash invoked by gdb. The shared library dbo.so loaded by
LD_PRELOAD is quite special, I think. What dbo.so does is try
to be executed before the real __libc_start_main, does some hacking,
then pass to the real __libc_start_main.
Here is the code snippet,
----------------------------------------------------------------
// __libc_start_main provided by dbo.so
__libc_start_main( PARAMS_START_MAIN )
{
// copy the original command line argument
for( i = 1; i < argc; i++ )
argv[i] = ubp_av[i];
/*
* Here we tend to open "bzip2_base.i386-m32-gcc44-annotated"
*/
dbo.OpenELF(argv[3]);
// pass to the real __libc_start_main
real_libc_start_main( main, argc, ( char** )argv, init, fini,
rtld_fini, stack_end );
}
----------------------------------------------------------------
The reason why "open "/bin/bash" failed: Permission denied
" occured while using gdb is that the bash invoked by gdb is affected
by LD_PRELOAD, too. Thus, bash will try to open something rather than
"bzip2_base.i386-m32-gcc44-annotated".
Regards,
chenwj
--
Wei-Ren Chen (陳韋任)
Parallel Processing Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
More information about the Gdb
mailing list