mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-30 16:01:22 +08:00
Merge remote-tracking branch 'origin/GP-6055_dev747368_fix_golang_abi0_func_callingconv'
This commit is contained in:
+12
-10
@@ -276,17 +276,19 @@ public class GolangSymbolAnalyzer extends AbstractAnalyzer {
|
|||||||
functionSignatureFromMethod++;
|
functionSignatureFromMethod++;
|
||||||
}
|
}
|
||||||
|
|
||||||
GoFunctionFixup ff = new GoFunctionFixup(func, funcDefResult.funcDef(),
|
if (funcdata.getFlags().isEmpty()) {
|
||||||
goBinary.getCallingConventionFor(funcdata), goBinary.newStorageAllocator());
|
GoFunctionFixup ff = new GoFunctionFixup(func, funcDefResult.funcDef(),
|
||||||
|
goBinary.getDefaultCallingConventionName(), goBinary.newStorageAllocator());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
ff.apply();
|
ff.apply();
|
||||||
}
|
}
|
||||||
catch (DuplicateNameException | InvalidInputException
|
catch (DuplicateNameException | InvalidInputException
|
||||||
| IllegalArgumentException e) {
|
| IllegalArgumentException e) {
|
||||||
MarkupSession.logWarningAt(program, func.getEntryPoint(),
|
MarkupSession.logWarningAt(program, func.getEntryPoint(),
|
||||||
"Failed to update function signature: " + e.getMessage());
|
"Failed to update function signature: " + e.getMessage());
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (funcDefResult.symbolName().hasReceiver()) {
|
if (funcDefResult.symbolName().hasReceiver()) {
|
||||||
|
|||||||
+15
-3
@@ -53,24 +53,36 @@ public class GoFunctionFixup {
|
|||||||
this.func = func;
|
this.func = func;
|
||||||
this.storageAllocator = new GoParamStorageAllocator(program, goVersion);
|
this.storageAllocator = new GoParamStorageAllocator(program, goVersion);
|
||||||
this.newSignature = func.getSignature();
|
this.newSignature = func.getSignature();
|
||||||
this.newCallingConv = null;
|
|
||||||
|
|
||||||
if (GoRttiMapper.isAbi0Func(func.getEntryPoint(), program)) {
|
if (GoRttiMapper.isAbi0Func(func.getEntryPoint(), program)) {
|
||||||
// Some (typically lower level) functions in the binary will be marked with a
|
// Some (typically lower level) functions in the binary will be marked with a
|
||||||
// symbol that ends in the string "abi0".
|
// symbol that ends in the string "abi0".
|
||||||
// Throw away all registers and force stack allocation for everything
|
// Throw away all registers and force stack allocation for everything
|
||||||
storageAllocator.setAbi0Mode();
|
storageAllocator.setAbi0Mode();
|
||||||
|
this.newCallingConv = GoConstants.GOLANG_ABI0_CALLINGCONVENTION_NAME;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.newCallingConv = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public GoFunctionFixup(Function func, FunctionSignature newSignature, String newCallingConv,
|
public GoFunctionFixup(Function func, FunctionSignature newSignature, String defaultCCName,
|
||||||
GoParamStorageAllocator storageAllocator) {
|
GoParamStorageAllocator storageAllocator) {
|
||||||
this.program = func.getProgram();
|
this.program = func.getProgram();
|
||||||
this.dtm = program.getDataTypeManager();
|
this.dtm = program.getDataTypeManager();
|
||||||
this.func = func;
|
this.func = func;
|
||||||
this.storageAllocator = storageAllocator;
|
this.storageAllocator = storageAllocator;
|
||||||
this.newSignature = newSignature;
|
this.newSignature = newSignature;
|
||||||
this.newCallingConv = newCallingConv;
|
if (GoRttiMapper.isAbi0Func(func.getEntryPoint(), program)) {
|
||||||
|
// Some (typically lower level) functions in the binary will be marked with a
|
||||||
|
// symbol that ends in the string "abi0".
|
||||||
|
// Throw away all registers and force stack allocation for everything
|
||||||
|
storageAllocator.setAbi0Mode();
|
||||||
|
this.newCallingConv = GoConstants.GOLANG_ABI0_CALLINGCONVENTION_NAME;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.newCallingConv = defaultCCName;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isClosureContext(ParameterDefinition p) {
|
public static boolean isClosureContext(ParameterDefinition p) {
|
||||||
|
|||||||
-8
@@ -552,14 +552,6 @@ public class GoRttiMapper extends DataTypeMapper implements DataTypeMapperContex
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCallingConventionFor(GoFuncData func) {
|
|
||||||
// TODO: this logic needs work. Currently we are not strongly declaring functions
|
|
||||||
// as abi0.
|
|
||||||
return defaultCCName != null && !isAbi0Func(func.getFuncAddress(), program)
|
|
||||||
? defaultCCName
|
|
||||||
: null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns true if the specified calling convention is defined for the program.
|
* Returns true if the specified calling convention is defined for the program.
|
||||||
* @param ccName calling convention name
|
* @param ccName calling convention name
|
||||||
|
|||||||
Reference in New Issue
Block a user