peachsim 0.1.2589 → 0.1.2590
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-lib/agent-daemon-client.cjs +1 -1
- package/dist-lib/agent-events.cjs +1 -1
- package/dist-lib/attached-projects.cjs +1 -1
- package/dist-lib/auth/shared-session.cjs +1 -1
- package/dist-lib/backend-origin.cjs +1 -1
- package/dist-lib/beta.cjs +1 -1
- package/dist-lib/beta.mjs +2 -2
- package/dist-lib/bridge-constants.cjs +1 -1
- package/dist-lib/bridge-contract-input.cjs +1 -1
- package/dist-lib/bridge-contract-input.mjs +5 -5
- package/dist-lib/bridge-contract.cjs +1 -1
- package/dist-lib/bridge-contract.mjs +3 -3
- package/dist-lib/bundle-channel.cjs +1172 -446
- package/dist-lib/capture-contract.cjs +1 -1
- package/dist-lib/capture-contract.mjs +3 -3
- package/dist-lib/cloud-contract.cjs +1 -1
- package/dist-lib/cloud-contract.mjs +3 -3
- package/dist-lib/cloud-test-args.cjs +1 -1
- package/dist-lib/cloud-test-args.mjs +2 -2
- package/dist-lib/cloud.cjs +1 -1
- package/dist-lib/cloud.mjs +7 -7
- package/dist-lib/config.cjs +1 -1
- package/dist-lib/config.mjs +5 -5
- package/dist-lib/detox/index.cjs +1 -1
- package/dist-lib/dev-bundle-resolution.cjs +1 -1
- package/dist-lib/esm-chunks/{acorn-6FUOY6FX.mjs → acorn-65FNEARV.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-EAIFG4MQ.mjs → chunk-2GUB5OLB.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-FQQ2DMXS.mjs → chunk-462CWTWI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-L3OSVIGA.mjs → chunk-4VCRUQ36.mjs} +1178 -452
- package/dist-lib/esm-chunks/{chunk-5QWQDXXD.mjs → chunk-5GNGHM5B.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-JLOJZF2Y.mjs → chunk-ADKUIQXX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-M4KUWGU3.mjs → chunk-BZS5SIYK.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-47K4QPVA.mjs → chunk-EFKDUMB5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-I22LAVD5.mjs → chunk-GBD26EBV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-CRIYVOMB.mjs → chunk-HZTK7TP5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-5EFD2VBY.mjs → chunk-JG4AANWA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-FMWEI6OI.mjs → chunk-N2II5SRJ.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-33SCXU3Y.mjs → chunk-NZY4GOG5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-KFHCRS5K.mjs → chunk-OZJ66CXY.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-464CBA5U.mjs → chunk-RGC2JNCL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-57FFWABF.mjs → chunk-SLPXTLBK.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-Y4PV4HZB.mjs → chunk-SRFKOU76.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-3VNUC4DT.mjs → chunk-V5TTEXYO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-MKSOJCRT.mjs → chunk-WPDY5IAD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WQ73RKJY.mjs → chunk-WYDRQRJL.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-BSAAJR25.mjs → chunk-X2EKFONU.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-PUBH3EXI.mjs → chunk-XE3VHAU2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-XTKKROVU.mjs → chunk-YPPH6F77.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-T5QIJTEV.mjs → metro-layout-parser-CRI3GMCM.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-AWTZHPDM.mjs → swift-package-prebuilt-5XDZ2HZZ.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-MGTJTVKU.mjs → swift-sdk-app-module-6H3G6AXD.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-JABGF3ZR.mjs → swift-sdk-image-WAC7GG2R.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-RJRJ3EFU.mjs → swift-sdk-image-producer-B3L27QTG.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +1171 -445
- package/dist-lib/expo-swift-metadata.cjs +1 -1
- package/dist-lib/expo-swift-metadata.mjs +7 -7
- package/dist-lib/home-paths.cjs +1 -1
- package/dist-lib/host/bridge-host.cjs +1200 -469
- package/dist-lib/host/fetch-proxy-handler.cjs +4 -4
- package/dist-lib/host/fetch-proxy-overrides.cjs +1 -1
- package/dist-lib/host/fetch-proxy-overrides.mjs +2 -2
- package/dist-lib/host/replacement-module-handler.cjs +1 -1
- package/dist-lib/host/websocket-proxy.cjs +1 -1
- package/dist-lib/index.cjs +1 -1
- package/dist-lib/kotlin-host.cjs +1 -1
- package/dist-lib/menu.cjs +1 -1
- package/dist-lib/menu.mjs +3 -3
- package/dist-lib/metro-fingerprint-registry.cjs +1 -1
- package/dist-lib/metro-fingerprint-registry.mjs +3 -3
- package/dist-lib/metro-production-bundle.cjs +1 -1
- package/dist-lib/metro-production-bundle.mjs +4 -4
- package/dist-lib/native-app-identity-project.cjs +2 -2
- package/dist-lib/native-app-identity-project.mjs +16 -16
- package/dist-lib/native-app-identity.cjs +1 -1
- package/dist-lib/native-app-identity.mjs +6 -6
- package/dist-lib/native-firebase-metadata.cjs +1 -1
- package/dist-lib/native-firebase-metadata.mjs +3 -3
- package/dist-lib/pdfium-raster.cjs +1 -1
- package/dist-lib/pdfium-raster.mjs +2 -2
- package/dist-lib/plist.cjs +1 -1
- package/dist-lib/plist.mjs +3 -3
- package/dist-lib/profiles.cjs +1 -1
- package/dist-lib/public-brand.cjs +1 -1
- package/dist-lib/public-origins-lib-esm.json +81 -81
- package/dist-lib/public-origins-lib.json +69 -69
- package/dist-lib/react-native-host-modules.cjs +1 -1
- package/dist-lib/react-native-host-modules.mjs +2 -2
- package/dist-lib/reap-browser.cjs +1 -1
- package/dist-lib/scripts/dev-server-scanner.cjs +1 -1
- package/dist-lib/sdk.cjs +1 -1
- package/dist-lib/sdk.mjs +8 -8
- package/dist-lib/skills.cjs +1202 -471
- package/dist-lib/swift-compile.cjs +1168 -442
- package/dist-lib/swift-compile.mjs +10 -10
- package/dist-lib/swift-package.cjs +1 -1
- package/dist-lib/swift-package.mjs +3 -3
- package/dist-lib/swift-submit.cjs +1 -1
- package/dist-lib/swift-submit.mjs +6 -6
- package/dist-lib/swift-svg-raster.cjs +1 -1
- package/dist-lib/swift-svg-raster.mjs +2 -2
- package/dist-lib/swift-toolchain.cjs +1 -1
- package/dist-lib/swift.cjs +1 -1
- package/dist-lib/vendor/@peculiar/x509.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/nodes.js.cjs +1 -1
- package/dist-lib/vendor/@ruby/prism/src/parsePrism.js.cjs +1 -1
- package/dist-lib/vendor/@xmldom/xmldom.cjs +1 -1
- package/dist-lib/vendor/acorn.cjs +1 -1
- package/dist-lib/vendor/bplist-parser.cjs +1 -1
- package/dist-lib/vendor/ignore.cjs +1 -1
- package/dist-lib/vendor/magic-string.cjs +1 -1
- package/dist-lib/vendor/plist.cjs +1 -1
- package/dist-lib/vendor/smol-toml.cjs +1 -1
- package/dist-lib/vendor/stream-json.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/index.js.cjs +1 -1
- package/dist-lib/vendor/sucrase/dist/parser/tokenizer/types.js.cjs +1 -1
- package/dist-lib/vendor/sucrase.cjs +1 -1
- package/dist-lib/vendor/terser.cjs +1 -1
- package/dist-lib/vendor/valibot.cjs +1 -1
- package/dist-lib/vendor/ws.cjs +1 -1
- package/dist-lib/vendor/zod.cjs +1 -1
- package/dist-lib/worklet-executable.cjs +1 -1
- package/dist-lib/worklet-executable.mjs +3 -3
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/src/swift-guest-compile.ts +2 -2
- package/src/swift-guest-dyld-table.ts +9 -2
- package/src/swift-guest-image-ledger.ts +403 -208
- package/src/swift-guest-link.ts +255 -113
- package/src/swift-guest-linked-spans.ts +217 -28
- package/src/swift-guest-manifest.ts +24 -13
- package/src/swift-guest-projection-storage.ts +6 -8
- package/src/swift-guest-projection.ts +7 -6
- package/src/swift-sdk-image-map.ts +137 -35
- package/src/swift-wasm-prune.ts +263 -85
- package/src/swiftGuestImageContract.ts +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! peach v0.1.
|
|
1
|
+
/*! peach v0.1.2590 | (c) 2026 Tamagui LLC | Proprietary; see LICENSE */
|
|
2
2
|
let __sootsim_import_meta_url = '', __sootsim_import_meta_dirname = '', __sootsim_import_meta_filename = ''; try { __sootsim_import_meta_url = require('url').pathToFileURL(__filename).href; __sootsim_import_meta_dirname = __dirname; __sootsim_import_meta_filename = __filename; } catch {}
|
|
3
3
|
"use strict";
|
|
4
4
|
var __create = Object.create;
|
|
@@ -5712,13 +5712,13 @@ var init_swift_standin_digest = __esm({
|
|
|
5712
5712
|
STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
|
|
5713
5713
|
SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
5714
5714
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
|
|
5715
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
5715
|
+
STANDIN_SOURCE_DIGEST = true ? "a3bcdfe9c9957355a59c2c26155470c89a2abb30907aeeaaf1de8463aa74fc8c" : standinSourceDigest();
|
|
5716
5716
|
}
|
|
5717
5717
|
});
|
|
5718
5718
|
|
|
5719
5719
|
// src/expo-native-compiler-digest.ts
|
|
5720
5720
|
function expoNativeCompilerDigestValue() {
|
|
5721
|
-
return true ? "
|
|
5721
|
+
return true ? "a8b60651de79588c6c5143dd2545ccd8e3b858acd992f46b35ba3de883118ac5" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
5722
5722
|
}
|
|
5723
5723
|
var import_node_crypto11;
|
|
5724
5724
|
var init_expo_native_compiler_digest = __esm({
|
|
@@ -36314,24 +36314,56 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
36314
36314
|
const code = sections.get(10);
|
|
36315
36315
|
if (code) {
|
|
36316
36316
|
let pos = code[0];
|
|
36317
|
-
|
|
36318
|
-
|
|
36317
|
+
const codeStart = code[0];
|
|
36318
|
+
const codeEnd = code[1];
|
|
36319
|
+
let count = 0;
|
|
36320
|
+
{
|
|
36321
|
+
let shift = 0;
|
|
36322
|
+
for (; ; ) {
|
|
36323
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
36324
|
+
const byte = bytes[pos++];
|
|
36325
|
+
count += (byte & 127) * 2 ** shift;
|
|
36326
|
+
if (!(byte & 128)) break;
|
|
36327
|
+
shift += 7;
|
|
36328
|
+
}
|
|
36329
|
+
}
|
|
36319
36330
|
for (let i = 0; i < count; i++) {
|
|
36320
36331
|
const prefix = pos;
|
|
36321
|
-
let size2;
|
|
36322
|
-
|
|
36323
|
-
|
|
36332
|
+
let size2 = 0;
|
|
36333
|
+
const b0 = bytes[pos++];
|
|
36334
|
+
if (b0 < 128) {
|
|
36335
|
+
size2 = b0;
|
|
36336
|
+
} else {
|
|
36337
|
+
size2 = b0 & 127;
|
|
36338
|
+
let shift = 7;
|
|
36339
|
+
for (; ; ) {
|
|
36340
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
36341
|
+
const byte = bytes[pos++];
|
|
36342
|
+
size2 += (byte & 127) * 2 ** shift;
|
|
36343
|
+
if (!(byte & 128)) break;
|
|
36344
|
+
shift += 7;
|
|
36345
|
+
}
|
|
36346
|
+
}
|
|
36347
|
+
functionsByCodeOffset.set(prefix - codeStart, imports2 + i);
|
|
36324
36348
|
if (imports2 + i === startFunction) startup = bytes.subarray(pos, pos + size2);
|
|
36325
36349
|
pos += size2;
|
|
36326
|
-
if (pos >
|
|
36350
|
+
if (pos > codeEnd) throw new Error("invalid wasm code");
|
|
36327
36351
|
}
|
|
36328
|
-
if (pos !==
|
|
36352
|
+
if (pos !== codeEnd) throw new Error("invalid wasm code section");
|
|
36329
36353
|
}
|
|
36330
36354
|
const functionsByTableSlot = /* @__PURE__ */ new Map();
|
|
36331
36355
|
const elements = sections.get(9);
|
|
36332
36356
|
if (elements) {
|
|
36333
36357
|
let pos = elements[0];
|
|
36358
|
+
const elemEnd = elements[1];
|
|
36334
36359
|
const read = () => {
|
|
36360
|
+
if (pos < elemEnd) {
|
|
36361
|
+
const b0 = bytes[pos];
|
|
36362
|
+
if (b0 < 128) {
|
|
36363
|
+
pos++;
|
|
36364
|
+
return b0;
|
|
36365
|
+
}
|
|
36366
|
+
}
|
|
36335
36367
|
const [value, next] = number(bytes, pos);
|
|
36336
36368
|
pos = next;
|
|
36337
36369
|
return value;
|
|
@@ -36361,7 +36393,7 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
36361
36393
|
functionsByTableSlot.set(slot, read());
|
|
36362
36394
|
}
|
|
36363
36395
|
}
|
|
36364
|
-
if (pos !==
|
|
36396
|
+
if (pos !== elemEnd) throw new Error("invalid wasm element section");
|
|
36365
36397
|
}
|
|
36366
36398
|
const data = [];
|
|
36367
36399
|
const passive = /* @__PURE__ */ new Map();
|
|
@@ -36426,36 +36458,141 @@ function guestWasmDataSegments(bytes, requireExports = true) {
|
|
|
36426
36458
|
length: segment2.bytes.length
|
|
36427
36459
|
}));
|
|
36428
36460
|
}
|
|
36429
|
-
function
|
|
36461
|
+
function isMapSpace(code) {
|
|
36462
|
+
return code === 32 || code >= 9 && code <= 13;
|
|
36463
|
+
}
|
|
36464
|
+
function isMapHex(code) {
|
|
36465
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
36466
|
+
}
|
|
36467
|
+
function mapHexDigit(code) {
|
|
36468
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
36469
|
+
}
|
|
36470
|
+
function* stringLines(text7) {
|
|
36471
|
+
let start = 0;
|
|
36472
|
+
for (let end = text7.indexOf("\n"); end !== -1; end = text7.indexOf("\n", start)) {
|
|
36473
|
+
yield text7.slice(start, end);
|
|
36474
|
+
start = end + 1;
|
|
36475
|
+
}
|
|
36476
|
+
yield text7.slice(start);
|
|
36477
|
+
}
|
|
36478
|
+
function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PURE__ */ new Map(), importsLayout = false, extra) {
|
|
36430
36479
|
const unchanged = before === after;
|
|
36431
36480
|
const original = layout(before, !unchanged, !importsLayout);
|
|
36432
36481
|
const optimized = unchanged ? original : layout(after, true, !importsLayout);
|
|
36482
|
+
const collectSymbols = extra?.collectSymbols;
|
|
36483
|
+
const trackedObject = extra?.trackedObject;
|
|
36484
|
+
const trackedObjectOwner = extra?.trackedObjectOwner;
|
|
36485
|
+
const trackedLinearSpans = extra?.trackedLinearSpans;
|
|
36486
|
+
const hasSectionOwners = sectionOwners.size > 0;
|
|
36433
36487
|
let codeOffset;
|
|
36434
36488
|
let outputSection = "";
|
|
36435
36489
|
const codeOwners = /* @__PURE__ */ new Map();
|
|
36436
36490
|
const pieces = [];
|
|
36437
|
-
|
|
36438
|
-
|
|
36439
|
-
|
|
36440
|
-
|
|
36441
|
-
|
|
36442
|
-
|
|
36443
|
-
|
|
36491
|
+
const lines = typeof map2 === "string" ? stringLines(map2) : map2;
|
|
36492
|
+
for (const line of lines) {
|
|
36493
|
+
const lineLen = line.length;
|
|
36494
|
+
let pos = 0;
|
|
36495
|
+
let onlySpaces = true;
|
|
36496
|
+
while (pos < lineLen) {
|
|
36497
|
+
const ch = line.charCodeAt(pos);
|
|
36498
|
+
if (!isMapSpace(ch)) break;
|
|
36499
|
+
if (ch !== 32) onlySpaces = false;
|
|
36500
|
+
pos++;
|
|
36501
|
+
}
|
|
36502
|
+
const leadingSpaces = pos;
|
|
36503
|
+
if (pos >= lineLen) continue;
|
|
36504
|
+
const addrStart = pos;
|
|
36505
|
+
while (pos < lineLen && !isMapSpace(line.charCodeAt(pos))) pos++;
|
|
36506
|
+
const addrEnd = pos;
|
|
36507
|
+
if (pos >= lineLen) continue;
|
|
36508
|
+
const s1 = pos;
|
|
36509
|
+
while (pos < lineLen) {
|
|
36510
|
+
const ch = line.charCodeAt(pos);
|
|
36511
|
+
if (!isMapSpace(ch)) break;
|
|
36512
|
+
if (ch !== 32) onlySpaces = false;
|
|
36513
|
+
pos++;
|
|
36514
|
+
}
|
|
36515
|
+
if (pos === s1 || pos >= lineLen) continue;
|
|
36516
|
+
const offStart = pos;
|
|
36517
|
+
let offsetVal = 0;
|
|
36518
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
36519
|
+
offsetVal = offsetVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
36520
|
+
}
|
|
36521
|
+
if (pos === offStart || pos >= lineLen) continue;
|
|
36522
|
+
const s2 = pos;
|
|
36523
|
+
while (pos < lineLen) {
|
|
36524
|
+
const ch = line.charCodeAt(pos);
|
|
36525
|
+
if (!isMapSpace(ch)) break;
|
|
36526
|
+
if (ch !== 32) onlySpaces = false;
|
|
36527
|
+
pos++;
|
|
36528
|
+
}
|
|
36529
|
+
if (pos === s2 || pos >= lineLen) continue;
|
|
36530
|
+
const sizeStart = pos;
|
|
36531
|
+
let sizeVal = 0;
|
|
36532
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
36533
|
+
sizeVal = sizeVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
36534
|
+
}
|
|
36535
|
+
if (pos === sizeStart || pos >= lineLen) continue;
|
|
36536
|
+
const indentStart = pos;
|
|
36537
|
+
while (pos < lineLen && line.charCodeAt(pos) === 32) pos++;
|
|
36538
|
+
const indentLen = pos - indentStart;
|
|
36539
|
+
if (indentLen === 0 || pos >= lineLen) continue;
|
|
36540
|
+
const firstCh = line.charCodeAt(pos);
|
|
36541
|
+
if (isMapSpace(firstCh)) continue;
|
|
36542
|
+
const sourceStart = pos;
|
|
36543
|
+
if (collectSymbols && onlySpaces && leadingSpaces > 0 && indentLen >= 9 && firstCh !== 47 && firstCh !== 60) {
|
|
36544
|
+
let symEnd = sourceStart + 1;
|
|
36545
|
+
while (symEnd < lineLen && !isMapSpace(line.charCodeAt(symEnd))) symEnd++;
|
|
36546
|
+
collectSymbols.add(line.slice(sourceStart, symEnd));
|
|
36547
|
+
}
|
|
36548
|
+
const isDash = addrEnd - addrStart === 1 && line.charCodeAt(addrStart) === 45;
|
|
36549
|
+
if (isDash && indentLen === 1) {
|
|
36550
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
36551
|
+
outputSection = line.slice(sourceStart);
|
|
36552
|
+
if (outputSection === "CODE") codeOffset = offsetVal;
|
|
36444
36553
|
continue;
|
|
36445
36554
|
}
|
|
36446
|
-
|
|
36555
|
+
if (sizeVal === 0) continue;
|
|
36556
|
+
const separator = line.indexOf(":(", sourceStart);
|
|
36447
36557
|
if (separator < 0) continue;
|
|
36448
|
-
|
|
36449
|
-
|
|
36450
|
-
|
|
36451
|
-
|
|
36452
|
-
if (
|
|
36453
|
-
|
|
36558
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
36559
|
+
let hasLineSep = false;
|
|
36560
|
+
for (let i = sourceStart; i < lineLen; i++) {
|
|
36561
|
+
const ch = line.charCodeAt(i);
|
|
36562
|
+
if (ch === 8232 || ch === 8233) {
|
|
36563
|
+
hasLineSep = true;
|
|
36564
|
+
break;
|
|
36565
|
+
}
|
|
36566
|
+
}
|
|
36567
|
+
if (hasLineSep) continue;
|
|
36568
|
+
const objectPath = line.slice(sourceStart, separator);
|
|
36569
|
+
let image = hasSectionOwners ? sectionOwners.get(line.slice(sourceStart)) : void 0;
|
|
36570
|
+
if (image === void 0) image = owners.get(objectPath);
|
|
36571
|
+
if (!isDash) {
|
|
36572
|
+
if (outputSection === "DATA") {
|
|
36573
|
+
let addressVal = 0;
|
|
36574
|
+
let allHex = true;
|
|
36575
|
+
for (let i = addrStart; i < addrEnd; i++) {
|
|
36576
|
+
const ch = line.charCodeAt(i);
|
|
36577
|
+
if (isMapHex(ch)) addressVal = addressVal * 16 + mapHexDigit(ch);
|
|
36578
|
+
else {
|
|
36579
|
+
allHex = false;
|
|
36580
|
+
break;
|
|
36581
|
+
}
|
|
36582
|
+
}
|
|
36583
|
+
if (!allHex) addressVal = parseInt(line.slice(addrStart, addrEnd), 16);
|
|
36584
|
+
pieces.push({
|
|
36585
|
+
image,
|
|
36586
|
+
address: addressVal,
|
|
36587
|
+
length: sizeVal,
|
|
36588
|
+
tracked: trackedObject !== void 0 && objectPath === trackedObject
|
|
36589
|
+
});
|
|
36590
|
+
}
|
|
36454
36591
|
continue;
|
|
36455
36592
|
}
|
|
36456
36593
|
if (image === void 0 || outputSection !== "CODE") continue;
|
|
36457
36594
|
if (codeOffset === void 0) throw new Error("link map has no code section");
|
|
36458
|
-
const index = original.functionsByCodeOffset.get(
|
|
36595
|
+
const index = original.functionsByCodeOffset.get(offsetVal - codeOffset);
|
|
36459
36596
|
if (index === void 0) throw new Error("link map function has no wasm body");
|
|
36460
36597
|
const existing = codeOwners.get(index);
|
|
36461
36598
|
if (existing !== void 0 && existing !== image)
|
|
@@ -36464,12 +36601,23 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
36464
36601
|
}
|
|
36465
36602
|
pieces.sort((a, b) => a.address - b.address);
|
|
36466
36603
|
const spans = [];
|
|
36467
|
-
for (
|
|
36468
|
-
|
|
36604
|
+
for (let index = 0; index < pieces.length; index++) {
|
|
36605
|
+
const piece = pieces[index];
|
|
36606
|
+
const { image, address, length, tracked } = piece;
|
|
36607
|
+
if (image === void 0 && !tracked) continue;
|
|
36469
36608
|
let next = index + 1;
|
|
36470
36609
|
while (next < pieces.length && pieces[next].address < address + length) next++;
|
|
36471
36610
|
const end = pieces[next]?.address ?? address + length;
|
|
36472
|
-
|
|
36611
|
+
const spanLength = end - address;
|
|
36612
|
+
if (image !== void 0)
|
|
36613
|
+
spans.push({ image, space: "linear-memory", address, length: spanLength });
|
|
36614
|
+
if (tracked && trackedLinearSpans && trackedObjectOwner !== void 0)
|
|
36615
|
+
trackedLinearSpans.push({
|
|
36616
|
+
image: trackedObjectOwner,
|
|
36617
|
+
space: "linear-memory",
|
|
36618
|
+
address,
|
|
36619
|
+
length: spanLength
|
|
36620
|
+
});
|
|
36473
36621
|
}
|
|
36474
36622
|
const optimizedOwners = /* @__PURE__ */ new Map();
|
|
36475
36623
|
const dataAt = (module2, start, length) => {
|
|
@@ -36508,7 +36656,7 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
36508
36656
|
throw new Error(`optimization changed linked data at ${span.address}`);
|
|
36509
36657
|
}
|
|
36510
36658
|
let previous;
|
|
36511
|
-
for (const span of
|
|
36659
|
+
for (const span of spans) {
|
|
36512
36660
|
if (previous && span.address < previous.address + previous.length && span.image !== previous.image)
|
|
36513
36661
|
throw new Error("linked data belongs to multiple images");
|
|
36514
36662
|
if (!previous || span.address + span.length > previous.address + previous.length)
|
|
@@ -36690,6 +36838,20 @@ var init_swift_guest_linked_spans = __esm({
|
|
|
36690
36838
|
});
|
|
36691
36839
|
|
|
36692
36840
|
// src/swift-sdk-image-map.ts
|
|
36841
|
+
function isHexChar(code) {
|
|
36842
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
36843
|
+
}
|
|
36844
|
+
function hexDigit(code) {
|
|
36845
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
36846
|
+
}
|
|
36847
|
+
function hasLineBreak(line, from) {
|
|
36848
|
+
if (line.indexOf("\r", from) >= 0) return true;
|
|
36849
|
+
for (let i = from; i < line.length; i++) {
|
|
36850
|
+
const ch = line.charCodeAt(i);
|
|
36851
|
+
if (ch === 8232 || ch === 8233) return true;
|
|
36852
|
+
}
|
|
36853
|
+
return false;
|
|
36854
|
+
}
|
|
36693
36855
|
function readWasmLinkMap(file, partition) {
|
|
36694
36856
|
const segments = /* @__PURE__ */ new Map();
|
|
36695
36857
|
const data = [];
|
|
@@ -36697,48 +36859,117 @@ function readWasmLinkMap(file, partition) {
|
|
|
36697
36859
|
let kind = "";
|
|
36698
36860
|
let segment2 = "";
|
|
36699
36861
|
let previous;
|
|
36700
|
-
const hex = (value) => value === "-" ? -1 : parseInt(value, 16);
|
|
36701
36862
|
for (const line of guestLinkLines(file)) {
|
|
36702
|
-
const
|
|
36703
|
-
|
|
36704
|
-
|
|
36705
|
-
|
|
36706
|
-
|
|
36707
|
-
|
|
36708
|
-
|
|
36863
|
+
const length = line.length;
|
|
36864
|
+
let pos = 0;
|
|
36865
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
36866
|
+
if (pos >= length) continue;
|
|
36867
|
+
const leadingSpaces = pos;
|
|
36868
|
+
let address = -1;
|
|
36869
|
+
if (line.charCodeAt(pos) === 45) {
|
|
36870
|
+
pos++;
|
|
36871
|
+
} else {
|
|
36872
|
+
const start = pos;
|
|
36873
|
+
let value = 0;
|
|
36874
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
36875
|
+
value = value * 16 + hexDigit(line.charCodeAt(pos++));
|
|
36876
|
+
}
|
|
36877
|
+
if (pos === start) continue;
|
|
36878
|
+
address = value;
|
|
36879
|
+
}
|
|
36880
|
+
const s1 = pos;
|
|
36881
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
36882
|
+
if (pos === s1 || pos >= length) continue;
|
|
36883
|
+
const offStart = pos;
|
|
36884
|
+
let offset = 0;
|
|
36885
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
36886
|
+
offset = offset * 16 + hexDigit(line.charCodeAt(pos++));
|
|
36887
|
+
}
|
|
36888
|
+
if (pos === offStart) continue;
|
|
36889
|
+
const s2 = pos;
|
|
36890
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
36891
|
+
if (pos === s2 || pos >= length) continue;
|
|
36892
|
+
const sizeStart = pos;
|
|
36893
|
+
let size2 = 0;
|
|
36894
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
36895
|
+
size2 = size2 * 16 + hexDigit(line.charCodeAt(pos++));
|
|
36896
|
+
}
|
|
36897
|
+
if (pos === sizeStart || pos >= length) continue;
|
|
36898
|
+
const indentStart = pos;
|
|
36899
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
36900
|
+
const indent2 = pos - indentStart;
|
|
36901
|
+
if (indent2 === 0 || pos >= length) continue;
|
|
36902
|
+
if (indent2 === 17) {
|
|
36903
|
+
if (previous) {
|
|
36904
|
+
const first = line.charCodeAt(pos);
|
|
36905
|
+
if (first > 32 && !hasLineBreak(line, pos)) {
|
|
36906
|
+
previous.symbols.push({
|
|
36907
|
+
name: line.slice(pos),
|
|
36908
|
+
address,
|
|
36909
|
+
size: size2
|
|
36910
|
+
});
|
|
36911
|
+
}
|
|
36912
|
+
}
|
|
36709
36913
|
continue;
|
|
36710
36914
|
}
|
|
36711
|
-
|
|
36712
|
-
|
|
36713
|
-
|
|
36915
|
+
if (indent2 === 1) {
|
|
36916
|
+
let hasWhitespace = false;
|
|
36917
|
+
for (let i = pos; i < length; i++) {
|
|
36918
|
+
const ch = line.charCodeAt(i);
|
|
36919
|
+
if (ch <= 32) {
|
|
36920
|
+
hasWhitespace = true;
|
|
36921
|
+
break;
|
|
36922
|
+
}
|
|
36923
|
+
}
|
|
36924
|
+
if (hasWhitespace) continue;
|
|
36925
|
+
if (address < 0 && leadingSpaces > 0) {
|
|
36926
|
+
kind = line.slice(pos);
|
|
36927
|
+
} else if (kind === "DATA" && address >= 0) {
|
|
36928
|
+
segment2 = line.slice(pos);
|
|
36929
|
+
segments.set(segment2, { address, size: size2 });
|
|
36930
|
+
}
|
|
36714
36931
|
continue;
|
|
36715
36932
|
}
|
|
36716
|
-
if (kind === "DATA") {
|
|
36717
|
-
const
|
|
36718
|
-
if (
|
|
36719
|
-
|
|
36720
|
-
|
|
36721
|
-
|
|
36933
|
+
if (indent2 === 9 && (kind === "DATA" || kind === "CODE")) {
|
|
36934
|
+
const first = line.charCodeAt(pos);
|
|
36935
|
+
if (first !== 47 && first !== 60) continue;
|
|
36936
|
+
if (hasLineBreak(line, pos)) continue;
|
|
36937
|
+
const name3 = line.slice(pos);
|
|
36938
|
+
let filePath = name3;
|
|
36939
|
+
let section2 = "";
|
|
36940
|
+
if (name3.charCodeAt(name3.length - 1) === 41) {
|
|
36941
|
+
const splitAt = name3.indexOf(":(");
|
|
36942
|
+
if (splitAt >= 0) {
|
|
36943
|
+
filePath = name3.slice(0, splitAt);
|
|
36944
|
+
section2 = name3.slice(splitAt + 2, -1);
|
|
36945
|
+
}
|
|
36946
|
+
}
|
|
36947
|
+
let objectName;
|
|
36948
|
+
if (filePath.charCodeAt(filePath.length - 1) === 41) {
|
|
36949
|
+
const open = filePath.lastIndexOf("(");
|
|
36950
|
+
if (open >= 0 && open + 1 < filePath.length - 1) {
|
|
36951
|
+
const close = filePath.indexOf(")", open + 1);
|
|
36952
|
+
if (close === filePath.length - 1) {
|
|
36953
|
+
objectName = filePath.slice(open + 1, -1);
|
|
36954
|
+
}
|
|
36955
|
+
}
|
|
36722
36956
|
}
|
|
36957
|
+
if (objectName === void 0) objectName = (0, import_node_path56.basename)(filePath);
|
|
36958
|
+
if (objectName.startsWith("lib") && objectName.includes("__")) {
|
|
36959
|
+
objectName = objectName.replace(/^lib\w*?__/, "");
|
|
36960
|
+
}
|
|
36961
|
+
previous = {
|
|
36962
|
+
inputFile: filePath,
|
|
36963
|
+
segment: segment2,
|
|
36964
|
+
address,
|
|
36965
|
+
offset,
|
|
36966
|
+
size: size2,
|
|
36967
|
+
object: objectName,
|
|
36968
|
+
section: section2,
|
|
36969
|
+
symbols: []
|
|
36970
|
+
};
|
|
36971
|
+
(kind === "DATA" ? data : code).push(previous);
|
|
36723
36972
|
}
|
|
36724
|
-
if (kind !== "DATA" && kind !== "CODE") continue;
|
|
36725
|
-
const input = /^ *([0-9a-f]+|-) +([0-9a-f]+) +([0-9a-f]+) {9}([/<].*)$/.exec(line);
|
|
36726
|
-
if (!input) continue;
|
|
36727
|
-
const name3 = input[4];
|
|
36728
|
-
const split = /^(.*?):\((.*)\)$/s.exec(name3);
|
|
36729
|
-
const path161 = split ? split[1] : name3;
|
|
36730
|
-
const member = /\(([^()]+)\)$/.exec(path161);
|
|
36731
|
-
previous = {
|
|
36732
|
-
inputFile: path161,
|
|
36733
|
-
segment: segment2,
|
|
36734
|
-
address: hex(input[1]),
|
|
36735
|
-
offset: parseInt(input[2], 16),
|
|
36736
|
-
size: parseInt(input[3], 16),
|
|
36737
|
-
object: (member ? member[1] : (0, import_node_path56.basename)(path161)).replace(/^lib\w*?__/, ""),
|
|
36738
|
-
section: split ? split[2] : "",
|
|
36739
|
-
symbols: []
|
|
36740
|
-
};
|
|
36741
|
-
(kind === "DATA" ? data : code).push(previous);
|
|
36742
36973
|
}
|
|
36743
36974
|
return { segments, data: partition ? data.flatMap(symbolPieces) : data, code };
|
|
36744
36975
|
}
|
|
@@ -37884,6 +38115,7 @@ function patchSwiftrtObject(src) {
|
|
|
37884
38115
|
return buf;
|
|
37885
38116
|
}
|
|
37886
38117
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
38118
|
+
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
37887
38119
|
let pos = 8;
|
|
37888
38120
|
let numImportFuncs = 0;
|
|
37889
38121
|
let importsDlsym = false;
|
|
@@ -37919,10 +38151,10 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
37919
38151
|
let [cnt, cp] = readULEB2(buf, p);
|
|
37920
38152
|
for (let i = 0; i < cnt; i++) {
|
|
37921
38153
|
const [mLen, m2] = readULEB2(buf, cp);
|
|
37922
|
-
const mName =
|
|
38154
|
+
const mName = rawBuf.toString("utf8", m2, m2 + mLen);
|
|
37923
38155
|
cp = m2 + mLen;
|
|
37924
38156
|
const [fLen, f2] = readULEB2(buf, cp);
|
|
37925
|
-
const fName =
|
|
38157
|
+
const fName = rawBuf.toString("utf8", f2, f2 + fLen);
|
|
37926
38158
|
cp = f2 + fLen;
|
|
37927
38159
|
const kind = buf[cp++];
|
|
37928
38160
|
if (kind === 0) {
|
|
@@ -38002,7 +38234,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
38002
38234
|
}
|
|
38003
38235
|
} else if (id === 0) {
|
|
38004
38236
|
const [nLen, np] = readULEB2(buf, p);
|
|
38005
|
-
const name3 =
|
|
38237
|
+
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
38006
38238
|
const cp = np + nLen;
|
|
38007
38239
|
if (name3 === "linking") {
|
|
38008
38240
|
let [, lp] = readULEB2(buf, cp);
|
|
@@ -38015,7 +38247,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
38015
38247
|
let cur = p2;
|
|
38016
38248
|
for (let i = 0; i < cnt; i++) {
|
|
38017
38249
|
const [sLen, s2] = readULEB2(buf, cur);
|
|
38018
|
-
segNames.push(
|
|
38250
|
+
segNames.push(rawBuf.toString("utf8", s2, s2 + sLen));
|
|
38019
38251
|
cur = s2 + sLen;
|
|
38020
38252
|
const [, s3] = readULEB2(buf, cur);
|
|
38021
38253
|
const [fl, s4] = readULEB2(buf, s3);
|
|
@@ -38055,7 +38287,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
38055
38287
|
let sName = "";
|
|
38056
38288
|
if (!isUndef || isExplicitName) {
|
|
38057
38289
|
const [sLen, c4] = readULEB2(buf, cur);
|
|
38058
|
-
sName =
|
|
38290
|
+
sName = rawBuf.toString("utf8", c4, c4 + sLen);
|
|
38059
38291
|
cur = c4 + sLen;
|
|
38060
38292
|
} else if (kind === 0) {
|
|
38061
38293
|
sName = importFuncNames[el] ?? "";
|
|
@@ -38071,7 +38303,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
38071
38303
|
symNames.push(sName);
|
|
38072
38304
|
} else if (kind === 1) {
|
|
38073
38305
|
const [sLen, c3] = readULEB2(buf, cur);
|
|
38074
|
-
const sName =
|
|
38306
|
+
const sName = rawBuf.toString("utf8", c3, c3 + sLen);
|
|
38075
38307
|
cur = c3 + sLen;
|
|
38076
38308
|
if (!isUndef) {
|
|
38077
38309
|
const [segIdx, c4] = readULEB2(buf, cur);
|
|
@@ -38186,9 +38418,21 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
38186
38418
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
38187
38419
|
let ownerSymIdx = -1;
|
|
38188
38420
|
const topList = segTopSyms.get(lo);
|
|
38189
|
-
if (topList) {
|
|
38190
|
-
|
|
38191
|
-
|
|
38421
|
+
if (topList && topList.length > 0) {
|
|
38422
|
+
let tLo = 0;
|
|
38423
|
+
let tHi = topList.length - 1;
|
|
38424
|
+
while (tLo <= tHi) {
|
|
38425
|
+
const tMid = tLo + tHi >> 1;
|
|
38426
|
+
const top = topList[tMid];
|
|
38427
|
+
if (offInSeg < top.off) {
|
|
38428
|
+
tHi = tMid - 1;
|
|
38429
|
+
} else if (offInSeg >= top.end) {
|
|
38430
|
+
tLo = tMid + 1;
|
|
38431
|
+
} else {
|
|
38432
|
+
ownerSymIdx = top.symIdx;
|
|
38433
|
+
break;
|
|
38434
|
+
}
|
|
38435
|
+
}
|
|
38192
38436
|
}
|
|
38193
38437
|
if (ownerSymIdx !== -1) {
|
|
38194
38438
|
let list2 = symDataRelocs.get(ownerSymIdx);
|
|
@@ -38443,54 +38687,151 @@ function localizeDefinedWasmSymbols(bytes, names) {
|
|
|
38443
38687
|
return output;
|
|
38444
38688
|
}
|
|
38445
38689
|
function guestWasmSymbols(bytes) {
|
|
38446
|
-
const
|
|
38690
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
38691
|
+
let cur = 8;
|
|
38692
|
+
const readU = () => {
|
|
38693
|
+
const b0 = bytes[cur++];
|
|
38694
|
+
if (b0 < 128) return b0;
|
|
38695
|
+
let res = b0 & 127;
|
|
38696
|
+
let shift = 7;
|
|
38697
|
+
while (true) {
|
|
38698
|
+
const byte = bytes[cur++];
|
|
38699
|
+
res |= (byte & 127) << shift;
|
|
38700
|
+
if ((byte & 128) === 0) return res;
|
|
38701
|
+
shift += 7;
|
|
38702
|
+
}
|
|
38703
|
+
};
|
|
38704
|
+
let importsDlsym = false;
|
|
38705
|
+
const importFuncNames = [];
|
|
38706
|
+
const importFuncModules = [];
|
|
38707
|
+
const importGlobalNames = [];
|
|
38708
|
+
const importTableNames = [];
|
|
38709
|
+
const importEventNames = [];
|
|
38710
|
+
const undefinedSyms = /* @__PURE__ */ new Set();
|
|
38711
|
+
const tags = /* @__PURE__ */ new Set();
|
|
38712
|
+
const globals = /* @__PURE__ */ new Set();
|
|
38713
|
+
const hostImports = /* @__PURE__ */ new Set();
|
|
38714
|
+
const weakUndefined = /* @__PURE__ */ new Set();
|
|
38715
|
+
const defined = /* @__PURE__ */ new Set();
|
|
38716
|
+
const weakDefined = /* @__PURE__ */ new Set();
|
|
38717
|
+
while (cur < bytes.length) {
|
|
38718
|
+
const id = bytes[cur++];
|
|
38719
|
+
const sz = readU();
|
|
38720
|
+
const end = cur + sz;
|
|
38721
|
+
if (id === 2) {
|
|
38722
|
+
const cnt = readU();
|
|
38723
|
+
for (let i = 0; i < cnt; i++) {
|
|
38724
|
+
const mLen = readU();
|
|
38725
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
38726
|
+
cur += mLen;
|
|
38727
|
+
const fLen = readU();
|
|
38728
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
38729
|
+
cur += fLen;
|
|
38730
|
+
const kind = bytes[cur++];
|
|
38731
|
+
if (kind === 0) {
|
|
38732
|
+
readU();
|
|
38733
|
+
importFuncNames.push(fName);
|
|
38734
|
+
importFuncModules.push(mName);
|
|
38735
|
+
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
38736
|
+
} else if (kind === 1) {
|
|
38737
|
+
cur++;
|
|
38738
|
+
const fl = readU();
|
|
38739
|
+
readU();
|
|
38740
|
+
if (fl & 1) readU();
|
|
38741
|
+
importTableNames.push(fName);
|
|
38742
|
+
} else if (kind === 2) {
|
|
38743
|
+
const fl = readU();
|
|
38744
|
+
readU();
|
|
38745
|
+
if (fl & 1) readU();
|
|
38746
|
+
} else if (kind === 3) {
|
|
38747
|
+
cur += 2;
|
|
38748
|
+
importGlobalNames.push(fName);
|
|
38749
|
+
} else if (kind === 4) {
|
|
38750
|
+
cur++;
|
|
38751
|
+
readU();
|
|
38752
|
+
importEventNames.push(fName);
|
|
38753
|
+
}
|
|
38754
|
+
}
|
|
38755
|
+
} else if (id === 0) {
|
|
38756
|
+
const nLen = readU();
|
|
38757
|
+
if (nLen === 7 && bytes[cur] === 108 && rawBuf.toString("utf8", cur, cur + nLen) === "linking") {
|
|
38758
|
+
cur += nLen;
|
|
38759
|
+
readU();
|
|
38760
|
+
while (cur < end) {
|
|
38761
|
+
const subId = bytes[cur++];
|
|
38762
|
+
const subLen = readU();
|
|
38763
|
+
const subEnd = cur + subLen;
|
|
38764
|
+
if (subId === 8) {
|
|
38765
|
+
const cnt = readU();
|
|
38766
|
+
for (let i = 0; i < cnt; i++) {
|
|
38767
|
+
const kind = bytes[cur++];
|
|
38768
|
+
const fl = readU();
|
|
38769
|
+
const isUndef = (fl & 16) !== 0;
|
|
38770
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
38771
|
+
let sName = "";
|
|
38772
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
38773
|
+
const el = readU();
|
|
38774
|
+
if (!isUndef || isExplicitName) {
|
|
38775
|
+
const sLen = readU();
|
|
38776
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
38777
|
+
cur += sLen;
|
|
38778
|
+
} else if (kind === 0) {
|
|
38779
|
+
sName = importFuncNames[el] ?? "";
|
|
38780
|
+
} else if (kind === 2) {
|
|
38781
|
+
sName = importGlobalNames[el] ?? "";
|
|
38782
|
+
} else if (kind === 4) {
|
|
38783
|
+
sName = importEventNames[el] ?? "";
|
|
38784
|
+
} else if (kind === 5) {
|
|
38785
|
+
sName = importTableNames[el] ?? "";
|
|
38786
|
+
}
|
|
38787
|
+
if (isUndef && kind === 0 && importFuncModules[el] !== "env")
|
|
38788
|
+
hostImports.add(sName);
|
|
38789
|
+
} else if (kind === 1) {
|
|
38790
|
+
const sLen = readU();
|
|
38791
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
38792
|
+
cur += sLen;
|
|
38793
|
+
if (!isUndef) {
|
|
38794
|
+
readU();
|
|
38795
|
+
readU();
|
|
38796
|
+
readU();
|
|
38797
|
+
}
|
|
38798
|
+
} else if (kind === 3) {
|
|
38799
|
+
readU();
|
|
38800
|
+
}
|
|
38801
|
+
if (sName) {
|
|
38802
|
+
if (isUndef) {
|
|
38803
|
+
undefinedSyms.add(sName);
|
|
38804
|
+
if ((fl & 19) === 17) weakUndefined.add(sName);
|
|
38805
|
+
} else if ((fl & 3) !== 2) {
|
|
38806
|
+
defined.add(sName);
|
|
38807
|
+
if ((fl & 19) === 1) weakDefined.add(sName);
|
|
38808
|
+
}
|
|
38809
|
+
if (kind === 4) tags.add(sName);
|
|
38810
|
+
else if (kind === 2 || kind === 5) globals.add(sName);
|
|
38811
|
+
}
|
|
38812
|
+
}
|
|
38813
|
+
break;
|
|
38814
|
+
}
|
|
38815
|
+
cur = subEnd;
|
|
38816
|
+
}
|
|
38817
|
+
break;
|
|
38818
|
+
}
|
|
38819
|
+
}
|
|
38820
|
+
cur = end;
|
|
38821
|
+
}
|
|
38447
38822
|
return {
|
|
38448
|
-
importsDlsym
|
|
38449
|
-
undefined: [
|
|
38450
|
-
...new Set(
|
|
38451
|
-
object8.symNames.filter(
|
|
38452
|
-
(name3, index) => name3 && (object8.symFlags[index] & 16) !== 0
|
|
38453
|
-
)
|
|
38454
|
-
)
|
|
38455
|
-
],
|
|
38823
|
+
importsDlsym,
|
|
38824
|
+
undefined: [...undefinedSyms],
|
|
38456
38825
|
// a wasm tag is one module entity unified by name across the link, as the
|
|
38457
38826
|
// main module owns it for dynamic images, so no image scope applies.
|
|
38458
|
-
tags: [
|
|
38459
|
-
|
|
38460
|
-
object8.symNames.filter((name3, index) => name3 && object8.symKind[index] === 4)
|
|
38461
|
-
)
|
|
38462
|
-
],
|
|
38463
|
-
globals: [
|
|
38464
|
-
...new Set(
|
|
38465
|
-
object8.symNames.filter(
|
|
38466
|
-
(name3, index) => name3 && (object8.symKind[index] === 2 || object8.symKind[index] === 5)
|
|
38467
|
-
)
|
|
38468
|
-
)
|
|
38469
|
-
],
|
|
38827
|
+
tags: [...tags],
|
|
38828
|
+
globals: [...globals],
|
|
38470
38829
|
// an undefined function imported from a module other than env is supplied
|
|
38471
38830
|
// by the host, whatever linker symbol names it.
|
|
38472
|
-
hostImports: [...
|
|
38473
|
-
weakUndefined: [
|
|
38474
|
-
|
|
38475
|
-
|
|
38476
|
-
(name3, index) => name3 && (object8.symFlags[index] & 19) === 17
|
|
38477
|
-
)
|
|
38478
|
-
)
|
|
38479
|
-
],
|
|
38480
|
-
defined: [
|
|
38481
|
-
...new Set(
|
|
38482
|
-
object8.symNames.filter(
|
|
38483
|
-
(name3, index) => name3 && (object8.symFlags[index] & 16) === 0 && (object8.symFlags[index] & 3) !== 2
|
|
38484
|
-
)
|
|
38485
|
-
)
|
|
38486
|
-
],
|
|
38487
|
-
weakDefined: [
|
|
38488
|
-
...new Set(
|
|
38489
|
-
object8.symNames.filter(
|
|
38490
|
-
(name3, index) => name3 && (object8.symFlags[index] & 19) === 1
|
|
38491
|
-
)
|
|
38492
|
-
)
|
|
38493
|
-
]
|
|
38831
|
+
hostImports: [...hostImports],
|
|
38832
|
+
weakUndefined: [...weakUndefined],
|
|
38833
|
+
defined: [...defined],
|
|
38834
|
+
weakDefined: [...weakDefined]
|
|
38494
38835
|
};
|
|
38495
38836
|
}
|
|
38496
38837
|
function sdkObjectName(archive, member, ordinal) {
|
|
@@ -39007,9 +39348,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
39007
39348
|
for (const entry of waiting) tryActivateConformance(entry);
|
|
39008
39349
|
}
|
|
39009
39350
|
};
|
|
39351
|
+
const checkedProtocolTriggers = /* @__PURE__ */ new Set();
|
|
39010
39352
|
const checkProtocolTrigger = (rawSymName) => {
|
|
39011
39353
|
if (!rawSymName) return;
|
|
39012
39354
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
39355
|
+
if (checkedProtocolTriggers.has(sName)) return;
|
|
39356
|
+
checkedProtocolTriggers.add(sName);
|
|
39013
39357
|
if (knownProtocols.has(sName)) {
|
|
39014
39358
|
markProtocolLive(sName);
|
|
39015
39359
|
return;
|
|
@@ -39042,6 +39386,43 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
39042
39386
|
}
|
|
39043
39387
|
}
|
|
39044
39388
|
};
|
|
39389
|
+
const typeIndexes = /* @__PURE__ */ new Map();
|
|
39390
|
+
const getTypeIndex = (obj) => {
|
|
39391
|
+
let idx = typeIndexes.get(obj);
|
|
39392
|
+
if (idx) return idx;
|
|
39393
|
+
const mnByPrefix = /* @__PURE__ */ new Map();
|
|
39394
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
39395
|
+
const name3 = obj.symNames[i];
|
|
39396
|
+
if ((obj.symFlags[i] & 16) === 0 && name3.startsWith("$s") && name3.endsWith("Mn")) {
|
|
39397
|
+
const pref = name3.slice(0, -2);
|
|
39398
|
+
let list2 = mnByPrefix.get(pref);
|
|
39399
|
+
if (!list2) mnByPrefix.set(pref, list2 = []);
|
|
39400
|
+
list2.push(i);
|
|
39401
|
+
}
|
|
39402
|
+
}
|
|
39403
|
+
const objcRegByPrefix = /* @__PURE__ */ new Map();
|
|
39404
|
+
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
39405
|
+
let list2 = objcRegByPrefix.get(p);
|
|
39406
|
+
if (!list2) objcRegByPrefix.set(p, list2 = []);
|
|
39407
|
+
list2.push(lf);
|
|
39408
|
+
}
|
|
39409
|
+
const objcClassByPrefix = /* @__PURE__ */ new Map();
|
|
39410
|
+
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
39411
|
+
if (!classSym.startsWith("._OBJC_CLASS_")) continue;
|
|
39412
|
+
let list2 = objcClassByPrefix.get(p);
|
|
39413
|
+
if (!list2) objcClassByPrefix.set(p, list2 = []);
|
|
39414
|
+
list2.push(classSym.slice("._OBJC_CLASS_".length));
|
|
39415
|
+
}
|
|
39416
|
+
let minPrefLen = Infinity;
|
|
39417
|
+
let maxPrefLen = 0;
|
|
39418
|
+
for (const p of obj.typePrefixesInObj) {
|
|
39419
|
+
if (p.length < minPrefLen) minPrefLen = p.length;
|
|
39420
|
+
if (p.length > maxPrefLen) maxPrefLen = p.length;
|
|
39421
|
+
}
|
|
39422
|
+
idx = { mnByPrefix, objcRegByPrefix, objcClassByPrefix, minPrefLen, maxPrefLen };
|
|
39423
|
+
typeIndexes.set(obj, idx);
|
|
39424
|
+
return idx;
|
|
39425
|
+
};
|
|
39045
39426
|
const markTypeLive = (obj, pref) => {
|
|
39046
39427
|
const set2 = liveTypes.get(obj);
|
|
39047
39428
|
if (set2.has(pref)) return;
|
|
@@ -39055,22 +39436,10 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
39055
39436
|
const outer = pref.slice(0, n);
|
|
39056
39437
|
if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer);
|
|
39057
39438
|
}
|
|
39058
|
-
const
|
|
39059
|
-
for (
|
|
39060
|
-
|
|
39061
|
-
|
|
39062
|
-
}
|
|
39063
|
-
}
|
|
39064
|
-
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
39065
|
-
if (p === pref) {
|
|
39066
|
-
markFuncLive(obj, lf);
|
|
39067
|
-
}
|
|
39068
|
-
}
|
|
39069
|
-
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
39070
|
-
if (p === pref && classSym.startsWith("._OBJC_CLASS_")) {
|
|
39071
|
-
markObjCClassLive(classSym.slice("._OBJC_CLASS_".length));
|
|
39072
|
-
}
|
|
39073
|
-
}
|
|
39439
|
+
const idx = getTypeIndex(obj);
|
|
39440
|
+
for (const i of idx.mnByPrefix.get(pref) ?? []) activateSymbolInObj(obj, i);
|
|
39441
|
+
for (const lf of idx.objcRegByPrefix.get(pref) ?? []) markFuncLive(obj, lf);
|
|
39442
|
+
for (const cls of idx.objcClassByPrefix.get(pref) ?? []) markObjCClassLive(cls);
|
|
39074
39443
|
};
|
|
39075
39444
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
39076
39445
|
if (!rawSymName) return;
|
|
@@ -39095,11 +39464,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
39095
39464
|
}
|
|
39096
39465
|
}
|
|
39097
39466
|
}
|
|
39098
|
-
if (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o")) {
|
|
39099
|
-
|
|
39100
|
-
|
|
39101
|
-
|
|
39102
|
-
|
|
39467
|
+
if (obj.typePrefixesInObj.size > 0 && (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o"))) {
|
|
39468
|
+
const { minPrefLen, maxPrefLen } = getTypeIndex(obj);
|
|
39469
|
+
const hi = Math.min(sName.length, maxPrefLen);
|
|
39470
|
+
for (let n = minPrefLen; n <= hi; n++) {
|
|
39471
|
+
const cand = sName.slice(0, n);
|
|
39472
|
+
if (obj.typePrefixesInObj.has(cand)) markTypeLive(obj, cand);
|
|
39103
39473
|
}
|
|
39104
39474
|
}
|
|
39105
39475
|
};
|
|
@@ -39192,7 +39562,8 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
39192
39562
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
39193
39563
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
39194
39564
|
for (const name3 of obj.symNames) {
|
|
39195
|
-
|
|
39565
|
+
if (!name3 || !name3.startsWith("_c_") || !name3.endsWith("__load")) continue;
|
|
39566
|
+
const loaded4 = name3.match(/^_c_(\w+)__load$/)?.[1];
|
|
39196
39567
|
if (!loaded4) continue;
|
|
39197
39568
|
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded4}`);
|
|
39198
39569
|
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
@@ -39340,14 +39711,30 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
39340
39711
|
const keepObjCClassesNamedInSegment = (obj, segIdx) => {
|
|
39341
39712
|
const range3 = obj.segPayloadRanges[segIdx];
|
|
39342
39713
|
if (!range3) return;
|
|
39714
|
+
const [rangeStart, rangeEnd] = range3;
|
|
39715
|
+
if (rangeEnd - rangeStart < 4) return;
|
|
39343
39716
|
let bytes = objectBytes.get(obj);
|
|
39344
39717
|
if (!bytes) objectBytes.set(obj, bytes = import_node_fs56.default.readFileSync(obj.file));
|
|
39345
|
-
|
|
39346
|
-
|
|
39347
|
-
const
|
|
39348
|
-
|
|
39349
|
-
|
|
39350
|
-
|
|
39718
|
+
let pos = rangeStart;
|
|
39719
|
+
while (pos < rangeEnd - 3) {
|
|
39720
|
+
const at = bytes.indexOf("So", pos);
|
|
39721
|
+
if (at < 0 || at >= rangeEnd - 2) break;
|
|
39722
|
+
let digitEnd = at + 2;
|
|
39723
|
+
let length = 0;
|
|
39724
|
+
while (digitEnd < rangeEnd) {
|
|
39725
|
+
const ch = bytes[digitEnd];
|
|
39726
|
+
if (ch < 48 || ch > 57) break;
|
|
39727
|
+
length = length * 10 + (ch - 48);
|
|
39728
|
+
digitEnd++;
|
|
39729
|
+
}
|
|
39730
|
+
if (digitEnd === at + 2) {
|
|
39731
|
+
pos = at + 2;
|
|
39732
|
+
continue;
|
|
39733
|
+
}
|
|
39734
|
+
pos = digitEnd;
|
|
39735
|
+
const nameEnd = digitEnd + length;
|
|
39736
|
+
if (nameEnd >= rangeEnd || bytes[nameEnd] !== 67) continue;
|
|
39737
|
+
const symbol2 = `._OBJC_CLASS_${bytes.toString("latin1", digitEnd, nameEnd)}`;
|
|
39351
39738
|
for (const provider of lazyProviders.get(symbol2) ?? []) {
|
|
39352
39739
|
eagerDynamicObjects.add(provider);
|
|
39353
39740
|
extractObject(provider);
|
|
@@ -40441,6 +40828,10 @@ var init_nativeDyldTableContract = __esm({
|
|
|
40441
40828
|
|
|
40442
40829
|
// src/swift-guest-image-ledger.ts
|
|
40443
40830
|
function readNumber(bytes, position) {
|
|
40831
|
+
if (position < bytes.length) {
|
|
40832
|
+
const first = bytes[position];
|
|
40833
|
+
if (first < 128) return [first, position + 1];
|
|
40834
|
+
}
|
|
40444
40835
|
let value = 0;
|
|
40445
40836
|
let shift = 0;
|
|
40446
40837
|
for (; ; ) {
|
|
@@ -40452,6 +40843,7 @@ function readNumber(bytes, position) {
|
|
|
40452
40843
|
}
|
|
40453
40844
|
}
|
|
40454
40845
|
function encodeNumber(value) {
|
|
40846
|
+
if (value < 128) return Buffer.from([value]);
|
|
40455
40847
|
const bytes = [];
|
|
40456
40848
|
do {
|
|
40457
40849
|
let byte = value % 128;
|
|
@@ -40473,6 +40865,9 @@ function encodedString(value) {
|
|
|
40473
40865
|
const bytes = Buffer.from(value);
|
|
40474
40866
|
return Buffer.concat([encodeNumber(bytes.length), bytes]);
|
|
40475
40867
|
}
|
|
40868
|
+
function isWasmMagic(bytes) {
|
|
40869
|
+
return bytes.length >= 8 && bytes[0] === 0 && bytes[1] === 97 && bytes[2] === 115 && bytes[3] === 109 && bytes[4] === 1 && bytes[5] === 0 && bytes[6] === 0 && bytes[7] === 0;
|
|
40870
|
+
}
|
|
40476
40871
|
function llvmType(value) {
|
|
40477
40872
|
switch (value) {
|
|
40478
40873
|
case 127:
|
|
@@ -40488,11 +40883,12 @@ function llvmType(value) {
|
|
|
40488
40883
|
}
|
|
40489
40884
|
}
|
|
40490
40885
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
|
|
40491
|
-
if (
|
|
40492
|
-
|
|
40886
|
+
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
40887
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
40493
40888
|
const { sdkLookupOnly, sdkProduct } = options2;
|
|
40494
40889
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
40495
|
-
const
|
|
40890
|
+
const rewrite = binding !== void 0;
|
|
40891
|
+
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
40496
40892
|
const types2 = [];
|
|
40497
40893
|
const functionTypes = [];
|
|
40498
40894
|
const definitions = [];
|
|
@@ -40506,45 +40902,74 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
40506
40902
|
const usedSymbols = /* @__PURE__ */ new Set();
|
|
40507
40903
|
let position = 8;
|
|
40508
40904
|
while (position < bytes.length) {
|
|
40905
|
+
const headerStart2 = position;
|
|
40509
40906
|
const id = bytes[position++];
|
|
40510
|
-
|
|
40907
|
+
let size2 = 0;
|
|
40908
|
+
if (position < bytes.length && bytes[position] < 128) {
|
|
40909
|
+
size2 = bytes[position++];
|
|
40910
|
+
} else {
|
|
40911
|
+
const [val, next] = readNumber(bytes, position);
|
|
40912
|
+
size2 = val;
|
|
40913
|
+
position = next;
|
|
40914
|
+
}
|
|
40915
|
+
const start = position;
|
|
40511
40916
|
const end = start + size2;
|
|
40512
40917
|
if (end > bytes.length) throw new Error("invalid wasm section");
|
|
40513
40918
|
position = end;
|
|
40514
|
-
if (
|
|
40515
|
-
|
|
40516
|
-
|
|
40919
|
+
if (id > 3) {
|
|
40920
|
+
if (sections) sections.push(bytes.subarray(headerStart2, end));
|
|
40921
|
+
continue;
|
|
40922
|
+
}
|
|
40923
|
+
let offset = start;
|
|
40517
40924
|
const number4 = () => {
|
|
40518
|
-
|
|
40519
|
-
|
|
40520
|
-
|
|
40925
|
+
if (offset < end) {
|
|
40926
|
+
const first = bytes[offset];
|
|
40927
|
+
if (first < 128) {
|
|
40928
|
+
offset++;
|
|
40929
|
+
return first;
|
|
40930
|
+
}
|
|
40931
|
+
}
|
|
40932
|
+
let value = 0;
|
|
40933
|
+
let shift = 0;
|
|
40934
|
+
for (; ; ) {
|
|
40935
|
+
if (offset >= end || shift > 63) throw new Error("invalid wasm integer");
|
|
40936
|
+
const byte = bytes[offset++];
|
|
40937
|
+
value += (byte & 127) * 2 ** shift;
|
|
40938
|
+
if (!(byte & 128)) return value;
|
|
40939
|
+
shift += 7;
|
|
40940
|
+
}
|
|
40521
40941
|
};
|
|
40522
40942
|
const string8 = () => {
|
|
40523
|
-
const
|
|
40524
|
-
|
|
40943
|
+
const length = number4();
|
|
40944
|
+
const strEnd = offset + length;
|
|
40945
|
+
if (strEnd > end) throw new Error("invalid wasm string");
|
|
40946
|
+
const value = rawBuf.toString("utf8", offset, strEnd);
|
|
40947
|
+
offset = strEnd;
|
|
40525
40948
|
return value;
|
|
40526
40949
|
};
|
|
40950
|
+
let rewrittenSection;
|
|
40527
40951
|
if (id === 1) {
|
|
40528
40952
|
const count = number4();
|
|
40529
40953
|
for (let i = 0; i < count; i++) {
|
|
40530
|
-
if (
|
|
40954
|
+
if (bytes[offset++] !== 96) throw new Error("unsupported wasm type");
|
|
40531
40955
|
const parameterCount = number4();
|
|
40532
|
-
|
|
40533
|
-
|
|
40534
|
-
|
|
40956
|
+
if (offset + parameterCount > end) throw new Error("invalid wasm type");
|
|
40957
|
+
const parameters = new Array(parameterCount);
|
|
40958
|
+
for (let p = 0; p < parameterCount; p++) parameters[p] = bytes[offset++];
|
|
40535
40959
|
const resultCount = number4();
|
|
40536
|
-
|
|
40537
|
-
|
|
40538
|
-
|
|
40960
|
+
if (offset + resultCount > end) throw new Error("invalid wasm type");
|
|
40961
|
+
const results = new Array(resultCount);
|
|
40962
|
+
for (let r = 0; r < resultCount; r++) results[r] = bytes[offset++];
|
|
40539
40963
|
types2.push({ parameters, results });
|
|
40540
40964
|
}
|
|
40541
40965
|
} else if (id === 2) {
|
|
40542
40966
|
const count = number4();
|
|
40543
|
-
const
|
|
40967
|
+
const importWriter = rewrite ? new ByteWriter(size2 + 64) : void 0;
|
|
40968
|
+
importWriter?.uleb(count);
|
|
40544
40969
|
for (let i = 0; i < count; i++) {
|
|
40545
40970
|
const module2 = string8();
|
|
40546
40971
|
const name3 = string8();
|
|
40547
|
-
const kind =
|
|
40972
|
+
const kind = bytes[offset++];
|
|
40548
40973
|
const typeStart = offset;
|
|
40549
40974
|
let functionType2 = -1;
|
|
40550
40975
|
if (kind === 0) {
|
|
@@ -40552,7 +40977,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
40552
40977
|
functionTypes.push(functionType2);
|
|
40553
40978
|
functionImportNames.push(name3);
|
|
40554
40979
|
} else if (kind === 1) {
|
|
40555
|
-
const referenceType =
|
|
40980
|
+
const referenceType = bytes[offset++];
|
|
40556
40981
|
if (referenceType !== 112 && referenceType !== 111)
|
|
40557
40982
|
throw new Error("unsupported table type");
|
|
40558
40983
|
const flags = number4();
|
|
@@ -40571,11 +40996,15 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
40571
40996
|
} else throw new Error("unsupported wasm import");
|
|
40572
40997
|
const isDlsym = instrumentDynamicLookups && module2 === "env" && name3 === "dlsym" && kind === 0;
|
|
40573
40998
|
const isDlerror = instrumentDynamicLookups && module2 === "env" && name3 === "dlerror" && kind === 0;
|
|
40574
|
-
if (
|
|
40575
|
-
|
|
40576
|
-
|
|
40577
|
-
|
|
40578
|
-
|
|
40999
|
+
if (!rewrite) {
|
|
41000
|
+
if (module2 === "env" && names.has(name3)) {
|
|
41001
|
+
usedSymbols.add(name3);
|
|
41002
|
+
if (kind === 0) {
|
|
41003
|
+
const type = types2[functionType2];
|
|
41004
|
+
if (!type) throw new Error(`missing import type for ${name3}`);
|
|
41005
|
+
functionImports.set(name3, type);
|
|
41006
|
+
}
|
|
41007
|
+
}
|
|
40579
41008
|
}
|
|
40580
41009
|
if (isDlsym || isDlerror) {
|
|
40581
41010
|
const type = types2[functionType2];
|
|
@@ -40585,17 +41014,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
40585
41014
|
}
|
|
40586
41015
|
if (isDlsym) usesDlsym = true;
|
|
40587
41016
|
if (isDlerror) usesDlerror = true;
|
|
40588
|
-
|
|
40589
|
-
|
|
40590
|
-
|
|
40591
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding
|
|
40592
|
-
)
|
|
40593
|
-
|
|
40594
|
-
|
|
40595
|
-
|
|
41017
|
+
if (importWriter && binding) {
|
|
41018
|
+
importWriter.string(module2);
|
|
41019
|
+
importWriter.string(
|
|
41020
|
+
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
|
|
41021
|
+
);
|
|
41022
|
+
importWriter.byte(kind);
|
|
41023
|
+
importWriter.bytes(bytes, typeStart, offset);
|
|
41024
|
+
}
|
|
40596
41025
|
}
|
|
40597
|
-
if (offset !==
|
|
40598
|
-
if (
|
|
41026
|
+
if (offset !== end) throw new Error("invalid wasm import section");
|
|
41027
|
+
if (importWriter) rewrittenSection = importWriter.finish();
|
|
40599
41028
|
} else if (id === 3) {
|
|
40600
41029
|
const count = number4();
|
|
40601
41030
|
for (let i = 0; i < count; i++) functionTypes.push(number4());
|
|
@@ -40604,43 +41033,40 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
40604
41033
|
if (sectionName === "linking") {
|
|
40605
41034
|
const version2 = number4();
|
|
40606
41035
|
if (version2 !== 2) throw new Error("unsupported wasm linking version");
|
|
40607
|
-
const subsections = [];
|
|
41036
|
+
const subsections = rewrite ? [] : void 0;
|
|
40608
41037
|
let objcLoader;
|
|
40609
|
-
while (offset <
|
|
40610
|
-
const kind =
|
|
41038
|
+
while (offset < end) {
|
|
41039
|
+
const kind = bytes[offset++];
|
|
40611
41040
|
const length = number4();
|
|
40612
41041
|
const stop = offset + length;
|
|
40613
|
-
if (stop >
|
|
40614
|
-
|
|
40615
|
-
if (kind === 7 && !sdkLookupOnly) {
|
|
40616
|
-
const
|
|
41042
|
+
if (stop > end) throw new Error("invalid linking subsection");
|
|
41043
|
+
const contentStart = offset;
|
|
41044
|
+
if (kind === 7 && rewrite && !sdkLookupOnly) {
|
|
41045
|
+
const comdatWriter = new ByteWriter(length + 64);
|
|
40617
41046
|
const count = number4();
|
|
40618
|
-
|
|
41047
|
+
comdatWriter.uleb(count);
|
|
40619
41048
|
for (let i = 0; i < count; i++) {
|
|
40620
41049
|
const group = string8();
|
|
40621
41050
|
const begin = offset;
|
|
40622
41051
|
number4();
|
|
40623
41052
|
const members2 = number4();
|
|
40624
41053
|
for (let member = 0; member < members2 * 2; member++) number4();
|
|
40625
|
-
|
|
40626
|
-
|
|
40627
|
-
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
40628
|
-
),
|
|
40629
|
-
section2.subarray(begin, offset)
|
|
41054
|
+
comdatWriter.string(
|
|
41055
|
+
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
40630
41056
|
);
|
|
41057
|
+
comdatWriter.bytes(bytes, begin, offset);
|
|
40631
41058
|
}
|
|
40632
41059
|
if (offset !== stop) throw new Error("invalid comdat subsection");
|
|
40633
|
-
|
|
40634
|
-
|
|
40635
|
-
if (kind === 8) {
|
|
40636
|
-
const
|
|
40637
|
-
|
|
41060
|
+
const buf = comdatWriter.finish();
|
|
41061
|
+
subsections.push({ kind, parts: [buf], byteLength: buf.length });
|
|
41062
|
+
} else if (kind === 8) {
|
|
41063
|
+
const entryWriter = rewrite ? new ByteWriter(length + 128) : void 0;
|
|
41064
|
+
let extraWriter;
|
|
40638
41065
|
const count = number4();
|
|
40639
|
-
entries2.push(encodeNumber(count));
|
|
40640
41066
|
let added = 0;
|
|
40641
41067
|
for (let i = 0; i < count; i++) {
|
|
40642
41068
|
const begin = offset;
|
|
40643
|
-
const symbolKind =
|
|
41069
|
+
const symbolKind = bytes[offset++];
|
|
40644
41070
|
const flags = number4();
|
|
40645
41071
|
const flagsEnd = offset;
|
|
40646
41072
|
let index = -1;
|
|
@@ -40668,25 +41094,43 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
40668
41094
|
}
|
|
40669
41095
|
} else if (symbolKind === 3) number4();
|
|
40670
41096
|
else throw new Error("unsupported wasm symbol kind");
|
|
40671
|
-
if (symbolKind === 0)
|
|
41097
|
+
if (!rewrite && symbolKind === 0)
|
|
40672
41098
|
functionSymbols[i] = name3 || functionImportNames[index];
|
|
40673
|
-
if (!sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
41099
|
+
if (rewrite && !sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
40674
41100
|
objcLoader = i;
|
|
40675
41101
|
}
|
|
40676
41102
|
const alias = names.get(name3);
|
|
40677
|
-
if (flags & 16 && symbolKind === 1 && alias)
|
|
40678
|
-
|
|
40679
|
-
|
|
40680
|
-
|
|
40681
|
-
|
|
40682
|
-
|
|
40683
|
-
|
|
40684
|
-
|
|
40685
|
-
|
|
40686
|
-
|
|
40687
|
-
|
|
40688
|
-
|
|
40689
|
-
|
|
41103
|
+
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
41104
|
+
usedSymbols.add(name3);
|
|
41105
|
+
if (entryWriter && binding) {
|
|
41106
|
+
if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
41107
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
41108
|
+
entryWriter.string(name3 === "dlsym" ? callerAlias : dlerrorAlias);
|
|
41109
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
41110
|
+
} else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
|
|
41111
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
41112
|
+
entryWriter.string(binding(name3));
|
|
41113
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
41114
|
+
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
41115
|
+
if (symbolKind !== 0 && symbolKind !== 1)
|
|
41116
|
+
throw new Error(`unsupported symbol ${name3}`);
|
|
41117
|
+
if (preserveCanonical.has(name3)) {
|
|
41118
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
41119
|
+
extraWriter ??= new ByteWriter(256);
|
|
41120
|
+
extraWriter.byte(bytes[begin]);
|
|
41121
|
+
extraWriter.uleb(flags & ~32);
|
|
41122
|
+
extraWriter.bytes(bytes, flagsEnd, nameStart);
|
|
41123
|
+
extraWriter.string(alias);
|
|
41124
|
+
extraWriter.bytes(bytes, nameEnd, offset);
|
|
41125
|
+
added++;
|
|
41126
|
+
} else {
|
|
41127
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
41128
|
+
entryWriter.string(alias);
|
|
41129
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
41130
|
+
}
|
|
41131
|
+
} else {
|
|
41132
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
41133
|
+
}
|
|
40690
41134
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
40691
41135
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
40692
41136
|
throw new Error(`unsupported symbol ${name3}`);
|
|
@@ -40700,63 +41144,73 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
40700
41144
|
hidden: (flags & 4) !== 0,
|
|
40701
41145
|
type
|
|
40702
41146
|
});
|
|
40703
|
-
|
|
40704
|
-
entries2.push(section2.subarray(begin, offset));
|
|
40705
|
-
extraEntries.push(
|
|
40706
|
-
section2.subarray(begin, begin + 1),
|
|
40707
|
-
encodeNumber(flags & ~32),
|
|
40708
|
-
section2.subarray(flagsEnd, nameStart),
|
|
40709
|
-
encodedString(alias),
|
|
40710
|
-
section2.subarray(nameEnd, offset)
|
|
40711
|
-
);
|
|
40712
|
-
added++;
|
|
40713
|
-
} else {
|
|
40714
|
-
entries2.push(
|
|
40715
|
-
section2.subarray(begin, nameStart),
|
|
40716
|
-
encodedString(alias),
|
|
40717
|
-
section2.subarray(nameEnd, offset)
|
|
40718
|
-
);
|
|
40719
|
-
}
|
|
40720
|
-
} else entries2.push(section2.subarray(begin, offset));
|
|
41147
|
+
}
|
|
40721
41148
|
}
|
|
40722
41149
|
if (offset !== stop) throw new Error("invalid symbol subsection");
|
|
40723
|
-
|
|
40724
|
-
|
|
41150
|
+
if (entryWriter) {
|
|
41151
|
+
const countBytes = encodeNumber(count + added);
|
|
41152
|
+
const entryBuf = entryWriter.finish();
|
|
41153
|
+
if (extraWriter) {
|
|
41154
|
+
const extraBuf = extraWriter.finish();
|
|
41155
|
+
subsections.push({
|
|
41156
|
+
kind,
|
|
41157
|
+
parts: [countBytes, entryBuf, extraBuf],
|
|
41158
|
+
byteLength: countBytes.length + entryBuf.length + extraBuf.length
|
|
41159
|
+
});
|
|
41160
|
+
} else {
|
|
41161
|
+
subsections.push({
|
|
41162
|
+
kind,
|
|
41163
|
+
parts: [countBytes, entryBuf],
|
|
41164
|
+
byteLength: countBytes.length + entryBuf.length
|
|
41165
|
+
});
|
|
41166
|
+
}
|
|
41167
|
+
}
|
|
41168
|
+
} else if (subsections) {
|
|
41169
|
+
subsections.push({
|
|
41170
|
+
kind,
|
|
41171
|
+
parts: [bytes.subarray(contentStart, stop)],
|
|
41172
|
+
byteLength: length
|
|
41173
|
+
});
|
|
40725
41174
|
}
|
|
40726
41175
|
offset = stop;
|
|
40727
|
-
|
|
40728
|
-
|
|
40729
|
-
|
|
40730
|
-
|
|
40731
|
-
|
|
40732
|
-
|
|
40733
|
-
|
|
40734
|
-
|
|
40735
|
-
|
|
40736
|
-
|
|
40737
|
-
|
|
40738
|
-
|
|
40739
|
-
|
|
40740
|
-
|
|
40741
|
-
content
|
|
40742
|
-
|
|
40743
|
-
|
|
40744
|
-
|
|
40745
|
-
|
|
40746
|
-
|
|
41176
|
+
}
|
|
41177
|
+
if (subsections) {
|
|
41178
|
+
const linkingWriter = new ByteWriter(size2 + 128);
|
|
41179
|
+
linkingWriter.string(sectionName);
|
|
41180
|
+
linkingWriter.uleb(version2);
|
|
41181
|
+
for (const subsection of subsections) {
|
|
41182
|
+
if (subsection.kind === 6 && objcLoader !== void 0) {
|
|
41183
|
+
const content = subsection.parts[0];
|
|
41184
|
+
const [count, entriesStart] = readNumber(content, 0);
|
|
41185
|
+
const initWriter = new ByteWriter(content.length + 16);
|
|
41186
|
+
initWriter.bytes(content, 0, entriesStart);
|
|
41187
|
+
let entryStart = entriesStart;
|
|
41188
|
+
for (let i = 0; i < count; i++) {
|
|
41189
|
+
const [, symbolStart] = readNumber(content, entryStart);
|
|
41190
|
+
const [symbol2, entryEnd] = readNumber(content, symbolStart);
|
|
41191
|
+
if (symbol2 === objcLoader) {
|
|
41192
|
+
initWriter.uleb(1);
|
|
41193
|
+
initWriter.bytes(content, symbolStart, entryEnd);
|
|
41194
|
+
} else {
|
|
41195
|
+
initWriter.bytes(content, entryStart, entryEnd);
|
|
41196
|
+
}
|
|
41197
|
+
entryStart = entryEnd;
|
|
41198
|
+
}
|
|
41199
|
+
if (entryStart !== content.length)
|
|
41200
|
+
throw new Error("invalid init functions subsection");
|
|
41201
|
+
const initBuf = initWriter.finish();
|
|
41202
|
+
linkingWriter.byte(subsection.kind);
|
|
41203
|
+
linkingWriter.uleb(initBuf.length);
|
|
41204
|
+
linkingWriter.bytes(initBuf);
|
|
41205
|
+
} else {
|
|
41206
|
+
linkingWriter.byte(subsection.kind);
|
|
41207
|
+
linkingWriter.uleb(subsection.byteLength);
|
|
41208
|
+
for (const part of subsection.parts) linkingWriter.bytes(part);
|
|
40747
41209
|
}
|
|
40748
|
-
if (entryStart !== content.length)
|
|
40749
|
-
throw new Error("invalid init functions subsection");
|
|
40750
|
-
content = Buffer.concat(entries2);
|
|
40751
41210
|
}
|
|
40752
|
-
|
|
40753
|
-
Buffer.from([subsection.kind]),
|
|
40754
|
-
encodeNumber(content.length),
|
|
40755
|
-
content
|
|
40756
|
-
);
|
|
41211
|
+
rewrittenSection = linkingWriter.finish();
|
|
40757
41212
|
}
|
|
40758
|
-
|
|
40759
|
-
} else if (!sections && sectionName.startsWith("reloc.")) {
|
|
41213
|
+
} else if (!rewrite && sectionName.startsWith("reloc.")) {
|
|
40760
41214
|
number4();
|
|
40761
41215
|
for (let count = number4(); count > 0; count--) {
|
|
40762
41216
|
const type = number4();
|
|
@@ -40766,18 +41220,27 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
40766
41220
|
if (name3 !== void 0 && TABLE_INDEX_RELOCATIONS.has(type))
|
|
40767
41221
|
addressTaken.add(name3);
|
|
40768
41222
|
}
|
|
40769
|
-
if (offset !==
|
|
40770
|
-
|
|
41223
|
+
if (offset !== end) throw new Error(`invalid relocation section ${sectionName}`);
|
|
41224
|
+
}
|
|
41225
|
+
}
|
|
41226
|
+
if (sections) {
|
|
41227
|
+
if (rewrittenSection) {
|
|
41228
|
+
sections.push(
|
|
41229
|
+
Buffer.from([id]),
|
|
41230
|
+
encodeNumber(rewrittenSection.length),
|
|
41231
|
+
rewrittenSection
|
|
41232
|
+
);
|
|
41233
|
+
} else {
|
|
41234
|
+
sections.push(bytes.subarray(headerStart2, end));
|
|
40771
41235
|
}
|
|
40772
41236
|
}
|
|
40773
|
-
sections?.push(Buffer.from([id]), encodeNumber(section2.length), section2);
|
|
40774
41237
|
}
|
|
40775
41238
|
return {
|
|
40776
41239
|
bytes: sections ? Buffer.concat(sections) : bytes,
|
|
40777
41240
|
definitions,
|
|
40778
41241
|
functionImports,
|
|
40779
41242
|
usesDlsym,
|
|
40780
|
-
usedSymbols
|
|
41243
|
+
usedSymbols,
|
|
40781
41244
|
addressTaken: [...addressTaken]
|
|
40782
41245
|
};
|
|
40783
41246
|
}
|
|
@@ -40866,36 +41329,51 @@ function createGuestImageLedger(input) {
|
|
|
40866
41329
|
}
|
|
40867
41330
|
}
|
|
40868
41331
|
}
|
|
40869
|
-
|
|
40870
|
-
for (const definition2 of definitions)
|
|
40871
|
-
|
|
40872
|
-
|
|
40873
|
-
|
|
40874
|
-
|
|
40875
|
-
|
|
41332
|
+
let hasNonAscii = false;
|
|
41333
|
+
for (const definition2 of definitions) {
|
|
41334
|
+
const s = definition2.name;
|
|
41335
|
+
for (let i = 0; i < s.length; i++) {
|
|
41336
|
+
if (s.charCodeAt(i) > 127) {
|
|
41337
|
+
hasNonAscii = true;
|
|
41338
|
+
break;
|
|
41339
|
+
}
|
|
41340
|
+
}
|
|
41341
|
+
if (hasNonAscii) break;
|
|
41342
|
+
}
|
|
41343
|
+
if (hasNonAscii) {
|
|
41344
|
+
const nameBytes = /* @__PURE__ */ new Map();
|
|
41345
|
+
for (const definition2 of definitions)
|
|
41346
|
+
if (!nameBytes.has(definition2.name))
|
|
41347
|
+
nameBytes.set(definition2.name, Buffer.from(definition2.name));
|
|
41348
|
+
definitions.sort(
|
|
41349
|
+
(a, b) => Buffer.compare(nameBytes.get(a.name), nameBytes.get(b.name)) || a.image - b.image
|
|
41350
|
+
);
|
|
41351
|
+
} else {
|
|
41352
|
+
definitions.sort(
|
|
41353
|
+
(a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : a.image - b.image
|
|
41354
|
+
);
|
|
41355
|
+
}
|
|
40876
41356
|
const preserveCanonical = /* @__PURE__ */ new Set();
|
|
40877
41357
|
const definitionsByName = Map.groupBy(definitions, (definition2) => definition2.name);
|
|
40878
|
-
|
|
41358
|
+
if (symbolIndices.has("__cxa_throw")) {
|
|
41359
|
+
const name3 = "__cxa_throw";
|
|
40879
41360
|
const matching2 = definitionsByName.get(name3) ?? [];
|
|
40880
|
-
if (new Set(matching2.map((definition2) => definition2.image)).size
|
|
40881
|
-
|
|
40882
|
-
|
|
40883
|
-
|
|
40884
|
-
|
|
40885
|
-
|
|
40886
|
-
|
|
40887
|
-
|
|
40888
|
-
|
|
40889
|
-
|
|
40890
|
-
|
|
40891
|
-
|
|
40892
|
-
|
|
40893
|
-
|
|
40894
|
-
);
|
|
40895
|
-
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
40896
|
-
throw new Error(`weak interposition scope excludes runtime for ${name3}`);
|
|
41361
|
+
if (new Set(matching2.map((definition2) => definition2.image)).size >= 2 && matching2.some((definition2) => definition2.weak)) {
|
|
41362
|
+
const weak = matching2.filter((definition2) => definition2.weak);
|
|
41363
|
+
const strong = matching2.filter((definition2) => !definition2.weak);
|
|
41364
|
+
if (weak.length !== 1 || strong.length !== 1)
|
|
41365
|
+
throw new Error(`unsupported weak interposition for ${name3}`);
|
|
41366
|
+
const [local] = weak;
|
|
41367
|
+
const [runtime] = strong;
|
|
41368
|
+
if (local.kind !== "function" || runtime.kind !== "function" || local.result !== runtime.result || local.parameters.join(",") !== runtime.parameters.join(","))
|
|
41369
|
+
throw new Error(`incompatible weak interposition for ${name3}`);
|
|
41370
|
+
for (const caller of input.callers) {
|
|
41371
|
+
const uses = caller.image === local.image || units.some((unit2) => unit2.image === caller.image && unit2.usedSymbols.has(name3));
|
|
41372
|
+
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
41373
|
+
throw new Error(`weak interposition scope excludes runtime for ${name3}`);
|
|
41374
|
+
}
|
|
41375
|
+
preserveCanonical.add(name3);
|
|
40897
41376
|
}
|
|
40898
|
-
preserveCanonical.add(name3);
|
|
40899
41377
|
}
|
|
40900
41378
|
for (const name3 of [
|
|
40901
41379
|
"dlsym",
|
|
@@ -40907,40 +41385,76 @@ function createGuestImageLedger(input) {
|
|
|
40907
41385
|
])
|
|
40908
41386
|
preserveCanonical.add(name3);
|
|
40909
41387
|
for (const name3 of input.commandLineSymbols ?? []) preserveCanonical.add(name3);
|
|
40910
|
-
const
|
|
40911
|
-
const
|
|
41388
|
+
const imageAliases = /* @__PURE__ */ new Map();
|
|
41389
|
+
const imageWeakNames = /* @__PURE__ */ new Map();
|
|
41390
|
+
const singleOwnerByName = /* @__PURE__ */ new Map();
|
|
41391
|
+
for (const definition2 of definitions) {
|
|
41392
|
+
let aliases = imageAliases.get(definition2.image);
|
|
41393
|
+
if (!aliases) imageAliases.set(definition2.image, aliases = /* @__PURE__ */ new Map());
|
|
41394
|
+
const existing = aliases.get(definition2.name);
|
|
41395
|
+
if (existing === void 0) {
|
|
41396
|
+
aliases.set(definition2.name, definition2.alias);
|
|
41397
|
+
if (definition2.weak) {
|
|
41398
|
+
let weak = imageWeakNames.get(definition2.image);
|
|
41399
|
+
if (!weak) imageWeakNames.set(definition2.image, weak = /* @__PURE__ */ new Set());
|
|
41400
|
+
weak.add(definition2.name);
|
|
41401
|
+
}
|
|
41402
|
+
const owner = singleOwnerByName.get(definition2.name);
|
|
41403
|
+
if (owner === void 0)
|
|
41404
|
+
singleOwnerByName.set(definition2.name, {
|
|
41405
|
+
image: definition2.image,
|
|
41406
|
+
alias: definition2.alias
|
|
41407
|
+
});
|
|
41408
|
+
else if (owner !== null && owner.image !== definition2.image)
|
|
41409
|
+
singleOwnerByName.set(definition2.name, null);
|
|
41410
|
+
} else if (!definition2.weak && imageWeakNames.get(definition2.image)?.has(definition2.name)) {
|
|
41411
|
+
aliases.set(definition2.name, definition2.alias);
|
|
41412
|
+
imageWeakNames.get(definition2.image).delete(definition2.name);
|
|
41413
|
+
const owner = singleOwnerByName.get(definition2.name);
|
|
41414
|
+
if (owner && owner.image === definition2.image) owner.alias = definition2.alias;
|
|
41415
|
+
}
|
|
41416
|
+
}
|
|
41417
|
+
const sharedLookupByImage = /* @__PURE__ */ new Map();
|
|
40912
41418
|
for (const caller of input.callers) {
|
|
40913
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
40914
|
-
const seen = /* @__PURE__ */ new Map();
|
|
40915
41419
|
const scope2 = [caller.image, ...caller.next];
|
|
40916
41420
|
if (input.systemImage !== void 0 && !scope2.includes(input.systemImage))
|
|
40917
41421
|
scope2.push(input.systemImage);
|
|
40918
|
-
|
|
40919
|
-
|
|
40920
|
-
|
|
40921
|
-
|
|
40922
|
-
|
|
40923
|
-
|
|
40924
|
-
|
|
40925
|
-
|
|
40926
|
-
|
|
40927
|
-
|
|
40928
|
-
|
|
40929
|
-
|
|
40930
|
-
|
|
40931
|
-
|
|
40932
|
-
|
|
41422
|
+
const scopeSet = new Set(scope2);
|
|
41423
|
+
const scopeMaps = [];
|
|
41424
|
+
const seenImages = /* @__PURE__ */ new Set();
|
|
41425
|
+
for (const image of scope2) {
|
|
41426
|
+
if (seenImages.has(image)) continue;
|
|
41427
|
+
seenImages.add(image);
|
|
41428
|
+
const aliases = imageAliases.get(image);
|
|
41429
|
+
if (aliases) scopeMaps.push(aliases);
|
|
41430
|
+
}
|
|
41431
|
+
const cache = /* @__PURE__ */ new Map();
|
|
41432
|
+
sharedLookupByImage.set(caller.image, (name3) => {
|
|
41433
|
+
if (preserveCanonical.has(name3)) return void 0;
|
|
41434
|
+
const single = singleOwnerByName.get(name3);
|
|
41435
|
+
if (single === void 0) return void 0;
|
|
41436
|
+
if (single !== null) return scopeSet.has(single.image) ? single.alias : void 0;
|
|
41437
|
+
const hit = cache.get(name3);
|
|
41438
|
+
if (hit !== void 0) return hit ?? void 0;
|
|
41439
|
+
for (const aliases of scopeMaps) {
|
|
41440
|
+
const alias = aliases.get(name3);
|
|
41441
|
+
if (alias !== void 0) {
|
|
41442
|
+
cache.set(name3, alias);
|
|
41443
|
+
return alias;
|
|
40933
41444
|
}
|
|
40934
41445
|
}
|
|
40935
|
-
|
|
41446
|
+
cache.set(name3, null);
|
|
41447
|
+
return void 0;
|
|
41448
|
+
});
|
|
40936
41449
|
}
|
|
40937
41450
|
const startup = /* @__PURE__ */ new Map();
|
|
41451
|
+
const unitsByPath = new Map(units.map((unit2) => [unit2.object.path, unit2]));
|
|
40938
41452
|
for (const binding of input.directBindings ?? []) {
|
|
40939
|
-
const unit2 =
|
|
41453
|
+
const unit2 = unitsByPath.get(binding.object);
|
|
40940
41454
|
const matches = (definitionsByName.get(binding.symbol) ?? []).filter(
|
|
40941
41455
|
(definition2) => definition2.object === binding.providerObject && definition2.image === binding.providerImage
|
|
40942
41456
|
);
|
|
40943
|
-
if (!unit2 || !unit2.usedSymbols.
|
|
41457
|
+
if (!unit2 || !unit2.usedSymbols.has(binding.symbol) || matches.length !== 1)
|
|
40944
41458
|
throw new Error(`invalid startup binding ${binding.object} ${binding.symbol}`);
|
|
40945
41459
|
const bindings = startup.get(binding.object) ?? /* @__PURE__ */ new Map();
|
|
40946
41460
|
if (bindings.has(binding.symbol))
|
|
@@ -40981,11 +41495,11 @@ function createGuestImageLedger(input) {
|
|
|
40981
41495
|
}
|
|
40982
41496
|
}
|
|
40983
41497
|
const objects = units.map(({ image, object: object8, aliases, functionImports }) => {
|
|
40984
|
-
const shared =
|
|
41498
|
+
const shared = sharedLookupByImage.get(image);
|
|
40985
41499
|
const own2 = startup.get(object8.path);
|
|
40986
41500
|
const bindings = new Map(own2);
|
|
40987
41501
|
const weak = input.sdkWeakReferences?.get(object8.path);
|
|
40988
|
-
const binding = (name3) => bindings.get(name3) ?? shared
|
|
41502
|
+
const binding = (name3) => bindings.get(name3) ?? shared(name3) ?? (weak?.has(name3) ? void 0 : sdkGlobalBindings.get(name3));
|
|
40989
41503
|
for (const [name3, type] of functionImports) {
|
|
40990
41504
|
const alias = binding(name3);
|
|
40991
41505
|
const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
|
|
@@ -41250,7 +41764,7 @@ function nameGuestImageAliases(wasm, symbols) {
|
|
|
41250
41764
|
}
|
|
41251
41765
|
return Buffer.concat(parts2);
|
|
41252
41766
|
}
|
|
41253
|
-
var import_node_crypto31, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
41767
|
+
var import_node_crypto31, ByteWriter, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
41254
41768
|
var init_swift_guest_image_ledger = __esm({
|
|
41255
41769
|
"src/swift-guest-image-ledger.ts"() {
|
|
41256
41770
|
"use strict";
|
|
@@ -41258,6 +41772,57 @@ var init_swift_guest_image_ledger = __esm({
|
|
|
41258
41772
|
init_nativeWasmContract();
|
|
41259
41773
|
init_swift_sdk_image_wasm();
|
|
41260
41774
|
init_swiftSdkLinkContract();
|
|
41775
|
+
ByteWriter = class {
|
|
41776
|
+
buf;
|
|
41777
|
+
pos = 0;
|
|
41778
|
+
constructor(initialCapacity = 256) {
|
|
41779
|
+
this.buf = Buffer.allocUnsafe(Math.max(64, initialCapacity));
|
|
41780
|
+
}
|
|
41781
|
+
ensure(extra) {
|
|
41782
|
+
const needed = this.pos + extra;
|
|
41783
|
+
if (needed <= this.buf.length) return;
|
|
41784
|
+
let next = this.buf.length * 2;
|
|
41785
|
+
while (next < needed) next *= 2;
|
|
41786
|
+
const grown = Buffer.allocUnsafe(next);
|
|
41787
|
+
this.buf.copy(grown, 0, 0, this.pos);
|
|
41788
|
+
this.buf = grown;
|
|
41789
|
+
}
|
|
41790
|
+
byte(value) {
|
|
41791
|
+
this.ensure(1);
|
|
41792
|
+
this.buf[this.pos++] = value;
|
|
41793
|
+
}
|
|
41794
|
+
uleb(value) {
|
|
41795
|
+
this.ensure(10);
|
|
41796
|
+
let pos = this.pos;
|
|
41797
|
+
const buf = this.buf;
|
|
41798
|
+
do {
|
|
41799
|
+
let byte = value % 128;
|
|
41800
|
+
value = Math.floor(value / 128);
|
|
41801
|
+
if (value) byte |= 128;
|
|
41802
|
+
buf[pos++] = byte;
|
|
41803
|
+
} while (value);
|
|
41804
|
+
this.pos = pos;
|
|
41805
|
+
}
|
|
41806
|
+
bytes(source, start = 0, end = source.length) {
|
|
41807
|
+
const len = end - start;
|
|
41808
|
+
if (len <= 0) return;
|
|
41809
|
+
this.ensure(len);
|
|
41810
|
+
this.buf.set(source.subarray(start, end), this.pos);
|
|
41811
|
+
this.pos += len;
|
|
41812
|
+
}
|
|
41813
|
+
string(value) {
|
|
41814
|
+
const len = Buffer.byteLength(value, "utf8");
|
|
41815
|
+
this.uleb(len);
|
|
41816
|
+
if (len > 0) {
|
|
41817
|
+
this.ensure(len);
|
|
41818
|
+
this.buf.write(value, this.pos, len, "utf8");
|
|
41819
|
+
this.pos += len;
|
|
41820
|
+
}
|
|
41821
|
+
}
|
|
41822
|
+
finish() {
|
|
41823
|
+
return this.buf.subarray(0, this.pos);
|
|
41824
|
+
}
|
|
41825
|
+
};
|
|
41261
41826
|
OBJC_INIT_RECORD = ".objc_init";
|
|
41262
41827
|
TABLE_INDEX_RELOCATIONS = /* @__PURE__ */ new Set([1, 2, 12, 18, 19, 24]);
|
|
41263
41828
|
GUEST_DYLD_VALUES_SECTION = "peach_dyld_values";
|
|
@@ -41875,8 +42440,11 @@ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
41875
42440
|
function guestDyldValueRange(map2) {
|
|
41876
42441
|
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
41877
42442
|
let found2;
|
|
41878
|
-
for (
|
|
41879
|
-
|
|
42443
|
+
for (let at = map2.indexOf(suffix); at !== -1; at = map2.indexOf(suffix, at + suffix.length)) {
|
|
42444
|
+
const lineEnd = at + suffix.length;
|
|
42445
|
+
if (lineEnd < map2.length && map2.charCodeAt(lineEnd) !== 10) continue;
|
|
42446
|
+
const lineStart = map2.lastIndexOf("\n", at) + 1;
|
|
42447
|
+
const line = map2.slice(lineStart, lineEnd);
|
|
41880
42448
|
const match = /^\s*([\da-f]+)\s+[\da-f]+\s+([\da-f]+)\s/.exec(line);
|
|
41881
42449
|
if (!match) throw new Error("unreadable dyld values map line");
|
|
41882
42450
|
if (found2) throw new Error("link map has several dyld value sections");
|
|
@@ -41929,7 +42497,7 @@ var init_swift_guest_link_plan = __esm({
|
|
|
41929
42497
|
});
|
|
41930
42498
|
|
|
41931
42499
|
// src/swift-guest-manifest.ts
|
|
41932
|
-
function selectedGuestManifestInputs(plan, selection, identities) {
|
|
42500
|
+
function selectedGuestManifestInputs(plan, selection, identities, readSelected) {
|
|
41933
42501
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
41934
42502
|
const archives = /* @__PURE__ */ new Map();
|
|
41935
42503
|
const images = /* @__PURE__ */ new Map();
|
|
@@ -41940,19 +42508,29 @@ function selectedGuestManifestInputs(plan, selection, identities) {
|
|
|
41940
42508
|
throw new Error(`selected input has no logical identity: ${item.artifact}`);
|
|
41941
42509
|
let bytes;
|
|
41942
42510
|
let memberIdentity = null;
|
|
41943
|
-
if (item.member === null)
|
|
41944
|
-
|
|
41945
|
-
|
|
41946
|
-
if (
|
|
41947
|
-
|
|
41948
|
-
|
|
42511
|
+
if (item.member === null) {
|
|
42512
|
+
bytes = readSelected ? readSelected(item) : (0, import_node_fs58.readFileSync)(item.artifact);
|
|
42513
|
+
} else {
|
|
42514
|
+
if (readSelected) {
|
|
42515
|
+
bytes = readSelected(item);
|
|
42516
|
+
} else {
|
|
42517
|
+
let members2 = archives.get(item.artifact);
|
|
42518
|
+
if (!members2) {
|
|
42519
|
+
members2 = /* @__PURE__ */ new Map();
|
|
42520
|
+
for (const member of readArMembers((0, import_node_fs58.readFileSync)(item.artifact))) {
|
|
42521
|
+
let list2 = members2.get(member.name);
|
|
42522
|
+
if (!list2) members2.set(member.name, list2 = []);
|
|
42523
|
+
list2.push(member.bytes);
|
|
42524
|
+
}
|
|
42525
|
+
archives.set(item.artifact, members2);
|
|
42526
|
+
}
|
|
42527
|
+
const matching2 = members2.get(item.member);
|
|
42528
|
+
if (!matching2 || matching2.length !== 1)
|
|
42529
|
+
throw new Error(
|
|
42530
|
+
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
42531
|
+
);
|
|
42532
|
+
bytes = matching2[0];
|
|
41949
42533
|
}
|
|
41950
|
-
const matching2 = members2.filter((member) => member.name === item.member);
|
|
41951
|
-
if (matching2.length !== 1)
|
|
41952
|
-
throw new Error(
|
|
41953
|
-
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
41954
|
-
);
|
|
41955
|
-
bytes = matching2[0].bytes;
|
|
41956
42534
|
const origin = artifact.memberOrigins?.get(item.member);
|
|
41957
42535
|
if (artifact.memberOrigins && !origin)
|
|
41958
42536
|
throw new Error(
|
|
@@ -42044,7 +42622,7 @@ var init_swift_guest_manifest = __esm({
|
|
|
42044
42622
|
function isSwiftGuestImageManifest(value) {
|
|
42045
42623
|
const uint = (value2, maximum) => typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 && value2 <= maximum;
|
|
42046
42624
|
const text7 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
42047
|
-
const name3 = (value2) => text7(value2) &&
|
|
42625
|
+
const name3 = (value2) => text7(value2) && Buffer.byteLength(value2, "utf8") <= 16;
|
|
42048
42626
|
const version2 = (value2) => isRecord(value2) && uint(value2.major, 65535) && uint(value2.minor, 255) && uint(value2.patch, 255);
|
|
42049
42627
|
if (!isRecord(value) || value.version !== 1 || !text7(value.id) || !text7(value.installName) || value.resourceBundlePath !== void 0 && !isSwiftBundlePath(value.resourceBundlePath) || value.fileType !== "executable" && value.fileType !== "dylib" || !isRecord(value.target) || value.target.triple !== SWIFT_WASM_TRIPLE || value.target.pointerWidth !== 64 || value.target.byteOrder !== "little" || value.target.cpuType !== -1 || value.target.cpuSubtype !== 0 || typeof value.inputsSha256 !== "string" || !/^[a-f0-9]{64}$/.test(value.inputsSha256) || value.uuid !== value.inputsSha256.slice(0, 32) || !isRecord(value.buildVersion) || !uint(value.buildVersion.platform, 4294967295) || !version2(value.buildVersion.minimum) || !version2(value.buildVersion.sdk) || !Array.isArray(value.regions))
|
|
42050
42628
|
return false;
|
|
@@ -42358,27 +42936,25 @@ function planGuestProjectionRegions(images, capacities, spans) {
|
|
|
42358
42936
|
function finalizeGuestProjectionStorage(options2) {
|
|
42359
42937
|
const owner = options2.owners.get(options2.projectionObject);
|
|
42360
42938
|
if (owner === void 0) throw new Error("guest projection object has no image owner");
|
|
42939
|
+
const ranges = [];
|
|
42361
42940
|
const spans = guestLinkedSpans(
|
|
42362
42941
|
options2.map,
|
|
42363
42942
|
options2.linked,
|
|
42364
42943
|
options2.optimized,
|
|
42365
42944
|
options2.owners,
|
|
42366
42945
|
options2.sectionOwners,
|
|
42367
|
-
options2.sdkSpans !== void 0
|
|
42946
|
+
options2.sdkSpans !== void 0,
|
|
42947
|
+
{
|
|
42948
|
+
trackedObject: options2.projectionObject,
|
|
42949
|
+
trackedObjectOwner: owner,
|
|
42950
|
+
trackedLinearSpans: ranges
|
|
42951
|
+
}
|
|
42368
42952
|
);
|
|
42369
42953
|
const images = planGuestProjectionRegions(
|
|
42370
42954
|
options2.reserved.images,
|
|
42371
42955
|
options2.reserved.capacities,
|
|
42372
42956
|
options2.sdkSpans ? [...spans, ...options2.sdkSpans] : spans
|
|
42373
42957
|
);
|
|
42374
|
-
const ranges = guestLinkedSpans(
|
|
42375
|
-
options2.map,
|
|
42376
|
-
options2.linked,
|
|
42377
|
-
options2.optimized,
|
|
42378
|
-
/* @__PURE__ */ new Map([[options2.projectionObject, owner]]),
|
|
42379
|
-
void 0,
|
|
42380
|
-
options2.sdkSpans !== void 0
|
|
42381
|
-
).filter((span) => span.space === "linear-memory");
|
|
42382
42958
|
const result = Buffer.from(options2.optimized);
|
|
42383
42959
|
const data = guestWasmDataSegments(options2.optimized, options2.sdkSpans === void 0);
|
|
42384
42960
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -43446,7 +44022,7 @@ function occurrences(plan, args) {
|
|
|
43446
44022
|
throw new Error("guest plan does not match linker inputs");
|
|
43447
44023
|
return found2;
|
|
43448
44024
|
}
|
|
43449
|
-
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
44025
|
+
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace, archiveCache) {
|
|
43450
44026
|
const rows = whyExtract.trimEnd().split("\n");
|
|
43451
44027
|
if (rows.shift() !== "reference extracted symbol")
|
|
43452
44028
|
throw new Error("invalid wasm-ld extraction report");
|
|
@@ -43461,8 +44037,38 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
43461
44037
|
for (const file of extracted)
|
|
43462
44038
|
if (!traced.has(file))
|
|
43463
44039
|
throw new Error(`extracted guest input is absent from link trace ${file}`);
|
|
44040
|
+
const foundOccurrences = occurrences(plan, args);
|
|
44041
|
+
const archivePaths = /* @__PURE__ */ new Set();
|
|
44042
|
+
for (const { artifact } of foundOccurrences)
|
|
44043
|
+
if (artifact.kind === "archive") archivePaths.add(artifact.path);
|
|
44044
|
+
const tracedMembers = /* @__PURE__ */ new Map();
|
|
44045
|
+
if (archivePaths.size > 0) {
|
|
44046
|
+
const archivePrefixes = [...archivePaths].map(
|
|
44047
|
+
(archivePath) => [archivePath, `${archivePath}(`]
|
|
44048
|
+
);
|
|
44049
|
+
for (const item of traced) {
|
|
44050
|
+
if (!item.endsWith(")")) continue;
|
|
44051
|
+
const open = item.lastIndexOf("(");
|
|
44052
|
+
if (open > 0) {
|
|
44053
|
+
const archivePath = item.slice(0, open);
|
|
44054
|
+
if (archivePaths.has(archivePath)) {
|
|
44055
|
+
let list2 = tracedMembers.get(archivePath);
|
|
44056
|
+
if (!list2) tracedMembers.set(archivePath, list2 = []);
|
|
44057
|
+
list2.push(item.slice(open + 1, -1));
|
|
44058
|
+
continue;
|
|
44059
|
+
}
|
|
44060
|
+
}
|
|
44061
|
+
for (const [archivePath, prefix] of archivePrefixes) {
|
|
44062
|
+
if (item.startsWith(prefix)) {
|
|
44063
|
+
let list2 = tracedMembers.get(archivePath);
|
|
44064
|
+
if (!list2) tracedMembers.set(archivePath, list2 = []);
|
|
44065
|
+
list2.push(item.slice(prefix.length, -1));
|
|
44066
|
+
}
|
|
44067
|
+
}
|
|
44068
|
+
}
|
|
44069
|
+
}
|
|
43464
44070
|
const result = [];
|
|
43465
|
-
for (const { artifact, lazy, whole } of
|
|
44071
|
+
for (const { artifact, lazy, whole } of foundOccurrences) {
|
|
43466
44072
|
if (artifact.kind === "object") {
|
|
43467
44073
|
if (!lazy && !traced.has(artifact.path))
|
|
43468
44074
|
throw new Error(`eager guest input is absent from link trace ${artifact.path}`);
|
|
@@ -43470,15 +44076,21 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
43470
44076
|
result.push({ artifact: artifact.path, member: null });
|
|
43471
44077
|
continue;
|
|
43472
44078
|
}
|
|
43473
|
-
const
|
|
43474
|
-
const
|
|
43475
|
-
|
|
44079
|
+
const names = tracedMembers.get(artifact.path) ?? [];
|
|
44080
|
+
const nameSet = new Set(names);
|
|
44081
|
+
let members2 = archiveCache?.get(artifact.path);
|
|
44082
|
+
if (!members2) {
|
|
44083
|
+
members2 = readArMembers(import_node_fs61.default.readFileSync(artifact.path));
|
|
44084
|
+
archiveCache?.set(artifact.path, members2);
|
|
44085
|
+
}
|
|
44086
|
+
const memberCounts = /* @__PURE__ */ new Map();
|
|
43476
44087
|
for (const member of members2) {
|
|
43477
|
-
|
|
44088
|
+
memberCounts.set(member.name, (memberCounts.get(member.name) ?? 0) + 1);
|
|
44089
|
+
if (whole || nameSet.has(member.name))
|
|
43478
44090
|
result.push({ artifact: artifact.path, member: member.name });
|
|
43479
44091
|
}
|
|
43480
44092
|
for (const name3 of names)
|
|
43481
|
-
if (
|
|
44093
|
+
if (memberCounts.get(name3) !== 1)
|
|
43482
44094
|
throw new Error(
|
|
43483
44095
|
`ambiguous or unsupported archive member ${artifact.path}(${name3})`
|
|
43484
44096
|
);
|
|
@@ -43555,14 +44167,25 @@ function linkGuestImages(options2) {
|
|
|
43555
44167
|
}
|
|
43556
44168
|
const archives = /* @__PURE__ */ new Map();
|
|
43557
44169
|
const memberBytes = /* @__PURE__ */ new Map();
|
|
44170
|
+
const objectBytes = /* @__PURE__ */ new Map();
|
|
43558
44171
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
43559
44172
|
const providerSymbol = "__peach_dlsym_from_image";
|
|
43560
44173
|
const readSelected = (item) => {
|
|
43561
|
-
if (item.member === null)
|
|
44174
|
+
if (item.member === null) {
|
|
44175
|
+
let bytes = objectBytes.get(item.artifact);
|
|
44176
|
+
if (!bytes) {
|
|
44177
|
+
bytes = import_node_fs61.default.readFileSync(item.artifact);
|
|
44178
|
+
objectBytes.set(item.artifact, bytes);
|
|
44179
|
+
}
|
|
44180
|
+
return bytes;
|
|
44181
|
+
}
|
|
43562
44182
|
let byName2 = memberBytes.get(item.artifact);
|
|
43563
44183
|
if (!byName2) {
|
|
43564
|
-
|
|
43565
|
-
|
|
44184
|
+
let members2 = archives.get(item.artifact);
|
|
44185
|
+
if (!members2) {
|
|
44186
|
+
members2 = readArMembers(import_node_fs61.default.readFileSync(item.artifact));
|
|
44187
|
+
archives.set(item.artifact, members2);
|
|
44188
|
+
}
|
|
43566
44189
|
byName2 = /* @__PURE__ */ new Map();
|
|
43567
44190
|
for (const member of members2)
|
|
43568
44191
|
if (!byName2.has(member.name))
|
|
@@ -43586,7 +44209,13 @@ function linkGuestImages(options2) {
|
|
|
43586
44209
|
`--why-extract=${whyPath}`,
|
|
43587
44210
|
`--Map=${mapPath}`
|
|
43588
44211
|
]);
|
|
43589
|
-
return selectedGuestLinkInputs(
|
|
44212
|
+
return selectedGuestLinkInputs(
|
|
44213
|
+
plan,
|
|
44214
|
+
args,
|
|
44215
|
+
import_node_fs61.default.readFileSync(whyPath, "utf8"),
|
|
44216
|
+
trace,
|
|
44217
|
+
archives
|
|
44218
|
+
);
|
|
43590
44219
|
};
|
|
43591
44220
|
const needsProvider = (item) => {
|
|
43592
44221
|
if (!artifacts.get(item.artifact).instrumentDynamicLookups) return false;
|
|
@@ -43626,7 +44255,7 @@ function linkGuestImages(options2) {
|
|
|
43626
44255
|
)
|
|
43627
44256
|
]);
|
|
43628
44257
|
const originalOwnership = identity2(plan);
|
|
43629
|
-
const resolved = options2.resolvePlan(selected, plan);
|
|
44258
|
+
const resolved = options2.resolvePlan(selected, plan, readSelected);
|
|
43630
44259
|
if (identity2(resolved) !== originalOwnership)
|
|
43631
44260
|
throw new Error("resolved guest scopes changed input ownership");
|
|
43632
44261
|
plan = resolved;
|
|
@@ -43680,6 +44309,7 @@ function linkGuestImages(options2) {
|
|
|
43680
44309
|
}
|
|
43681
44310
|
}
|
|
43682
44311
|
let discoveryRegions;
|
|
44312
|
+
let liveSymbols;
|
|
43683
44313
|
if (discoveryProjection && options2.projection) {
|
|
43684
44314
|
const owners = /* @__PURE__ */ new Map([[discoveryProjection, options2.projection.image]]);
|
|
43685
44315
|
for (const item of selected)
|
|
@@ -43688,10 +44318,15 @@ function linkGuestImages(options2) {
|
|
|
43688
44318
|
selectedGuestInputImage(artifacts.get(item.artifact), item.member)
|
|
43689
44319
|
);
|
|
43690
44320
|
const wasm = import_node_fs61.default.readFileSync(discovery);
|
|
44321
|
+
liveSymbols = /* @__PURE__ */ new Set();
|
|
43691
44322
|
discoveryRegions = guestProjectionRegionCounts(
|
|
43692
44323
|
plan.images.length,
|
|
43693
|
-
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners
|
|
44324
|
+
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners, void 0, false, {
|
|
44325
|
+
collectSymbols: liveSymbols
|
|
44326
|
+
})
|
|
43694
44327
|
);
|
|
44328
|
+
} else {
|
|
44329
|
+
liveSymbols = linkedMapSymbols(guestLinkLines(mapPath));
|
|
43695
44330
|
}
|
|
43696
44331
|
const ledger = createGuestImageLedger({
|
|
43697
44332
|
images: plan.images.map((image) => ({
|
|
@@ -43700,7 +44335,7 @@ function linkGuestImages(options2) {
|
|
|
43700
44335
|
})),
|
|
43701
44336
|
callers: plan.callers,
|
|
43702
44337
|
symbols: plan.symbols,
|
|
43703
|
-
liveSymbols
|
|
44338
|
+
liveSymbols,
|
|
43704
44339
|
commandLineSymbols: commandLineSymbols(args),
|
|
43705
44340
|
directBindings: plan.directBindings,
|
|
43706
44341
|
registerAppTables: sdkCallers !== void 0,
|
|
@@ -43832,7 +44467,8 @@ function linkGuestImages(options2) {
|
|
|
43832
44467
|
const selectedInputs = selectedGuestManifestInputs(
|
|
43833
44468
|
plan,
|
|
43834
44469
|
selected,
|
|
43835
|
-
projection.identities
|
|
44470
|
+
projection.identities,
|
|
44471
|
+
readSelected
|
|
43836
44472
|
);
|
|
43837
44473
|
const images = projection.images.map(
|
|
43838
44474
|
(image) => createGuestImageManifest({
|
|
@@ -43842,6 +44478,9 @@ function linkGuestImages(options2) {
|
|
|
43842
44478
|
regions: []
|
|
43843
44479
|
})
|
|
43844
44480
|
);
|
|
44481
|
+
objectBytes.clear();
|
|
44482
|
+
memberBytes.clear();
|
|
44483
|
+
archives.clear();
|
|
43845
44484
|
if (!discoveryRegions) throw new Error("guest projection layout object missing");
|
|
43846
44485
|
const regionsBefore = discoveryRegions;
|
|
43847
44486
|
const ledgerPieces = guestProjectionRegionCapacity([import_node_fs61.default.readFileSync(ledgerObject)], 0);
|
|
@@ -43935,10 +44574,47 @@ ${changed2.join("\n")}`
|
|
|
43935
44574
|
}
|
|
43936
44575
|
function linkedMapSymbols(lines) {
|
|
43937
44576
|
const names = /* @__PURE__ */ new Set();
|
|
43938
|
-
const symbol2 = /^ +\S+ +[0-9a-f]+ +[0-9a-f]+ {9,}([^\s/<]\S*)/;
|
|
43939
44577
|
for (const line of lines) {
|
|
43940
|
-
const
|
|
43941
|
-
if (
|
|
44578
|
+
const length = line.length;
|
|
44579
|
+
if (length < 15 || line.charCodeAt(0) !== 32) continue;
|
|
44580
|
+
let pos = 1;
|
|
44581
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
44582
|
+
const c1 = pos;
|
|
44583
|
+
while (pos < length) {
|
|
44584
|
+
const ch = line.charCodeAt(pos);
|
|
44585
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
44586
|
+
pos++;
|
|
44587
|
+
}
|
|
44588
|
+
if (pos === c1 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
44589
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
44590
|
+
const c2 = pos;
|
|
44591
|
+
while (pos < length) {
|
|
44592
|
+
const ch = line.charCodeAt(pos);
|
|
44593
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
44594
|
+
pos++;
|
|
44595
|
+
}
|
|
44596
|
+
if (pos === c2 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
44597
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
44598
|
+
const c3 = pos;
|
|
44599
|
+
while (pos < length) {
|
|
44600
|
+
const ch = line.charCodeAt(pos);
|
|
44601
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
44602
|
+
pos++;
|
|
44603
|
+
}
|
|
44604
|
+
if (pos === c3 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
44605
|
+
const sStart = pos;
|
|
44606
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
44607
|
+
if (pos - sStart < 9 || pos >= length) continue;
|
|
44608
|
+
const first = line.charCodeAt(pos);
|
|
44609
|
+
if (first === 47 || first === 60 || first === 32 || first >= 9 && first <= 13)
|
|
44610
|
+
continue;
|
|
44611
|
+
let end = pos + 1;
|
|
44612
|
+
while (end < length) {
|
|
44613
|
+
const ch = line.charCodeAt(end);
|
|
44614
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
44615
|
+
end++;
|
|
44616
|
+
}
|
|
44617
|
+
names.add(line.slice(pos, end));
|
|
43942
44618
|
}
|
|
43943
44619
|
return names;
|
|
43944
44620
|
}
|
|
@@ -44037,7 +44713,7 @@ function discoverGuestLinkInputs(options2) {
|
|
|
44037
44713
|
import_node_fs61.default.mkdirSync(options2.directory, { recursive: true });
|
|
44038
44714
|
const why = import_node_path61.default.join(options2.directory, "preselection-why.txt");
|
|
44039
44715
|
const response = import_node_path61.default.join(options2.directory, "preselection.rsp");
|
|
44040
|
-
const output = import_node_path61.default.join(options2.directory, "preselection.wasm");
|
|
44716
|
+
const output = process.platform !== "win32" ? "/dev/null" : import_node_path61.default.join(options2.directory, "preselection.wasm");
|
|
44041
44717
|
const flags = [
|
|
44042
44718
|
...withOutput(args, output, true),
|
|
44043
44719
|
...options2.objects,
|
|
@@ -44135,7 +44811,7 @@ function prepareGuestRuntimeInputs(options2) {
|
|
|
44135
44811
|
});
|
|
44136
44812
|
return { args, selected, originalSelection, archives, sdkProducts, archiveArtifacts };
|
|
44137
44813
|
}
|
|
44138
|
-
function selectedGuestSymbolInputs(plan, selected) {
|
|
44814
|
+
function selectedGuestSymbolInputs(plan, selected, readSelected) {
|
|
44139
44815
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
44140
44816
|
const archives = /* @__PURE__ */ new Map();
|
|
44141
44817
|
const symbols = /* @__PURE__ */ new Set();
|
|
@@ -44151,22 +44827,27 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
44151
44827
|
if (!artifact) throw new Error(`selected symbol input has no owner ${item.artifact}`);
|
|
44152
44828
|
let bytes;
|
|
44153
44829
|
let name3 = item.artifact;
|
|
44154
|
-
if (item.member === null)
|
|
44155
|
-
|
|
44156
|
-
|
|
44157
|
-
if (
|
|
44158
|
-
|
|
44159
|
-
|
|
44160
|
-
|
|
44161
|
-
)
|
|
44162
|
-
|
|
44830
|
+
if (item.member === null) {
|
|
44831
|
+
bytes = readSelected ? readSelected(item) : import_node_fs61.default.readFileSync(item.artifact);
|
|
44832
|
+
} else {
|
|
44833
|
+
if (readSelected) {
|
|
44834
|
+
bytes = readSelected(item);
|
|
44835
|
+
} else {
|
|
44836
|
+
let members2 = archives.get(item.artifact);
|
|
44837
|
+
if (!members2) {
|
|
44838
|
+
members2 = Map.groupBy(
|
|
44839
|
+
readArMembers(import_node_fs61.default.readFileSync(item.artifact)),
|
|
44840
|
+
(member) => member.name
|
|
44841
|
+
);
|
|
44842
|
+
archives.set(item.artifact, members2);
|
|
44843
|
+
}
|
|
44844
|
+
const matching2 = members2.get(item.member) ?? [];
|
|
44845
|
+
if (matching2.length !== 1)
|
|
44846
|
+
throw new Error(
|
|
44847
|
+
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
44848
|
+
);
|
|
44849
|
+
bytes = matching2[0].bytes;
|
|
44163
44850
|
}
|
|
44164
|
-
const matching2 = members2.get(item.member) ?? [];
|
|
44165
|
-
if (matching2.length !== 1)
|
|
44166
|
-
throw new Error(
|
|
44167
|
-
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
44168
|
-
);
|
|
44169
|
-
bytes = matching2[0].bytes;
|
|
44170
44851
|
name3 += `(${item.member})`;
|
|
44171
44852
|
}
|
|
44172
44853
|
if (owners.has(name3)) throw new Error(`duplicate selected symbol input ${name3}`);
|
|
@@ -44179,9 +44860,9 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
44179
44860
|
for (const symbol2 of names.tags) tags.add(symbol2);
|
|
44180
44861
|
for (const symbol2 of names.defined) {
|
|
44181
44862
|
definitions.add(symbol2);
|
|
44182
|
-
|
|
44863
|
+
let objects = definitionObjects.get(symbol2);
|
|
44864
|
+
if (!objects) definitionObjects.set(symbol2, objects = /* @__PURE__ */ new Set());
|
|
44183
44865
|
objects.add(name3);
|
|
44184
|
-
definitionObjects.set(symbol2, objects);
|
|
44185
44866
|
}
|
|
44186
44867
|
}
|
|
44187
44868
|
return {
|
|
@@ -44202,7 +44883,7 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
44202
44883
|
if (!symbols.length) return { bindings: [], directBindings: [] };
|
|
44203
44884
|
import_node_fs61.default.mkdirSync(options2.directory, { recursive: true });
|
|
44204
44885
|
const response = import_node_path61.default.join(options2.directory, "scope-trace.rsp");
|
|
44205
|
-
const output = import_node_path61.default.join(options2.directory, "scope-trace.wasm");
|
|
44886
|
+
const output = process.platform !== "win32" ? "/dev/null" : import_node_path61.default.join(options2.directory, "scope-trace.wasm");
|
|
44206
44887
|
const args = [
|
|
44207
44888
|
...withOutput(normalizedGuestLinkArgs(options2.args), output, true),
|
|
44208
44889
|
...options2.objects,
|
|
@@ -44220,55 +44901,76 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
44220
44901
|
import_node_fs61.default.closeSync(traceOutput);
|
|
44221
44902
|
}
|
|
44222
44903
|
const records = /* @__PURE__ */ new Map();
|
|
44223
|
-
const
|
|
44224
|
-
const
|
|
44225
|
-
|
|
44226
|
-
|
|
44227
|
-
|
|
44228
|
-
|
|
44229
|
-
const
|
|
44230
|
-
|
|
44231
|
-
|
|
44232
|
-
|
|
44233
|
-
|
|
44904
|
+
for (const line of guestLinkLines(tracePath)) {
|
|
44905
|
+
const refSep = line.lastIndexOf(": reference to ");
|
|
44906
|
+
const defSep = line.lastIndexOf(": definition of ");
|
|
44907
|
+
if (refSep < 0 && defSep < 0) continue;
|
|
44908
|
+
const isRef = refSep > defSep;
|
|
44909
|
+
const sep3 = isRef ? refSep : defSep;
|
|
44910
|
+
const symbol2 = line.slice(sep3 + (isRef ? 15 : 16));
|
|
44911
|
+
if (!requested.has(symbol2) || options2.hostImports.has(symbol2)) continue;
|
|
44912
|
+
let record6 = records.get(symbol2);
|
|
44913
|
+
if (!record6) {
|
|
44914
|
+
record6 = {
|
|
44915
|
+
references: /* @__PURE__ */ new Map(),
|
|
44916
|
+
providers: /* @__PURE__ */ new Map(),
|
|
44917
|
+
physicalModule: false
|
|
44918
|
+
};
|
|
44919
|
+
records.set(symbol2, record6);
|
|
44920
|
+
}
|
|
44921
|
+
const object8 = line.slice(0, sep3);
|
|
44234
44922
|
if (object8 === "<internal>") {
|
|
44235
|
-
if (
|
|
44923
|
+
if (!isRef) record6.physicalModule = true;
|
|
44236
44924
|
} else {
|
|
44237
44925
|
const image = options2.owners.get(object8);
|
|
44238
44926
|
if (image === void 0)
|
|
44239
44927
|
throw new Error(`traced guest object has no owner ${object8}`);
|
|
44240
|
-
(
|
|
44241
|
-
object8,
|
|
44242
|
-
image
|
|
44243
|
-
);
|
|
44928
|
+
(isRef ? record6.references : record6.providers).set(object8, image);
|
|
44244
44929
|
}
|
|
44245
|
-
|
|
44246
|
-
};
|
|
44247
|
-
for (const line of guestLinkLines(tracePath)) consume(line);
|
|
44930
|
+
}
|
|
44248
44931
|
const callers = new Map(options2.callers.map((caller) => [caller.image, caller.next]));
|
|
44932
|
+
const callerSets = new Map(
|
|
44933
|
+
options2.callers.map((caller) => [caller.image, new Set(caller.next)])
|
|
44934
|
+
);
|
|
44935
|
+
const rootScope = callerSets.get(0);
|
|
44249
44936
|
const result = [];
|
|
44250
44937
|
const directBindings = [];
|
|
44251
44938
|
for (const symbol2 of symbols) {
|
|
44252
44939
|
const record6 = records.get(symbol2);
|
|
44253
44940
|
if (!record6 || !record6.references.size) continue;
|
|
44254
44941
|
if (!record6.providers.size && options2.hostImports.has(symbol2)) continue;
|
|
44255
|
-
const startupReferences = [
|
|
44256
|
-
|
|
44257
|
-
|
|
44258
|
-
const
|
|
44259
|
-
|
|
44260
|
-
|
|
44942
|
+
const startupReferences = [];
|
|
44943
|
+
const otherReferences = [];
|
|
44944
|
+
let allWeakRefs = true;
|
|
44945
|
+
for (const [object8, caller] of record6.references) {
|
|
44946
|
+
const isWeakRef = options2.weakReferences.get(object8)?.has(symbol2) === true;
|
|
44947
|
+
if (!isWeakRef) allWeakRefs = false;
|
|
44948
|
+
if (isWeakRef && options2.startupObjects.has(object8)) {
|
|
44949
|
+
startupReferences.push([object8, caller]);
|
|
44950
|
+
} else {
|
|
44951
|
+
otherReferences.push([object8, caller]);
|
|
44952
|
+
}
|
|
44953
|
+
}
|
|
44261
44954
|
for (const [, caller] of startupReferences)
|
|
44262
44955
|
if (!callers.has(caller))
|
|
44263
44956
|
throw new Error(`guest image has no caller scope ${caller}`);
|
|
44264
44957
|
if (startupReferences.length && !record6.physicalModule) {
|
|
44265
|
-
const
|
|
44266
|
-
|
|
44958
|
+
const candidates2 = options2.definitionObjects.get(symbol2);
|
|
44959
|
+
const candidateSize = candidates2?.size ?? 0;
|
|
44960
|
+
if (candidateSize > 1 || record6.providers.size > 1)
|
|
44267
44961
|
throw new Error(`ambiguous startup provider ${symbol2}`);
|
|
44268
|
-
|
|
44269
|
-
|
|
44962
|
+
let unproven = candidateSize !== record6.providers.size;
|
|
44963
|
+
if (!unproven && candidates2) {
|
|
44964
|
+
for (const object8 of record6.providers.keys()) {
|
|
44965
|
+
if (!candidates2.has(object8)) {
|
|
44966
|
+
unproven = true;
|
|
44967
|
+
break;
|
|
44968
|
+
}
|
|
44969
|
+
}
|
|
44970
|
+
}
|
|
44971
|
+
if (unproven) throw new Error(`unproven startup provider ${symbol2}`);
|
|
44270
44972
|
if (record6.providers.size === 1) {
|
|
44271
|
-
const [providerObject, providerImage] =
|
|
44973
|
+
const [providerObject, providerImage] = record6.providers.entries().next().value;
|
|
44272
44974
|
if (options2.weakDefinitions.get(providerObject)?.has(symbol2))
|
|
44273
44975
|
throw new Error(`weak startup provider ${symbol2}`);
|
|
44274
44976
|
for (const [object8] of startupReferences)
|
|
@@ -44276,28 +44978,34 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
44276
44978
|
}
|
|
44277
44979
|
if (!otherReferences.length) continue;
|
|
44278
44980
|
}
|
|
44279
|
-
if (!record6.providers.size && !record6.physicalModule &&
|
|
44280
|
-
(object8) => options2.weakReferences.get(object8)?.has(symbol2)
|
|
44281
|
-
))
|
|
44282
|
-
continue;
|
|
44981
|
+
if (!record6.providers.size && !record6.physicalModule && allWeakRefs) continue;
|
|
44283
44982
|
const providerImages = new Set(record6.providers.values());
|
|
44284
|
-
const
|
|
44285
|
-
|
|
44983
|
+
const candidates = options2.definitionObjects.get(symbol2);
|
|
44984
|
+
const copyImages = /* @__PURE__ */ new Set();
|
|
44985
|
+
const strongImages = /* @__PURE__ */ new Set();
|
|
44986
|
+
let weakDefinerImages;
|
|
44987
|
+
if (candidates) {
|
|
44988
|
+
for (const object8 of candidates) {
|
|
44286
44989
|
const image = options2.owners.get(object8);
|
|
44287
|
-
|
|
44990
|
+
if (image === void 0) continue;
|
|
44991
|
+
copyImages.add(image);
|
|
44992
|
+
if (options2.weakDefinitions.get(object8)?.has(symbol2)) {
|
|
44993
|
+
;
|
|
44994
|
+
(weakDefinerImages ??= /* @__PURE__ */ new Set()).add(image);
|
|
44995
|
+
} else {
|
|
44996
|
+
strongImages.add(image);
|
|
44997
|
+
}
|
|
44288
44998
|
}
|
|
44289
|
-
|
|
44290
|
-
const copyImages = new Set(copies.map((copy) => copy.image));
|
|
44291
|
-
const strongImages = new Set(
|
|
44292
|
-
copies.filter((copy) => !copy.weak).map((copy) => copy.image)
|
|
44293
|
-
);
|
|
44999
|
+
}
|
|
44294
45000
|
const interposed = !record6.physicalModule && copyImages.size > 1;
|
|
44295
45001
|
const providerCount = interposed ? 1 : providerImages.size + Number(record6.physicalModule);
|
|
44296
45002
|
if (!providerCount) continue;
|
|
44297
45003
|
if (providerCount !== 1)
|
|
44298
45004
|
throw new Error(`guest symbol has ambiguous provider ${symbol2}`);
|
|
44299
|
-
const scopedReferences = record6.physicalModule ?
|
|
44300
|
-
const
|
|
45005
|
+
const scopedReferences = record6.physicalModule ? record6.references : otherReferences;
|
|
45006
|
+
const firstProviderImage = providerImages.values().next().value;
|
|
45007
|
+
const uniqueProvider = strongImages.size > 1 ? void 0 : strongImages.values().next().value ?? firstProviderImage;
|
|
45008
|
+
let interposedByCaller;
|
|
44301
45009
|
for (const [object8, caller] of scopedReferences) {
|
|
44302
45010
|
const scope2 = callers.get(caller);
|
|
44303
45011
|
if (!scope2) throw new Error(`guest image has no caller scope ${caller}`);
|
|
@@ -44305,18 +45013,35 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
44305
45013
|
result.push({ symbol: symbol2, caller, provider: { kind: "physical-module" } });
|
|
44306
45014
|
continue;
|
|
44307
45015
|
}
|
|
44308
|
-
|
|
45016
|
+
let provider;
|
|
45017
|
+
if (interposed) {
|
|
45018
|
+
if (interposedByCaller?.has(caller)) {
|
|
45019
|
+
provider = interposedByCaller.get(caller);
|
|
45020
|
+
} else {
|
|
45021
|
+
if (copyImages.has(caller)) {
|
|
45022
|
+
provider = caller;
|
|
45023
|
+
} else {
|
|
45024
|
+
for (const image of scope2) {
|
|
45025
|
+
if (copyImages.has(image)) {
|
|
45026
|
+
provider = image;
|
|
45027
|
+
break;
|
|
45028
|
+
}
|
|
45029
|
+
}
|
|
45030
|
+
if (provider === void 0) provider = uniqueProvider;
|
|
45031
|
+
}
|
|
45032
|
+
;
|
|
45033
|
+
(interposedByCaller ??= /* @__PURE__ */ new Map()).set(caller, provider);
|
|
45034
|
+
}
|
|
45035
|
+
} else {
|
|
45036
|
+
provider = firstProviderImage;
|
|
45037
|
+
}
|
|
44309
45038
|
if (provider === void 0) {
|
|
44310
45039
|
if (options2.weakReferences.get(object8)?.has(symbol2)) continue;
|
|
44311
45040
|
throw new Error(`guest scope ${caller} omits every provider of ${symbol2}`);
|
|
44312
45041
|
}
|
|
44313
45042
|
if (caller === provider) continue;
|
|
44314
|
-
if (
|
|
44315
|
-
|
|
44316
|
-
))
|
|
44317
|
-
continue;
|
|
44318
|
-
if (!scope2.includes(provider)) {
|
|
44319
|
-
const candidates = options2.definitionObjects.get(symbol2) ?? /* @__PURE__ */ new Set();
|
|
45043
|
+
if (weakDefinerImages?.has(caller)) continue;
|
|
45044
|
+
if (!callerSets.get(caller).has(provider)) {
|
|
44320
45045
|
const traced = [...record6.providers.keys()];
|
|
44321
45046
|
const strongTraced = traced.filter(
|
|
44322
45047
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
@@ -44324,16 +45049,17 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
44324
45049
|
const providers = strongTraced.length === 1 ? strongTraced : traced;
|
|
44325
45050
|
if (options2.weakReferences.get(object8)?.has(symbol2) && !providers.some((provider2) => options2.systemProviders.has(provider2)))
|
|
44326
45051
|
continue;
|
|
44327
|
-
const
|
|
45052
|
+
const candidateSet = candidates ?? /* @__PURE__ */ new Set();
|
|
45053
|
+
const equivalentCopies = providers.length === 1 && candidateSet.has(providers[0]) && [...candidateSet].every(
|
|
44328
45054
|
(definer) => options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
44329
45055
|
);
|
|
44330
|
-
const strongCandidates = [...
|
|
45056
|
+
const strongCandidates = [...candidateSet].filter(
|
|
44331
45057
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
44332
45058
|
);
|
|
44333
|
-
const soleCandidate =
|
|
44334
|
-
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !
|
|
45059
|
+
const soleCandidate = candidateSet.size === 1 || strongCandidates.length === 1 && strongCandidates[0] === providers[0];
|
|
45060
|
+
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !candidateSet.has(providers[0]) || !(options2.systemProviders.has(providers[0]) || // a strong undefined reference binds through the process global
|
|
44335
45061
|
// scope, the root image and its dependency closure, as in elf.
|
|
44336
|
-
provider === 0 ||
|
|
45062
|
+
provider === 0 || rootScope?.has(provider) || !options2.weakReferences.get(object8)?.has(symbol2) && options2.frameworkProviders.get(object8)?.has(providers[0]))))
|
|
44337
45063
|
throw new Error(
|
|
44338
45064
|
`guest scope ${caller} omits traced provider ${provider} for ${symbol2}`
|
|
44339
45065
|
);
|
|
@@ -50467,9 +51193,9 @@ async function compileGuestLink(options2) {
|
|
|
50467
51193
|
}
|
|
50468
51194
|
};
|
|
50469
51195
|
},
|
|
50470
|
-
resolvePlan: (selected, plan) => {
|
|
51196
|
+
resolvePlan: (selected, plan, readSelected) => {
|
|
50471
51197
|
if (!prepared) throw new Error("guest runtime selection is unavailable");
|
|
50472
|
-
const scope2 = selectedGuestSymbolInputs(plan, selected);
|
|
51198
|
+
const scope2 = selectedGuestSymbolInputs(plan, selected, readSelected);
|
|
50473
51199
|
const owners = new Map(scope2.owners);
|
|
50474
51200
|
owners.set(import_node_path72.default.join(directory2, "projection-discovery.o"), 0);
|
|
50475
51201
|
const providersByImage = Map.groupBy(scope2.owners, ([, image]) => image);
|
|
@@ -58145,7 +58871,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
58145
58871
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
58146
58872
|
MULTI_MANIFEST_VERSION = 76;
|
|
58147
58873
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
58148
|
-
compilerSourceDigest = true ? "
|
|
58874
|
+
compilerSourceDigest = true ? "7b91fa4405159335b5484c82700e001e4c27abf15621b724ea8af4edea693f66" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
|
|
58149
58875
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
58150
58876
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
58151
58877
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
@@ -113575,7 +114301,7 @@ function eventBindings(name3, source) {
|
|
|
113575
114301
|
});
|
|
113576
114302
|
continue;
|
|
113577
114303
|
}
|
|
113578
|
-
const call = /emitter->(\w+)\(
|
|
114304
|
+
const call = /emitter->(\w+)\(\s*\{([^}]*)\}\s*\)/.exec(body);
|
|
113579
114305
|
if (!call) throw new Error(`${name3}: unmapped event block ${property}`);
|
|
113580
114306
|
const fields = [...call[2].matchAll(/\.(\w+) = ([^,]+)/g)].map(
|
|
113581
114307
|
([, field, expression]) => {
|
|
@@ -113617,18 +114343,20 @@ function configuration(name3, source) {
|
|
|
113617
114343
|
}
|
|
113618
114344
|
function arrayBindings(name3, body) {
|
|
113619
114345
|
const bindings = /* @__PURE__ */ new Map();
|
|
113620
|
-
for (const [, prop, element] of body.matchAll(
|
|
113621
|
-
/for \(const auto &
|
|
114346
|
+
for (const [, item, prop, variable, element] of body.matchAll(
|
|
114347
|
+
/for \(const auto &(\w+) : next\.(\w+)\) \[(\w+) addObject:(.*?)\];/g
|
|
113622
114348
|
)) {
|
|
113623
|
-
if (element ===
|
|
113624
|
-
bindings.set(prop, []);
|
|
114349
|
+
if (element === `RCTNSStringFromString(${item})`) {
|
|
114350
|
+
bindings.set(variable, { prop, fields: [] });
|
|
113625
114351
|
continue;
|
|
113626
114352
|
}
|
|
113627
114353
|
const fields = [
|
|
113628
|
-
...element.matchAll(
|
|
114354
|
+
...element.matchAll(
|
|
114355
|
+
new RegExp(`@"(\\w+)" ?: (RCTNSStringFromString|@)\\(${item}\\.\\w+\\)`, "g")
|
|
114356
|
+
)
|
|
113629
114357
|
].map(([, name4, kind]) => ({ name: name4, defaultValue: kind === "@" ? 0 : "" }));
|
|
113630
114358
|
if (!fields.length) throw new Error(`${name3}: unmapped array ${prop}`);
|
|
113631
|
-
bindings.set(prop, fields);
|
|
114359
|
+
bindings.set(variable, { prop, fields });
|
|
113632
114360
|
}
|
|
113633
114361
|
return bindings;
|
|
113634
114362
|
}
|
|
@@ -113680,38 +114408,41 @@ function swiftGuestControls(one, names, linkedGroups) {
|
|
|
113680
114408
|
}
|
|
113681
114409
|
const withLabel = /^(\w+)With([A-Z])(\w*)$/.exec(first);
|
|
113682
114410
|
const args = selector.map(({ label, expression }, index) => {
|
|
113683
|
-
const
|
|
114411
|
+
const array9 = arrays.get(expression);
|
|
113684
114412
|
let value;
|
|
113685
114413
|
if (expression === "OneNativeStyleDictionary(next.swiftStyle)") value = "style";
|
|
113686
114414
|
else if (expression === "boundedHeight")
|
|
113687
114415
|
value = 'spec["boundedHeight"] as? Bool ?? false';
|
|
113688
114416
|
else if (/^@"[^"]*"$/.test(expression)) value = expression.slice(1);
|
|
113689
|
-
else if (fields
|
|
113690
|
-
const entries3 = fields.map(
|
|
113691
|
-
({ name: name4, defaultValue: defaultValue2 }) => `"${name4}": row["${name4}"]
|
|
114417
|
+
else if (array9?.fields.length) {
|
|
114418
|
+
const entries3 = array9.fields.map(
|
|
114419
|
+
({ name: name4, defaultValue: defaultValue2 }) => `"${name4}": row["${name4}"] as? ${typeof defaultValue2 === "number" ? "Double" : "String"} ?? ${JSON.stringify(defaultValue2)}`
|
|
113692
114420
|
).join(", ");
|
|
113693
|
-
value = `(spec["${
|
|
113694
|
-
} else if (
|
|
114421
|
+
value = `(spec["${array9.prop}"] as? [Spec] ?? []).map { row in [${entries3}] }`;
|
|
114422
|
+
} else if (array9) value = `spec["${array9.prop}"] as? [String] ?? []`;
|
|
113695
114423
|
else {
|
|
113696
|
-
const prop = /\bnext\.(\w+)/.exec(expression)?.[1];
|
|
114424
|
+
const prop = /\bnext\.(\w+)/.exec(expression)?.[1] ?? "";
|
|
113697
114425
|
const types2 = {
|
|
113698
|
-
string:
|
|
113699
|
-
boolean: "Bool
|
|
113700
|
-
Double: "Double
|
|
113701
|
-
Int32: "Int
|
|
114426
|
+
string: ["String", ""],
|
|
114427
|
+
boolean: ["Bool", false],
|
|
114428
|
+
Double: ["Double", 0],
|
|
114429
|
+
Int32: ["Int", 0]
|
|
113702
114430
|
};
|
|
113703
|
-
const
|
|
114431
|
+
const field = props[prop];
|
|
114432
|
+
const type = field?.type;
|
|
113704
114433
|
if (type === "ColorValue") value = `spec["${prop}"].flatMap(oneControlColor)`;
|
|
113705
|
-
else if (type && types2[type])
|
|
113706
|
-
|
|
114434
|
+
else if (type && types2[type]) {
|
|
114435
|
+
const [swiftType, implicitDefault] = types2[type];
|
|
114436
|
+
value = `spec["${prop}"] as? ${swiftType} ?? ${JSON.stringify(field.default ?? implicitDefault)}`;
|
|
114437
|
+
} else throw new Error(`${name3}: unmapped guest argument ${expression}`);
|
|
113707
114438
|
}
|
|
113708
114439
|
const argLabel = index ? label : withLabel ? withLabel[2].toLowerCase() + withLabel[3] : "";
|
|
113709
114440
|
return argLabel ? argLabel + ": " + value : value;
|
|
113710
114441
|
});
|
|
113711
114442
|
const call = `view.${withLabel?.[1] ?? first}(${args.join(", ")})`;
|
|
113712
|
-
const array8 = selector[0].expression;
|
|
114443
|
+
const array8 = arrays.get(selector[0].expression)?.prop;
|
|
113713
114444
|
lines.push(
|
|
113714
|
-
|
|
114445
|
+
array8 ? ` if previous == nil || (spec["${array8}"] as? NSArray) != (previous?["${array8}"] as? NSArray) { ${call} }` : ` ${call}`
|
|
113715
114446
|
);
|
|
113716
114447
|
}
|
|
113717
114448
|
for (const { property, parameters, fields, event, sync } of eventBindings(
|
|
@@ -118850,7 +119581,7 @@ var init_nitro_superset = __esm({
|
|
|
118850
119581
|
init_nitroContract();
|
|
118851
119582
|
init_swift_standin_digest();
|
|
118852
119583
|
NITRO_SUPERSET_ENTRY_NAME = "superset";
|
|
118853
|
-
NITRO_COMPILER_DIGEST = true ? "
|
|
119584
|
+
NITRO_COMPILER_DIGEST = true ? "ffe0ab1580ebcb5a184764bfb3b3650342c8644057a95423913e7078c208f318" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
|
|
118854
119585
|
nitroSupersetLock = parseLock(nitro_superset_lock_default);
|
|
118855
119586
|
nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
|
|
118856
119587
|
published3 = /* @__PURE__ */ new Map();
|