Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_object: filter non-external symbols in dylibs #16

Merged
merged 1 commit into from
Oct 6, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions abi3audit/_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,17 +152,13 @@ def __iter__(self) -> Iterator[Symbol]:
raise SharedObjectError("shared object has no symbol table")

for symbol in symtab_cmd.symbols:
# TODO(ww): Do a better job of filtering here.
# The Mach-O symbol table includes all kinds of junk, including
# symbolic entries for debuggers. We should exclude all of
# these non-function/data entries, as well as any symbols
# that isn't marked as external (since we're linking against
# the Python interpreter for the ABI).
if (name := symbol.name) is None:
# We only care about symbols that have the external bit set,
# since these are the ones resolved when linking to CPython.
if not symbol.type & 0x01:
continue

# All symbols on macOS are prefixed with _; remove it.
yield Symbol(name[1:])
yield Symbol(symbol.name[1:])


class _Dll(_SharedObjectBase):
Expand Down