forked from mooncat-greenpy/Ghidra_GolangAnalyzerExtension
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support RISC-V and PowerPC arguments
- Loading branch information
root
committed
Feb 26, 2023
1 parent
f5d25bd
commit 0ce0c22
Showing
4 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
44 changes: 44 additions & 0 deletions
44
src/main/java/golanganalyzerextension/function/GolangFunctionPpc.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package golanganalyzerextension.function; | ||
|
||
import java.util.Map; | ||
|
||
import ghidra.program.model.address.Address; | ||
import ghidra.program.model.lang.Register; | ||
import ghidra.program.model.listing.Function; | ||
import ghidra.program.model.listing.Instruction; | ||
import golanganalyzerextension.gobinary.GolangBinary; | ||
import golanganalyzerextension.service.GolangAnalyzerExtensionService; | ||
|
||
public class GolangFunctionPpc extends GolangFunction { | ||
|
||
private static final String[] reg_arg_str={"r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10", "r14", "r15", "r16", "r17"}; | ||
|
||
GolangFunctionPpc(GolangBinary go_bin, GolangAnalyzerExtensionService service, Address func_info_addr, long func_size, boolean disasm_option, boolean extended_option) { | ||
super(go_bin, service, func_info_addr, func_size, disasm_option, extended_option); | ||
} | ||
|
||
GolangFunctionPpc(GolangBinary go_bin, GolangAnalyzerExtensionService service, Function func, boolean disasm_option, boolean extended_option) { | ||
super(go_bin, service, func, disasm_option, extended_option); | ||
} | ||
|
||
@Override | ||
String get_reg_arg_name(int arg_count) { | ||
if(arg_count<0 || reg_arg_str.length<=arg_count) { | ||
return ""; | ||
} | ||
return reg_arg_str[arg_count]; | ||
} | ||
|
||
@Override | ||
int get_arg_stack_base() { | ||
return go_bin.get_pointer_size()*3; | ||
} | ||
|
||
@Override | ||
boolean check_inst_reg_arg(Instruction inst, Map<Register, REG_FLAG> builtin_reg_state) { | ||
if(go_bin.lt_go_version("go1.18beta1") || go_bin.get_pointer_size()!=8) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
src/main/java/golanganalyzerextension/function/GolangFunctionRiscv.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package golanganalyzerextension.function; | ||
|
||
import java.util.Map; | ||
|
||
import ghidra.program.model.address.Address; | ||
import ghidra.program.model.lang.Register; | ||
import ghidra.program.model.listing.Function; | ||
import ghidra.program.model.listing.Instruction; | ||
import golanganalyzerextension.gobinary.GolangBinary; | ||
import golanganalyzerextension.service.GolangAnalyzerExtensionService; | ||
|
||
public class GolangFunctionRiscv extends GolangFunction { | ||
|
||
private static final String[] reg_arg_str={"a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7", "s0", "s1", "s2", "s3", "s4", "s5", "s6", "s7"}; | ||
|
||
GolangFunctionRiscv(GolangBinary go_bin, GolangAnalyzerExtensionService service, Address func_info_addr, long func_size, boolean disasm_option, boolean extended_option) { | ||
super(go_bin, service, func_info_addr, func_size, disasm_option, extended_option); | ||
} | ||
|
||
GolangFunctionRiscv(GolangBinary go_bin, GolangAnalyzerExtensionService service, Function func, boolean disasm_option, boolean extended_option) { | ||
super(go_bin, service, func, disasm_option, extended_option); | ||
} | ||
|
||
@Override | ||
String get_reg_arg_name(int arg_count) { | ||
if(arg_count<0 || reg_arg_str.length<=arg_count) { | ||
return ""; | ||
} | ||
return reg_arg_str[arg_count]; | ||
} | ||
|
||
@Override | ||
boolean check_inst_reg_arg(Instruction inst, Map<Register, REG_FLAG> builtin_reg_state) { | ||
if(go_bin.lt_go_version("go1.18beta1") || go_bin.get_pointer_size()!=8) { | ||
return false; | ||
} | ||
return true; | ||
} | ||
} |
This file contains 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