From 4279136cc033e93a2ec4afec0c6cab037e76c907 Mon Sep 17 00:00:00 2001 From: Zichuan Li <34680029+river-li@users.noreply.github.com> Date: Fri, 31 May 2024 11:19:55 -0400 Subject: Fixed type propagation issue in AARCH64 and MIPS Previously, prtinf type library is not being appropriately applied. #3092 --- arch/arm64/arch_arm64.cpp | 18 +++++++++++++++--- arch/mips/arch_mips.cpp | 30 +++++++++++++++++++++++++++--- 2 files changed, 42 insertions(+), 6 deletions(-) (limited to 'arch') 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() != targetReg) return false; - Ref funcSym = Symbol::ImportedFunctionFromImportAddressSymbol(sym, func->GetStart()); + Ref 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 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 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; } -- cgit v1.3.1