RISC-V: Cannot invoke Varnode.getAddress because the return value of VariableStorage.getFirstVarnode is null
See original GitHub issueDescribe the bug I’m reverse engineering rv32imafc binary, and for some functions, decompiler shows this error:
Cannot invoke "ghidra.program.model.pcode.Varnode.getAddress()" because the return value of
"ghidra.program.model.listing.VariableStorage.getFirstVarnode()" is null
To Reproduce Steps to reproduce the behavior:
- Open
firmware.bin
attached, select RV32IMC language, and set base address to0x23000000
- Go to
0x23000dae
and check decompile panel - (Optional) Go to similar function (but smaller) at
0x23000d68
, this decompiles nicely.
Expected behavior Decompiler should be able to decompile the function.
Screenshots
Stacktrace:
Attachments firmware.bin.zip
(In show log, there wasn’t anything useful)
Environment
- OS: Linux 6.0.8
- Java Version: 19.0.1
- Ghidra Version: 10.2.2 DEV 2022-Nov-15 2224 CET
- Ghidra Origin: ArchLinux Packages
Additional context Let me know if any other information will be needed. Thanks
Issue Analytics
- State:
- Created 10 months ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Issues · NationalSecurityAgency/ghidra - GitHub
RISC-V : Cannot invoke Varnode.getAddress because the return value of VariableStorage.getFirstVarnode is null Status: Internal This is being ...
Read more >cannot invoke org.springframework.web.servlet.mvc.condition ...
NationalSecurityAgency/ghidraRISC-V: Cannot invoke Varnode.getAddress because the return value of VariableStorage.getFirstVarnode is null#4770.
Read more >CS61C Discussion 3 – RISC-V
Write a function power in RISC-V that takes in two numbers x and n, and returns xn. You may assume that n ≥...
Read more >RISC-V recursive function debugging - Stack Overflow
On a machine where the return address linkage is done in a register (RISC V, MIPS, ARM), a nested call done without having...
Read more >ghidra - bytemeta
RISC-V : Cannot invoke Varnode.getAddress because the return value of VariableStorage.getFirstVarnode is null. KooShnoo.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Hi @mumbel , thanks for all the help. (For anyone struggling with this) Since I applied mumbel’s recommendation, I got memory reads on memory areas, which didn’t gave any sense, generally having GP at
0x1F0164F0
didn’t gave any sense in context of real MCU memory map. After a bit thinking, I find out, this GP is wrong.The first instruction is AUIPC, which add upper immediate to PC. This instruction adds a 20-bit immediate value to the upper 20 bits of the program counter and set it to register. This means for:
23000000 97 61 01 1f auipc gp,0x1f016
:0x23000000 + (0x1F016 << 12)
=0x42016000
23000004 93 81 01 4f addi gp,gp,0x4f0
:0x42016000 + 0x4F0
=0x420164F0
So correct GP is
0x420164F0
.You might be able to close the code browser and right click firmware.bin in the frontend window and “choose language” (I think, AFK now) and see if it lets yous choose a new language.
Id leave open for now just track if there’s something that could be fixed for gp detection