(filepath)
Parse and return ELFInfo.

    Adds various calculated properties to the ELF header, segments and sections.
    Such added properties are those with prefix 'x_' in the returned dicts.
Parse and return ELFInfo.
Parse and return ELFInfo .
def get_elf_info(filepath):
    """
    Parse and return ELFInfo.

    Adds various calculated properties to the ELF header, segments and sections.
    Such added properties are those with prefix 'x_' in the returned dicts.
    """
    local_path = pwndbg.file.get_file(filepath)
    with open(local_path, 'rb') as f:
        elffile = ELFFile(f)
        header = dict(elffile.header)
        segments = []
        for seg in elffile.iter_segments():
            s = dict(seg.header)
            s['x_perms'] = [
                mnemonic for mask, mnemonic in [(PF_R, 'read'), (PF_W, 'write'), (PF_X, 'execute')]
                if s['p_flags'] & mask != 0
            ]
            # end of memory backing
            s['x_vaddr_mem_end'] = s['p_vaddr'] + s['p_memsz']
            # end of file backing
            s['x_vaddr_file_end'] = s['p_vaddr'] + s['p_filesz']
            segments.append(s)
        sections = []
        for sec in elffile.iter_sections():
            s = dict(sec.header)
            s['x_name'] = sec.name
            s['x_addr_mem_end'] = s['x_addr_file_end'] = s['sh_addr'] + s['sh_size']
            sections.append(s)
        return ELFInfo(header, sections, segments)
def get_elf_info ( filepath ) : local_path = pwndbg . file . get_file ( filepath ) with open ( local_path , 'rb' ) as f : elffile = ELFFile ( f ) header = dict ( elffile . header ) segments = [ ] for seg in elffile . iter_segments ( ) : s = dict ( seg . header ) s [ 'x_perms' ] = [ mnemonic for mask , mnemonic in [ ( PF_R , 'read' ) , ( PF_W , 'write' ) , ( PF_X , 'execute' ) ] if s [ 'p_flags' ] & mask != 0 ] # end of memory backing s [ 'x_vaddr_mem_end' ] = s [ 'p_vaddr' ] + s [ 'p_memsz' ] # end of file backing s [ 'x_vaddr_file_end' ] = s [ 'p_vaddr' ] + s [ 'p_filesz' ] segments . append ( s ) sections = [ ] for sec in elffile . iter_sections ( ) : s = dict ( sec . header ) s [ 'x_name' ] = sec . name s [ 'x_addr_mem_end' ] = s [ 'x_addr_file_end' ] = s [ 'sh_addr' ] + s [ 'sh_size' ] sections . append ( s ) return ELFInfo ( header , sections , segments )