'Returns the address of the first Program Header with the type
PT_DYNAMIC.'

def _find_dynamic_phdr(self):

    leak = self.leak
    base = self.libbase
    Ehdr = {32: elf.Elf32_Ehdr, 64: elf.Elf64_Ehdr}[self.elfclass]
    Phdr = {32: elf.Elf32_Phdr, 64: elf.Elf64_Phdr}[self.elfclass]
    self.status('PT_DYNAMIC')
    phead = (base + leak.field(base, Ehdr.e_phoff))
    self.status(('PT_DYNAMIC    header    =    %#x' % phead))
    phnum = leak.field(base, Ehdr.e_phnum)
    self.status(('PT_DYNAMIC    count    =    %#x' % phnum))
    for i in range(phnum):
        if leak.field_compare(phead, Phdr.p_type, constants.PT_DYNAMIC):
            break
        phead += sizeof(Phdr)
    else:
        self.failure('Could    not    find    Program    Header    of    type    PT_DYNAMIC')
        return None
    dynamic = leak.field(phead, Phdr.p_vaddr)
    self.status(('PT_DYNAMIC    @    %#x' % dynamic))
    dynamic = self._make_absolute_ptr(dynamic)
    return dynamic
