summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build-id.c17
1 files changed, 15 insertions, 2 deletions
diff --git a/build-id.c b/build-id.c
index e686335..900f507 100644
--- a/build-id.c
+++ b/build-id.c
@@ -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)