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

Xtensa Support #2380

Merged
merged 20 commits into from
Sep 30, 2024
Merged

Xtensa Support #2380

merged 20 commits into from
Sep 30, 2024

Conversation

imbillow
Copy link
Contributor

@imbillow imbillow commented Jun 4, 2024

Your checklist for this pull request

  • I've documented or updated the documentation of every API function and struct this PR changes.
  • I've added tests that prove my fix is effective or that my feature works (if possible)

Detailed description

...

Test plan

...

Closing issues

...

Copy link
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please keep in mind the LITBASE mechanic Xtensa has.
No other disassembler seems to support it. So it would be nice if CS gives at least an option to take care of it.
See: https://youtu.be/QMO2vMBcx7Y?feature=shared&t=808

@XVilka
Copy link
Contributor

XVilka commented Jun 6, 2024

@imbillow what LLVM version you have used as a base for this PR? Mainstream LLVM 18? Or a fork from developers working on the Xtensa patches?

@imbillow
Copy link
Contributor Author

imbillow commented Jun 6, 2024

@imbillow what LLVM version you have used as a base for this PR? Mainstream LLVM 18? Or a fork from developers working on the Xtensa patches?

I'm using the auto-sync branch of llvm-capstone, I think it's llvm-18, I'm not sure.

commit 5943ec6923d64e63b9645aa230cd9b86bd63a51b (HEAD -> auto-sync, origin/auto-sync, origin/HEAD)
Author: Rot127 <[email protected]>
Date:   Tue Jun 4 03:29:20 2024 -0500

    Add Alpha and LoongArch to the CI tests.

@Rot127
Copy link
Collaborator

Rot127 commented Jun 6, 2024

It is LLVM 18. Please quickly diff the Target/Xtensa directories against each other. If there are vast differences, we can consider merging them earlier.

suite/cstest/Makefile Outdated Show resolved Hide resolved
@XVilka

This comment was marked as resolved.

@Rot127
Copy link
Collaborator

Rot127 commented Sep 26, 2024

@imbillow I fixed some issue while being at it: imbillow#1

Please check this issue here with test_litbase:

ctest --test-dir build --output-on-failure -R integration*
Internal ctest changing into directory: /home/user/repos/capstone/build
Test project /home/user/repos/capstone/build
...
    Start 11: integration_test_litbase
3/3 Test #11: integration_test_litbase .........Subprocess aborted***Exception:   0.16 sec
test_litbase: /home/user/repos/capstone/arch/Xtensa/XtensaInstPrinter.c:131: printL32RTarget: Assertion `(Value >= -262144 && Value <= -4) && "Invalid argument, value must be in ranges [-262144,-4]"' failed.

Also, it is weird. But in the CI it builds Xtensa without my edits. But it shouldn't because those macros don't exist. Or did you add them and I just overlooked them?

imbillow and others added 15 commits September 27, 2024 08:05
- fix MCExpr
- fix Xtensa_add_cs_detail
- add `add_cs_detail`
- add `MCExpr *MCOperand_getExpr(const MCOperand *MC)` `void printExpr(const MCExpr *E, SStream *O)`

autosync fix

- fix StreamOperation.py
- replace `report_fatal_error` with `CS_ASSERT`
- fix patch StreamOperation.py
- replace `assert` with `CS_ASSERT`
- fix AddCSDetail.py
- fix QualifiedIdentifier
@imbillow
Copy link
Contributor Author

The clang-tidy warnings are a false positive, because SRDecoderTable[i + 1] does not cause the array to go out of bounds if i + 1 < sizeof(SRDecoderTable) is satisfied.

@imbillow
Copy link
Contributor Author

Auto-Sync/check fix in capstone-engine/llvm-capstone#61

arch/Xtensa/XtensaDisassembler.c Outdated Show resolved Hide resolved
arch/Xtensa/XtensaDisassembler.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@Rot127 Rot127 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kabeor Your turn

Copy link
Member

@kabeor kabeor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WoW, really cool, thanks!

@kabeor kabeor merged commit 21f7bc8 into capstone-engine:next Sep 30, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants