Skip to content

Commit

Permalink
Use static mutex
Browse files Browse the repository at this point in the history
  • Loading branch information
sei-eschwartz authored Apr 23, 2024
1 parent ac622a7 commit 28b3a50
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion libpharos/funcs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1058,6 +1058,8 @@ void FunctionDescriptor::_compute_function_hashes(ExtraFunctionHashData *extra)
// mwd: this code assumes this. Is it guaranteed?
assert(func);

static std::mutex matcher_mutex;

const CFG& cfg = get_pharos_cfg();
write_guard<decltype(mutex)> guard{mutex};
if (hashes_calculated) { return; }
Expand Down Expand Up @@ -1208,7 +1210,7 @@ void FunctionDescriptor::_compute_function_hashes(ExtraFunctionHashData *extra)

// First we'll look for RIP-relative offsets, e.g., [rip + offset]
{
write_guard<decltype(mutex)> guard{mutex};
write_guard<decltype(matcher_mutex)> guard{matcher_mutex};
AstMatching m;
MatchResult rip_offsets = m.performMatching("$EXP=SgAsmMemoryReferenceExpression(SgAsmBinaryAdd($REG=SgAsmDirectRegisterExpression,$OFFSET=SgAsmIntegerValueExpression),$SEGMENTREG)", insn);

Expand Down

0 comments on commit 28b3a50

Please sign in to comment.