Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Fix compilation with MSVC: arm64/disassembler/decode_scratchpad.c #6574

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 27, 2025

Conversation

justanotheranonymoususer
Copy link
Contributor

MSVC shows several warnings, but this one is shown as an error, preventing compilation.

error C4146: unary minus operator applied to unsigned type, result still unsigned

MSVC shows several warnings, but this one is shown as an error, preventing compilation.
@galenbwill galenbwill self-assigned this May 7, 2025
@galenbwill galenbwill added Component: Architecture Issue needs changes to an architecture plugin Arch: ARM64 Issues with the AArch64 architecture plugin Impact: Medium Issue is impactful with a bad, or no, workaround Effort: Trivial Issue should take < 1 day Type: DX Issue affects or improves developer/api consumer experience labels May 7, 2025
@galenbwill galenbwill added this to the Helion milestone May 7, 2025
@galenbwill galenbwill merged commit d5080db into Vector35:dev May 27, 2025
1 check passed
@galenbwill
Copy link
Contributor

Unfortunately, I had to revert this commit as it broke the arm64test.py output for BFI. For example:

LIFT MISMATCH AT TEST 3157!
           input: c31d1c33 bfi     w3, w14, #0xffffffe4, #0x8
            test: 331C1DC3 bfi w3, w14, #0xffffffe4, #0x8
        expected: LLIL_SET_REG.d(w3,LLIL_OR.d(LLIL_AND.d(LLIL_CONST.d(0xFFFFF00F),LLIL_REG.d(w3)),LLIL_LSL.d(LLIL_AND.d(LLIL_CONST.d(0xFF),LLIL_REG.d(w14)),LLIL_CONST.b(0x4))))
          actual: LLIL_SET_REG.d(w3,LLIL_OR.d(LLIL_AND.d(LLIL_CONST.d(-0xFEF00000001),LLIL_REG.d(w3)),LLIL_LSL.d(LLIL_AND.d(LLIL_CONST.d(0xFF),LLIL_REG.d(w14)),LLIL_CONST.b(0xFFFFFFE4))))
            tree:
LLIL_SET_REG.d
    w3
    LLIL_OR.d
        LLIL_AND.d
            LLIL_CONST.d
                -0xFEF00000001
            LLIL_REG.d
                w3
        LLIL_LSL.d
            LLIL_AND.d
                LLIL_CONST.d
                    0xFF
                LLIL_REG.d
                    w14
            LLIL_CONST.b
                0xFFFFFFE4

After some closer investigation, it also turns out that this change causes the disassembly output to be incorrect, and the LLIL to be lifted incorrectly:

Before/After this patch:

Disassembly:

c31d1c33   bfi     w3, w14, #0x4, #8
c31d1c33   bfi     w3, w14, #0xffffffe4, #0x8

LLIL:

w3 = (-0xff1 & w3) | (0xff & w14) << 4
w3 = (-0xff000000001 & w3) | (0xff & w14) << 0xffffffe4

MLIL:

x3 = zx.q((0xfffff00f & arg4) | zx.d(arg5) << 4)
x3 = zx.q((0xffffffff & arg4) | zx.d(arg5) << 0xe4)

I have also verified that the original code does not cause a warning on the version of MSVC we use in our build infrastructure. Also, from the link you posted above, it sounds like the problem might be a bug in the version of MSVC you're using.

Try adding #pragma warning(disable:4146) right above the offending line and see if that prevents the error.

@justanotheranonymoususer
Copy link
Contributor Author

@galenbwill
Copy link
Contributor

I actually did try exactly that code when I was investigating, and yes, it does pass the tests and seems to result in semantically correct decompilation.

If you update the PR, I will merge it the next time I'm pushing another change (which will probably be in the next day or so).

@justanotheranonymoususer justanotheranonymoususer deleted the patch-1 branch May 28, 2025 21:59
@justanotheranonymoususer
Copy link
Contributor Author

Actually the pragma works too and it's less ugly. Created #6896

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Arch: ARM64 Issues with the AArch64 architecture plugin Component: Architecture Issue needs changes to an architecture plugin Effort: Trivial Issue should take < 1 day Impact: Medium Issue is impactful with a bad, or no, workaround Type: DX Issue affects or improves developer/api consumer experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.