Skip to content

Commit

Permalink
Merge pull request #69 from yomaytk/fix-bug
Browse files Browse the repository at this point in the history
Fix the bug of strange instruction like 'bl _d_24.' by cross compilation.
  • Loading branch information
yomaytk authored Nov 23, 2024
2 parents b248374 + 3b1c948 commit 7074277
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions backend/remill/lib/BC/TraceLifter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,9 +613,12 @@ bool TraceLifter::Impl::Lift(uint64_t addr, const char *fn_name,
case Instruction::kCategoryDirectFunctionCall: {
direct_func_call:
try_add_delay_slot(true, block);
if (inst.branch_not_taken_pc != inst.branch_taken_pc) {
auto target_trace = get_trace_decl(inst.branch_taken_pc);
// The ELF/aarch64 binary generated by cross compilation of clang-16 has the instruction like a `bl _d_24`.
// However, the symbol like `_d_24` doesn't indicate the function, so lifting it is invalid.
// When we find such a instruction, we treat it as `nop`.
if (target_trace && inst.branch_not_taken_pc != inst.branch_taken_pc) {
trace_work_list.insert(inst.branch_taken_pc);
auto target_trace = get_trace_decl(inst.branch_taken_pc);
auto lifted_func_call = AddCall(
block, target_trace, *intrinsics,
llvm::ConstantInt::get(llvm::Type::getInt64Ty(context), inst.branch_taken_pc));
Expand Down

0 comments on commit 7074277

Please sign in to comment.