adjust dladdr dli_fbase definition to match other implementations
authorRich Felker <dalias@aerifal.cx>
Fri, 2 Feb 2018 17:15:43 +0000 (12:15 -0500)
committerRich Felker <dalias@aerifal.cx>
Fri, 2 Feb 2018 17:15:43 +0000 (12:15 -0500)
the Linux and FreeBSD man pages for dladdr document dli_fbase as the
"base address" of the library/module found. normally (e.g. AT_BASE)
the term "base" is used to denote the base address relative to which
p_vaddr addresses are interpreted; however in the case of dladdr's
Dl_info structure, existing implementations define it as the lowest
address of the mapping, which makes sense in the context of
determining which module's memory range the input address falls
within.

since this is a nonstandard interface provided to mimic one provided
by other implementations, adjust it to match their behavior.

ldso/dynlink.c

index 4b4841f..3380240 100644 (file)
@@ -1961,7 +1961,7 @@ int dladdr(const void *addr, Dl_info *info)
                best = p->funcdescs + (bestsym - p->syms);
 
        info->dli_fname = p->name;
-       info->dli_fbase = p->base;
+       info->dli_fbase = p->map;
        info->dli_sname = strings + bestsym->st_name;
        info->dli_saddr = best;