dissect.cstruct_legacy icon indicating copy to clipboard operation
dissect.cstruct_legacy copied to clipboard

bitfield members are missing in ._sizes

Open lwerdna opened this issue 3 years ago • 0 comments

Here is a simple struct with bitfields:

struct relocation_info {
    uint32 r_address;
    uint32 r_symbolname:24;
    uint32 r_pcrel:1;
    uint32 r_length:2;
    uint32 r_extern:1;
    uint32 r_type:4;
}

After parsing (result = cparser.relocation_info(data)), only r_address appears in ._sizes. The other fields (r_symbolname, r_pcrel, r_length, r_extern, r_type) are missing:

>>> result._sizes
{'r_address': 4}

This makes it impossible to use dumpstruct() which I assume loops through the OrderedDict ._values and attempts to look each one up in ._sizes:

>>> dumpstruct(result)
Traceback (most recent call last):
...
/cstruct/types/instance.py", line 47, in _size
    return self._sizes[field]
KeyError: 'r_symbolname'

lwerdna avatar Mar 30 '21 18:03 lwerdna