Check if the given binary context is a valid match candidate. Args: bin_ctx (ComparableContext): context representing a binary function (potential match) Return Value: False iff the binary context was found as an invalid match candidate
(self, bin_ctx)
| 557 | return None |
| 558 | |
| 559 | def isValidCandidate(self, bin_ctx): |
| 560 | """Check if the given binary context is a valid match candidate. |
| 561 | |
| 562 | Args: |
| 563 | bin_ctx (ComparableContext): context representing a binary function (potential match) |
| 564 | |
| 565 | Return Value: |
| 566 | False iff the binary context was found as an invalid match candidate |
| 567 | """ |
| 568 | # 0. Both must be in the game |
| 569 | if not self.active() or not bin_ctx.active(): |
| 570 | return False |
| 571 | |
| 572 | # 1. They must be in the same file |
| 573 | if not bin_ctx.isFileSuitable(self): |
| 574 | return False |
| 575 | |
| 576 | # 2. A static function can not have an xref from outside the library (weak because of possible inlining) |
| 577 | if self.is_static and not bin_ctx.is_static: |
| 578 | return False |
| 579 | |
| 580 | # 3. A collision candidate must not conflict with the previous matches |
| 581 | if not bin_ctx.isPartial() and bin_ctx.matched() and self.hash != bin_ctx.match.hash: |
| 582 | return False |
| 583 | |
| 584 | # If reached this line, the candidate is probably fine |
| 585 | return True |
| 586 | |
| 587 | def compare(self, bin_ctx, logger): |
| 588 | """Compare our (source) function to a potential binary match. |
no test coverage detected