diff --git a/src/memmap.c b/src/memmap.c index 0daa5b2..6141281 100644 --- a/src/memmap.c +++ b/src/memmap.c @@ -87,7 +87,18 @@ MemorySpan memmaps_find_by_name(const char region_name[static 1], const MemoryMap *reg = &vector_at(maps, i); - if (reg->pathname && strcmp(reg->pathname, region_name) == 0) { + // The name shown in /proc/pid/maps and the one given by dlinfo don't + // always match. More specific version numbers might be different, or + // the file could be e.g. "libelf-0.188.so", but the fname ends in + // libelf with a different path. /usr/lib vs. /lib is a common mismatch. + // + // It doesn't concern as most times, as that tends to happen in system + // libraries, but just in case we now cut the compare length to what + // was given. + // + // TODO: use only the libname-until.so for equality comparisons + if (reg->pathname && + strncmp(reg->pathname, region_name, strlen(region_name)) == 0) { if (reg->span.start < start) { start = reg->span.start; }