diff options
Diffstat (limited to 'src/util/build_id.c')
-rw-r--r-- | src/util/build_id.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/util/build_id.c b/src/util/build_id.c index 536c74360ea..fb67d160e38 100644 --- a/src/util/build_id.c +++ b/src/util/build_id.c @@ -58,7 +58,18 @@ build_id_find_nhdr_callback(struct dl_phdr_info *info, size_t size, void *data_) { struct callback_data *data = data_; - if ((void *)info->dlpi_addr != data->dli_fbase) + /* 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++) { |