* Verify the binary speaks our wire contract: same ABI version and byte-equal * NodeKind/EdgeKind tables (kinds cross the boundary as indexes into these).
(mod: KernelModule, from: string)
| 122 | * NodeKind/EdgeKind tables (kinds cross the boundary as indexes into these). |
| 123 | */ |
| 124 | function verifyContract(mod: KernelModule, from: string): boolean { |
| 125 | const info = mod.contractInfo(); |
| 126 | if (info.abiVersion !== KERNEL_ABI_VERSION) { |
| 127 | debug(`${from}: ABI ${info.abiVersion} != expected ${KERNEL_ABI_VERSION} — ignoring kernel`); |
| 128 | return false; |
| 129 | } |
| 130 | const sameTable = (a: readonly string[], b: readonly string[]) => |
| 131 | a.length === b.length && a.every((v, i) => v === b[i]); |
| 132 | if (!sameTable(info.nodeKinds, NODE_KINDS) || !sameTable(info.edgeKinds, EDGE_KINDS)) { |
| 133 | debug(`${from}: NodeKind/EdgeKind tables differ from src/types.ts — ignoring kernel`); |
| 134 | return false; |
| 135 | } |
| 136 | return true; |
| 137 | } |
| 138 | |
| 139 | /** |
| 140 | * Load (once per process) and return the kernel module, or null when |
no test coverage detected