(filepath, vaddr)
return ELFInfo(headers, sections, segments)
Parse and return ELFInfo with all virtual addresses rebased to vaddr
Parse and return ELFInfo with all virtual addresses rebased to vaddr
Parse and return ELFInfo with all virtual addresses rebased to vaddr
def get_elf_info_rebased(filepath, vaddr):
    """
    Parse and return ELFInfo with all virtual addresses rebased to vaddr
    """
    raw_info = get_elf_info(filepath)
    # silently ignores "wrong" vaddr supplied for non-PIE ELF
    load = vaddr if raw_info.is_pic else 0
    headers = dict(raw_info.header)
    headers['e_entry'] += load

    segments = []
    for seg in raw_info.segments:
        s = dict(seg)
        for vaddr_attr in ['p_vaddr', 'x_vaddr_mem_end', 'x_vaddr_file_end']:
            s[vaddr_attr] += load
        segments.append(s)

    sections = []
    for sec in raw_info.sections:
        s = dict(sec)
        for vaddr_attr in ['sh_addr', 'x_addr_mem_end', 'x_addr_file_end']:
            s[vaddr_attr] += load
        sections.append(s)

    return ELFInfo(headers, sections, segments)
def get_elf_info_rebased ( filepath , vaddr ) : raw_info = get_elf_info ( filepath ) # silently ignores "wrong" vaddr supplied for non-PIE ELF load = vaddr if raw_info . is_pic else 0 headers = dict ( raw_info . header ) headers [ 'e_entry' ] += load segments = [ ] for seg in raw_info . segments : s = dict ( seg ) for vaddr_attr in [ 'p_vaddr' , 'x_vaddr_mem_end' , 'x_vaddr_file_end' ] : s [ vaddr_attr ] += load segments . append ( s ) sections = [ ] for sec in raw_info . sections : s = dict ( sec ) for vaddr_attr in [ 'sh_addr' , 'x_addr_mem_end' , 'x_addr_file_end' ] : s [ vaddr_attr ] += load sections . append ( s ) return ELFInfo ( headers , sections , segments )