rizinorg / rz-rzilcompiler

C to RZIL Compiler to extend the Rizin Hexagon plugin.
4 stars 2 forks source link

Some instructions compile non reproducable #13

Closed Rot127 closed 8 months ago

Rot127 commented 1 year ago

The instruction a2_roundsat compiles onlye every second time successful. Otherwise it fails with `GCC extended expressions without expression are not implemented.

syntax:

'{ size8s_t tmp;
        uint64_t __a = ((uint64_t)(RssV));
        uint64_t __b = ((uint64_t)(0x080000000ULL));
        uint64_t __sum = __a + __b;
        uint64_t __xor = __a ^ __b;
        const uint64_t __mask = 0x8000000000000000ULL;
        if (__xor & __mask) {
            tmp = __sum;
        }
        else if ((__a ^ __sum) & __mask) {
            if (__sum & __mask) {
                tmp = 0x7FFFFFFFFFFFFFFFLL;
                HEX_REG_ALIAS_USR_NEW = ((REGFIELD(RF_WIDTH, HEX_REG_FIELD_USR_OVF)) ? deposit64(HEX_REG_ALIAS_USR_NEW, (REGFIELD(RF_OFFSET, HEX_REG_FIELD_USR_OVF)), (REGFIELD(RF_WIDTH, HEX_REG_FIELD_USR_OVF)), ((1))) : HEX_REG_ALIAS_USR_NEW);
            } else {
                tmp = 0x8000000000000000LL;
                HEX_REG_ALIAS_USR_NEW = ((REGFIELD(RF_WIDTH, HEX_REG_FIELD_USR_OVF)) ? deposit64(HEX_REG_ALIAS_USR_NEW, (REGFIELD(RF_OFFSET, HEX_REG_FIELD_USR_OVF)), (REGFIELD(RF_WIDTH, HEX_REG_FIELD_USR_OVF)), ((1))) : HEX_REG_ALIAS_USR_NEW);
            }
        } else {
            tmp = __sum;
        }    ; RdV = ((int64_t)((int32_t)((tmp >> ((1) * 32)) & 0x0ffffffffLL))); }'

Ambiguity in grammar?

Rot127 commented 1 year ago

Shoudl be fixed with https://github.com/Rot127/rzil-compiler/commit/6bd902ed65b88727e1b979ddfbf1805caa5e670f

Rot127 commented 1 year ago

The ambiguity is still there. The gcc compounds and normal compound statements get confused and non reproducable builds are the result.