diff options
Diffstat (limited to 'build-id.c')
-rw-r--r-- | build-id.c | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -68,8 +68,21 @@ build_id_find_nhdr_callback(struct dl_phdr_info *info, size_t size, void *data_) if (data->tag == BY_NAME && strcmp(info->dlpi_name, data->name) != 0) return 0; - if (data->tag == BY_SYMBOL && (void *)info->dlpi_addr != data->dli_fbase) - return 0; + if (data->tag == BY_SYMBOL) { + /* Calculate address where shared object is mapped into the process space. + * (Using the base address and the virtual address of the first LOAD segment) + */ + void *map_start = NULL; + for (unsigned i = 0; i < info->dlpi_phnum; i++) { + if (info->dlpi_phdr[i].p_type == PT_LOAD) { + map_start = (void *)(info->dlpi_addr + info->dlpi_phdr[i].p_vaddr); + break; + } + } + + if (map_start != data->dli_fbase) + return 0; + } for (unsigned i = 0; i < info->dlpi_phnum; i++) { if (info->dlpi_phdr[i].p_type != PT_NOTE) |