'Get headers information of an ELF file using \'readelf\'
Args:
- filename: ELF file (String)
- name: specific header name (String)
Returns:
- dictionary of headers (name(String), value(Int)) (Dict)'

@memoized
def readelf_header(self, filename, name=None):

    elfinfo = {}
    vmap = self.get_vmmap(filename)
    elfbase = (vmap[0][0] if vmap else 0)
    out = execute_external_command(('%s    -W    -S    %s' % (config.READELF, filename)))
    if (not out):
        return {}
    p = re.compile('.*\\[.*\\]    (\\.[^    ]*)    [^0-9]*    ([^    ]*)    [^    ]*    ([^    ]*)(.*)')
    matches = p.findall(out)
    if (not matches):
        return result
    for (hname, start, size, attr) in matches:
        (start, end) = (to_int(('0x' + start)), (to_int(('0x' + start)) + to_int(('0x' + size))))
        if (start < elfbase):
            start += elfbase
        if (end < elfbase):
            end += elfbase
        if ('X' in attr):
            htype = 'code'
        elif ('W' in attr):
            htype = 'data'
        else:
            htype = 'rodata'
        elfinfo[hname.strip()] = (start, end, htype)
    result = {}
    if (name is None):
        result = elfinfo
    elif (name in elfinfo):
        result[name] = elfinfo[name]
    else:
        for (k, v) in elfinfo.items():
            if (name in k):
                result[k] = v
    return result
