On Tue, Oct 27, 2009 at 12:37 PM, Daniel Jacobowitz <[email protected]> wrote:
> On Tue, Oct 27, 2009 at 12:33:39PM -0700, Bruce Korb wrote:
>> Exactly. I know it'd be some work. I think I need to
>> call: dlopen(NULL, RTLD_NOW)
>
> No. You need to open the file and have your own ELF and symbol table
> reader. They are not in the area mapped by dlopen.
OK. Still not terribly hard:
{
static char const exe_fmt[] =
"/proc/%d/exe";
char bf[sizeof (exe_fmt) + 12];
sprintf(bf, exe_fmt, getpid());
path_len = readlink(bf, exe_path, sizeof (exe_path) - 1);
}
(This is for Linux only...)
> GDB is almost certainly not where you want to get this code from. We
> just use BFD...
Ah! There we go. That's what I was looking for. Thank you!