@@ -1010,13 +1010,13 @@ File-by-file map:
10101010 type/method/image/assembly/referenced-assembly decoders, P/Invoke
10111011 and reverse-P/Invoke enumerators, endian-safe LE readers
10121012 (`RD_LE32`, `RD_LE16`).
1013- - `src/lib/elf .c` — ELF32/64 loader, dynamic-table walk, relative
1014- relocation application (`DT_REL`, `DT_RELA`, `DT_RELR`),
1015- method-pointer-array heuristic.
1016- - `src/lib/macho.c` — Mach-O 64 loader (thin + FAT first-ARM64),
1017- `LC_SEGMENT_64` walk, method-pointer-array heuristic.
1018- - `src/lib/pe.c` — PE32/PE32+ loader, section walk, method-pointer-
1019- array heuristic .
1013+ - `src/lib/bin/native .c` — shared native-binary view,
1014+ CodeRegistration/MetadataRegistration anchor resolution, structural
1015+ CodeRegistration parsing, RBin adapter, and the generic section-scan
1016+ fallback.
1017+ - `src/lib/bin/elf.c`, `src/lib/bin/macho.c`, `src/lib/bin/pe.c` —
1018+ simple file-backed format parsers used when the RBin path cannot
1019+ recover method pointers .
10201020- `src/main.c` — CLI entry point and output emitters.
10211021
10221022Every row decoder reads via `r_read_le32`/`r_read_le16` (LE on all
@@ -1027,45 +1027,41 @@ retained for the two string pools.
10271027## 6. Native-binary scanning, in one picture
10281028
10291029```text
1030- ELF/Mach-O/PE image on disk
1030+ Native IL2CPP image opened by r_bin or a simple ELF/Mach-O/PE mapper
10311031 │
1032- ├─ load & parse segments/sections
1032+ ├─ use r_bin sections/symbols/relocs when available
1033+ │ or simple file-backed sections for fallback
10331034 │ ↓
1034- │ segments { vaddr/vmaddr , size, perms, file mapping }
1035+ │ sections { vaddr, size, perms }
10351036 │ ↓
10361037 │ [text_lo, text_hi) (executable union)
10371038 │
1038- ├─ ELF only: apply DT_REL / DT_RELA / DT_RELR relative fixups
1039- │ so data-segment pointer arrays match the runtime
1040- │ state (addends resolved, RELR bitmap expanded).
1039+ ├─ resolve g_CodeRegistration / g_MetadataRegistration
1040+ │ order: CLI -O / r2 eval vars / r2 flags / r_bin symbols
10411041 │
1042- ├─ scan each writable/data segment :
1043- │ pass 1: {count32, pad32, ptr} tuple
1044- │ (CodeRegistration-shaped anchor pair)
1045- │ pass 2: {count32, ptr} generic
1042+ ├─ parse Il2CppCodeRegistration :
1043+ │ v24.2+: match codeGenModules[] to metadata images and
1044+ │ copy each module's methodPointers[]
1045+ │ older: recover the global methodPointers[] pair
10461046 │
1047- └─ accept if a sample of entries at *ptr[] lands in text,
1048- either already (post-relocations) or after + base_vaddr
1049- (raw RVA case). Emit absolute VAs, one per method index.
1047+ └─ fallback when forced or unresolved:
1048+ scan non-executable data/readable sections for {count, ptr}
1049+ pairs whose table entries land in executable code.
1050+ Emit absolute VAs, one per method index.
10501051```
10511052
1052- The heuristic is deliberately weaker than a structural
1053- ` Il2CppCodeRegistration ` match, but it works on every supported
1054- target and doesn't need symbol tables. It does, however, lock onto
1055- ** one** ` {count, ptr} ` array, which on v24.2+ means one image's
1056- methods, not all of them (§3.1 / §3.7). A proper structural match
1057- that walks ` codeGenModules[] ` is on the roadmap.
1053+ The structural path is preferred because it follows Unity's native
1054+ registration structures instead of guessing which ` {count, ptr} ` pair
1055+ is the method-pointer table. The fallback remains useful for stripped
1056+ binaries or builds where the registration symbols cannot be resolved.
1057+ The simple ELF/Mach-O/PE parsers do not reimplement full symbol-table
1058+ parsing; they use explicit registration addresses when provided and
1059+ otherwise feed their sections into the fallback scanner.
10581060
1059- For ELF the relocation pass matters because the Android linker
1060- produces method-pointer arrays almost entirely as
1061- ` R_AARCH64_RELATIVE ` (type 1027) entries. Without applying them,
1062- the raw array on disk is a run of zeros. Packed Android relocations
1063- (` DT_ANDROID_RELA ` , ` DT_ANDROID_RELR ` ) are not handled yet and
1064- cause the same "empty array" symptom on Play Store builds.
1065-
1066- For Mach-O and PE the linker has already materialised concrete
1067- values; no explicit relocation pass is required for the tables
1068- r2unity currently scans.
1061+ Relocation handling is delegated to r_bin (` r_bin_patch_relocs ` ) on
1062+ the RBin path. The simple ELF parser also applies the common relative
1063+ REL/RELA/RELR forms so stripped Android/Linux inputs still have a
1064+ lightweight fallback.
10691065
10701066## 7. Data we can extract today vs. data we do not
10711067
@@ -1083,7 +1079,7 @@ Already extracted by r2unity (library + CLI):
10831079| referenced assemblies | flat int32 array |
10841080| P/Invoke marker methods | ` -P ` enumeration |
10851081| reverse-P/Invoke on v29+ | ` -R ` enumeration via BLOB |
1086- | method-pointer VA (global) | ELF/Mach-O/PE heuristic |
1082+ | method-pointer VA | CodeRegistration parse + r_bin/simple-parser section-scan fallback |
10871083
10881084Data present on disk / in the binary but ** not yet consumed** :
10891085
@@ -1109,14 +1105,14 @@ Data present on disk / in the binary but **not yet consumed**:
11091105 metadata load in compiled code (§2.12).
11101106- ` fieldMarshaledSizes ` , ` unresolvedVirtualCall* ` , WinRT tables,
11111107 `exportedTypeDefinitions`, RGCTX tables (§2.14–2.18).
1112- - Native-side ` CodeRegistration ` and ` MetadataRegistration ` walk →
1108+ - Native-side registration data beyond method pointers →
11131109 `invokerPointers`, `customAttributeGenerators`,
11141110 `reversePInvokeWrappers`, `genericMethodPointers`,
1115- `interopData`, `codeGenModules[] `, `types `, `fieldOffsets `,
1116- `typeDefinitionsSizes`, ` metadataUsages` (§3).
1117- - Richer native scanning: per-module ` methodPointers ` on v24.2+,
1118- packed Android relocations , Mach-O FAT multi-slice,
1119- chained-fixups, PE import table.
1111+ `interopData`, `types `, `fieldOffsets `, `typeDefinitionsSizes `,
1112+ `metadataUsages` (§3).
1113+ - Richer native support: packed Android relocations and other loader
1114+ details not yet handled by r_bin for a given target , Mach-O FAT
1115+ multi-slice selection, chained-fixups, PE import table.
11201116
11211117## 8. validation corpus
11221118
0 commit comments