Skip to content

Fix Mach-O section metadata and function discovery - #810

Merged
ltfish merged 2 commits into
angr:masterfrom
blankwall:fix/macho-loader-metadata
Sep 4, 2026
Merged

Fix Mach-O section metadata and function discovery#810
ltfish merged 2 commits into
angr:masterfrom
blankwall:fix/macho-loader-metadata

Conversation

@blankwall

Copy link
Copy Markdown
Contributor

Summary

  • represent Mach-O zero-fill sections with filesize == 0 while preserving their virtual size
  • publish decoded LC_FUNCTION_STARTS entries through CLE's standard function_hints interface
  • cover file-offset containment, ordinary section sizing, hint ordering, zero-sized hint metadata, and rebasing

Rationale

Mach-O section size is a virtual size. S_ZEROFILL, S_GB_ZEROFILL, and
S_THREAD_LOCAL_ZEROFILL occupy memory but have no file-backed bytes. Passing
their virtual size as CLE's file size makes them claim unrelated file offsets,
often including offset zero.

CLE already decodes LC_FUNCTION_STARTS, but previously retained those
addresses only in the Mach-O-specific lc_function_starts list. Publishing
them as source-labeled FunctionHint entries lets existing CFG consumers use
the linker-provided starts without Mach-O-specific integration.

Validation

  • pytest -q tests/test_macho.py -k 'not relocatable_object' (14 passed, 1 deselected)
  • verified all 11,199 decoded starts from a stripped AArch64 Mach-O are exposed as ordered function hints
  • verified hints rebase by image_base_delta

The deselected test was added to CLE master by #787, but its
relocatable_object.macho fixtures are not yet present in the current
angr/binaries master.

Represent zero-fill sections with no file-backed bytes while preserving their virtual size, and publish LC_FUNCTION_STARTS entries through CLE's function-hint interface.

Add regression coverage for file-offset containment, ordinary sections, hint ordering, metadata, and rebasing.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 67ccc324-20c3-4b04-8e9f-0bd97acc31f5
@blankwall
blankwall force-pushed the fix/macho-loader-metadata branch from 907a7df to 77e13e2 Compare September 3, 2026 18:12
Remove the superfluous condition parentheses and narrow the rebased Mach-O test object and optional function-start list for type checking.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: 67ccc324-20c3-4b04-8e9f-0bd97acc31f5
@ltfish
ltfish merged commit 0e77ade into angr:master Sep 4, 2026
20 checks passed
@ltfish

ltfish commented Sep 4, 2026

Copy link
Copy Markdown
Member

Thanks!

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.

2 participants