summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZichuan Li <34680029+river-li@users.noreply.github.com>2024-05-31 11:19:55 -0400
committerZichuan Li <34680029+river-li@users.noreply.github.com>2024-05-31 15:27:38 -0400
commit4279136cc033e93a2ec4afec0c6cab037e76c907 (patch)
tree8c3e121a019db403f28453989bff68ddd4bcba10
parent12d47835b1127605d224178e8e67c29f609a1a86 (diff)
Fixed type propagation issue in AARCH64 and MIPS
Previously, prtinf type library is not being appropriately applied. #3092
-rw-r--r--arch/arm64/arch_arm64.cpp18
-rw-r--r--arch/mips/arch_mips.cpp30
2 files changed, 42 insertions, 6 deletions
diff --git a/arch/arm64/arch_arm64.cpp b/arch/arm64/arch_arm64.cpp
index ffa05fe8..68cfae5a 100644
--- a/arch/arm64/arch_arm64.cpp
+++ b/arch/arm64/arch_arm64.cpp
@@ -2448,10 +2448,22 @@ class Arm64ImportedFunctionRecognizer : public FunctionRecognizer
if (jumpOperand.GetSourceRegister<LLIL_REG>() != targetReg)
return false;
- Ref<Symbol> funcSym = Symbol::ImportedFunctionFromImportAddressSymbol(sym, func->GetStart());
+ Ref<Symbol> funcSym = Symbol::ImportedFunctionFromImportAddressSymbol(sym, func->GetStart()); // func is plt function
data->DefineAutoSymbol(funcSym);
- func->ApplyImportedTypes(funcSym);
- return true;
+ for (auto& extSym : data->GetSymbolsByName(funcSym->GetRawName()))
+ {
+ if (extSym->GetType() == ExternalSymbol)
+ {
+ DataVariable var;
+ if (data->GetDataVariableAtAddress(extSym->GetAddress(), var))
+ {
+ func->ApplyImportedTypes(funcSym, var.type);
+ }
+
+ return true;
+ }
+ }
+ return false;
}
diff --git a/arch/mips/arch_mips.cpp b/arch/mips/arch_mips.cpp
index 50ad0f75..1fa6b169 100644
--- a/arch/mips/arch_mips.cpp
+++ b/arch/mips/arch_mips.cpp
@@ -1747,8 +1747,20 @@ private:
Ref<Symbol> funcSym = Symbol::ImportedFunctionFromImportAddressSymbol(sym, func->GetStart());
data->DefineAutoSymbol(funcSym);
- func->ApplyImportedTypes(funcSym);
- return true;
+ for (auto& extSym : data->GetSymbolsByName(funcSym->GetRawName()))
+ {
+ if (extSym->GetType() == ExternalSymbol)
+ {
+ DataVariable var;
+ if (data->GetDataVariableAtAddress(extSym->GetAddress(), var))
+ {
+ func->ApplyImportedTypes(funcSym, var.type);
+ }
+
+ return true;
+ }
+ }
+ return false;
}
@@ -1939,7 +1951,19 @@ private:
Ref<Symbol> funcSym = Symbol::ImportedFunctionFromImportAddressSymbol(sym, func->GetStart());
data->DefineAutoSymbol(funcSym);
- func->ApplyImportedTypes(funcSym);
+ for (auto& extSym : data->GetSymbolsByName(funcSym->GetRawName()))
+ {
+ if (extSym->GetType() == ExternalSymbol)
+ {
+ DataVariable var;
+ if (data->GetDataVariableAtAddress(extSym->GetAddress(), var))
+ {
+ func->ApplyImportedTypes(funcSym, var.type);
+ }
+
+ return true;
+ }
+ }
return true;
}