Skip to content

Feat/macho symbol provider#89

Merged
r0ny123 merged 5 commits into
master-forkfrom
feat/macho-symbol-provider
Jun 22, 2026
Merged

Feat/macho symbol provider#89
r0ny123 merged 5 commits into
master-forkfrom
feat/macho-symbol-provider

Conversation

@r0ny123

@r0ny123 r0ny123 commented Jun 22, 2026

Copy link
Copy Markdown
Owner

No description provided.

r0ny123 added 4 commits June 18, 2026 20:15
Unify BinaryInfo xmetadata and provider contracts across PE and ELF:
- Share ELF relocation import parsing between ElfSymbolProvider and ElfApiResolver.
- Merge ELF symtab/dynamic/export symbols in getSymbols(); reset ElfApiResolver cache.
- Normalize ELF OEP to base-relative offset for candidate seeding.
- Route PE imports/exports/symbols/OEP through base_addr; add collectSymbols().
- Delegate WinApiResolver PE imports to PeSymbolProvider.parseImports().

Validation: make lint, make test (285 passed)
- parseImports uses _resolve_base_addr (imagebase fallback, None-safe).
- Guard ELF getOep when base_addr is unset.
- Update PE import default test to expect imagebase fallback.

Validation: make lint, make test (285 passed)
…tadata parity

Finish Tier-2 label backlog deferred from PR #84: align RustSymbolProvider PE
paths with active base_addr, add MachoSymbolProvider.collectSymbols wired through
BinaryInfo.getSymbols(), extract shared import parsers, and document the xmetadata
address contract across PE/ELF/Mach-O.

Validation: make lint, make test (293 passed)
- Treat falsy base_addr as unset (BinaryInfo defaults to 0).
- Hoist PE library name lowercasing; guard None library/binding names.
@coderabbitai

coderabbitai Bot commented Jun 22, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. To trigger a review, include @coderabbit in the PR description. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: cf55150a-c5bf-4dbb-b89c-50bb412a344d

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@r0ny123 r0ny123 marked this pull request as ready for review June 22, 2026 12:01
@r0ny123 r0ny123 merged commit f1d8f25 into master-fork Jun 22, 2026
17 checks passed
@r0ny123 r0ny123 deleted the feat/macho-symbol-provider branch June 22, 2026 12:01

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors and normalizes binary metadata parsing (exports, imports, symbols, OEP, and sections) across PE, ELF, and Mach-O formats using LIEF, extracting shared import-table parsers into a new import_parsers.py module and updating providers to use consistent virtual address conventions. Feedback on these changes suggests importing and calling parse_pe_imports directly in WinApiResolver.py to avoid unnecessary class instantiation, and adding defensive checks in import_parsers.py to prevent potential AttributeError crashes when parsing malformed ELF binaries.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

from smda.common.labelprovider.OrdinalHelper import OrdinalHelper # noqa: E402

from .AbstractLabelProvider import AbstractLabelProvider # noqa: E402
from .PeSymbolProvider import PeSymbolProvider # noqa: E402

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Instead of importing PeSymbolProvider only to instantiate it for calling parseImports, we can import parse_pe_imports directly from .import_parsers. This is cleaner and avoids unnecessary class instantiation.

Suggested change
from .PeSymbolProvider import PeSymbolProvider # noqa: E402
from .import_parsers import parse_pe_imports # noqa: E402

imported_library.name.lower(),
ordinal_name,
)
self._api_map["lief"] = PeSymbolProvider(None).parseImports(lief_binary, binary_info.base_addr)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Directly call parse_pe_imports instead of instantiating PeSymbolProvider(None) to call parseImports. This improves efficiency and maintainability.

Suggested change
self._api_map["lief"] = PeSymbolProvider(None).parseImports(lief_binary, binary_info.base_addr)
self._api_map["lief"] = parse_pe_imports(lief_binary, binary_info.base_addr)

Comment on lines +53 to +54
if symbol.has_version and symbol.symbol_version.has_auxiliary_version:
lib = symbol.symbol_version.symbol_version_auxiliary.name

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Add defensive checks to ensure symbol.symbol_version and symbol.symbol_version.symbol_version_auxiliary are not None before accessing their attributes. This prevents potential AttributeError crashes when parsing malformed or unusual ELF binaries.

Suggested change
if symbol.has_version and symbol.symbol_version.has_auxiliary_version:
lib = symbol.symbol_version.symbol_version_auxiliary.name
if symbol.has_version and symbol.symbol_version and symbol.symbol_version.has_auxiliary_version:
aux = symbol.symbol_version.symbol_version_auxiliary
lib = aux.name if aux else None

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a7af4693f1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

self.oep = lief_result.optional_header.addressof_entrypoint
elif lief_type == "ELF":
self.oep = lief_result.header.entrypoint
self.oep = lief_result.header.entrypoint - (self.base_addr or 0)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve PIE ELF entrypoint offsets

When analyzing an ET_DYN/PIE ELF buffer with a nonzero binary_info.base_addr, LIEF reports header.entrypoint as an offset relative to the load base, not an absolute VA. This subtraction makes binary_info.oep negative, and RecursiveDisassembler later queues base_addr + oep, so it starts at the small file VA (for example 0x1050) instead of base_addr + 0x1050 and can miss the real entry point.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant