AArch64: fix LDR literal detail operand truncation#2984
Draft
amaanmujawar wants to merge 3 commits into
Draft
Conversation
Rot127
requested changes
Jul 3, 2026
Collaborator
There was a problem hiding this comment.
That it is a memory operand is intended.
Because the instruction loads at that memory address.
So in the Capstone model it is not an immediate operand but a memory operand.
Please change the disp type to an int64 instead, update the v6 guide (docs/cs_v6_release_guide.mde) and add a test please.
Author
|
Done, thanks. I kept it as |
Collaborator
|
Please check the tests. Changing the API means you also need to change the test code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Your checklist for this pull request
Detailed description
This PR fixes an AArch64 detail operand issue for LDR literal instructions.
For this instruction:
Capstone prints the correct resolved target address:
Before this change, the detail operand was emitted as a memory operand with a truncated displacement:
The label operand is mapped as
CS_OP_IMM | CS_OP_MEM. Previously,AArch64_set_detail_op_imm()redirected any operand carryingCS_OP_MEMinto the memory-operand path. For an LDR literal target, this stored the resolved address inaarch64_op_mem.disp, which isint32_t, so target addresses above 32 bits were truncated.This change only routes an immediate into the memory-displacement path when the previous detail operand is an in-progress memory operand with a base register. Standalone literal-load target addresses remain immediate operands and preserve the full resolved address.
Normal base+displacement memory operands are still emitted as
AARCH64_OP_MEM.No public API function or struct is changed.
Test plan
Added a regression test in
tests/issues/issues.yamlfor issue 2878.Ran locally:
The issue case now reports the full address as an immediate operand:
A normal base+displacement load still reports a memory operand:
I could not run
cstestlocally on macOS because my local build attempts to linkcstestas a universalx86_64/arm64binary while its dependencies are arm64-only. I did not include any build-system changes in this PR.Closing issues
Closes #2878