'Resolve base addresses of all loaded libraries.
Return a dictionary mapping library path to its base address.'

def bases(self):

    if (not self._bases):
        leak = self.leak
        LinkMap = {32: elf.Elf32_Link_Map, 64: elf.Elf64_Link_Map}[self.elfclass]
        cur = self.link_map
        while leak.field(cur, LinkMap.l_prev):
            cur = leak.field(cur, LinkMap.l_prev)
        while cur:
            p_name = leak.field(cur, LinkMap.l_name)
            name = leak.s(p_name)
            addr = leak.field(cur, LinkMap.l_addr)
            cur = leak.field(cur, LinkMap.l_next)
            log.debug(('Found    %r    @    %#x' % (name, addr)))
            self._bases[name] = addr
    return self._bases
