Skip to content
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

Instructions marked as alias with alias_id 0 #2634

Open
OBarronCS opened this issue Feb 26, 2025 · 4 comments · May be fixed by #2635
Open

Instructions marked as alias with alias_id 0 #2634

OBarronCS opened this issue Feb 26, 2025 · 4 comments · May be fixed by #2635
Labels
bug Something is not working as it should Mips Arch

Comments

@OBarronCS
Copy link

OBarronCS commented Feb 26, 2025

Work environment

Questions Answers
Capstone module affected Mips
Source of Capstone git clone
Version/git commit 8ac2843 (HEAD, tag: 6.0.0-Alpha3)

I've run into some instructions in MIPS that have the .is_alias flag set to true, with the alias_id set to 0.

# bnez   $t0, 0x10
cstool -d mipsel "0x03 0x00 0x00 0x15"

 0  03 00 00 15  bnez   $t0, 0x10
        ID: 23 (bne)
        Is alias: 0 (invalid) with REAL operand set
        op_count: 2
                operands[0].type: REG = t0
                operands[0].is_reglist: false
                operands[1].type: IMM = 0x10
                operands[1].is_unsigned: true
        Groups: jump branch_relative HasStdEnc NotInMicroMips NotNanoMips 

This problem might be more widespread, but I have only encountered it in MIPS instructions. It is not the case for all instructions.

Other examples here: #2628 (search for the word invalid)

Expected behavior

If the instruction is marked as an alias, the alias_id should be a valid ID.

@OBarronCS
Copy link
Author

A theory is that all aliases have the alias_id set to zero in mips?

@Rot127 Rot127 added bug Something is not working as it should Mips Arch labels Feb 26, 2025
@wargio
Copy link
Contributor

wargio commented Feb 26, 2025

I noticed this also on other instructions, tbh, i do not know why, probably missing a change to fix this, like lapc is an alias for addiupc but doesn't get resolved either.

$ ./build/cstool -r -d mipsel64r6 190040ec
 0  19 00 40 ec  lapc   $v0, 0x64
        ID: 99 (addiupc)
        Is alias: 0 (invalid) with REAL operand set
        op_count: 2
                operands[0].type: REG = v0
                operands[0].is_reglist: false
                operands[1].type: IMM = 0x64
                operands[1].is_unsigned: false
        Groups: HasStdEnc HasMips32r6 

@Rot127
Copy link
Collaborator

Rot127 commented Feb 26, 2025

but doesn't get resolved either.

This indicates it is missing in LLVM. Which is annoying to fix. Because it is TableGen land.

@wargio wargio linked a pull request Feb 26, 2025 that will close this issue
2 tasks
@wargio
Copy link
Contributor

wargio commented Feb 26, 2025

It turns out it was my fault, and i forgot to implement the code that does that mapping.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working as it should Mips Arch
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants