-
-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
10 additions
and
17 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
// SPDX-FileCopyrightText: 2024 Crabtux <[email protected]> | ||
// SPDX-License-Identifier: LGPL-3.0-or-later | ||
|
||
#include "RizinLoadImage.h" | ||
#include "RizinUtils.h" | ||
#include "PcodeFixupPreprocessor.h" | ||
|
||
#include <funcdata.hh> | ||
|
@@ -11,24 +13,15 @@ using namespace ghidra; | |
|
||
void PcodeFixupPreprocessor::fixupSharedReturnJumpToRelocs(RzAnalysisFunction *function, Funcdata *func, RzCore *core, RizinArchitecture &arch) | ||
{ | ||
RzList *refs = rz_analysis_function_get_xrefs_from(function); | ||
|
||
RzListIter *it; | ||
RzAnalysisXRef *xref; | ||
|
||
// C++ has more strict type checking than C, which stops us from implicitly casting void * to RzListIter *. | ||
// Expand the rz_list_foreach macro manually. | ||
if (refs) for (it = refs->head; it && (xref = (RzAnalysisXRef *)it->elem, 1); it = it->next) | ||
{ | ||
RzList *xrefs = rz_analysis_function_get_xrefs_from(function); | ||
rz_list_foreach_cpp<RzAnalysisXRef>(xrefs, [&](RzAnalysisXRef *xref){ | ||
// To ensure the instruction is a `jmp` instruction | ||
if (xref->type != RZ_ANALYSIS_XREF_TYPE_CODE) | ||
continue; | ||
|
||
// If the target location is a imported function, then do the patch. | ||
RzBinReloc *reloc = rz_core_get_reloc_to(core, xref->to); | ||
if (reloc != nullptr && reloc->import != nullptr) | ||
if (xref->type == RZ_ANALYSIS_XREF_TYPE_CODE) | ||
{ | ||
func->getOverride().insertFlowOverride(Address(arch.getDefaultCodeSpace(), xref->from), Override::CALL_RETURN); | ||
// If the target location is a imported function, then do the patch. | ||
RzBinReloc *reloc = rz_core_get_reloc_to(core, xref->to); | ||
if (reloc != nullptr && reloc->import != nullptr) | ||
func->getOverride().insertFlowOverride(Address(arch.getDefaultCodeSpace(), xref->from), Override::CALL_RETURN); | ||
} | ||
} | ||
}); | ||
} |