def get_offset2DIE(dwarfinfo):
    """
    Returns dict keyed by Compilation Unit offsets.
    Each dict-value is another dict mapping an offset to a DIE.
    """
    result = {}
    for compile_unit in dwarfinfo.iter_CUs():
        result[compile_unit.cu_offset] = {}
        # print('# CU ----------------------------')
        for die in compile_unit.iter_DIEs():
            # DIE attributes are CU-relative, thus the need for the subtraction
            result[compile_unit.cu_offset][die.offset -
                                           compile_unit.cu_offset] = die
    return result