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;
|
|
@@ -26243,13 +26243,13 @@ var init_swift_standin_digest = __esm({
|
|
|
26243
26243
|
STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
|
|
26244
26244
|
SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
26245
26245
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
|
|
26246
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
26246
|
+
STANDIN_SOURCE_DIGEST = true ? "a3bcdfe9c9957355a59c2c26155470c89a2abb30907aeeaaf1de8463aa74fc8c" : standinSourceDigest();
|
|
26247
26247
|
}
|
|
26248
26248
|
});
|
|
26249
26249
|
|
|
26250
26250
|
// src/expo-native-compiler-digest.ts
|
|
26251
26251
|
function expoNativeCompilerDigestValue() {
|
|
26252
|
-
return true ? "
|
|
26252
|
+
return true ? "a8b60651de79588c6c5143dd2545ccd8e3b858acd992f46b35ba3de883118ac5" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
26253
26253
|
}
|
|
26254
26254
|
var import_node_crypto17;
|
|
26255
26255
|
var init_expo_native_compiler_digest = __esm({
|
|
@@ -31115,24 +31115,56 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
31115
31115
|
const code = sections.get(10);
|
|
31116
31116
|
if (code) {
|
|
31117
31117
|
let pos = code[0];
|
|
31118
|
-
|
|
31119
|
-
|
|
31118
|
+
const codeStart = code[0];
|
|
31119
|
+
const codeEnd = code[1];
|
|
31120
|
+
let count = 0;
|
|
31121
|
+
{
|
|
31122
|
+
let shift = 0;
|
|
31123
|
+
for (; ; ) {
|
|
31124
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
31125
|
+
const byte = bytes[pos++];
|
|
31126
|
+
count += (byte & 127) * 2 ** shift;
|
|
31127
|
+
if (!(byte & 128)) break;
|
|
31128
|
+
shift += 7;
|
|
31129
|
+
}
|
|
31130
|
+
}
|
|
31120
31131
|
for (let i = 0; i < count; i++) {
|
|
31121
31132
|
const prefix = pos;
|
|
31122
|
-
let size2;
|
|
31123
|
-
|
|
31124
|
-
|
|
31133
|
+
let size2 = 0;
|
|
31134
|
+
const b0 = bytes[pos++];
|
|
31135
|
+
if (b0 < 128) {
|
|
31136
|
+
size2 = b0;
|
|
31137
|
+
} else {
|
|
31138
|
+
size2 = b0 & 127;
|
|
31139
|
+
let shift = 7;
|
|
31140
|
+
for (; ; ) {
|
|
31141
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
31142
|
+
const byte = bytes[pos++];
|
|
31143
|
+
size2 += (byte & 127) * 2 ** shift;
|
|
31144
|
+
if (!(byte & 128)) break;
|
|
31145
|
+
shift += 7;
|
|
31146
|
+
}
|
|
31147
|
+
}
|
|
31148
|
+
functionsByCodeOffset.set(prefix - codeStart, imports2 + i);
|
|
31125
31149
|
if (imports2 + i === startFunction) startup = bytes.subarray(pos, pos + size2);
|
|
31126
31150
|
pos += size2;
|
|
31127
|
-
if (pos >
|
|
31151
|
+
if (pos > codeEnd) throw new Error("invalid wasm code");
|
|
31128
31152
|
}
|
|
31129
|
-
if (pos !==
|
|
31153
|
+
if (pos !== codeEnd) throw new Error("invalid wasm code section");
|
|
31130
31154
|
}
|
|
31131
31155
|
const functionsByTableSlot = /* @__PURE__ */ new Map();
|
|
31132
31156
|
const elements = sections.get(9);
|
|
31133
31157
|
if (elements) {
|
|
31134
31158
|
let pos = elements[0];
|
|
31159
|
+
const elemEnd = elements[1];
|
|
31135
31160
|
const read = () => {
|
|
31161
|
+
if (pos < elemEnd) {
|
|
31162
|
+
const b0 = bytes[pos];
|
|
31163
|
+
if (b0 < 128) {
|
|
31164
|
+
pos++;
|
|
31165
|
+
return b0;
|
|
31166
|
+
}
|
|
31167
|
+
}
|
|
31136
31168
|
const [value, next] = number(bytes, pos);
|
|
31137
31169
|
pos = next;
|
|
31138
31170
|
return value;
|
|
@@ -31162,7 +31194,7 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
31162
31194
|
functionsByTableSlot.set(slot, read());
|
|
31163
31195
|
}
|
|
31164
31196
|
}
|
|
31165
|
-
if (pos !==
|
|
31197
|
+
if (pos !== elemEnd) throw new Error("invalid wasm element section");
|
|
31166
31198
|
}
|
|
31167
31199
|
const data = [];
|
|
31168
31200
|
const passive = /* @__PURE__ */ new Map();
|
|
@@ -31227,36 +31259,141 @@ function guestWasmDataSegments(bytes, requireExports = true) {
|
|
|
31227
31259
|
length: segment2.bytes.length
|
|
31228
31260
|
}));
|
|
31229
31261
|
}
|
|
31230
|
-
function
|
|
31262
|
+
function isMapSpace(code) {
|
|
31263
|
+
return code === 32 || code >= 9 && code <= 13;
|
|
31264
|
+
}
|
|
31265
|
+
function isMapHex(code) {
|
|
31266
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
31267
|
+
}
|
|
31268
|
+
function mapHexDigit(code) {
|
|
31269
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
31270
|
+
}
|
|
31271
|
+
function* stringLines(text7) {
|
|
31272
|
+
let start = 0;
|
|
31273
|
+
for (let end = text7.indexOf("\n"); end !== -1; end = text7.indexOf("\n", start)) {
|
|
31274
|
+
yield text7.slice(start, end);
|
|
31275
|
+
start = end + 1;
|
|
31276
|
+
}
|
|
31277
|
+
yield text7.slice(start);
|
|
31278
|
+
}
|
|
31279
|
+
function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PURE__ */ new Map(), importsLayout = false, extra) {
|
|
31231
31280
|
const unchanged = before === after;
|
|
31232
31281
|
const original = layout(before, !unchanged, !importsLayout);
|
|
31233
31282
|
const optimized = unchanged ? original : layout(after, true, !importsLayout);
|
|
31283
|
+
const collectSymbols = extra?.collectSymbols;
|
|
31284
|
+
const trackedObject = extra?.trackedObject;
|
|
31285
|
+
const trackedObjectOwner = extra?.trackedObjectOwner;
|
|
31286
|
+
const trackedLinearSpans = extra?.trackedLinearSpans;
|
|
31287
|
+
const hasSectionOwners = sectionOwners.size > 0;
|
|
31234
31288
|
let codeOffset;
|
|
31235
31289
|
let outputSection = "";
|
|
31236
31290
|
const codeOwners = /* @__PURE__ */ new Map();
|
|
31237
31291
|
const pieces = [];
|
|
31238
|
-
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
31244
|
-
|
|
31292
|
+
const lines = typeof map2 === "string" ? stringLines(map2) : map2;
|
|
31293
|
+
for (const line of lines) {
|
|
31294
|
+
const lineLen = line.length;
|
|
31295
|
+
let pos = 0;
|
|
31296
|
+
let onlySpaces = true;
|
|
31297
|
+
while (pos < lineLen) {
|
|
31298
|
+
const ch = line.charCodeAt(pos);
|
|
31299
|
+
if (!isMapSpace(ch)) break;
|
|
31300
|
+
if (ch !== 32) onlySpaces = false;
|
|
31301
|
+
pos++;
|
|
31302
|
+
}
|
|
31303
|
+
const leadingSpaces = pos;
|
|
31304
|
+
if (pos >= lineLen) continue;
|
|
31305
|
+
const addrStart = pos;
|
|
31306
|
+
while (pos < lineLen && !isMapSpace(line.charCodeAt(pos))) pos++;
|
|
31307
|
+
const addrEnd = pos;
|
|
31308
|
+
if (pos >= lineLen) continue;
|
|
31309
|
+
const s1 = pos;
|
|
31310
|
+
while (pos < lineLen) {
|
|
31311
|
+
const ch = line.charCodeAt(pos);
|
|
31312
|
+
if (!isMapSpace(ch)) break;
|
|
31313
|
+
if (ch !== 32) onlySpaces = false;
|
|
31314
|
+
pos++;
|
|
31315
|
+
}
|
|
31316
|
+
if (pos === s1 || pos >= lineLen) continue;
|
|
31317
|
+
const offStart = pos;
|
|
31318
|
+
let offsetVal = 0;
|
|
31319
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
31320
|
+
offsetVal = offsetVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
31321
|
+
}
|
|
31322
|
+
if (pos === offStart || pos >= lineLen) continue;
|
|
31323
|
+
const s2 = pos;
|
|
31324
|
+
while (pos < lineLen) {
|
|
31325
|
+
const ch = line.charCodeAt(pos);
|
|
31326
|
+
if (!isMapSpace(ch)) break;
|
|
31327
|
+
if (ch !== 32) onlySpaces = false;
|
|
31328
|
+
pos++;
|
|
31329
|
+
}
|
|
31330
|
+
if (pos === s2 || pos >= lineLen) continue;
|
|
31331
|
+
const sizeStart = pos;
|
|
31332
|
+
let sizeVal = 0;
|
|
31333
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
31334
|
+
sizeVal = sizeVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
31335
|
+
}
|
|
31336
|
+
if (pos === sizeStart || pos >= lineLen) continue;
|
|
31337
|
+
const indentStart = pos;
|
|
31338
|
+
while (pos < lineLen && line.charCodeAt(pos) === 32) pos++;
|
|
31339
|
+
const indentLen = pos - indentStart;
|
|
31340
|
+
if (indentLen === 0 || pos >= lineLen) continue;
|
|
31341
|
+
const firstCh = line.charCodeAt(pos);
|
|
31342
|
+
if (isMapSpace(firstCh)) continue;
|
|
31343
|
+
const sourceStart = pos;
|
|
31344
|
+
if (collectSymbols && onlySpaces && leadingSpaces > 0 && indentLen >= 9 && firstCh !== 47 && firstCh !== 60) {
|
|
31345
|
+
let symEnd = sourceStart + 1;
|
|
31346
|
+
while (symEnd < lineLen && !isMapSpace(line.charCodeAt(symEnd))) symEnd++;
|
|
31347
|
+
collectSymbols.add(line.slice(sourceStart, symEnd));
|
|
31348
|
+
}
|
|
31349
|
+
const isDash = addrEnd - addrStart === 1 && line.charCodeAt(addrStart) === 45;
|
|
31350
|
+
if (isDash && indentLen === 1) {
|
|
31351
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
31352
|
+
outputSection = line.slice(sourceStart);
|
|
31353
|
+
if (outputSection === "CODE") codeOffset = offsetVal;
|
|
31245
31354
|
continue;
|
|
31246
31355
|
}
|
|
31247
|
-
|
|
31356
|
+
if (sizeVal === 0) continue;
|
|
31357
|
+
const separator = line.indexOf(":(", sourceStart);
|
|
31248
31358
|
if (separator < 0) continue;
|
|
31249
|
-
|
|
31250
|
-
|
|
31251
|
-
|
|
31252
|
-
|
|
31253
|
-
if (
|
|
31254
|
-
|
|
31359
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
31360
|
+
let hasLineSep = false;
|
|
31361
|
+
for (let i = sourceStart; i < lineLen; i++) {
|
|
31362
|
+
const ch = line.charCodeAt(i);
|
|
31363
|
+
if (ch === 8232 || ch === 8233) {
|
|
31364
|
+
hasLineSep = true;
|
|
31365
|
+
break;
|
|
31366
|
+
}
|
|
31367
|
+
}
|
|
31368
|
+
if (hasLineSep) continue;
|
|
31369
|
+
const objectPath = line.slice(sourceStart, separator);
|
|
31370
|
+
let image = hasSectionOwners ? sectionOwners.get(line.slice(sourceStart)) : void 0;
|
|
31371
|
+
if (image === void 0) image = owners.get(objectPath);
|
|
31372
|
+
if (!isDash) {
|
|
31373
|
+
if (outputSection === "DATA") {
|
|
31374
|
+
let addressVal = 0;
|
|
31375
|
+
let allHex = true;
|
|
31376
|
+
for (let i = addrStart; i < addrEnd; i++) {
|
|
31377
|
+
const ch = line.charCodeAt(i);
|
|
31378
|
+
if (isMapHex(ch)) addressVal = addressVal * 16 + mapHexDigit(ch);
|
|
31379
|
+
else {
|
|
31380
|
+
allHex = false;
|
|
31381
|
+
break;
|
|
31382
|
+
}
|
|
31383
|
+
}
|
|
31384
|
+
if (!allHex) addressVal = parseInt(line.slice(addrStart, addrEnd), 16);
|
|
31385
|
+
pieces.push({
|
|
31386
|
+
image,
|
|
31387
|
+
address: addressVal,
|
|
31388
|
+
length: sizeVal,
|
|
31389
|
+
tracked: trackedObject !== void 0 && objectPath === trackedObject
|
|
31390
|
+
});
|
|
31391
|
+
}
|
|
31255
31392
|
continue;
|
|
31256
31393
|
}
|
|
31257
31394
|
if (image === void 0 || outputSection !== "CODE") continue;
|
|
31258
31395
|
if (codeOffset === void 0) throw new Error("link map has no code section");
|
|
31259
|
-
const index = original.functionsByCodeOffset.get(
|
|
31396
|
+
const index = original.functionsByCodeOffset.get(offsetVal - codeOffset);
|
|
31260
31397
|
if (index === void 0) throw new Error("link map function has no wasm body");
|
|
31261
31398
|
const existing = codeOwners.get(index);
|
|
31262
31399
|
if (existing !== void 0 && existing !== image)
|
|
@@ -31265,12 +31402,23 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
31265
31402
|
}
|
|
31266
31403
|
pieces.sort((a, b) => a.address - b.address);
|
|
31267
31404
|
const spans = [];
|
|
31268
|
-
for (
|
|
31269
|
-
|
|
31405
|
+
for (let index = 0; index < pieces.length; index++) {
|
|
31406
|
+
const piece = pieces[index];
|
|
31407
|
+
const { image, address, length, tracked } = piece;
|
|
31408
|
+
if (image === void 0 && !tracked) continue;
|
|
31270
31409
|
let next = index + 1;
|
|
31271
31410
|
while (next < pieces.length && pieces[next].address < address + length) next++;
|
|
31272
31411
|
const end = pieces[next]?.address ?? address + length;
|
|
31273
|
-
|
|
31412
|
+
const spanLength = end - address;
|
|
31413
|
+
if (image !== void 0)
|
|
31414
|
+
spans.push({ image, space: "linear-memory", address, length: spanLength });
|
|
31415
|
+
if (tracked && trackedLinearSpans && trackedObjectOwner !== void 0)
|
|
31416
|
+
trackedLinearSpans.push({
|
|
31417
|
+
image: trackedObjectOwner,
|
|
31418
|
+
space: "linear-memory",
|
|
31419
|
+
address,
|
|
31420
|
+
length: spanLength
|
|
31421
|
+
});
|
|
31274
31422
|
}
|
|
31275
31423
|
const optimizedOwners = /* @__PURE__ */ new Map();
|
|
31276
31424
|
const dataAt = (module2, start, length) => {
|
|
@@ -31309,7 +31457,7 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
31309
31457
|
throw new Error(`optimization changed linked data at ${span.address}`);
|
|
31310
31458
|
}
|
|
31311
31459
|
let previous;
|
|
31312
|
-
for (const span of
|
|
31460
|
+
for (const span of spans) {
|
|
31313
31461
|
if (previous && span.address < previous.address + previous.length && span.image !== previous.image)
|
|
31314
31462
|
throw new Error("linked data belongs to multiple images");
|
|
31315
31463
|
if (!previous || span.address + span.length > previous.address + previous.length)
|
|
@@ -31491,6 +31639,20 @@ var init_swift_guest_linked_spans = __esm({
|
|
|
31491
31639
|
});
|
|
31492
31640
|
|
|
31493
31641
|
// src/swift-sdk-image-map.ts
|
|
31642
|
+
function isHexChar(code) {
|
|
31643
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
31644
|
+
}
|
|
31645
|
+
function hexDigit(code) {
|
|
31646
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
31647
|
+
}
|
|
31648
|
+
function hasLineBreak(line, from) {
|
|
31649
|
+
if (line.indexOf("\r", from) >= 0) return true;
|
|
31650
|
+
for (let i = from; i < line.length; i++) {
|
|
31651
|
+
const ch = line.charCodeAt(i);
|
|
31652
|
+
if (ch === 8232 || ch === 8233) return true;
|
|
31653
|
+
}
|
|
31654
|
+
return false;
|
|
31655
|
+
}
|
|
31494
31656
|
function readWasmLinkMap(file, partition) {
|
|
31495
31657
|
const segments = /* @__PURE__ */ new Map();
|
|
31496
31658
|
const data = [];
|
|
@@ -31498,48 +31660,117 @@ function readWasmLinkMap(file, partition) {
|
|
|
31498
31660
|
let kind = "";
|
|
31499
31661
|
let segment2 = "";
|
|
31500
31662
|
let previous;
|
|
31501
|
-
const hex = (value) => value === "-" ? -1 : parseInt(value, 16);
|
|
31502
31663
|
for (const line of guestLinkLines(file)) {
|
|
31503
|
-
const
|
|
31504
|
-
|
|
31505
|
-
|
|
31506
|
-
|
|
31507
|
-
|
|
31508
|
-
|
|
31509
|
-
|
|
31664
|
+
const length = line.length;
|
|
31665
|
+
let pos = 0;
|
|
31666
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
31667
|
+
if (pos >= length) continue;
|
|
31668
|
+
const leadingSpaces = pos;
|
|
31669
|
+
let address = -1;
|
|
31670
|
+
if (line.charCodeAt(pos) === 45) {
|
|
31671
|
+
pos++;
|
|
31672
|
+
} else {
|
|
31673
|
+
const start = pos;
|
|
31674
|
+
let value = 0;
|
|
31675
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
31676
|
+
value = value * 16 + hexDigit(line.charCodeAt(pos++));
|
|
31677
|
+
}
|
|
31678
|
+
if (pos === start) continue;
|
|
31679
|
+
address = value;
|
|
31680
|
+
}
|
|
31681
|
+
const s1 = pos;
|
|
31682
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
31683
|
+
if (pos === s1 || pos >= length) continue;
|
|
31684
|
+
const offStart = pos;
|
|
31685
|
+
let offset = 0;
|
|
31686
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
31687
|
+
offset = offset * 16 + hexDigit(line.charCodeAt(pos++));
|
|
31688
|
+
}
|
|
31689
|
+
if (pos === offStart) continue;
|
|
31690
|
+
const s2 = pos;
|
|
31691
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
31692
|
+
if (pos === s2 || pos >= length) continue;
|
|
31693
|
+
const sizeStart = pos;
|
|
31694
|
+
let size2 = 0;
|
|
31695
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
31696
|
+
size2 = size2 * 16 + hexDigit(line.charCodeAt(pos++));
|
|
31697
|
+
}
|
|
31698
|
+
if (pos === sizeStart || pos >= length) continue;
|
|
31699
|
+
const indentStart = pos;
|
|
31700
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
31701
|
+
const indent2 = pos - indentStart;
|
|
31702
|
+
if (indent2 === 0 || pos >= length) continue;
|
|
31703
|
+
if (indent2 === 17) {
|
|
31704
|
+
if (previous) {
|
|
31705
|
+
const first = line.charCodeAt(pos);
|
|
31706
|
+
if (first > 32 && !hasLineBreak(line, pos)) {
|
|
31707
|
+
previous.symbols.push({
|
|
31708
|
+
name: line.slice(pos),
|
|
31709
|
+
address,
|
|
31710
|
+
size: size2
|
|
31711
|
+
});
|
|
31712
|
+
}
|
|
31713
|
+
}
|
|
31510
31714
|
continue;
|
|
31511
31715
|
}
|
|
31512
|
-
|
|
31513
|
-
|
|
31514
|
-
|
|
31716
|
+
if (indent2 === 1) {
|
|
31717
|
+
let hasWhitespace = false;
|
|
31718
|
+
for (let i = pos; i < length; i++) {
|
|
31719
|
+
const ch = line.charCodeAt(i);
|
|
31720
|
+
if (ch <= 32) {
|
|
31721
|
+
hasWhitespace = true;
|
|
31722
|
+
break;
|
|
31723
|
+
}
|
|
31724
|
+
}
|
|
31725
|
+
if (hasWhitespace) continue;
|
|
31726
|
+
if (address < 0 && leadingSpaces > 0) {
|
|
31727
|
+
kind = line.slice(pos);
|
|
31728
|
+
} else if (kind === "DATA" && address >= 0) {
|
|
31729
|
+
segment2 = line.slice(pos);
|
|
31730
|
+
segments.set(segment2, { address, size: size2 });
|
|
31731
|
+
}
|
|
31515
31732
|
continue;
|
|
31516
31733
|
}
|
|
31517
|
-
if (kind === "DATA") {
|
|
31518
|
-
const
|
|
31519
|
-
if (
|
|
31520
|
-
|
|
31521
|
-
|
|
31522
|
-
|
|
31734
|
+
if (indent2 === 9 && (kind === "DATA" || kind === "CODE")) {
|
|
31735
|
+
const first = line.charCodeAt(pos);
|
|
31736
|
+
if (first !== 47 && first !== 60) continue;
|
|
31737
|
+
if (hasLineBreak(line, pos)) continue;
|
|
31738
|
+
const name3 = line.slice(pos);
|
|
31739
|
+
let filePath = name3;
|
|
31740
|
+
let section2 = "";
|
|
31741
|
+
if (name3.charCodeAt(name3.length - 1) === 41) {
|
|
31742
|
+
const splitAt = name3.indexOf(":(");
|
|
31743
|
+
if (splitAt >= 0) {
|
|
31744
|
+
filePath = name3.slice(0, splitAt);
|
|
31745
|
+
section2 = name3.slice(splitAt + 2, -1);
|
|
31746
|
+
}
|
|
31747
|
+
}
|
|
31748
|
+
let objectName;
|
|
31749
|
+
if (filePath.charCodeAt(filePath.length - 1) === 41) {
|
|
31750
|
+
const open = filePath.lastIndexOf("(");
|
|
31751
|
+
if (open >= 0 && open + 1 < filePath.length - 1) {
|
|
31752
|
+
const close = filePath.indexOf(")", open + 1);
|
|
31753
|
+
if (close === filePath.length - 1) {
|
|
31754
|
+
objectName = filePath.slice(open + 1, -1);
|
|
31755
|
+
}
|
|
31756
|
+
}
|
|
31757
|
+
}
|
|
31758
|
+
if (objectName === void 0) objectName = (0, import_node_path42.basename)(filePath);
|
|
31759
|
+
if (objectName.startsWith("lib") && objectName.includes("__")) {
|
|
31760
|
+
objectName = objectName.replace(/^lib\w*?__/, "");
|
|
31523
31761
|
}
|
|
31762
|
+
previous = {
|
|
31763
|
+
inputFile: filePath,
|
|
31764
|
+
segment: segment2,
|
|
31765
|
+
address,
|
|
31766
|
+
offset,
|
|
31767
|
+
size: size2,
|
|
31768
|
+
object: objectName,
|
|
31769
|
+
section: section2,
|
|
31770
|
+
symbols: []
|
|
31771
|
+
};
|
|
31772
|
+
(kind === "DATA" ? data : code).push(previous);
|
|
31524
31773
|
}
|
|
31525
|
-
if (kind !== "DATA" && kind !== "CODE") continue;
|
|
31526
|
-
const input = /^ *([0-9a-f]+|-) +([0-9a-f]+) +([0-9a-f]+) {9}([/<].*)$/.exec(line);
|
|
31527
|
-
if (!input) continue;
|
|
31528
|
-
const name3 = input[4];
|
|
31529
|
-
const split = /^(.*?):\((.*)\)$/s.exec(name3);
|
|
31530
|
-
const path115 = split ? split[1] : name3;
|
|
31531
|
-
const member = /\(([^()]+)\)$/.exec(path115);
|
|
31532
|
-
previous = {
|
|
31533
|
-
inputFile: path115,
|
|
31534
|
-
segment: segment2,
|
|
31535
|
-
address: hex(input[1]),
|
|
31536
|
-
offset: parseInt(input[2], 16),
|
|
31537
|
-
size: parseInt(input[3], 16),
|
|
31538
|
-
object: (member ? member[1] : (0, import_node_path42.basename)(path115)).replace(/^lib\w*?__/, ""),
|
|
31539
|
-
section: split ? split[2] : "",
|
|
31540
|
-
symbols: []
|
|
31541
|
-
};
|
|
31542
|
-
(kind === "DATA" ? data : code).push(previous);
|
|
31543
31774
|
}
|
|
31544
31775
|
return { segments, data: partition ? data.flatMap(symbolPieces) : data, code };
|
|
31545
31776
|
}
|
|
@@ -32685,6 +32916,7 @@ function patchSwiftrtObject(src) {
|
|
|
32685
32916
|
return buf;
|
|
32686
32917
|
}
|
|
32687
32918
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
32919
|
+
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
32688
32920
|
let pos = 8;
|
|
32689
32921
|
let numImportFuncs = 0;
|
|
32690
32922
|
let importsDlsym = false;
|
|
@@ -32720,10 +32952,10 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32720
32952
|
let [cnt, cp] = readULEB2(buf, p);
|
|
32721
32953
|
for (let i = 0; i < cnt; i++) {
|
|
32722
32954
|
const [mLen, m2] = readULEB2(buf, cp);
|
|
32723
|
-
const mName =
|
|
32955
|
+
const mName = rawBuf.toString("utf8", m2, m2 + mLen);
|
|
32724
32956
|
cp = m2 + mLen;
|
|
32725
32957
|
const [fLen, f2] = readULEB2(buf, cp);
|
|
32726
|
-
const fName =
|
|
32958
|
+
const fName = rawBuf.toString("utf8", f2, f2 + fLen);
|
|
32727
32959
|
cp = f2 + fLen;
|
|
32728
32960
|
const kind = buf[cp++];
|
|
32729
32961
|
if (kind === 0) {
|
|
@@ -32803,7 +33035,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32803
33035
|
}
|
|
32804
33036
|
} else if (id === 0) {
|
|
32805
33037
|
const [nLen, np] = readULEB2(buf, p);
|
|
32806
|
-
const name3 =
|
|
33038
|
+
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
32807
33039
|
const cp = np + nLen;
|
|
32808
33040
|
if (name3 === "linking") {
|
|
32809
33041
|
let [, lp] = readULEB2(buf, cp);
|
|
@@ -32816,7 +33048,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32816
33048
|
let cur = p2;
|
|
32817
33049
|
for (let i = 0; i < cnt; i++) {
|
|
32818
33050
|
const [sLen, s2] = readULEB2(buf, cur);
|
|
32819
|
-
segNames.push(
|
|
33051
|
+
segNames.push(rawBuf.toString("utf8", s2, s2 + sLen));
|
|
32820
33052
|
cur = s2 + sLen;
|
|
32821
33053
|
const [, s3] = readULEB2(buf, cur);
|
|
32822
33054
|
const [fl, s4] = readULEB2(buf, s3);
|
|
@@ -32856,7 +33088,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32856
33088
|
let sName = "";
|
|
32857
33089
|
if (!isUndef || isExplicitName) {
|
|
32858
33090
|
const [sLen, c4] = readULEB2(buf, cur);
|
|
32859
|
-
sName =
|
|
33091
|
+
sName = rawBuf.toString("utf8", c4, c4 + sLen);
|
|
32860
33092
|
cur = c4 + sLen;
|
|
32861
33093
|
} else if (kind === 0) {
|
|
32862
33094
|
sName = importFuncNames[el] ?? "";
|
|
@@ -32872,7 +33104,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32872
33104
|
symNames.push(sName);
|
|
32873
33105
|
} else if (kind === 1) {
|
|
32874
33106
|
const [sLen, c3] = readULEB2(buf, cur);
|
|
32875
|
-
const sName =
|
|
33107
|
+
const sName = rawBuf.toString("utf8", c3, c3 + sLen);
|
|
32876
33108
|
cur = c3 + sLen;
|
|
32877
33109
|
if (!isUndef) {
|
|
32878
33110
|
const [segIdx, c4] = readULEB2(buf, cur);
|
|
@@ -32987,9 +33219,21 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32987
33219
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
32988
33220
|
let ownerSymIdx = -1;
|
|
32989
33221
|
const topList = segTopSyms.get(lo);
|
|
32990
|
-
if (topList) {
|
|
32991
|
-
|
|
32992
|
-
|
|
33222
|
+
if (topList && topList.length > 0) {
|
|
33223
|
+
let tLo = 0;
|
|
33224
|
+
let tHi = topList.length - 1;
|
|
33225
|
+
while (tLo <= tHi) {
|
|
33226
|
+
const tMid = tLo + tHi >> 1;
|
|
33227
|
+
const top = topList[tMid];
|
|
33228
|
+
if (offInSeg < top.off) {
|
|
33229
|
+
tHi = tMid - 1;
|
|
33230
|
+
} else if (offInSeg >= top.end) {
|
|
33231
|
+
tLo = tMid + 1;
|
|
33232
|
+
} else {
|
|
33233
|
+
ownerSymIdx = top.symIdx;
|
|
33234
|
+
break;
|
|
33235
|
+
}
|
|
33236
|
+
}
|
|
32993
33237
|
}
|
|
32994
33238
|
if (ownerSymIdx !== -1) {
|
|
32995
33239
|
let list2 = symDataRelocs.get(ownerSymIdx);
|
|
@@ -33244,54 +33488,151 @@ function localizeDefinedWasmSymbols(bytes, names) {
|
|
|
33244
33488
|
return output;
|
|
33245
33489
|
}
|
|
33246
33490
|
function guestWasmSymbols(bytes) {
|
|
33247
|
-
const
|
|
33491
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
33492
|
+
let cur = 8;
|
|
33493
|
+
const readU = () => {
|
|
33494
|
+
const b0 = bytes[cur++];
|
|
33495
|
+
if (b0 < 128) return b0;
|
|
33496
|
+
let res = b0 & 127;
|
|
33497
|
+
let shift = 7;
|
|
33498
|
+
while (true) {
|
|
33499
|
+
const byte = bytes[cur++];
|
|
33500
|
+
res |= (byte & 127) << shift;
|
|
33501
|
+
if ((byte & 128) === 0) return res;
|
|
33502
|
+
shift += 7;
|
|
33503
|
+
}
|
|
33504
|
+
};
|
|
33505
|
+
let importsDlsym = false;
|
|
33506
|
+
const importFuncNames = [];
|
|
33507
|
+
const importFuncModules = [];
|
|
33508
|
+
const importGlobalNames = [];
|
|
33509
|
+
const importTableNames = [];
|
|
33510
|
+
const importEventNames = [];
|
|
33511
|
+
const undefinedSyms = /* @__PURE__ */ new Set();
|
|
33512
|
+
const tags = /* @__PURE__ */ new Set();
|
|
33513
|
+
const globals = /* @__PURE__ */ new Set();
|
|
33514
|
+
const hostImports = /* @__PURE__ */ new Set();
|
|
33515
|
+
const weakUndefined = /* @__PURE__ */ new Set();
|
|
33516
|
+
const defined = /* @__PURE__ */ new Set();
|
|
33517
|
+
const weakDefined = /* @__PURE__ */ new Set();
|
|
33518
|
+
while (cur < bytes.length) {
|
|
33519
|
+
const id = bytes[cur++];
|
|
33520
|
+
const sz = readU();
|
|
33521
|
+
const end = cur + sz;
|
|
33522
|
+
if (id === 2) {
|
|
33523
|
+
const cnt = readU();
|
|
33524
|
+
for (let i = 0; i < cnt; i++) {
|
|
33525
|
+
const mLen = readU();
|
|
33526
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
33527
|
+
cur += mLen;
|
|
33528
|
+
const fLen = readU();
|
|
33529
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
33530
|
+
cur += fLen;
|
|
33531
|
+
const kind = bytes[cur++];
|
|
33532
|
+
if (kind === 0) {
|
|
33533
|
+
readU();
|
|
33534
|
+
importFuncNames.push(fName);
|
|
33535
|
+
importFuncModules.push(mName);
|
|
33536
|
+
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
33537
|
+
} else if (kind === 1) {
|
|
33538
|
+
cur++;
|
|
33539
|
+
const fl = readU();
|
|
33540
|
+
readU();
|
|
33541
|
+
if (fl & 1) readU();
|
|
33542
|
+
importTableNames.push(fName);
|
|
33543
|
+
} else if (kind === 2) {
|
|
33544
|
+
const fl = readU();
|
|
33545
|
+
readU();
|
|
33546
|
+
if (fl & 1) readU();
|
|
33547
|
+
} else if (kind === 3) {
|
|
33548
|
+
cur += 2;
|
|
33549
|
+
importGlobalNames.push(fName);
|
|
33550
|
+
} else if (kind === 4) {
|
|
33551
|
+
cur++;
|
|
33552
|
+
readU();
|
|
33553
|
+
importEventNames.push(fName);
|
|
33554
|
+
}
|
|
33555
|
+
}
|
|
33556
|
+
} else if (id === 0) {
|
|
33557
|
+
const nLen = readU();
|
|
33558
|
+
if (nLen === 7 && bytes[cur] === 108 && rawBuf.toString("utf8", cur, cur + nLen) === "linking") {
|
|
33559
|
+
cur += nLen;
|
|
33560
|
+
readU();
|
|
33561
|
+
while (cur < end) {
|
|
33562
|
+
const subId = bytes[cur++];
|
|
33563
|
+
const subLen = readU();
|
|
33564
|
+
const subEnd = cur + subLen;
|
|
33565
|
+
if (subId === 8) {
|
|
33566
|
+
const cnt = readU();
|
|
33567
|
+
for (let i = 0; i < cnt; i++) {
|
|
33568
|
+
const kind = bytes[cur++];
|
|
33569
|
+
const fl = readU();
|
|
33570
|
+
const isUndef = (fl & 16) !== 0;
|
|
33571
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
33572
|
+
let sName = "";
|
|
33573
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
33574
|
+
const el = readU();
|
|
33575
|
+
if (!isUndef || isExplicitName) {
|
|
33576
|
+
const sLen = readU();
|
|
33577
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
33578
|
+
cur += sLen;
|
|
33579
|
+
} else if (kind === 0) {
|
|
33580
|
+
sName = importFuncNames[el] ?? "";
|
|
33581
|
+
} else if (kind === 2) {
|
|
33582
|
+
sName = importGlobalNames[el] ?? "";
|
|
33583
|
+
} else if (kind === 4) {
|
|
33584
|
+
sName = importEventNames[el] ?? "";
|
|
33585
|
+
} else if (kind === 5) {
|
|
33586
|
+
sName = importTableNames[el] ?? "";
|
|
33587
|
+
}
|
|
33588
|
+
if (isUndef && kind === 0 && importFuncModules[el] !== "env")
|
|
33589
|
+
hostImports.add(sName);
|
|
33590
|
+
} else if (kind === 1) {
|
|
33591
|
+
const sLen = readU();
|
|
33592
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
33593
|
+
cur += sLen;
|
|
33594
|
+
if (!isUndef) {
|
|
33595
|
+
readU();
|
|
33596
|
+
readU();
|
|
33597
|
+
readU();
|
|
33598
|
+
}
|
|
33599
|
+
} else if (kind === 3) {
|
|
33600
|
+
readU();
|
|
33601
|
+
}
|
|
33602
|
+
if (sName) {
|
|
33603
|
+
if (isUndef) {
|
|
33604
|
+
undefinedSyms.add(sName);
|
|
33605
|
+
if ((fl & 19) === 17) weakUndefined.add(sName);
|
|
33606
|
+
} else if ((fl & 3) !== 2) {
|
|
33607
|
+
defined.add(sName);
|
|
33608
|
+
if ((fl & 19) === 1) weakDefined.add(sName);
|
|
33609
|
+
}
|
|
33610
|
+
if (kind === 4) tags.add(sName);
|
|
33611
|
+
else if (kind === 2 || kind === 5) globals.add(sName);
|
|
33612
|
+
}
|
|
33613
|
+
}
|
|
33614
|
+
break;
|
|
33615
|
+
}
|
|
33616
|
+
cur = subEnd;
|
|
33617
|
+
}
|
|
33618
|
+
break;
|
|
33619
|
+
}
|
|
33620
|
+
}
|
|
33621
|
+
cur = end;
|
|
33622
|
+
}
|
|
33248
33623
|
return {
|
|
33249
|
-
importsDlsym
|
|
33250
|
-
undefined: [
|
|
33251
|
-
...new Set(
|
|
33252
|
-
object7.symNames.filter(
|
|
33253
|
-
(name3, index) => name3 && (object7.symFlags[index] & 16) !== 0
|
|
33254
|
-
)
|
|
33255
|
-
)
|
|
33256
|
-
],
|
|
33624
|
+
importsDlsym,
|
|
33625
|
+
undefined: [...undefinedSyms],
|
|
33257
33626
|
// a wasm tag is one module entity unified by name across the link, as the
|
|
33258
33627
|
// main module owns it for dynamic images, so no image scope applies.
|
|
33259
|
-
tags: [
|
|
33260
|
-
|
|
33261
|
-
object7.symNames.filter((name3, index) => name3 && object7.symKind[index] === 4)
|
|
33262
|
-
)
|
|
33263
|
-
],
|
|
33264
|
-
globals: [
|
|
33265
|
-
...new Set(
|
|
33266
|
-
object7.symNames.filter(
|
|
33267
|
-
(name3, index) => name3 && (object7.symKind[index] === 2 || object7.symKind[index] === 5)
|
|
33268
|
-
)
|
|
33269
|
-
)
|
|
33270
|
-
],
|
|
33628
|
+
tags: [...tags],
|
|
33629
|
+
globals: [...globals],
|
|
33271
33630
|
// an undefined function imported from a module other than env is supplied
|
|
33272
33631
|
// by the host, whatever linker symbol names it.
|
|
33273
|
-
hostImports: [...
|
|
33274
|
-
weakUndefined: [
|
|
33275
|
-
|
|
33276
|
-
|
|
33277
|
-
(name3, index) => name3 && (object7.symFlags[index] & 19) === 17
|
|
33278
|
-
)
|
|
33279
|
-
)
|
|
33280
|
-
],
|
|
33281
|
-
defined: [
|
|
33282
|
-
...new Set(
|
|
33283
|
-
object7.symNames.filter(
|
|
33284
|
-
(name3, index) => name3 && (object7.symFlags[index] & 16) === 0 && (object7.symFlags[index] & 3) !== 2
|
|
33285
|
-
)
|
|
33286
|
-
)
|
|
33287
|
-
],
|
|
33288
|
-
weakDefined: [
|
|
33289
|
-
...new Set(
|
|
33290
|
-
object7.symNames.filter(
|
|
33291
|
-
(name3, index) => name3 && (object7.symFlags[index] & 19) === 1
|
|
33292
|
-
)
|
|
33293
|
-
)
|
|
33294
|
-
]
|
|
33632
|
+
hostImports: [...hostImports],
|
|
33633
|
+
weakUndefined: [...weakUndefined],
|
|
33634
|
+
defined: [...defined],
|
|
33635
|
+
weakDefined: [...weakDefined]
|
|
33295
33636
|
};
|
|
33296
33637
|
}
|
|
33297
33638
|
function sdkObjectName(archive, member, ordinal) {
|
|
@@ -33808,9 +34149,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33808
34149
|
for (const entry of waiting) tryActivateConformance(entry);
|
|
33809
34150
|
}
|
|
33810
34151
|
};
|
|
34152
|
+
const checkedProtocolTriggers = /* @__PURE__ */ new Set();
|
|
33811
34153
|
const checkProtocolTrigger = (rawSymName) => {
|
|
33812
34154
|
if (!rawSymName) return;
|
|
33813
34155
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
34156
|
+
if (checkedProtocolTriggers.has(sName)) return;
|
|
34157
|
+
checkedProtocolTriggers.add(sName);
|
|
33814
34158
|
if (knownProtocols.has(sName)) {
|
|
33815
34159
|
markProtocolLive(sName);
|
|
33816
34160
|
return;
|
|
@@ -33843,6 +34187,43 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33843
34187
|
}
|
|
33844
34188
|
}
|
|
33845
34189
|
};
|
|
34190
|
+
const typeIndexes = /* @__PURE__ */ new Map();
|
|
34191
|
+
const getTypeIndex = (obj) => {
|
|
34192
|
+
let idx = typeIndexes.get(obj);
|
|
34193
|
+
if (idx) return idx;
|
|
34194
|
+
const mnByPrefix = /* @__PURE__ */ new Map();
|
|
34195
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
34196
|
+
const name3 = obj.symNames[i];
|
|
34197
|
+
if ((obj.symFlags[i] & 16) === 0 && name3.startsWith("$s") && name3.endsWith("Mn")) {
|
|
34198
|
+
const pref = name3.slice(0, -2);
|
|
34199
|
+
let list2 = mnByPrefix.get(pref);
|
|
34200
|
+
if (!list2) mnByPrefix.set(pref, list2 = []);
|
|
34201
|
+
list2.push(i);
|
|
34202
|
+
}
|
|
34203
|
+
}
|
|
34204
|
+
const objcRegByPrefix = /* @__PURE__ */ new Map();
|
|
34205
|
+
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
34206
|
+
let list2 = objcRegByPrefix.get(p);
|
|
34207
|
+
if (!list2) objcRegByPrefix.set(p, list2 = []);
|
|
34208
|
+
list2.push(lf);
|
|
34209
|
+
}
|
|
34210
|
+
const objcClassByPrefix = /* @__PURE__ */ new Map();
|
|
34211
|
+
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
34212
|
+
if (!classSym.startsWith("._OBJC_CLASS_")) continue;
|
|
34213
|
+
let list2 = objcClassByPrefix.get(p);
|
|
34214
|
+
if (!list2) objcClassByPrefix.set(p, list2 = []);
|
|
34215
|
+
list2.push(classSym.slice("._OBJC_CLASS_".length));
|
|
34216
|
+
}
|
|
34217
|
+
let minPrefLen = Infinity;
|
|
34218
|
+
let maxPrefLen = 0;
|
|
34219
|
+
for (const p of obj.typePrefixesInObj) {
|
|
34220
|
+
if (p.length < minPrefLen) minPrefLen = p.length;
|
|
34221
|
+
if (p.length > maxPrefLen) maxPrefLen = p.length;
|
|
34222
|
+
}
|
|
34223
|
+
idx = { mnByPrefix, objcRegByPrefix, objcClassByPrefix, minPrefLen, maxPrefLen };
|
|
34224
|
+
typeIndexes.set(obj, idx);
|
|
34225
|
+
return idx;
|
|
34226
|
+
};
|
|
33846
34227
|
const markTypeLive = (obj, pref) => {
|
|
33847
34228
|
const set2 = liveTypes.get(obj);
|
|
33848
34229
|
if (set2.has(pref)) return;
|
|
@@ -33856,22 +34237,10 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33856
34237
|
const outer = pref.slice(0, n);
|
|
33857
34238
|
if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer);
|
|
33858
34239
|
}
|
|
33859
|
-
const
|
|
33860
|
-
for (
|
|
33861
|
-
|
|
33862
|
-
|
|
33863
|
-
}
|
|
33864
|
-
}
|
|
33865
|
-
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
33866
|
-
if (p === pref) {
|
|
33867
|
-
markFuncLive(obj, lf);
|
|
33868
|
-
}
|
|
33869
|
-
}
|
|
33870
|
-
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
33871
|
-
if (p === pref && classSym.startsWith("._OBJC_CLASS_")) {
|
|
33872
|
-
markObjCClassLive(classSym.slice("._OBJC_CLASS_".length));
|
|
33873
|
-
}
|
|
33874
|
-
}
|
|
34240
|
+
const idx = getTypeIndex(obj);
|
|
34241
|
+
for (const i of idx.mnByPrefix.get(pref) ?? []) activateSymbolInObj(obj, i);
|
|
34242
|
+
for (const lf of idx.objcRegByPrefix.get(pref) ?? []) markFuncLive(obj, lf);
|
|
34243
|
+
for (const cls of idx.objcClassByPrefix.get(pref) ?? []) markObjCClassLive(cls);
|
|
33875
34244
|
};
|
|
33876
34245
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
33877
34246
|
if (!rawSymName) return;
|
|
@@ -33896,11 +34265,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33896
34265
|
}
|
|
33897
34266
|
}
|
|
33898
34267
|
}
|
|
33899
|
-
if (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o")) {
|
|
33900
|
-
|
|
33901
|
-
|
|
33902
|
-
|
|
33903
|
-
|
|
34268
|
+
if (obj.typePrefixesInObj.size > 0 && (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o"))) {
|
|
34269
|
+
const { minPrefLen, maxPrefLen } = getTypeIndex(obj);
|
|
34270
|
+
const hi = Math.min(sName.length, maxPrefLen);
|
|
34271
|
+
for (let n = minPrefLen; n <= hi; n++) {
|
|
34272
|
+
const cand = sName.slice(0, n);
|
|
34273
|
+
if (obj.typePrefixesInObj.has(cand)) markTypeLive(obj, cand);
|
|
33904
34274
|
}
|
|
33905
34275
|
}
|
|
33906
34276
|
};
|
|
@@ -33993,7 +34363,8 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33993
34363
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
33994
34364
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
33995
34365
|
for (const name3 of obj.symNames) {
|
|
33996
|
-
|
|
34366
|
+
if (!name3 || !name3.startsWith("_c_") || !name3.endsWith("__load")) continue;
|
|
34367
|
+
const loaded3 = name3.match(/^_c_(\w+)__load$/)?.[1];
|
|
33997
34368
|
if (!loaded3) continue;
|
|
33998
34369
|
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded3}`);
|
|
33999
34370
|
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
@@ -34141,14 +34512,30 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
34141
34512
|
const keepObjCClassesNamedInSegment = (obj, segIdx) => {
|
|
34142
34513
|
const range3 = obj.segPayloadRanges[segIdx];
|
|
34143
34514
|
if (!range3) return;
|
|
34515
|
+
const [rangeStart, rangeEnd] = range3;
|
|
34516
|
+
if (rangeEnd - rangeStart < 4) return;
|
|
34144
34517
|
let bytes = objectBytes.get(obj);
|
|
34145
34518
|
if (!bytes) objectBytes.set(obj, bytes = import_node_fs44.default.readFileSync(obj.file));
|
|
34146
|
-
|
|
34147
|
-
|
|
34148
|
-
const
|
|
34149
|
-
|
|
34150
|
-
|
|
34151
|
-
|
|
34519
|
+
let pos = rangeStart;
|
|
34520
|
+
while (pos < rangeEnd - 3) {
|
|
34521
|
+
const at = bytes.indexOf("So", pos);
|
|
34522
|
+
if (at < 0 || at >= rangeEnd - 2) break;
|
|
34523
|
+
let digitEnd = at + 2;
|
|
34524
|
+
let length = 0;
|
|
34525
|
+
while (digitEnd < rangeEnd) {
|
|
34526
|
+
const ch = bytes[digitEnd];
|
|
34527
|
+
if (ch < 48 || ch > 57) break;
|
|
34528
|
+
length = length * 10 + (ch - 48);
|
|
34529
|
+
digitEnd++;
|
|
34530
|
+
}
|
|
34531
|
+
if (digitEnd === at + 2) {
|
|
34532
|
+
pos = at + 2;
|
|
34533
|
+
continue;
|
|
34534
|
+
}
|
|
34535
|
+
pos = digitEnd;
|
|
34536
|
+
const nameEnd = digitEnd + length;
|
|
34537
|
+
if (nameEnd >= rangeEnd || bytes[nameEnd] !== 67) continue;
|
|
34538
|
+
const symbol2 = `._OBJC_CLASS_${bytes.toString("latin1", digitEnd, nameEnd)}`;
|
|
34152
34539
|
for (const provider of lazyProviders.get(symbol2) ?? []) {
|
|
34153
34540
|
eagerDynamicObjects.add(provider);
|
|
34154
34541
|
extractObject(provider);
|
|
@@ -35125,6 +35512,10 @@ var init_nativeDyldTableContract = __esm({
|
|
|
35125
35512
|
|
|
35126
35513
|
// src/swift-guest-image-ledger.ts
|
|
35127
35514
|
function readNumber(bytes, position) {
|
|
35515
|
+
if (position < bytes.length) {
|
|
35516
|
+
const first = bytes[position];
|
|
35517
|
+
if (first < 128) return [first, position + 1];
|
|
35518
|
+
}
|
|
35128
35519
|
let value = 0;
|
|
35129
35520
|
let shift = 0;
|
|
35130
35521
|
for (; ; ) {
|
|
@@ -35136,6 +35527,7 @@ function readNumber(bytes, position) {
|
|
|
35136
35527
|
}
|
|
35137
35528
|
}
|
|
35138
35529
|
function encodeNumber(value) {
|
|
35530
|
+
if (value < 128) return Buffer.from([value]);
|
|
35139
35531
|
const bytes = [];
|
|
35140
35532
|
do {
|
|
35141
35533
|
let byte = value % 128;
|
|
@@ -35157,6 +35549,9 @@ function encodedString(value) {
|
|
|
35157
35549
|
const bytes = Buffer.from(value);
|
|
35158
35550
|
return Buffer.concat([encodeNumber(bytes.length), bytes]);
|
|
35159
35551
|
}
|
|
35552
|
+
function isWasmMagic(bytes) {
|
|
35553
|
+
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;
|
|
35554
|
+
}
|
|
35160
35555
|
function llvmType(value) {
|
|
35161
35556
|
switch (value) {
|
|
35162
35557
|
case 127:
|
|
@@ -35172,11 +35567,12 @@ function llvmType(value) {
|
|
|
35172
35567
|
}
|
|
35173
35568
|
}
|
|
35174
35569
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
|
|
35175
|
-
if (
|
|
35176
|
-
|
|
35570
|
+
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
35571
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
35177
35572
|
const { sdkLookupOnly, sdkProduct } = options2;
|
|
35178
35573
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
35179
|
-
const
|
|
35574
|
+
const rewrite = binding !== void 0;
|
|
35575
|
+
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
35180
35576
|
const types2 = [];
|
|
35181
35577
|
const functionTypes = [];
|
|
35182
35578
|
const definitions = [];
|
|
@@ -35190,45 +35586,74 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35190
35586
|
const usedSymbols = /* @__PURE__ */ new Set();
|
|
35191
35587
|
let position = 8;
|
|
35192
35588
|
while (position < bytes.length) {
|
|
35589
|
+
const headerStart2 = position;
|
|
35193
35590
|
const id = bytes[position++];
|
|
35194
|
-
|
|
35591
|
+
let size2 = 0;
|
|
35592
|
+
if (position < bytes.length && bytes[position] < 128) {
|
|
35593
|
+
size2 = bytes[position++];
|
|
35594
|
+
} else {
|
|
35595
|
+
const [val, next] = readNumber(bytes, position);
|
|
35596
|
+
size2 = val;
|
|
35597
|
+
position = next;
|
|
35598
|
+
}
|
|
35599
|
+
const start = position;
|
|
35195
35600
|
const end = start + size2;
|
|
35196
35601
|
if (end > bytes.length) throw new Error("invalid wasm section");
|
|
35197
35602
|
position = end;
|
|
35198
|
-
if (
|
|
35199
|
-
|
|
35200
|
-
|
|
35603
|
+
if (id > 3) {
|
|
35604
|
+
if (sections) sections.push(bytes.subarray(headerStart2, end));
|
|
35605
|
+
continue;
|
|
35606
|
+
}
|
|
35607
|
+
let offset = start;
|
|
35201
35608
|
const number3 = () => {
|
|
35202
|
-
|
|
35203
|
-
|
|
35204
|
-
|
|
35609
|
+
if (offset < end) {
|
|
35610
|
+
const first = bytes[offset];
|
|
35611
|
+
if (first < 128) {
|
|
35612
|
+
offset++;
|
|
35613
|
+
return first;
|
|
35614
|
+
}
|
|
35615
|
+
}
|
|
35616
|
+
let value = 0;
|
|
35617
|
+
let shift = 0;
|
|
35618
|
+
for (; ; ) {
|
|
35619
|
+
if (offset >= end || shift > 63) throw new Error("invalid wasm integer");
|
|
35620
|
+
const byte = bytes[offset++];
|
|
35621
|
+
value += (byte & 127) * 2 ** shift;
|
|
35622
|
+
if (!(byte & 128)) return value;
|
|
35623
|
+
shift += 7;
|
|
35624
|
+
}
|
|
35205
35625
|
};
|
|
35206
35626
|
const string7 = () => {
|
|
35207
|
-
const
|
|
35208
|
-
|
|
35627
|
+
const length = number3();
|
|
35628
|
+
const strEnd = offset + length;
|
|
35629
|
+
if (strEnd > end) throw new Error("invalid wasm string");
|
|
35630
|
+
const value = rawBuf.toString("utf8", offset, strEnd);
|
|
35631
|
+
offset = strEnd;
|
|
35209
35632
|
return value;
|
|
35210
35633
|
};
|
|
35634
|
+
let rewrittenSection;
|
|
35211
35635
|
if (id === 1) {
|
|
35212
35636
|
const count = number3();
|
|
35213
35637
|
for (let i = 0; i < count; i++) {
|
|
35214
|
-
if (
|
|
35638
|
+
if (bytes[offset++] !== 96) throw new Error("unsupported wasm type");
|
|
35215
35639
|
const parameterCount = number3();
|
|
35216
|
-
|
|
35217
|
-
|
|
35218
|
-
|
|
35640
|
+
if (offset + parameterCount > end) throw new Error("invalid wasm type");
|
|
35641
|
+
const parameters = new Array(parameterCount);
|
|
35642
|
+
for (let p = 0; p < parameterCount; p++) parameters[p] = bytes[offset++];
|
|
35219
35643
|
const resultCount = number3();
|
|
35220
|
-
|
|
35221
|
-
|
|
35222
|
-
|
|
35644
|
+
if (offset + resultCount > end) throw new Error("invalid wasm type");
|
|
35645
|
+
const results = new Array(resultCount);
|
|
35646
|
+
for (let r = 0; r < resultCount; r++) results[r] = bytes[offset++];
|
|
35223
35647
|
types2.push({ parameters, results });
|
|
35224
35648
|
}
|
|
35225
35649
|
} else if (id === 2) {
|
|
35226
35650
|
const count = number3();
|
|
35227
|
-
const
|
|
35651
|
+
const importWriter = rewrite ? new ByteWriter(size2 + 64) : void 0;
|
|
35652
|
+
importWriter?.uleb(count);
|
|
35228
35653
|
for (let i = 0; i < count; i++) {
|
|
35229
35654
|
const module2 = string7();
|
|
35230
35655
|
const name3 = string7();
|
|
35231
|
-
const kind =
|
|
35656
|
+
const kind = bytes[offset++];
|
|
35232
35657
|
const typeStart = offset;
|
|
35233
35658
|
let functionType2 = -1;
|
|
35234
35659
|
if (kind === 0) {
|
|
@@ -35236,7 +35661,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35236
35661
|
functionTypes.push(functionType2);
|
|
35237
35662
|
functionImportNames.push(name3);
|
|
35238
35663
|
} else if (kind === 1) {
|
|
35239
|
-
const referenceType =
|
|
35664
|
+
const referenceType = bytes[offset++];
|
|
35240
35665
|
if (referenceType !== 112 && referenceType !== 111)
|
|
35241
35666
|
throw new Error("unsupported table type");
|
|
35242
35667
|
const flags = number3();
|
|
@@ -35255,11 +35680,15 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35255
35680
|
} else throw new Error("unsupported wasm import");
|
|
35256
35681
|
const isDlsym = instrumentDynamicLookups && module2 === "env" && name3 === "dlsym" && kind === 0;
|
|
35257
35682
|
const isDlerror = instrumentDynamicLookups && module2 === "env" && name3 === "dlerror" && kind === 0;
|
|
35258
|
-
if (
|
|
35259
|
-
|
|
35260
|
-
|
|
35261
|
-
|
|
35262
|
-
|
|
35683
|
+
if (!rewrite) {
|
|
35684
|
+
if (module2 === "env" && names.has(name3)) {
|
|
35685
|
+
usedSymbols.add(name3);
|
|
35686
|
+
if (kind === 0) {
|
|
35687
|
+
const type = types2[functionType2];
|
|
35688
|
+
if (!type) throw new Error(`missing import type for ${name3}`);
|
|
35689
|
+
functionImports.set(name3, type);
|
|
35690
|
+
}
|
|
35691
|
+
}
|
|
35263
35692
|
}
|
|
35264
35693
|
if (isDlsym || isDlerror) {
|
|
35265
35694
|
const type = types2[functionType2];
|
|
@@ -35269,17 +35698,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35269
35698
|
}
|
|
35270
35699
|
if (isDlsym) usesDlsym = true;
|
|
35271
35700
|
if (isDlerror) usesDlerror = true;
|
|
35272
|
-
|
|
35273
|
-
|
|
35274
|
-
|
|
35275
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding
|
|
35276
|
-
)
|
|
35277
|
-
|
|
35278
|
-
|
|
35279
|
-
|
|
35701
|
+
if (importWriter && binding) {
|
|
35702
|
+
importWriter.string(module2);
|
|
35703
|
+
importWriter.string(
|
|
35704
|
+
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
|
|
35705
|
+
);
|
|
35706
|
+
importWriter.byte(kind);
|
|
35707
|
+
importWriter.bytes(bytes, typeStart, offset);
|
|
35708
|
+
}
|
|
35280
35709
|
}
|
|
35281
|
-
if (offset !==
|
|
35282
|
-
if (
|
|
35710
|
+
if (offset !== end) throw new Error("invalid wasm import section");
|
|
35711
|
+
if (importWriter) rewrittenSection = importWriter.finish();
|
|
35283
35712
|
} else if (id === 3) {
|
|
35284
35713
|
const count = number3();
|
|
35285
35714
|
for (let i = 0; i < count; i++) functionTypes.push(number3());
|
|
@@ -35288,43 +35717,40 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35288
35717
|
if (sectionName === "linking") {
|
|
35289
35718
|
const version2 = number3();
|
|
35290
35719
|
if (version2 !== 2) throw new Error("unsupported wasm linking version");
|
|
35291
|
-
const subsections = [];
|
|
35720
|
+
const subsections = rewrite ? [] : void 0;
|
|
35292
35721
|
let objcLoader;
|
|
35293
|
-
while (offset <
|
|
35294
|
-
const kind =
|
|
35722
|
+
while (offset < end) {
|
|
35723
|
+
const kind = bytes[offset++];
|
|
35295
35724
|
const length = number3();
|
|
35296
35725
|
const stop = offset + length;
|
|
35297
|
-
if (stop >
|
|
35298
|
-
|
|
35299
|
-
if (kind === 7 && !sdkLookupOnly) {
|
|
35300
|
-
const
|
|
35726
|
+
if (stop > end) throw new Error("invalid linking subsection");
|
|
35727
|
+
const contentStart = offset;
|
|
35728
|
+
if (kind === 7 && rewrite && !sdkLookupOnly) {
|
|
35729
|
+
const comdatWriter = new ByteWriter(length + 64);
|
|
35301
35730
|
const count = number3();
|
|
35302
|
-
|
|
35731
|
+
comdatWriter.uleb(count);
|
|
35303
35732
|
for (let i = 0; i < count; i++) {
|
|
35304
35733
|
const group = string7();
|
|
35305
35734
|
const begin = offset;
|
|
35306
35735
|
number3();
|
|
35307
35736
|
const members2 = number3();
|
|
35308
35737
|
for (let member = 0; member < members2 * 2; member++) number3();
|
|
35309
|
-
|
|
35310
|
-
|
|
35311
|
-
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
35312
|
-
),
|
|
35313
|
-
section2.subarray(begin, offset)
|
|
35738
|
+
comdatWriter.string(
|
|
35739
|
+
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
35314
35740
|
);
|
|
35741
|
+
comdatWriter.bytes(bytes, begin, offset);
|
|
35315
35742
|
}
|
|
35316
35743
|
if (offset !== stop) throw new Error("invalid comdat subsection");
|
|
35317
|
-
|
|
35318
|
-
|
|
35319
|
-
if (kind === 8) {
|
|
35320
|
-
const
|
|
35321
|
-
|
|
35744
|
+
const buf = comdatWriter.finish();
|
|
35745
|
+
subsections.push({ kind, parts: [buf], byteLength: buf.length });
|
|
35746
|
+
} else if (kind === 8) {
|
|
35747
|
+
const entryWriter = rewrite ? new ByteWriter(length + 128) : void 0;
|
|
35748
|
+
let extraWriter;
|
|
35322
35749
|
const count = number3();
|
|
35323
|
-
entries2.push(encodeNumber(count));
|
|
35324
35750
|
let added = 0;
|
|
35325
35751
|
for (let i = 0; i < count; i++) {
|
|
35326
35752
|
const begin = offset;
|
|
35327
|
-
const symbolKind =
|
|
35753
|
+
const symbolKind = bytes[offset++];
|
|
35328
35754
|
const flags = number3();
|
|
35329
35755
|
const flagsEnd = offset;
|
|
35330
35756
|
let index = -1;
|
|
@@ -35352,25 +35778,43 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35352
35778
|
}
|
|
35353
35779
|
} else if (symbolKind === 3) number3();
|
|
35354
35780
|
else throw new Error("unsupported wasm symbol kind");
|
|
35355
|
-
if (symbolKind === 0)
|
|
35781
|
+
if (!rewrite && symbolKind === 0)
|
|
35356
35782
|
functionSymbols[i] = name3 || functionImportNames[index];
|
|
35357
|
-
if (!sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
35783
|
+
if (rewrite && !sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
35358
35784
|
objcLoader = i;
|
|
35359
35785
|
}
|
|
35360
35786
|
const alias = names.get(name3);
|
|
35361
|
-
if (flags & 16 && symbolKind === 1 && alias)
|
|
35362
|
-
|
|
35363
|
-
|
|
35364
|
-
|
|
35365
|
-
|
|
35366
|
-
|
|
35367
|
-
|
|
35368
|
-
|
|
35369
|
-
|
|
35370
|
-
|
|
35371
|
-
|
|
35372
|
-
|
|
35373
|
-
|
|
35787
|
+
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
35788
|
+
usedSymbols.add(name3);
|
|
35789
|
+
if (entryWriter && binding) {
|
|
35790
|
+
if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
35791
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
35792
|
+
entryWriter.string(name3 === "dlsym" ? callerAlias : dlerrorAlias);
|
|
35793
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
35794
|
+
} else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
|
|
35795
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
35796
|
+
entryWriter.string(binding(name3));
|
|
35797
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
35798
|
+
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
35799
|
+
if (symbolKind !== 0 && symbolKind !== 1)
|
|
35800
|
+
throw new Error(`unsupported symbol ${name3}`);
|
|
35801
|
+
if (preserveCanonical.has(name3)) {
|
|
35802
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
35803
|
+
extraWriter ??= new ByteWriter(256);
|
|
35804
|
+
extraWriter.byte(bytes[begin]);
|
|
35805
|
+
extraWriter.uleb(flags & ~32);
|
|
35806
|
+
extraWriter.bytes(bytes, flagsEnd, nameStart);
|
|
35807
|
+
extraWriter.string(alias);
|
|
35808
|
+
extraWriter.bytes(bytes, nameEnd, offset);
|
|
35809
|
+
added++;
|
|
35810
|
+
} else {
|
|
35811
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
35812
|
+
entryWriter.string(alias);
|
|
35813
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
35814
|
+
}
|
|
35815
|
+
} else {
|
|
35816
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
35817
|
+
}
|
|
35374
35818
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
35375
35819
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
35376
35820
|
throw new Error(`unsupported symbol ${name3}`);
|
|
@@ -35384,63 +35828,73 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35384
35828
|
hidden: (flags & 4) !== 0,
|
|
35385
35829
|
type
|
|
35386
35830
|
});
|
|
35387
|
-
|
|
35388
|
-
entries2.push(section2.subarray(begin, offset));
|
|
35389
|
-
extraEntries.push(
|
|
35390
|
-
section2.subarray(begin, begin + 1),
|
|
35391
|
-
encodeNumber(flags & ~32),
|
|
35392
|
-
section2.subarray(flagsEnd, nameStart),
|
|
35393
|
-
encodedString(alias),
|
|
35394
|
-
section2.subarray(nameEnd, offset)
|
|
35395
|
-
);
|
|
35396
|
-
added++;
|
|
35397
|
-
} else {
|
|
35398
|
-
entries2.push(
|
|
35399
|
-
section2.subarray(begin, nameStart),
|
|
35400
|
-
encodedString(alias),
|
|
35401
|
-
section2.subarray(nameEnd, offset)
|
|
35402
|
-
);
|
|
35403
|
-
}
|
|
35404
|
-
} else entries2.push(section2.subarray(begin, offset));
|
|
35831
|
+
}
|
|
35405
35832
|
}
|
|
35406
35833
|
if (offset !== stop) throw new Error("invalid symbol subsection");
|
|
35407
|
-
|
|
35408
|
-
|
|
35834
|
+
if (entryWriter) {
|
|
35835
|
+
const countBytes = encodeNumber(count + added);
|
|
35836
|
+
const entryBuf = entryWriter.finish();
|
|
35837
|
+
if (extraWriter) {
|
|
35838
|
+
const extraBuf = extraWriter.finish();
|
|
35839
|
+
subsections.push({
|
|
35840
|
+
kind,
|
|
35841
|
+
parts: [countBytes, entryBuf, extraBuf],
|
|
35842
|
+
byteLength: countBytes.length + entryBuf.length + extraBuf.length
|
|
35843
|
+
});
|
|
35844
|
+
} else {
|
|
35845
|
+
subsections.push({
|
|
35846
|
+
kind,
|
|
35847
|
+
parts: [countBytes, entryBuf],
|
|
35848
|
+
byteLength: countBytes.length + entryBuf.length
|
|
35849
|
+
});
|
|
35850
|
+
}
|
|
35851
|
+
}
|
|
35852
|
+
} else if (subsections) {
|
|
35853
|
+
subsections.push({
|
|
35854
|
+
kind,
|
|
35855
|
+
parts: [bytes.subarray(contentStart, stop)],
|
|
35856
|
+
byteLength: length
|
|
35857
|
+
});
|
|
35409
35858
|
}
|
|
35410
35859
|
offset = stop;
|
|
35411
|
-
|
|
35412
|
-
|
|
35413
|
-
|
|
35414
|
-
|
|
35415
|
-
|
|
35416
|
-
|
|
35417
|
-
|
|
35418
|
-
|
|
35419
|
-
|
|
35420
|
-
|
|
35421
|
-
|
|
35422
|
-
|
|
35423
|
-
|
|
35424
|
-
|
|
35425
|
-
content
|
|
35426
|
-
|
|
35427
|
-
|
|
35428
|
-
|
|
35429
|
-
|
|
35430
|
-
|
|
35860
|
+
}
|
|
35861
|
+
if (subsections) {
|
|
35862
|
+
const linkingWriter = new ByteWriter(size2 + 128);
|
|
35863
|
+
linkingWriter.string(sectionName);
|
|
35864
|
+
linkingWriter.uleb(version2);
|
|
35865
|
+
for (const subsection of subsections) {
|
|
35866
|
+
if (subsection.kind === 6 && objcLoader !== void 0) {
|
|
35867
|
+
const content = subsection.parts[0];
|
|
35868
|
+
const [count, entriesStart] = readNumber(content, 0);
|
|
35869
|
+
const initWriter = new ByteWriter(content.length + 16);
|
|
35870
|
+
initWriter.bytes(content, 0, entriesStart);
|
|
35871
|
+
let entryStart = entriesStart;
|
|
35872
|
+
for (let i = 0; i < count; i++) {
|
|
35873
|
+
const [, symbolStart] = readNumber(content, entryStart);
|
|
35874
|
+
const [symbol2, entryEnd] = readNumber(content, symbolStart);
|
|
35875
|
+
if (symbol2 === objcLoader) {
|
|
35876
|
+
initWriter.uleb(1);
|
|
35877
|
+
initWriter.bytes(content, symbolStart, entryEnd);
|
|
35878
|
+
} else {
|
|
35879
|
+
initWriter.bytes(content, entryStart, entryEnd);
|
|
35880
|
+
}
|
|
35881
|
+
entryStart = entryEnd;
|
|
35882
|
+
}
|
|
35883
|
+
if (entryStart !== content.length)
|
|
35884
|
+
throw new Error("invalid init functions subsection");
|
|
35885
|
+
const initBuf = initWriter.finish();
|
|
35886
|
+
linkingWriter.byte(subsection.kind);
|
|
35887
|
+
linkingWriter.uleb(initBuf.length);
|
|
35888
|
+
linkingWriter.bytes(initBuf);
|
|
35889
|
+
} else {
|
|
35890
|
+
linkingWriter.byte(subsection.kind);
|
|
35891
|
+
linkingWriter.uleb(subsection.byteLength);
|
|
35892
|
+
for (const part of subsection.parts) linkingWriter.bytes(part);
|
|
35431
35893
|
}
|
|
35432
|
-
if (entryStart !== content.length)
|
|
35433
|
-
throw new Error("invalid init functions subsection");
|
|
35434
|
-
content = Buffer.concat(entries2);
|
|
35435
35894
|
}
|
|
35436
|
-
|
|
35437
|
-
Buffer.from([subsection.kind]),
|
|
35438
|
-
encodeNumber(content.length),
|
|
35439
|
-
content
|
|
35440
|
-
);
|
|
35895
|
+
rewrittenSection = linkingWriter.finish();
|
|
35441
35896
|
}
|
|
35442
|
-
|
|
35443
|
-
} else if (!sections && sectionName.startsWith("reloc.")) {
|
|
35897
|
+
} else if (!rewrite && sectionName.startsWith("reloc.")) {
|
|
35444
35898
|
number3();
|
|
35445
35899
|
for (let count = number3(); count > 0; count--) {
|
|
35446
35900
|
const type = number3();
|
|
@@ -35450,18 +35904,27 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35450
35904
|
if (name3 !== void 0 && TABLE_INDEX_RELOCATIONS.has(type))
|
|
35451
35905
|
addressTaken.add(name3);
|
|
35452
35906
|
}
|
|
35453
|
-
if (offset !==
|
|
35454
|
-
|
|
35907
|
+
if (offset !== end) throw new Error(`invalid relocation section ${sectionName}`);
|
|
35908
|
+
}
|
|
35909
|
+
}
|
|
35910
|
+
if (sections) {
|
|
35911
|
+
if (rewrittenSection) {
|
|
35912
|
+
sections.push(
|
|
35913
|
+
Buffer.from([id]),
|
|
35914
|
+
encodeNumber(rewrittenSection.length),
|
|
35915
|
+
rewrittenSection
|
|
35916
|
+
);
|
|
35917
|
+
} else {
|
|
35918
|
+
sections.push(bytes.subarray(headerStart2, end));
|
|
35455
35919
|
}
|
|
35456
35920
|
}
|
|
35457
|
-
sections?.push(Buffer.from([id]), encodeNumber(section2.length), section2);
|
|
35458
35921
|
}
|
|
35459
35922
|
return {
|
|
35460
35923
|
bytes: sections ? Buffer.concat(sections) : bytes,
|
|
35461
35924
|
definitions,
|
|
35462
35925
|
functionImports,
|
|
35463
35926
|
usesDlsym,
|
|
35464
|
-
usedSymbols
|
|
35927
|
+
usedSymbols,
|
|
35465
35928
|
addressTaken: [...addressTaken]
|
|
35466
35929
|
};
|
|
35467
35930
|
}
|
|
@@ -35550,36 +36013,51 @@ function createGuestImageLedger(input) {
|
|
|
35550
36013
|
}
|
|
35551
36014
|
}
|
|
35552
36015
|
}
|
|
35553
|
-
|
|
35554
|
-
for (const definition2 of definitions)
|
|
35555
|
-
|
|
35556
|
-
|
|
35557
|
-
|
|
35558
|
-
|
|
35559
|
-
|
|
36016
|
+
let hasNonAscii = false;
|
|
36017
|
+
for (const definition2 of definitions) {
|
|
36018
|
+
const s = definition2.name;
|
|
36019
|
+
for (let i = 0; i < s.length; i++) {
|
|
36020
|
+
if (s.charCodeAt(i) > 127) {
|
|
36021
|
+
hasNonAscii = true;
|
|
36022
|
+
break;
|
|
36023
|
+
}
|
|
36024
|
+
}
|
|
36025
|
+
if (hasNonAscii) break;
|
|
36026
|
+
}
|
|
36027
|
+
if (hasNonAscii) {
|
|
36028
|
+
const nameBytes = /* @__PURE__ */ new Map();
|
|
36029
|
+
for (const definition2 of definitions)
|
|
36030
|
+
if (!nameBytes.has(definition2.name))
|
|
36031
|
+
nameBytes.set(definition2.name, Buffer.from(definition2.name));
|
|
36032
|
+
definitions.sort(
|
|
36033
|
+
(a, b) => Buffer.compare(nameBytes.get(a.name), nameBytes.get(b.name)) || a.image - b.image
|
|
36034
|
+
);
|
|
36035
|
+
} else {
|
|
36036
|
+
definitions.sort(
|
|
36037
|
+
(a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : a.image - b.image
|
|
36038
|
+
);
|
|
36039
|
+
}
|
|
35560
36040
|
const preserveCanonical = /* @__PURE__ */ new Set();
|
|
35561
36041
|
const definitionsByName = Map.groupBy(definitions, (definition2) => definition2.name);
|
|
35562
|
-
|
|
36042
|
+
if (symbolIndices.has("__cxa_throw")) {
|
|
36043
|
+
const name3 = "__cxa_throw";
|
|
35563
36044
|
const matching = definitionsByName.get(name3) ?? [];
|
|
35564
|
-
if (new Set(matching.map((definition2) => definition2.image)).size
|
|
35565
|
-
|
|
35566
|
-
|
|
35567
|
-
|
|
35568
|
-
|
|
35569
|
-
|
|
35570
|
-
|
|
35571
|
-
|
|
35572
|
-
|
|
35573
|
-
|
|
35574
|
-
|
|
35575
|
-
|
|
35576
|
-
|
|
35577
|
-
|
|
35578
|
-
);
|
|
35579
|
-
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
35580
|
-
throw new Error(`weak interposition scope excludes runtime for ${name3}`);
|
|
36045
|
+
if (new Set(matching.map((definition2) => definition2.image)).size >= 2 && matching.some((definition2) => definition2.weak)) {
|
|
36046
|
+
const weak = matching.filter((definition2) => definition2.weak);
|
|
36047
|
+
const strong = matching.filter((definition2) => !definition2.weak);
|
|
36048
|
+
if (weak.length !== 1 || strong.length !== 1)
|
|
36049
|
+
throw new Error(`unsupported weak interposition for ${name3}`);
|
|
36050
|
+
const [local] = weak;
|
|
36051
|
+
const [runtime] = strong;
|
|
36052
|
+
if (local.kind !== "function" || runtime.kind !== "function" || local.result !== runtime.result || local.parameters.join(",") !== runtime.parameters.join(","))
|
|
36053
|
+
throw new Error(`incompatible weak interposition for ${name3}`);
|
|
36054
|
+
for (const caller of input.callers) {
|
|
36055
|
+
const uses = caller.image === local.image || units.some((unit2) => unit2.image === caller.image && unit2.usedSymbols.has(name3));
|
|
36056
|
+
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
36057
|
+
throw new Error(`weak interposition scope excludes runtime for ${name3}`);
|
|
36058
|
+
}
|
|
36059
|
+
preserveCanonical.add(name3);
|
|
35581
36060
|
}
|
|
35582
|
-
preserveCanonical.add(name3);
|
|
35583
36061
|
}
|
|
35584
36062
|
for (const name3 of [
|
|
35585
36063
|
"dlsym",
|
|
@@ -35591,40 +36069,76 @@ function createGuestImageLedger(input) {
|
|
|
35591
36069
|
])
|
|
35592
36070
|
preserveCanonical.add(name3);
|
|
35593
36071
|
for (const name3 of input.commandLineSymbols ?? []) preserveCanonical.add(name3);
|
|
35594
|
-
const
|
|
35595
|
-
const
|
|
36072
|
+
const imageAliases = /* @__PURE__ */ new Map();
|
|
36073
|
+
const imageWeakNames = /* @__PURE__ */ new Map();
|
|
36074
|
+
const singleOwnerByName = /* @__PURE__ */ new Map();
|
|
36075
|
+
for (const definition2 of definitions) {
|
|
36076
|
+
let aliases = imageAliases.get(definition2.image);
|
|
36077
|
+
if (!aliases) imageAliases.set(definition2.image, aliases = /* @__PURE__ */ new Map());
|
|
36078
|
+
const existing = aliases.get(definition2.name);
|
|
36079
|
+
if (existing === void 0) {
|
|
36080
|
+
aliases.set(definition2.name, definition2.alias);
|
|
36081
|
+
if (definition2.weak) {
|
|
36082
|
+
let weak = imageWeakNames.get(definition2.image);
|
|
36083
|
+
if (!weak) imageWeakNames.set(definition2.image, weak = /* @__PURE__ */ new Set());
|
|
36084
|
+
weak.add(definition2.name);
|
|
36085
|
+
}
|
|
36086
|
+
const owner = singleOwnerByName.get(definition2.name);
|
|
36087
|
+
if (owner === void 0)
|
|
36088
|
+
singleOwnerByName.set(definition2.name, {
|
|
36089
|
+
image: definition2.image,
|
|
36090
|
+
alias: definition2.alias
|
|
36091
|
+
});
|
|
36092
|
+
else if (owner !== null && owner.image !== definition2.image)
|
|
36093
|
+
singleOwnerByName.set(definition2.name, null);
|
|
36094
|
+
} else if (!definition2.weak && imageWeakNames.get(definition2.image)?.has(definition2.name)) {
|
|
36095
|
+
aliases.set(definition2.name, definition2.alias);
|
|
36096
|
+
imageWeakNames.get(definition2.image).delete(definition2.name);
|
|
36097
|
+
const owner = singleOwnerByName.get(definition2.name);
|
|
36098
|
+
if (owner && owner.image === definition2.image) owner.alias = definition2.alias;
|
|
36099
|
+
}
|
|
36100
|
+
}
|
|
36101
|
+
const sharedLookupByImage = /* @__PURE__ */ new Map();
|
|
35596
36102
|
for (const caller of input.callers) {
|
|
35597
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
35598
|
-
const seen = /* @__PURE__ */ new Map();
|
|
35599
36103
|
const scope2 = [caller.image, ...caller.next];
|
|
35600
36104
|
if (input.systemImage !== void 0 && !scope2.includes(input.systemImage))
|
|
35601
36105
|
scope2.push(input.systemImage);
|
|
35602
|
-
|
|
35603
|
-
|
|
35604
|
-
|
|
35605
|
-
|
|
35606
|
-
|
|
35607
|
-
|
|
35608
|
-
|
|
35609
|
-
|
|
35610
|
-
|
|
35611
|
-
|
|
35612
|
-
|
|
35613
|
-
|
|
35614
|
-
|
|
35615
|
-
|
|
35616
|
-
|
|
36106
|
+
const scopeSet = new Set(scope2);
|
|
36107
|
+
const scopeMaps = [];
|
|
36108
|
+
const seenImages = /* @__PURE__ */ new Set();
|
|
36109
|
+
for (const image of scope2) {
|
|
36110
|
+
if (seenImages.has(image)) continue;
|
|
36111
|
+
seenImages.add(image);
|
|
36112
|
+
const aliases = imageAliases.get(image);
|
|
36113
|
+
if (aliases) scopeMaps.push(aliases);
|
|
36114
|
+
}
|
|
36115
|
+
const cache = /* @__PURE__ */ new Map();
|
|
36116
|
+
sharedLookupByImage.set(caller.image, (name3) => {
|
|
36117
|
+
if (preserveCanonical.has(name3)) return void 0;
|
|
36118
|
+
const single = singleOwnerByName.get(name3);
|
|
36119
|
+
if (single === void 0) return void 0;
|
|
36120
|
+
if (single !== null) return scopeSet.has(single.image) ? single.alias : void 0;
|
|
36121
|
+
const hit = cache.get(name3);
|
|
36122
|
+
if (hit !== void 0) return hit ?? void 0;
|
|
36123
|
+
for (const aliases of scopeMaps) {
|
|
36124
|
+
const alias = aliases.get(name3);
|
|
36125
|
+
if (alias !== void 0) {
|
|
36126
|
+
cache.set(name3, alias);
|
|
36127
|
+
return alias;
|
|
35617
36128
|
}
|
|
35618
36129
|
}
|
|
35619
|
-
|
|
36130
|
+
cache.set(name3, null);
|
|
36131
|
+
return void 0;
|
|
36132
|
+
});
|
|
35620
36133
|
}
|
|
35621
36134
|
const startup = /* @__PURE__ */ new Map();
|
|
36135
|
+
const unitsByPath = new Map(units.map((unit2) => [unit2.object.path, unit2]));
|
|
35622
36136
|
for (const binding of input.directBindings ?? []) {
|
|
35623
|
-
const unit2 =
|
|
36137
|
+
const unit2 = unitsByPath.get(binding.object);
|
|
35624
36138
|
const matches = (definitionsByName.get(binding.symbol) ?? []).filter(
|
|
35625
36139
|
(definition2) => definition2.object === binding.providerObject && definition2.image === binding.providerImage
|
|
35626
36140
|
);
|
|
35627
|
-
if (!unit2 || !unit2.usedSymbols.
|
|
36141
|
+
if (!unit2 || !unit2.usedSymbols.has(binding.symbol) || matches.length !== 1)
|
|
35628
36142
|
throw new Error(`invalid startup binding ${binding.object} ${binding.symbol}`);
|
|
35629
36143
|
const bindings = startup.get(binding.object) ?? /* @__PURE__ */ new Map();
|
|
35630
36144
|
if (bindings.has(binding.symbol))
|
|
@@ -35665,11 +36179,11 @@ function createGuestImageLedger(input) {
|
|
|
35665
36179
|
}
|
|
35666
36180
|
}
|
|
35667
36181
|
const objects = units.map(({ image, object: object7, aliases, functionImports }) => {
|
|
35668
|
-
const shared =
|
|
36182
|
+
const shared = sharedLookupByImage.get(image);
|
|
35669
36183
|
const own2 = startup.get(object7.path);
|
|
35670
36184
|
const bindings = new Map(own2);
|
|
35671
36185
|
const weak = input.sdkWeakReferences?.get(object7.path);
|
|
35672
|
-
const binding = (name3) => bindings.get(name3) ?? shared
|
|
36186
|
+
const binding = (name3) => bindings.get(name3) ?? shared(name3) ?? (weak?.has(name3) ? void 0 : sdkGlobalBindings.get(name3));
|
|
35673
36187
|
for (const [name3, type] of functionImports) {
|
|
35674
36188
|
const alias = binding(name3);
|
|
35675
36189
|
const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
|
|
@@ -35934,7 +36448,7 @@ function nameGuestImageAliases(wasm, symbols) {
|
|
|
35934
36448
|
}
|
|
35935
36449
|
return Buffer.concat(parts);
|
|
35936
36450
|
}
|
|
35937
|
-
var import_node_crypto26, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
36451
|
+
var import_node_crypto26, ByteWriter, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
35938
36452
|
var init_swift_guest_image_ledger = __esm({
|
|
35939
36453
|
"src/swift-guest-image-ledger.ts"() {
|
|
35940
36454
|
"use strict";
|
|
@@ -35942,6 +36456,57 @@ var init_swift_guest_image_ledger = __esm({
|
|
|
35942
36456
|
init_nativeWasmContract();
|
|
35943
36457
|
init_swift_sdk_image_wasm();
|
|
35944
36458
|
init_swiftSdkLinkContract();
|
|
36459
|
+
ByteWriter = class {
|
|
36460
|
+
buf;
|
|
36461
|
+
pos = 0;
|
|
36462
|
+
constructor(initialCapacity = 256) {
|
|
36463
|
+
this.buf = Buffer.allocUnsafe(Math.max(64, initialCapacity));
|
|
36464
|
+
}
|
|
36465
|
+
ensure(extra) {
|
|
36466
|
+
const needed = this.pos + extra;
|
|
36467
|
+
if (needed <= this.buf.length) return;
|
|
36468
|
+
let next = this.buf.length * 2;
|
|
36469
|
+
while (next < needed) next *= 2;
|
|
36470
|
+
const grown = Buffer.allocUnsafe(next);
|
|
36471
|
+
this.buf.copy(grown, 0, 0, this.pos);
|
|
36472
|
+
this.buf = grown;
|
|
36473
|
+
}
|
|
36474
|
+
byte(value) {
|
|
36475
|
+
this.ensure(1);
|
|
36476
|
+
this.buf[this.pos++] = value;
|
|
36477
|
+
}
|
|
36478
|
+
uleb(value) {
|
|
36479
|
+
this.ensure(10);
|
|
36480
|
+
let pos = this.pos;
|
|
36481
|
+
const buf = this.buf;
|
|
36482
|
+
do {
|
|
36483
|
+
let byte = value % 128;
|
|
36484
|
+
value = Math.floor(value / 128);
|
|
36485
|
+
if (value) byte |= 128;
|
|
36486
|
+
buf[pos++] = byte;
|
|
36487
|
+
} while (value);
|
|
36488
|
+
this.pos = pos;
|
|
36489
|
+
}
|
|
36490
|
+
bytes(source, start = 0, end = source.length) {
|
|
36491
|
+
const len = end - start;
|
|
36492
|
+
if (len <= 0) return;
|
|
36493
|
+
this.ensure(len);
|
|
36494
|
+
this.buf.set(source.subarray(start, end), this.pos);
|
|
36495
|
+
this.pos += len;
|
|
36496
|
+
}
|
|
36497
|
+
string(value) {
|
|
36498
|
+
const len = Buffer.byteLength(value, "utf8");
|
|
36499
|
+
this.uleb(len);
|
|
36500
|
+
if (len > 0) {
|
|
36501
|
+
this.ensure(len);
|
|
36502
|
+
this.buf.write(value, this.pos, len, "utf8");
|
|
36503
|
+
this.pos += len;
|
|
36504
|
+
}
|
|
36505
|
+
}
|
|
36506
|
+
finish() {
|
|
36507
|
+
return this.buf.subarray(0, this.pos);
|
|
36508
|
+
}
|
|
36509
|
+
};
|
|
35945
36510
|
OBJC_INIT_RECORD = ".objc_init";
|
|
35946
36511
|
TABLE_INDEX_RELOCATIONS = /* @__PURE__ */ new Set([1, 2, 12, 18, 19, 24]);
|
|
35947
36512
|
GUEST_DYLD_VALUES_SECTION = "peach_dyld_values";
|
|
@@ -36393,8 +36958,11 @@ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
36393
36958
|
function guestDyldValueRange(map2) {
|
|
36394
36959
|
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
36395
36960
|
let found;
|
|
36396
|
-
for (
|
|
36397
|
-
|
|
36961
|
+
for (let at = map2.indexOf(suffix); at !== -1; at = map2.indexOf(suffix, at + suffix.length)) {
|
|
36962
|
+
const lineEnd = at + suffix.length;
|
|
36963
|
+
if (lineEnd < map2.length && map2.charCodeAt(lineEnd) !== 10) continue;
|
|
36964
|
+
const lineStart = map2.lastIndexOf("\n", at) + 1;
|
|
36965
|
+
const line = map2.slice(lineStart, lineEnd);
|
|
36398
36966
|
const match = /^\s*([\da-f]+)\s+[\da-f]+\s+([\da-f]+)\s/.exec(line);
|
|
36399
36967
|
if (!match) throw new Error("unreadable dyld values map line");
|
|
36400
36968
|
if (found) throw new Error("link map has several dyld value sections");
|
|
@@ -36447,7 +37015,7 @@ var init_swift_guest_link_plan = __esm({
|
|
|
36447
37015
|
});
|
|
36448
37016
|
|
|
36449
37017
|
// src/swift-guest-manifest.ts
|
|
36450
|
-
function selectedGuestManifestInputs(plan, selection, identities) {
|
|
37018
|
+
function selectedGuestManifestInputs(plan, selection, identities, readSelected) {
|
|
36451
37019
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
36452
37020
|
const archives = /* @__PURE__ */ new Map();
|
|
36453
37021
|
const images = /* @__PURE__ */ new Map();
|
|
@@ -36458,19 +37026,29 @@ function selectedGuestManifestInputs(plan, selection, identities) {
|
|
|
36458
37026
|
throw new Error(`selected input has no logical identity: ${item.artifact}`);
|
|
36459
37027
|
let bytes;
|
|
36460
37028
|
let memberIdentity = null;
|
|
36461
|
-
if (item.member === null)
|
|
36462
|
-
|
|
36463
|
-
|
|
36464
|
-
if (
|
|
36465
|
-
|
|
36466
|
-
|
|
37029
|
+
if (item.member === null) {
|
|
37030
|
+
bytes = readSelected ? readSelected(item) : (0, import_node_fs46.readFileSync)(item.artifact);
|
|
37031
|
+
} else {
|
|
37032
|
+
if (readSelected) {
|
|
37033
|
+
bytes = readSelected(item);
|
|
37034
|
+
} else {
|
|
37035
|
+
let members2 = archives.get(item.artifact);
|
|
37036
|
+
if (!members2) {
|
|
37037
|
+
members2 = /* @__PURE__ */ new Map();
|
|
37038
|
+
for (const member of readArMembers((0, import_node_fs46.readFileSync)(item.artifact))) {
|
|
37039
|
+
let list2 = members2.get(member.name);
|
|
37040
|
+
if (!list2) members2.set(member.name, list2 = []);
|
|
37041
|
+
list2.push(member.bytes);
|
|
37042
|
+
}
|
|
37043
|
+
archives.set(item.artifact, members2);
|
|
37044
|
+
}
|
|
37045
|
+
const matching = members2.get(item.member);
|
|
37046
|
+
if (!matching || matching.length !== 1)
|
|
37047
|
+
throw new Error(
|
|
37048
|
+
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
37049
|
+
);
|
|
37050
|
+
bytes = matching[0];
|
|
36467
37051
|
}
|
|
36468
|
-
const matching = members2.filter((member) => member.name === item.member);
|
|
36469
|
-
if (matching.length !== 1)
|
|
36470
|
-
throw new Error(
|
|
36471
|
-
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
36472
|
-
);
|
|
36473
|
-
bytes = matching[0].bytes;
|
|
36474
37052
|
const origin = artifact.memberOrigins?.get(item.member);
|
|
36475
37053
|
if (artifact.memberOrigins && !origin)
|
|
36476
37054
|
throw new Error(
|
|
@@ -36562,7 +37140,7 @@ var init_swift_guest_manifest = __esm({
|
|
|
36562
37140
|
function isSwiftGuestImageManifest(value) {
|
|
36563
37141
|
const uint = (value2, maximum) => typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 && value2 <= maximum;
|
|
36564
37142
|
const text7 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
36565
|
-
const name3 = (value2) => text7(value2) &&
|
|
37143
|
+
const name3 = (value2) => text7(value2) && Buffer.byteLength(value2, "utf8") <= 16;
|
|
36566
37144
|
const version2 = (value2) => isRecord(value2) && uint(value2.major, 65535) && uint(value2.minor, 255) && uint(value2.patch, 255);
|
|
36567
37145
|
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))
|
|
36568
37146
|
return false;
|
|
@@ -36876,27 +37454,25 @@ function planGuestProjectionRegions(images, capacities, spans) {
|
|
|
36876
37454
|
function finalizeGuestProjectionStorage(options2) {
|
|
36877
37455
|
const owner = options2.owners.get(options2.projectionObject);
|
|
36878
37456
|
if (owner === void 0) throw new Error("guest projection object has no image owner");
|
|
37457
|
+
const ranges = [];
|
|
36879
37458
|
const spans = guestLinkedSpans(
|
|
36880
37459
|
options2.map,
|
|
36881
37460
|
options2.linked,
|
|
36882
37461
|
options2.optimized,
|
|
36883
37462
|
options2.owners,
|
|
36884
37463
|
options2.sectionOwners,
|
|
36885
|
-
options2.sdkSpans !== void 0
|
|
37464
|
+
options2.sdkSpans !== void 0,
|
|
37465
|
+
{
|
|
37466
|
+
trackedObject: options2.projectionObject,
|
|
37467
|
+
trackedObjectOwner: owner,
|
|
37468
|
+
trackedLinearSpans: ranges
|
|
37469
|
+
}
|
|
36886
37470
|
);
|
|
36887
37471
|
const images = planGuestProjectionRegions(
|
|
36888
37472
|
options2.reserved.images,
|
|
36889
37473
|
options2.reserved.capacities,
|
|
36890
37474
|
options2.sdkSpans ? [...spans, ...options2.sdkSpans] : spans
|
|
36891
37475
|
);
|
|
36892
|
-
const ranges = guestLinkedSpans(
|
|
36893
|
-
options2.map,
|
|
36894
|
-
options2.linked,
|
|
36895
|
-
options2.optimized,
|
|
36896
|
-
/* @__PURE__ */ new Map([[options2.projectionObject, owner]]),
|
|
36897
|
-
void 0,
|
|
36898
|
-
options2.sdkSpans !== void 0
|
|
36899
|
-
).filter((span) => span.space === "linear-memory");
|
|
36900
37476
|
const result = Buffer.from(options2.optimized);
|
|
36901
37477
|
const data = guestWasmDataSegments(options2.optimized, options2.sdkSpans === void 0);
|
|
36902
37478
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -37964,7 +38540,7 @@ function occurrences(plan, args) {
|
|
|
37964
38540
|
throw new Error("guest plan does not match linker inputs");
|
|
37965
38541
|
return found;
|
|
37966
38542
|
}
|
|
37967
|
-
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
38543
|
+
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace, archiveCache) {
|
|
37968
38544
|
const rows = whyExtract.trimEnd().split("\n");
|
|
37969
38545
|
if (rows.shift() !== "reference extracted symbol")
|
|
37970
38546
|
throw new Error("invalid wasm-ld extraction report");
|
|
@@ -37979,8 +38555,38 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
37979
38555
|
for (const file of extracted)
|
|
37980
38556
|
if (!traced.has(file))
|
|
37981
38557
|
throw new Error(`extracted guest input is absent from link trace ${file}`);
|
|
38558
|
+
const foundOccurrences = occurrences(plan, args);
|
|
38559
|
+
const archivePaths = /* @__PURE__ */ new Set();
|
|
38560
|
+
for (const { artifact } of foundOccurrences)
|
|
38561
|
+
if (artifact.kind === "archive") archivePaths.add(artifact.path);
|
|
38562
|
+
const tracedMembers = /* @__PURE__ */ new Map();
|
|
38563
|
+
if (archivePaths.size > 0) {
|
|
38564
|
+
const archivePrefixes = [...archivePaths].map(
|
|
38565
|
+
(archivePath) => [archivePath, `${archivePath}(`]
|
|
38566
|
+
);
|
|
38567
|
+
for (const item of traced) {
|
|
38568
|
+
if (!item.endsWith(")")) continue;
|
|
38569
|
+
const open = item.lastIndexOf("(");
|
|
38570
|
+
if (open > 0) {
|
|
38571
|
+
const archivePath = item.slice(0, open);
|
|
38572
|
+
if (archivePaths.has(archivePath)) {
|
|
38573
|
+
let list2 = tracedMembers.get(archivePath);
|
|
38574
|
+
if (!list2) tracedMembers.set(archivePath, list2 = []);
|
|
38575
|
+
list2.push(item.slice(open + 1, -1));
|
|
38576
|
+
continue;
|
|
38577
|
+
}
|
|
38578
|
+
}
|
|
38579
|
+
for (const [archivePath, prefix] of archivePrefixes) {
|
|
38580
|
+
if (item.startsWith(prefix)) {
|
|
38581
|
+
let list2 = tracedMembers.get(archivePath);
|
|
38582
|
+
if (!list2) tracedMembers.set(archivePath, list2 = []);
|
|
38583
|
+
list2.push(item.slice(prefix.length, -1));
|
|
38584
|
+
}
|
|
38585
|
+
}
|
|
38586
|
+
}
|
|
38587
|
+
}
|
|
37982
38588
|
const result = [];
|
|
37983
|
-
for (const { artifact, lazy, whole } of
|
|
38589
|
+
for (const { artifact, lazy, whole } of foundOccurrences) {
|
|
37984
38590
|
if (artifact.kind === "object") {
|
|
37985
38591
|
if (!lazy && !traced.has(artifact.path))
|
|
37986
38592
|
throw new Error(`eager guest input is absent from link trace ${artifact.path}`);
|
|
@@ -37988,15 +38594,21 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
37988
38594
|
result.push({ artifact: artifact.path, member: null });
|
|
37989
38595
|
continue;
|
|
37990
38596
|
}
|
|
37991
|
-
const
|
|
37992
|
-
const
|
|
37993
|
-
|
|
38597
|
+
const names = tracedMembers.get(artifact.path) ?? [];
|
|
38598
|
+
const nameSet = new Set(names);
|
|
38599
|
+
let members2 = archiveCache?.get(artifact.path);
|
|
38600
|
+
if (!members2) {
|
|
38601
|
+
members2 = readArMembers(import_node_fs49.default.readFileSync(artifact.path));
|
|
38602
|
+
archiveCache?.set(artifact.path, members2);
|
|
38603
|
+
}
|
|
38604
|
+
const memberCounts = /* @__PURE__ */ new Map();
|
|
37994
38605
|
for (const member of members2) {
|
|
37995
|
-
|
|
38606
|
+
memberCounts.set(member.name, (memberCounts.get(member.name) ?? 0) + 1);
|
|
38607
|
+
if (whole || nameSet.has(member.name))
|
|
37996
38608
|
result.push({ artifact: artifact.path, member: member.name });
|
|
37997
38609
|
}
|
|
37998
38610
|
for (const name3 of names)
|
|
37999
|
-
if (
|
|
38611
|
+
if (memberCounts.get(name3) !== 1)
|
|
38000
38612
|
throw new Error(
|
|
38001
38613
|
`ambiguous or unsupported archive member ${artifact.path}(${name3})`
|
|
38002
38614
|
);
|
|
@@ -38073,14 +38685,25 @@ function linkGuestImages(options2) {
|
|
|
38073
38685
|
}
|
|
38074
38686
|
const archives = /* @__PURE__ */ new Map();
|
|
38075
38687
|
const memberBytes = /* @__PURE__ */ new Map();
|
|
38688
|
+
const objectBytes = /* @__PURE__ */ new Map();
|
|
38076
38689
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
38077
38690
|
const providerSymbol = "__peach_dlsym_from_image";
|
|
38078
38691
|
const readSelected = (item) => {
|
|
38079
|
-
if (item.member === null)
|
|
38692
|
+
if (item.member === null) {
|
|
38693
|
+
let bytes = objectBytes.get(item.artifact);
|
|
38694
|
+
if (!bytes) {
|
|
38695
|
+
bytes = import_node_fs49.default.readFileSync(item.artifact);
|
|
38696
|
+
objectBytes.set(item.artifact, bytes);
|
|
38697
|
+
}
|
|
38698
|
+
return bytes;
|
|
38699
|
+
}
|
|
38080
38700
|
let byName2 = memberBytes.get(item.artifact);
|
|
38081
38701
|
if (!byName2) {
|
|
38082
|
-
|
|
38083
|
-
|
|
38702
|
+
let members2 = archives.get(item.artifact);
|
|
38703
|
+
if (!members2) {
|
|
38704
|
+
members2 = readArMembers(import_node_fs49.default.readFileSync(item.artifact));
|
|
38705
|
+
archives.set(item.artifact, members2);
|
|
38706
|
+
}
|
|
38084
38707
|
byName2 = /* @__PURE__ */ new Map();
|
|
38085
38708
|
for (const member of members2)
|
|
38086
38709
|
if (!byName2.has(member.name))
|
|
@@ -38104,7 +38727,13 @@ function linkGuestImages(options2) {
|
|
|
38104
38727
|
`--why-extract=${whyPath}`,
|
|
38105
38728
|
`--Map=${mapPath}`
|
|
38106
38729
|
]);
|
|
38107
|
-
return selectedGuestLinkInputs(
|
|
38730
|
+
return selectedGuestLinkInputs(
|
|
38731
|
+
plan,
|
|
38732
|
+
args,
|
|
38733
|
+
import_node_fs49.default.readFileSync(whyPath, "utf8"),
|
|
38734
|
+
trace,
|
|
38735
|
+
archives
|
|
38736
|
+
);
|
|
38108
38737
|
};
|
|
38109
38738
|
const needsProvider = (item) => {
|
|
38110
38739
|
if (!artifacts.get(item.artifact).instrumentDynamicLookups) return false;
|
|
@@ -38144,7 +38773,7 @@ function linkGuestImages(options2) {
|
|
|
38144
38773
|
)
|
|
38145
38774
|
]);
|
|
38146
38775
|
const originalOwnership = identity2(plan);
|
|
38147
|
-
const resolved = options2.resolvePlan(selected, plan);
|
|
38776
|
+
const resolved = options2.resolvePlan(selected, plan, readSelected);
|
|
38148
38777
|
if (identity2(resolved) !== originalOwnership)
|
|
38149
38778
|
throw new Error("resolved guest scopes changed input ownership");
|
|
38150
38779
|
plan = resolved;
|
|
@@ -38198,6 +38827,7 @@ function linkGuestImages(options2) {
|
|
|
38198
38827
|
}
|
|
38199
38828
|
}
|
|
38200
38829
|
let discoveryRegions;
|
|
38830
|
+
let liveSymbols;
|
|
38201
38831
|
if (discoveryProjection && options2.projection) {
|
|
38202
38832
|
const owners = /* @__PURE__ */ new Map([[discoveryProjection, options2.projection.image]]);
|
|
38203
38833
|
for (const item of selected)
|
|
@@ -38206,10 +38836,15 @@ function linkGuestImages(options2) {
|
|
|
38206
38836
|
selectedGuestInputImage(artifacts.get(item.artifact), item.member)
|
|
38207
38837
|
);
|
|
38208
38838
|
const wasm = import_node_fs49.default.readFileSync(discovery);
|
|
38839
|
+
liveSymbols = /* @__PURE__ */ new Set();
|
|
38209
38840
|
discoveryRegions = guestProjectionRegionCounts(
|
|
38210
38841
|
plan.images.length,
|
|
38211
|
-
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners
|
|
38842
|
+
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners, void 0, false, {
|
|
38843
|
+
collectSymbols: liveSymbols
|
|
38844
|
+
})
|
|
38212
38845
|
);
|
|
38846
|
+
} else {
|
|
38847
|
+
liveSymbols = linkedMapSymbols(guestLinkLines(mapPath));
|
|
38213
38848
|
}
|
|
38214
38849
|
const ledger = createGuestImageLedger({
|
|
38215
38850
|
images: plan.images.map((image) => ({
|
|
@@ -38218,7 +38853,7 @@ function linkGuestImages(options2) {
|
|
|
38218
38853
|
})),
|
|
38219
38854
|
callers: plan.callers,
|
|
38220
38855
|
symbols: plan.symbols,
|
|
38221
|
-
liveSymbols
|
|
38856
|
+
liveSymbols,
|
|
38222
38857
|
commandLineSymbols: commandLineSymbols(args),
|
|
38223
38858
|
directBindings: plan.directBindings,
|
|
38224
38859
|
registerAppTables: sdkCallers !== void 0,
|
|
@@ -38350,7 +38985,8 @@ function linkGuestImages(options2) {
|
|
|
38350
38985
|
const selectedInputs = selectedGuestManifestInputs(
|
|
38351
38986
|
plan,
|
|
38352
38987
|
selected,
|
|
38353
|
-
projection.identities
|
|
38988
|
+
projection.identities,
|
|
38989
|
+
readSelected
|
|
38354
38990
|
);
|
|
38355
38991
|
const images = projection.images.map(
|
|
38356
38992
|
(image) => createGuestImageManifest({
|
|
@@ -38360,6 +38996,9 @@ function linkGuestImages(options2) {
|
|
|
38360
38996
|
regions: []
|
|
38361
38997
|
})
|
|
38362
38998
|
);
|
|
38999
|
+
objectBytes.clear();
|
|
39000
|
+
memberBytes.clear();
|
|
39001
|
+
archives.clear();
|
|
38363
39002
|
if (!discoveryRegions) throw new Error("guest projection layout object missing");
|
|
38364
39003
|
const regionsBefore = discoveryRegions;
|
|
38365
39004
|
const ledgerPieces = guestProjectionRegionCapacity([import_node_fs49.default.readFileSync(ledgerObject)], 0);
|
|
@@ -38453,10 +39092,47 @@ ${changed.join("\n")}`
|
|
|
38453
39092
|
}
|
|
38454
39093
|
function linkedMapSymbols(lines) {
|
|
38455
39094
|
const names = /* @__PURE__ */ new Set();
|
|
38456
|
-
const symbol2 = /^ +\S+ +[0-9a-f]+ +[0-9a-f]+ {9,}([^\s/<]\S*)/;
|
|
38457
39095
|
for (const line of lines) {
|
|
38458
|
-
const
|
|
38459
|
-
if (
|
|
39096
|
+
const length = line.length;
|
|
39097
|
+
if (length < 15 || line.charCodeAt(0) !== 32) continue;
|
|
39098
|
+
let pos = 1;
|
|
39099
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
39100
|
+
const c1 = pos;
|
|
39101
|
+
while (pos < length) {
|
|
39102
|
+
const ch = line.charCodeAt(pos);
|
|
39103
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
39104
|
+
pos++;
|
|
39105
|
+
}
|
|
39106
|
+
if (pos === c1 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
39107
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
39108
|
+
const c2 = pos;
|
|
39109
|
+
while (pos < length) {
|
|
39110
|
+
const ch = line.charCodeAt(pos);
|
|
39111
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
39112
|
+
pos++;
|
|
39113
|
+
}
|
|
39114
|
+
if (pos === c2 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
39115
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
39116
|
+
const c3 = pos;
|
|
39117
|
+
while (pos < length) {
|
|
39118
|
+
const ch = line.charCodeAt(pos);
|
|
39119
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
39120
|
+
pos++;
|
|
39121
|
+
}
|
|
39122
|
+
if (pos === c3 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
39123
|
+
const sStart = pos;
|
|
39124
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
39125
|
+
if (pos - sStart < 9 || pos >= length) continue;
|
|
39126
|
+
const first = line.charCodeAt(pos);
|
|
39127
|
+
if (first === 47 || first === 60 || first === 32 || first >= 9 && first <= 13)
|
|
39128
|
+
continue;
|
|
39129
|
+
let end = pos + 1;
|
|
39130
|
+
while (end < length) {
|
|
39131
|
+
const ch = line.charCodeAt(end);
|
|
39132
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
39133
|
+
end++;
|
|
39134
|
+
}
|
|
39135
|
+
names.add(line.slice(pos, end));
|
|
38460
39136
|
}
|
|
38461
39137
|
return names;
|
|
38462
39138
|
}
|
|
@@ -38555,7 +39231,7 @@ function discoverGuestLinkInputs(options2) {
|
|
|
38555
39231
|
import_node_fs49.default.mkdirSync(options2.directory, { recursive: true });
|
|
38556
39232
|
const why = import_node_path47.default.join(options2.directory, "preselection-why.txt");
|
|
38557
39233
|
const response = import_node_path47.default.join(options2.directory, "preselection.rsp");
|
|
38558
|
-
const output = import_node_path47.default.join(options2.directory, "preselection.wasm");
|
|
39234
|
+
const output = process.platform !== "win32" ? "/dev/null" : import_node_path47.default.join(options2.directory, "preselection.wasm");
|
|
38559
39235
|
const flags = [
|
|
38560
39236
|
...withOutput(args, output, true),
|
|
38561
39237
|
...options2.objects,
|
|
@@ -38653,7 +39329,7 @@ function prepareGuestRuntimeInputs(options2) {
|
|
|
38653
39329
|
});
|
|
38654
39330
|
return { args, selected, originalSelection, archives, sdkProducts, archiveArtifacts };
|
|
38655
39331
|
}
|
|
38656
|
-
function selectedGuestSymbolInputs(plan, selected) {
|
|
39332
|
+
function selectedGuestSymbolInputs(plan, selected, readSelected) {
|
|
38657
39333
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
38658
39334
|
const archives = /* @__PURE__ */ new Map();
|
|
38659
39335
|
const symbols = /* @__PURE__ */ new Set();
|
|
@@ -38669,22 +39345,27 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
38669
39345
|
if (!artifact) throw new Error(`selected symbol input has no owner ${item.artifact}`);
|
|
38670
39346
|
let bytes;
|
|
38671
39347
|
let name3 = item.artifact;
|
|
38672
|
-
if (item.member === null)
|
|
38673
|
-
|
|
38674
|
-
|
|
38675
|
-
if (
|
|
38676
|
-
|
|
38677
|
-
|
|
38678
|
-
|
|
38679
|
-
)
|
|
38680
|
-
|
|
39348
|
+
if (item.member === null) {
|
|
39349
|
+
bytes = readSelected ? readSelected(item) : import_node_fs49.default.readFileSync(item.artifact);
|
|
39350
|
+
} else {
|
|
39351
|
+
if (readSelected) {
|
|
39352
|
+
bytes = readSelected(item);
|
|
39353
|
+
} else {
|
|
39354
|
+
let members2 = archives.get(item.artifact);
|
|
39355
|
+
if (!members2) {
|
|
39356
|
+
members2 = Map.groupBy(
|
|
39357
|
+
readArMembers(import_node_fs49.default.readFileSync(item.artifact)),
|
|
39358
|
+
(member) => member.name
|
|
39359
|
+
);
|
|
39360
|
+
archives.set(item.artifact, members2);
|
|
39361
|
+
}
|
|
39362
|
+
const matching = members2.get(item.member) ?? [];
|
|
39363
|
+
if (matching.length !== 1)
|
|
39364
|
+
throw new Error(
|
|
39365
|
+
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
39366
|
+
);
|
|
39367
|
+
bytes = matching[0].bytes;
|
|
38681
39368
|
}
|
|
38682
|
-
const matching = members2.get(item.member) ?? [];
|
|
38683
|
-
if (matching.length !== 1)
|
|
38684
|
-
throw new Error(
|
|
38685
|
-
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
38686
|
-
);
|
|
38687
|
-
bytes = matching[0].bytes;
|
|
38688
39369
|
name3 += `(${item.member})`;
|
|
38689
39370
|
}
|
|
38690
39371
|
if (owners.has(name3)) throw new Error(`duplicate selected symbol input ${name3}`);
|
|
@@ -38697,9 +39378,9 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
38697
39378
|
for (const symbol2 of names.tags) tags.add(symbol2);
|
|
38698
39379
|
for (const symbol2 of names.defined) {
|
|
38699
39380
|
definitions.add(symbol2);
|
|
38700
|
-
|
|
39381
|
+
let objects = definitionObjects.get(symbol2);
|
|
39382
|
+
if (!objects) definitionObjects.set(symbol2, objects = /* @__PURE__ */ new Set());
|
|
38701
39383
|
objects.add(name3);
|
|
38702
|
-
definitionObjects.set(symbol2, objects);
|
|
38703
39384
|
}
|
|
38704
39385
|
}
|
|
38705
39386
|
return {
|
|
@@ -38720,7 +39401,7 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38720
39401
|
if (!symbols.length) return { bindings: [], directBindings: [] };
|
|
38721
39402
|
import_node_fs49.default.mkdirSync(options2.directory, { recursive: true });
|
|
38722
39403
|
const response = import_node_path47.default.join(options2.directory, "scope-trace.rsp");
|
|
38723
|
-
const output = import_node_path47.default.join(options2.directory, "scope-trace.wasm");
|
|
39404
|
+
const output = process.platform !== "win32" ? "/dev/null" : import_node_path47.default.join(options2.directory, "scope-trace.wasm");
|
|
38724
39405
|
const args = [
|
|
38725
39406
|
...withOutput(normalizedGuestLinkArgs(options2.args), output, true),
|
|
38726
39407
|
...options2.objects,
|
|
@@ -38738,55 +39419,76 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38738
39419
|
import_node_fs49.default.closeSync(traceOutput);
|
|
38739
39420
|
}
|
|
38740
39421
|
const records = /* @__PURE__ */ new Map();
|
|
38741
|
-
const
|
|
38742
|
-
const
|
|
38743
|
-
|
|
38744
|
-
|
|
38745
|
-
|
|
38746
|
-
|
|
38747
|
-
const
|
|
38748
|
-
|
|
38749
|
-
|
|
38750
|
-
|
|
38751
|
-
|
|
39422
|
+
for (const line of guestLinkLines(tracePath)) {
|
|
39423
|
+
const refSep = line.lastIndexOf(": reference to ");
|
|
39424
|
+
const defSep = line.lastIndexOf(": definition of ");
|
|
39425
|
+
if (refSep < 0 && defSep < 0) continue;
|
|
39426
|
+
const isRef = refSep > defSep;
|
|
39427
|
+
const sep2 = isRef ? refSep : defSep;
|
|
39428
|
+
const symbol2 = line.slice(sep2 + (isRef ? 15 : 16));
|
|
39429
|
+
if (!requested.has(symbol2) || options2.hostImports.has(symbol2)) continue;
|
|
39430
|
+
let record4 = records.get(symbol2);
|
|
39431
|
+
if (!record4) {
|
|
39432
|
+
record4 = {
|
|
39433
|
+
references: /* @__PURE__ */ new Map(),
|
|
39434
|
+
providers: /* @__PURE__ */ new Map(),
|
|
39435
|
+
physicalModule: false
|
|
39436
|
+
};
|
|
39437
|
+
records.set(symbol2, record4);
|
|
39438
|
+
}
|
|
39439
|
+
const object7 = line.slice(0, sep2);
|
|
38752
39440
|
if (object7 === "<internal>") {
|
|
38753
|
-
if (
|
|
39441
|
+
if (!isRef) record4.physicalModule = true;
|
|
38754
39442
|
} else {
|
|
38755
39443
|
const image = options2.owners.get(object7);
|
|
38756
39444
|
if (image === void 0)
|
|
38757
39445
|
throw new Error(`traced guest object has no owner ${object7}`);
|
|
38758
|
-
(
|
|
38759
|
-
object7,
|
|
38760
|
-
image
|
|
38761
|
-
);
|
|
39446
|
+
(isRef ? record4.references : record4.providers).set(object7, image);
|
|
38762
39447
|
}
|
|
38763
|
-
|
|
38764
|
-
};
|
|
38765
|
-
for (const line of guestLinkLines(tracePath)) consume(line);
|
|
39448
|
+
}
|
|
38766
39449
|
const callers = new Map(options2.callers.map((caller) => [caller.image, caller.next]));
|
|
39450
|
+
const callerSets = new Map(
|
|
39451
|
+
options2.callers.map((caller) => [caller.image, new Set(caller.next)])
|
|
39452
|
+
);
|
|
39453
|
+
const rootScope = callerSets.get(0);
|
|
38767
39454
|
const result = [];
|
|
38768
39455
|
const directBindings = [];
|
|
38769
39456
|
for (const symbol2 of symbols) {
|
|
38770
39457
|
const record4 = records.get(symbol2);
|
|
38771
39458
|
if (!record4 || !record4.references.size) continue;
|
|
38772
39459
|
if (!record4.providers.size && options2.hostImports.has(symbol2)) continue;
|
|
38773
|
-
const startupReferences = [
|
|
38774
|
-
|
|
38775
|
-
|
|
38776
|
-
const
|
|
38777
|
-
|
|
38778
|
-
|
|
39460
|
+
const startupReferences = [];
|
|
39461
|
+
const otherReferences = [];
|
|
39462
|
+
let allWeakRefs = true;
|
|
39463
|
+
for (const [object7, caller] of record4.references) {
|
|
39464
|
+
const isWeakRef = options2.weakReferences.get(object7)?.has(symbol2) === true;
|
|
39465
|
+
if (!isWeakRef) allWeakRefs = false;
|
|
39466
|
+
if (isWeakRef && options2.startupObjects.has(object7)) {
|
|
39467
|
+
startupReferences.push([object7, caller]);
|
|
39468
|
+
} else {
|
|
39469
|
+
otherReferences.push([object7, caller]);
|
|
39470
|
+
}
|
|
39471
|
+
}
|
|
38779
39472
|
for (const [, caller] of startupReferences)
|
|
38780
39473
|
if (!callers.has(caller))
|
|
38781
39474
|
throw new Error(`guest image has no caller scope ${caller}`);
|
|
38782
39475
|
if (startupReferences.length && !record4.physicalModule) {
|
|
38783
|
-
const
|
|
38784
|
-
|
|
39476
|
+
const candidates2 = options2.definitionObjects.get(symbol2);
|
|
39477
|
+
const candidateSize = candidates2?.size ?? 0;
|
|
39478
|
+
if (candidateSize > 1 || record4.providers.size > 1)
|
|
38785
39479
|
throw new Error(`ambiguous startup provider ${symbol2}`);
|
|
38786
|
-
|
|
38787
|
-
|
|
39480
|
+
let unproven = candidateSize !== record4.providers.size;
|
|
39481
|
+
if (!unproven && candidates2) {
|
|
39482
|
+
for (const object7 of record4.providers.keys()) {
|
|
39483
|
+
if (!candidates2.has(object7)) {
|
|
39484
|
+
unproven = true;
|
|
39485
|
+
break;
|
|
39486
|
+
}
|
|
39487
|
+
}
|
|
39488
|
+
}
|
|
39489
|
+
if (unproven) throw new Error(`unproven startup provider ${symbol2}`);
|
|
38788
39490
|
if (record4.providers.size === 1) {
|
|
38789
|
-
const [providerObject, providerImage] =
|
|
39491
|
+
const [providerObject, providerImage] = record4.providers.entries().next().value;
|
|
38790
39492
|
if (options2.weakDefinitions.get(providerObject)?.has(symbol2))
|
|
38791
39493
|
throw new Error(`weak startup provider ${symbol2}`);
|
|
38792
39494
|
for (const [object7] of startupReferences)
|
|
@@ -38794,28 +39496,34 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38794
39496
|
}
|
|
38795
39497
|
if (!otherReferences.length) continue;
|
|
38796
39498
|
}
|
|
38797
|
-
if (!record4.providers.size && !record4.physicalModule &&
|
|
38798
|
-
(object7) => options2.weakReferences.get(object7)?.has(symbol2)
|
|
38799
|
-
))
|
|
38800
|
-
continue;
|
|
39499
|
+
if (!record4.providers.size && !record4.physicalModule && allWeakRefs) continue;
|
|
38801
39500
|
const providerImages = new Set(record4.providers.values());
|
|
38802
|
-
const
|
|
38803
|
-
|
|
39501
|
+
const candidates = options2.definitionObjects.get(symbol2);
|
|
39502
|
+
const copyImages = /* @__PURE__ */ new Set();
|
|
39503
|
+
const strongImages = /* @__PURE__ */ new Set();
|
|
39504
|
+
let weakDefinerImages;
|
|
39505
|
+
if (candidates) {
|
|
39506
|
+
for (const object7 of candidates) {
|
|
38804
39507
|
const image = options2.owners.get(object7);
|
|
38805
|
-
|
|
39508
|
+
if (image === void 0) continue;
|
|
39509
|
+
copyImages.add(image);
|
|
39510
|
+
if (options2.weakDefinitions.get(object7)?.has(symbol2)) {
|
|
39511
|
+
;
|
|
39512
|
+
(weakDefinerImages ??= /* @__PURE__ */ new Set()).add(image);
|
|
39513
|
+
} else {
|
|
39514
|
+
strongImages.add(image);
|
|
39515
|
+
}
|
|
38806
39516
|
}
|
|
38807
|
-
|
|
38808
|
-
const copyImages = new Set(copies.map((copy) => copy.image));
|
|
38809
|
-
const strongImages = new Set(
|
|
38810
|
-
copies.filter((copy) => !copy.weak).map((copy) => copy.image)
|
|
38811
|
-
);
|
|
39517
|
+
}
|
|
38812
39518
|
const interposed = !record4.physicalModule && copyImages.size > 1;
|
|
38813
39519
|
const providerCount = interposed ? 1 : providerImages.size + Number(record4.physicalModule);
|
|
38814
39520
|
if (!providerCount) continue;
|
|
38815
39521
|
if (providerCount !== 1)
|
|
38816
39522
|
throw new Error(`guest symbol has ambiguous provider ${symbol2}`);
|
|
38817
|
-
const scopedReferences = record4.physicalModule ?
|
|
38818
|
-
const
|
|
39523
|
+
const scopedReferences = record4.physicalModule ? record4.references : otherReferences;
|
|
39524
|
+
const firstProviderImage = providerImages.values().next().value;
|
|
39525
|
+
const uniqueProvider = strongImages.size > 1 ? void 0 : strongImages.values().next().value ?? firstProviderImage;
|
|
39526
|
+
let interposedByCaller;
|
|
38819
39527
|
for (const [object7, caller] of scopedReferences) {
|
|
38820
39528
|
const scope2 = callers.get(caller);
|
|
38821
39529
|
if (!scope2) throw new Error(`guest image has no caller scope ${caller}`);
|
|
@@ -38823,18 +39531,35 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38823
39531
|
result.push({ symbol: symbol2, caller, provider: { kind: "physical-module" } });
|
|
38824
39532
|
continue;
|
|
38825
39533
|
}
|
|
38826
|
-
|
|
39534
|
+
let provider;
|
|
39535
|
+
if (interposed) {
|
|
39536
|
+
if (interposedByCaller?.has(caller)) {
|
|
39537
|
+
provider = interposedByCaller.get(caller);
|
|
39538
|
+
} else {
|
|
39539
|
+
if (copyImages.has(caller)) {
|
|
39540
|
+
provider = caller;
|
|
39541
|
+
} else {
|
|
39542
|
+
for (const image of scope2) {
|
|
39543
|
+
if (copyImages.has(image)) {
|
|
39544
|
+
provider = image;
|
|
39545
|
+
break;
|
|
39546
|
+
}
|
|
39547
|
+
}
|
|
39548
|
+
if (provider === void 0) provider = uniqueProvider;
|
|
39549
|
+
}
|
|
39550
|
+
;
|
|
39551
|
+
(interposedByCaller ??= /* @__PURE__ */ new Map()).set(caller, provider);
|
|
39552
|
+
}
|
|
39553
|
+
} else {
|
|
39554
|
+
provider = firstProviderImage;
|
|
39555
|
+
}
|
|
38827
39556
|
if (provider === void 0) {
|
|
38828
39557
|
if (options2.weakReferences.get(object7)?.has(symbol2)) continue;
|
|
38829
39558
|
throw new Error(`guest scope ${caller} omits every provider of ${symbol2}`);
|
|
38830
39559
|
}
|
|
38831
39560
|
if (caller === provider) continue;
|
|
38832
|
-
if (
|
|
38833
|
-
|
|
38834
|
-
))
|
|
38835
|
-
continue;
|
|
38836
|
-
if (!scope2.includes(provider)) {
|
|
38837
|
-
const candidates = options2.definitionObjects.get(symbol2) ?? /* @__PURE__ */ new Set();
|
|
39561
|
+
if (weakDefinerImages?.has(caller)) continue;
|
|
39562
|
+
if (!callerSets.get(caller).has(provider)) {
|
|
38838
39563
|
const traced = [...record4.providers.keys()];
|
|
38839
39564
|
const strongTraced = traced.filter(
|
|
38840
39565
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
@@ -38842,16 +39567,17 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38842
39567
|
const providers = strongTraced.length === 1 ? strongTraced : traced;
|
|
38843
39568
|
if (options2.weakReferences.get(object7)?.has(symbol2) && !providers.some((provider2) => options2.systemProviders.has(provider2)))
|
|
38844
39569
|
continue;
|
|
38845
|
-
const
|
|
39570
|
+
const candidateSet = candidates ?? /* @__PURE__ */ new Set();
|
|
39571
|
+
const equivalentCopies = providers.length === 1 && candidateSet.has(providers[0]) && [...candidateSet].every(
|
|
38846
39572
|
(definer) => options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
38847
39573
|
);
|
|
38848
|
-
const strongCandidates = [...
|
|
39574
|
+
const strongCandidates = [...candidateSet].filter(
|
|
38849
39575
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
38850
39576
|
);
|
|
38851
|
-
const soleCandidate =
|
|
38852
|
-
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !
|
|
39577
|
+
const soleCandidate = candidateSet.size === 1 || strongCandidates.length === 1 && strongCandidates[0] === providers[0];
|
|
39578
|
+
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !candidateSet.has(providers[0]) || !(options2.systemProviders.has(providers[0]) || // a strong undefined reference binds through the process global
|
|
38853
39579
|
// scope, the root image and its dependency closure, as in elf.
|
|
38854
|
-
provider === 0 ||
|
|
39580
|
+
provider === 0 || rootScope?.has(provider) || !options2.weakReferences.get(object7)?.has(symbol2) && options2.frameworkProviders.get(object7)?.has(providers[0]))))
|
|
38855
39581
|
throw new Error(
|
|
38856
39582
|
`guest scope ${caller} omits traced provider ${provider} for ${symbol2}`
|
|
38857
39583
|
);
|
|
@@ -44713,9 +45439,9 @@ async function compileGuestLink(options2) {
|
|
|
44713
45439
|
}
|
|
44714
45440
|
};
|
|
44715
45441
|
},
|
|
44716
|
-
resolvePlan: (selected, plan) => {
|
|
45442
|
+
resolvePlan: (selected, plan, readSelected) => {
|
|
44717
45443
|
if (!prepared) throw new Error("guest runtime selection is unavailable");
|
|
44718
|
-
const scope2 = selectedGuestSymbolInputs(plan, selected);
|
|
45444
|
+
const scope2 = selectedGuestSymbolInputs(plan, selected, readSelected);
|
|
44719
45445
|
const owners = new Map(scope2.owners);
|
|
44720
45446
|
owners.set(import_node_path58.default.join(directory2, "projection-discovery.o"), 0);
|
|
44721
45447
|
const providersByImage = Map.groupBy(scope2.owners, ([, image]) => image);
|
|
@@ -52394,7 +53120,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
52394
53120
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
52395
53121
|
MULTI_MANIFEST_VERSION = 76;
|
|
52396
53122
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
52397
|
-
compilerSourceDigest = true ? "
|
|
53123
|
+
compilerSourceDigest = true ? "7b91fa4405159335b5484c82700e001e4c27abf15621b724ea8af4edea693f66" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
|
|
52398
53124
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
52399
53125
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
52400
53126
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|