Skip to content

Humility fails on HIF initialization after Hubris toolchain bump #263

Closed
@bcantrill

Description

Running Humility on a Hubris archive after the toolchain bump to nightly-2022-11-01 bombs out on HIF initialization:

% humility -a ~/hubris/target/gimlet-b/dist/default/build-gimlet-b.zip hiffy -L
humility: attached via ST-Link V3
humility hiffy failed: function I2cBulkWrite in GOFF 0x000046aa (object 10): missing tag

Looking at the DWARF for Functions in hiffy reveals that... Humility has a point?

< 5><0x00004703 GOFF=0x00004703>            DW_TAG_variant            
                                              DW_AT_discr_value           29
< 6><0x00004705 GOFF=0x00004705>              DW_TAG_member           
                                                DW_AT_name                  I2cWrite
                                                DW_AT_type                  0x00004975<.debug_info+0x00004975>
                                                DW_AT_alignment             0x00000004
                                                DW_AT_data_member_location  0
< 5><0x00004711 GOFF=0x00004711>            DW_TAG_variant
< 6><0x00004712 GOFF=0x00004712>              DW_TAG_member
                                                DW_AT_name                  I2cBulkWrite
                                                DW_AT_type                  0x00004993<.debug_info+0x00004993>
                                                DW_AT_alignment             0x00000004
                                                DW_AT_data_member_location  0
< 5><0x0000471e GOFF=0x0000471e>            DW_TAG_variant                  
                                              DW_AT_discr_value           31
< 6><0x00004720 GOFF=0x00004720>              DW_TAG_member
                                                DW_AT_name                  GpioInput
                                                DW_AT_type                  0x000049b1<.debug_info+0x000049b1>
                                                DW_AT_alignment             0x00000004
                                                DW_AT_data_member_location  0

The I2cBulkWrite member of the Functions enum just seems to be missing a discriminant value? (Which should clearly be 30.) But that isn't the only bit of weirdness; for contrast, here is the same snippet of the Functions enum from the nightly-2022-07-27 toolchain:

< 5><0x00004506 GOFF=0x00004506>            DW_TAG_variant
                                              DW_AT_discr_value           5
< 6><0x00004508 GOFF=0x00004508>              DW_TAG_member
                                                DW_AT_name                  I2cWrite
                                                DW_AT_type                  0x00004779<.debug_info+0x00004779>
                                                DW_AT_alignment             0x00000004
                                                DW_AT_data_member_location  0
< 5><0x00004514 GOFF=0x00004514>            DW_TAG_variant
                                              DW_AT_discr_value           6
< 6><0x00004516 GOFF=0x00004516>              DW_TAG_member
                                                DW_AT_name                  I2cBulkWrite
                                                DW_AT_type                  0x00004797<.debug_info+0x00004797>
                                                DW_AT_alignment             0x00000004
                                                DW_AT_data_member_location  0
< 5><0x00004522 GOFF=0x00004522>            DW_TAG_variant
                                              DW_AT_discr_value           7
< 6><0x00004524 GOFF=0x00004524>              DW_TAG_member
                                                DW_AT_name                  GpioInput
                                                DW_AT_type                  0x000047b5<.debug_info+0x000047b5>
                                                DW_AT_alignment             0x00000004
                                                DW_AT_data_member_location  0

If it needs to be said: the values for DW_AT_discr_value in Functions used to start at 0 -- but now start at 24. (The only variant that doesn't have a discriminant value is I2cBulkWrite; the variants are numbered in ascending order from 24.)

The missing discriminant value is surprising (and may indicate a Rust bug -- to be investigated), but starting at a value other than 0 may be deliberate. The compiler is within its rights to do this, but it breaks Humility's mechanism for discovering HIF functions. (That is, we are getting a much more explicit error by missing DW_AT_discr_value on I2cBulkWrite; were it not for that, we would just be calling the wrong HIF functions!)

For the moment, the fix for this is to not rely on the tag, but raather on the ordering within the DWARF, which seems to honor the programmatic order in the enum.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions