Jacek Caban (@jacek) commented about loader/preloader.c:
interp = (char *)main_binary_map.l_addr + main_binary_map.l_interp; map_so_lib( interp, &ld_so_map );
- /* expose ld.so _r_debug as a separate namespace in r_next */
- ld_so_r_debug = find_symbol( &ld_so_map, "_r_debug", STT_OBJECT );
- if (ld_so_r_debug) _r_debug.r_next = (struct r_debug_extended *)ld_so_r_debug;
- else wld_printf( "_r_debug not found in ld.so\n" );
- wine_r_debug = find_symbol( &main_binary_map, "wine_r_debug", STT_OBJECT );
- if (wine_r_debug) *wine_r_debug = &_r_debug.base;
- else wld_printf( "wine_r_debug not found\n" );
While `_r_debug` itself seems good to allow the debugger to hook Unix libs, I'm not sure if it's the best choice for PE files. The whole `wine_r_debug` thing and ntdll looking into the preloader does not seem appealing to me. Do we need this for PE files anyway? There is also an interface for JIT code [1] that looks similar, but simpler, maybe we could use that in the second commit instead.
[1] https://sourceware.org/gdb/current/onlinedocs/gdb.html/Declarations.html#Dec...