Skip to content

Commit

Permalink
fix macho loading when symbols aren't availble as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
rhelmot committed Dec 4, 2024
1 parent 9fbf309 commit b6f958c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cle/backends/macho/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,11 @@ def resolve_symbol(self, solist, thumb=False, extern_object=None, **kwargs):
if isinstance(self.symbol, (SymbolTableSymbol, BindingSymbol, DyldBoundSymbol)):
for so in solist:
if self.symbol.library_base_name == so.binary_basename:
[symbol] = so.get_symbol(self.symbol.name)
symbols = so.get_symbol(self.symbol.name)
if not symbols:
log.warning("Symbol %s should have been resolved by %s but wasn't", self.symbol.name, so.binary_basename)
continue
(symbol,) = symbols
assert symbol.is_export
self.resolve(symbol, extern_object=extern_object)
log.info("Resolved %s to %s", self.symbol.name, symbol)
Expand Down
4 changes: 4 additions & 0 deletions cle/backends/macho/macho.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,10 @@ def _parse_load_commands(self, lc_offset):
f"Assertion triggered: {count} < {self.ncmds} or {offset - lc_offset} < {self.sizeofcmds}"
)

@staticmethod
def extract_soname(path):
return path.split('/')[-1]

@classmethod
def is_compatible(cls, stream):
stream.seek(0)
Expand Down

0 comments on commit b6f958c

Please sign in to comment.