Skip to content

Commit

Permalink
fix macho loading when symbols aren't availble as expected (#531)
Browse files Browse the repository at this point in the history
* fix macho loading when symbols aren't availble as expected

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
rhelmot and pre-commit-ci[bot] authored Dec 4, 2024
1 parent 9fbf309 commit 1410be9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cle/backends/macho/binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,13 @@ 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 1410be9

Please sign in to comment.