Example #1
0
/*ARGSUSED*/
void
la_activity(uintptr_t *cookie, uint_t flags)
{
    struct ps_prochandle *P;
    int err, ret;
    GElf_Sym sym;

    if (flags != LA_ACT_CONSISTENT)
        return;

    while (list != NULL) {
        obj_list_t *node = list;
        char *name = node->ol_name;

        list = node->ol_next;

        P = Pgrab(getpid(), PGRAB_RDONLY, &err);
        ret = Plookup_by_name(P, name, "___SUNW_dof", &sym);
        Prelease(P, 0);

        if (ret == 0) {
            dtrace_link_dof((void *)(uintptr_t)sym.st_value,
                            node->ol_lmid, node->ol_name, node->ol_addr);
        }

        free(node->ol_name);
        free(node);
    }
}
Example #2
0
/*
 * Search for a symbol by name and return the corresponding symbol
 * information.  If we're compiled _LP64, we just call Plookup_by_name
 * and return because ps_sym_t is defined to be an Elf64_Sym, which
 * is the same as a GElf_Sym.  In the _ILP32 case, we have to convert
 * Plookup_by_name's result back to a ps_sym_t (which is an Elf32_Sym).
 */
ps_err_e
ps_pglobal_sym(struct ps_prochandle *P, const char *object_name,
	const char *sym_name, ps_sym_t *symp)
{
#if defined(_ILP32)
	GElf_Sym sym;

	if (Plookup_by_name(P, object_name, sym_name, &sym) == 0) {
		symp->st_name = (Elf32_Word)sym.st_name;
		symp->st_value = (Elf32_Addr)sym.st_value;
		symp->st_size = (Elf32_Word)sym.st_size;
		symp->st_info = ELF32_ST_INFO(
		    GELF_ST_BIND(sym.st_info), GELF_ST_TYPE(sym.st_info));
		symp->st_other = sym.st_other;
		symp->st_shndx = sym.st_shndx;
		return (PS_OK);
	}

#elif defined(_LP64)
	if (Plookup_by_name(P, object_name, sym_name, symp) == 0)
		return (PS_OK);
#endif
	return (PS_NOSYM);
}
Example #3
0
/*
 * Search for a symbol by name and return the corresponding address.
 */
ps_err_e
ps_pglobal_lookup(struct ps_prochandle *P, const char *object_name,
	const char *sym_name, psaddr_t *sym_addr)
{
	GElf_Sym sym;

	if (Plookup_by_name(P, object_name, sym_name, &sym) == 0) {
		dprintf("pglobal_lookup <%s> -> %p\n",
		    sym_name, (void *)(uintptr_t)sym.st_value);
		*sym_addr = (psaddr_t)sym.st_value;
		return (PS_OK);
	}

	return (PS_NOSYM);
}