Get the best guess to the ELF object on the host machine.

#include <sys/procfs.h>

#define DCMD_PROC_MAPDEBUG  __DIOTF(_DCMD_PROC, __PROC_SUBCMD_PROCFS + 3, procfs_debuginfo)

The arguments to devctl() are:

Argument Value
filedes A file descriptor for the process.
dev_data_ptr A pointer to a procfs_debuginfo structure
n_bytes sizeof(procfs_debuginfo)
dev_info_ptr NULL

This is used by debuggers to find the object that contains the symbol information, even though it may have been stripped on the target machine. This call is useful only on MAP_ELF mappings. If any relocation of the ELF object was done, this translation will be undone. This lets you pass in an address within a ELF module, and get in return the address that the original object was linked at so a debugger can find the symbol. (This is an extension from the SYSV interface.)

The argument is a pointer to a procfs_debuginfo structure that's filled in with the required information on return. The procfs_debuginfo structure can specify the base address of the mapped segment that you're interested in. For example:

procfs_debuginfo map;

map.info.vaddr = some_vaddr;
devctl( fd, DCMD_PROC_MAPDEBUG, &map, sizeof map, NULL);

DCMD_PROC_MAPDEBUG is useful for non-ELF objects if you need to get the name. Note that the path member in procfs_debuginfo is a one-byte array; if you want to get the name, you need to allocate more space for it. For example:

struct {
    procfs_debuginfo   info;
    char               buff[_POSIX_PATH_MAX];
} map;