Changeset View
Changeset View
Standalone View
Standalone View
lib/librtld_db/rtld_db.c
Show First 20 Lines • Show All 159 Lines • ▼ Show 20 Lines | |||||
rd_loadobj_iter(rd_agent_t *rdap, rl_iter_f *cb, void *clnt_data) | rd_loadobj_iter(rd_agent_t *rdap, rl_iter_f *cb, void *clnt_data) | ||||
{ | { | ||||
struct kinfo_vmentry *kves, *kve; | struct kinfo_vmentry *kves, *kve; | ||||
const char *path; | const char *path; | ||||
uint64_t fileid; | uint64_t fileid; | ||||
rd_loadobj_t rdl; | rd_loadobj_t rdl; | ||||
rd_err_e ret; | rd_err_e ret; | ||||
uintptr_t base; | uintptr_t base; | ||||
uint32_t offset; | |||||
int cnt, i; | int cnt, i; | ||||
DPRINTF("%s\n", __func__); | DPRINTF("%s\n", __func__); | ||||
if ((kves = kinfo_getvmmap(proc_getpid(rdap->rda_php), &cnt)) == NULL) { | if ((kves = kinfo_getvmmap(proc_getpid(rdap->rda_php), &cnt)) == NULL) { | ||||
warn("ERROR: kinfo_getvmmap() failed"); | warn("ERROR: kinfo_getvmmap() failed"); | ||||
return (RD_ERR); | return (RD_ERR); | ||||
} | } | ||||
Show All 9 Lines | for (i = 0; i < cnt; i++) { | ||||
* field gives the file offset of a particular mapping into the | * field gives the file offset of a particular mapping into the | ||||
* file, but we want the mapping offset relative to the base | * file, but we want the mapping offset relative to the base | ||||
* mapping. | * mapping. | ||||
*/ | */ | ||||
if (kve->kve_type == KVME_TYPE_VNODE) { | if (kve->kve_type == KVME_TYPE_VNODE) { | ||||
if (kve->kve_vn_fileid != fileid) { | if (kve->kve_vn_fileid != fileid) { | ||||
base = kve->kve_start; | base = kve->kve_start; | ||||
fileid = kve->kve_vn_fileid; | fileid = kve->kve_vn_fileid; | ||||
path = kve->kve_path; | |||||
} | } | ||||
path = kve->kve_path; | |||||
offset = kve->kve_start - base; | |||||
} else { | } else { | ||||
base = 0; | |||||
path = NULL; | path = NULL; | ||||
offset = 0; | |||||
} | } | ||||
memset(&rdl, 0, sizeof(rdl)); | memset(&rdl, 0, sizeof(rdl)); | ||||
/* | /* | ||||
* Map the kinfo_vmentry struct to the rd_loadobj structure. | * Map the kinfo_vmentry struct to the rd_loadobj structure. | ||||
*/ | */ | ||||
rdl.rdl_saddr = kve->kve_start; | rdl.rdl_saddr = kve->kve_start; | ||||
rdl.rdl_eaddr = kve->kve_end; | rdl.rdl_eaddr = kve->kve_end; | ||||
rdl.rdl_offset = kve->kve_start - base; | rdl.rdl_offset = offset; | ||||
markj: This value ends up being nonsensical for non-vnode mappings. Can we also change the loop so… | |||||
if (kve->kve_protection & KVME_PROT_READ) | if (kve->kve_protection & KVME_PROT_READ) | ||||
rdl.rdl_prot |= RD_RDL_R; | rdl.rdl_prot |= RD_RDL_R; | ||||
if (kve->kve_protection & KVME_PROT_WRITE) | if (kve->kve_protection & KVME_PROT_WRITE) | ||||
rdl.rdl_prot |= RD_RDL_W; | rdl.rdl_prot |= RD_RDL_W; | ||||
if (kve->kve_protection & KVME_PROT_EXEC) | if (kve->kve_protection & KVME_PROT_EXEC) | ||||
rdl.rdl_prot |= RD_RDL_X; | rdl.rdl_prot |= RD_RDL_X; | ||||
if (path != NULL) | if (path != NULL) | ||||
strlcpy(rdl.rdl_path, path, sizeof(rdl.rdl_path)); | strlcpy(rdl.rdl_path, path, sizeof(rdl.rdl_path)); | ||||
▲ Show 20 Lines • Show All 194 Lines • Show Last 20 Lines |
This value ends up being nonsensical for non-vnode mappings. Can we also change the loop so that rdl_offset is 0 for such mappings?