-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Getting the address of a varnode (aka instruction operand) #4606
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
Getting the address of a varnode (aka instruction operand) #4606
Comments
Example for NationalSecurityAgency/ghidra#4606 It should compute the EA after the W^ offset has been read (PC at 0x04) Signed-off-by: Klaus Kämpf <[email protected]>
Wow! Implementing the VAX instruction set in Ghidra sounds like a very large task., certainly well beyond my level. But as a longtime VMS user and hobbyist, I'd sure love to see the end product. (Likewise for the PDP-11, if anyone is interested in taking up that architecture.) |
😊
It's on my list (now that I have some basic understanding of sleigh 😆 ) |
Since this is static within the instruction, I think context might work well here. Use something like For the opcode, use hen for each operand, you know how big it is, so you can increment op_addr each time. |
Thanks, something similar was my initial attempt. During parsing, the op_addr was computed correctly but it seems as if the final computation is done after the instruction is completely matched. So ever operand came out with the same (set by the last operand) op_addr. However, I didn't specify Thanks again ! Will report here 😉 |
Signed-off-by: Klaus Kämpf <[email protected]>
You may need to add a |
Were you able to get this to work? |
Sorry, I was out last week.
Not clear where to use this, as the I tried setting the offset (aka |
Solved this with a non-visible operand
Works nicely, as the However, when computing operands, every operand gets the final |
I now created a minified VAX processor description to visualize the problem better. I use lifting-bits disassembler with this binary:
It should disassemble to
but doesn't. Each operand disassembles to the same value. 😞 |
I've now tried all kind of combinations of This doesn't come as a surprise to me since ghidra has to process all operands twice. Once for computing |
I've solved it now by introducing an (Adding _printf_s to Ghidra pointed me to the right places, esp. showing that ParserWalker's value retrieval functions where called twice - once reading 4-byte-value to match against the disassembler spec and once reading correctly-sized values to compute the correct disassembly values) See f9a8788 for the
This works nicely and fixes the issue at hand. |
Will #4812 be considered now ? 🥺 |
Sorry, I didn't realize this was tied to those PR's. |
I found this issue because I searched for "VAX". I'm interested in this! However, I don't yet have any clue about Ghidra or Java. Is there any way to help with VAX support? Just to add a comment: The VAX ISA does have one-byte and two-byte opcodes. So relying on them as one-byte long would be wrong. And then there's a ton of addressing modes. Plus the oddity of the CASE* instructions. Alas... I really would love to help here. It would be great to have something that helps to dissect machine ROMs or system binaries. |
Hey @jbglaw , Ghidra VAX support is (mostly) done - except for #4812 😞 . If you want to build from source, check out the I'm also maintaining RPM packages for iopenSUSE Tumbleweed |
Please check out and contribute to https://github.com/kkaempf/ghidra-vax 😉
This all should be working in ghidra.vax
I'm already working on ROMs and I'd be happy to collaborate on http://ghidra-server.org/ |
Well, I just requested an account on ghidra-server.org. Let's see. OTOH, as I'm a 100% newbie to Ghidra, my first step should be to get it running. Source builds seem to be not too trivial with Debian as it's missing build tools (at least in the requested version.) And then there's that one outstanding patch. Are there chances those will be merged? At least it doesn't look as if it would break anything else. |
🤞🏻
If you're not afraid of downloading binaries (like gradle) on your machine, building should be as simple as
This will give you a
Ghidra (the project) is generally slow in merging outside contributions :-/
Certainly not. It's just exposing a value that is already tracked internally. |
|
So let's hope that this other PR is merged, and thereafter maybe the VAX CPU description. I'll try to get it working locally. :) |
Successfully built Ghidra (plain upstream sources, though with |
(rephrased to better match sleigh terminology)
I'm working on a processor description for VAX and would need to get the address of an instruction operand.
VAX has one-byte opcodes followed by operands with variable (1 to 5 bytes) length.
Examples (not exact mnemonics)
00000000: 90 01 50 - MOVE.B S^1, R0
00000000: 90 CF 34 12 E0 78 56 34 12 - MOVE.B (PC+0x1234), (R0 + 0x12345678)
Example 2 is the problem. The first operand ("CF 34 12") is PC-relative, it computes PC+0x1234, where PC is right after the final "12" value. In the example above, that would result in 0x1238.
Problem
To compute PC-relative offsets correctly, I need to know the operands memory address. However, neither
inst_start
, norinst_next
are usable here:I can't use
inst_start
because the operand might be second and I don't know the size of the first operand.I can't use
inst_next
because the operand might be first and I don't know the size of the second operand.Are there any other options ?
The text was updated successfully, but these errors were encountered: