From 1b533d8c2b687bbe757601efbb14bc0fac5a24a8 Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Wed, 25 Dec 2013 23:15:57 -0800 Subject: [PATCH] Fix for accidentally including rest fns as branches. --- src/alloy/frontend/ppc/ppc_scanner.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/alloy/frontend/ppc/ppc_scanner.cc b/src/alloy/frontend/ppc/ppc_scanner.cc index d9f636263..f75229b9e 100644 --- a/src/alloy/frontend/ppc/ppc_scanner.cc +++ b/src/alloy/frontend/ppc/ppc_scanner.cc @@ -113,6 +113,8 @@ int PPCScanner::FindExtents(FunctionInfo* symbol_info) { } else if (i.code == 0x4E800420) { // bctr -- unconditional branch to CTR. // This is generally a jump to a function pointer (non-return). + // This is almost always a jump table. + // TODO(benvanik): decode jump tables. if (furthest_target > address) { // Remaining targets within function, not end. XELOGSDB("ignoring bctr %.8X (branch to %.8X)", address, @@ -196,7 +198,7 @@ int PPCScanner::FindExtents(FunctionInfo* symbol_info) { } */ - if (!ends_fn) { + if (!ends_fn && !IsRestGprLr(target)) { furthest_target = MAX(furthest_target, target); // TODO(benvanik): perhaps queue up for a speculative check? I think @@ -222,7 +224,9 @@ int PPCScanner::FindExtents(FunctionInfo* symbol_info) { // TODO(benvanik): GetOrInsertFunction? it's likely a BB - furthest_target = MAX(furthest_target, target); + if (!IsRestGprLr(target)) { + furthest_target = MAX(furthest_target, target); + } } ends_block = true; } else if (i.type->opcode == 0x4C000020) { @@ -317,6 +321,8 @@ std::vector PPCScanner::FindBlocks(FunctionInfo* symbol_info) { ends_block = true; } else if (i.code == 0x4E800420) { // bctr -- unconditional branch to CTR. + // This is almost always a jump table. + // TODO(benvanik): decode jump tables. ends_block = true; } else if (i.type->opcode == 0x48000000) { // b/ba/bl/bla