peachsim 0.1.2588 → 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 +1174 -447
- 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-DG2TVZRD.mjs → acorn-65FNEARV.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-LW5F24Y7.mjs → chunk-2GUB5OLB.mjs} +3 -3
- package/dist-lib/esm-chunks/{chunk-4PNMHEJB.mjs → chunk-462CWTWI.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ASL4MACC.mjs → chunk-4VCRUQ36.mjs} +1180 -453
- package/dist-lib/esm-chunks/{chunk-UFXK4UQL.mjs → chunk-5GNGHM5B.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BAU3IFLL.mjs → chunk-ADKUIQXX.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-4GOTTBDL.mjs → chunk-BZS5SIYK.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-JE7EWYAV.mjs → chunk-EFKDUMB5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-WZHOX3BM.mjs → chunk-GBD26EBV.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-QRKZ3NSY.mjs → chunk-HZTK7TP5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-ELSAXANF.mjs → chunk-JG4AANWA.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-V2PI4V6K.mjs → chunk-N2II5SRJ.mjs} +4 -4
- package/dist-lib/esm-chunks/{chunk-C7MHFZIA.mjs → chunk-NZY4GOG5.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-AGQHPM6E.mjs → chunk-OZJ66CXY.mjs} +2 -2
- package/dist-lib/esm-chunks/{chunk-PL3OUSN3.mjs → chunk-RGC2JNCL.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-GIS6FXRN.mjs → chunk-SLPXTLBK.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-BSPFA6V2.mjs → chunk-SRFKOU76.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-BGCADZA2.mjs → chunk-V5TTEXYO.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-NSNT4FFS.mjs → chunk-WPDY5IAD.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-YHJXN2S6.mjs → chunk-WYDRQRJL.mjs} +5 -5
- package/dist-lib/esm-chunks/{chunk-CJ6UJWGD.mjs → chunk-X2EKFONU.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-OLEYCMVV.mjs → chunk-XE3VHAU2.mjs} +1 -1
- package/dist-lib/esm-chunks/{chunk-SDGYG4FM.mjs → chunk-YPPH6F77.mjs} +1 -1
- package/dist-lib/esm-chunks/{metro-layout-parser-VWCTMFOO.mjs → metro-layout-parser-CRI3GMCM.mjs} +3 -3
- package/dist-lib/esm-chunks/{swift-package-prebuilt-W7FEW6PS.mjs → swift-package-prebuilt-5XDZ2HZZ.mjs} +10 -10
- package/dist-lib/esm-chunks/{swift-sdk-app-module-J4KH7G35.mjs → swift-sdk-app-module-6H3G6AXD.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-MUWMBAKB.mjs → swift-sdk-image-WAC7GG2R.mjs} +14 -14
- package/dist-lib/esm-chunks/{swift-sdk-image-producer-BLO2DZ2C.mjs → swift-sdk-image-producer-B3L27QTG.mjs} +4 -4
- package/dist-lib/expo-swift-bundle.cjs +1173 -446
- 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 +1215 -480
- 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 +1225 -484
- package/dist-lib/swift-compile.cjs +1170 -443
- 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/dist-types/packages/peach-engine/src/ios/apps/canvas-map-data.d.ts +1 -1
- package/kotlin/sdk.tar.gz +0 -0
- package/package.json +1 -1
- package/src/one-native-controls-package.ts +8 -7
- 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-shared-sdk.ts +8 -4
- 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({
|
|
@@ -29448,6 +29448,7 @@ function stageOverlaySlot(realRoot, stagingRoot, relPath) {
|
|
|
29448
29448
|
const segment2 = segments[i];
|
|
29449
29449
|
for (const entry of (0, import_node_fs39.readdirSync)(real)) {
|
|
29450
29450
|
if (entry === segment2 || i === 0 && entry === SWIFT_CACHE_HOLD_MARKER) continue;
|
|
29451
|
+
if (mirror === stagingRoot && entry === "configuration") continue;
|
|
29451
29452
|
const dest = import_node_path37.default.join(mirror, entry);
|
|
29452
29453
|
if (!import_node_fs39.default.lstatSync(dest, { throwIfNoEntry: false })) {
|
|
29453
29454
|
import_node_fs39.default.symlinkSync(import_node_path37.default.join(real, entry), dest);
|
|
@@ -29482,7 +29483,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk2)
|
|
|
29482
29483
|
const stdint = import_node_path37.default.join(overlay, "include/stdint.h");
|
|
29483
29484
|
const key2 = JSON.stringify([
|
|
29484
29485
|
// bump the recipe when the transformation changes; bundling changes function text.
|
|
29485
|
-
"
|
|
29486
|
+
"v39",
|
|
29486
29487
|
[...WEAKEN_FOUNDATION_SYMS],
|
|
29487
29488
|
toolchainBin,
|
|
29488
29489
|
sdk2,
|
|
@@ -31114,24 +31115,56 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
31114
31115
|
const code = sections.get(10);
|
|
31115
31116
|
if (code) {
|
|
31116
31117
|
let pos = code[0];
|
|
31117
|
-
|
|
31118
|
-
|
|
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
|
+
}
|
|
31119
31131
|
for (let i = 0; i < count; i++) {
|
|
31120
31132
|
const prefix = pos;
|
|
31121
|
-
let size2;
|
|
31122
|
-
|
|
31123
|
-
|
|
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);
|
|
31124
31149
|
if (imports2 + i === startFunction) startup = bytes.subarray(pos, pos + size2);
|
|
31125
31150
|
pos += size2;
|
|
31126
|
-
if (pos >
|
|
31151
|
+
if (pos > codeEnd) throw new Error("invalid wasm code");
|
|
31127
31152
|
}
|
|
31128
|
-
if (pos !==
|
|
31153
|
+
if (pos !== codeEnd) throw new Error("invalid wasm code section");
|
|
31129
31154
|
}
|
|
31130
31155
|
const functionsByTableSlot = /* @__PURE__ */ new Map();
|
|
31131
31156
|
const elements = sections.get(9);
|
|
31132
31157
|
if (elements) {
|
|
31133
31158
|
let pos = elements[0];
|
|
31159
|
+
const elemEnd = elements[1];
|
|
31134
31160
|
const read = () => {
|
|
31161
|
+
if (pos < elemEnd) {
|
|
31162
|
+
const b0 = bytes[pos];
|
|
31163
|
+
if (b0 < 128) {
|
|
31164
|
+
pos++;
|
|
31165
|
+
return b0;
|
|
31166
|
+
}
|
|
31167
|
+
}
|
|
31135
31168
|
const [value, next] = number(bytes, pos);
|
|
31136
31169
|
pos = next;
|
|
31137
31170
|
return value;
|
|
@@ -31161,7 +31194,7 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
31161
31194
|
functionsByTableSlot.set(slot, read());
|
|
31162
31195
|
}
|
|
31163
31196
|
}
|
|
31164
|
-
if (pos !==
|
|
31197
|
+
if (pos !== elemEnd) throw new Error("invalid wasm element section");
|
|
31165
31198
|
}
|
|
31166
31199
|
const data = [];
|
|
31167
31200
|
const passive = /* @__PURE__ */ new Map();
|
|
@@ -31226,36 +31259,141 @@ function guestWasmDataSegments(bytes, requireExports = true) {
|
|
|
31226
31259
|
length: segment2.bytes.length
|
|
31227
31260
|
}));
|
|
31228
31261
|
}
|
|
31229
|
-
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) {
|
|
31230
31280
|
const unchanged = before === after;
|
|
31231
31281
|
const original = layout(before, !unchanged, !importsLayout);
|
|
31232
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;
|
|
31233
31288
|
let codeOffset;
|
|
31234
31289
|
let outputSection = "";
|
|
31235
31290
|
const codeOwners = /* @__PURE__ */ new Map();
|
|
31236
31291
|
const pieces = [];
|
|
31237
|
-
|
|
31238
|
-
|
|
31239
|
-
|
|
31240
|
-
|
|
31241
|
-
|
|
31242
|
-
|
|
31243
|
-
|
|
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;
|
|
31244
31354
|
continue;
|
|
31245
31355
|
}
|
|
31246
|
-
|
|
31356
|
+
if (sizeVal === 0) continue;
|
|
31357
|
+
const separator = line.indexOf(":(", sourceStart);
|
|
31247
31358
|
if (separator < 0) continue;
|
|
31248
|
-
|
|
31249
|
-
|
|
31250
|
-
|
|
31251
|
-
|
|
31252
|
-
if (
|
|
31253
|
-
|
|
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
|
+
}
|
|
31254
31392
|
continue;
|
|
31255
31393
|
}
|
|
31256
31394
|
if (image === void 0 || outputSection !== "CODE") continue;
|
|
31257
31395
|
if (codeOffset === void 0) throw new Error("link map has no code section");
|
|
31258
|
-
const index = original.functionsByCodeOffset.get(
|
|
31396
|
+
const index = original.functionsByCodeOffset.get(offsetVal - codeOffset);
|
|
31259
31397
|
if (index === void 0) throw new Error("link map function has no wasm body");
|
|
31260
31398
|
const existing = codeOwners.get(index);
|
|
31261
31399
|
if (existing !== void 0 && existing !== image)
|
|
@@ -31264,12 +31402,23 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
31264
31402
|
}
|
|
31265
31403
|
pieces.sort((a, b) => a.address - b.address);
|
|
31266
31404
|
const spans = [];
|
|
31267
|
-
for (
|
|
31268
|
-
|
|
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;
|
|
31269
31409
|
let next = index + 1;
|
|
31270
31410
|
while (next < pieces.length && pieces[next].address < address + length) next++;
|
|
31271
31411
|
const end = pieces[next]?.address ?? address + length;
|
|
31272
|
-
|
|
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
|
+
});
|
|
31273
31422
|
}
|
|
31274
31423
|
const optimizedOwners = /* @__PURE__ */ new Map();
|
|
31275
31424
|
const dataAt = (module2, start, length) => {
|
|
@@ -31308,7 +31457,7 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
31308
31457
|
throw new Error(`optimization changed linked data at ${span.address}`);
|
|
31309
31458
|
}
|
|
31310
31459
|
let previous;
|
|
31311
|
-
for (const span of
|
|
31460
|
+
for (const span of spans) {
|
|
31312
31461
|
if (previous && span.address < previous.address + previous.length && span.image !== previous.image)
|
|
31313
31462
|
throw new Error("linked data belongs to multiple images");
|
|
31314
31463
|
if (!previous || span.address + span.length > previous.address + previous.length)
|
|
@@ -31490,6 +31639,20 @@ var init_swift_guest_linked_spans = __esm({
|
|
|
31490
31639
|
});
|
|
31491
31640
|
|
|
31492
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
|
+
}
|
|
31493
31656
|
function readWasmLinkMap(file, partition) {
|
|
31494
31657
|
const segments = /* @__PURE__ */ new Map();
|
|
31495
31658
|
const data = [];
|
|
@@ -31497,48 +31660,117 @@ function readWasmLinkMap(file, partition) {
|
|
|
31497
31660
|
let kind = "";
|
|
31498
31661
|
let segment2 = "";
|
|
31499
31662
|
let previous;
|
|
31500
|
-
const hex = (value) => value === "-" ? -1 : parseInt(value, 16);
|
|
31501
31663
|
for (const line of guestLinkLines(file)) {
|
|
31502
|
-
const
|
|
31503
|
-
|
|
31504
|
-
|
|
31505
|
-
|
|
31506
|
-
|
|
31507
|
-
|
|
31508
|
-
|
|
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
|
+
}
|
|
31509
31714
|
continue;
|
|
31510
31715
|
}
|
|
31511
|
-
|
|
31512
|
-
|
|
31513
|
-
|
|
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
|
+
}
|
|
31514
31732
|
continue;
|
|
31515
31733
|
}
|
|
31516
|
-
if (kind === "DATA") {
|
|
31517
|
-
const
|
|
31518
|
-
if (
|
|
31519
|
-
|
|
31520
|
-
|
|
31521
|
-
|
|
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*?__/, "");
|
|
31522
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);
|
|
31523
31773
|
}
|
|
31524
|
-
if (kind !== "DATA" && kind !== "CODE") continue;
|
|
31525
|
-
const input = /^ *([0-9a-f]+|-) +([0-9a-f]+) +([0-9a-f]+) {9}([/<].*)$/.exec(line);
|
|
31526
|
-
if (!input) continue;
|
|
31527
|
-
const name3 = input[4];
|
|
31528
|
-
const split = /^(.*?):\((.*)\)$/s.exec(name3);
|
|
31529
|
-
const path115 = split ? split[1] : name3;
|
|
31530
|
-
const member = /\(([^()]+)\)$/.exec(path115);
|
|
31531
|
-
previous = {
|
|
31532
|
-
inputFile: path115,
|
|
31533
|
-
segment: segment2,
|
|
31534
|
-
address: hex(input[1]),
|
|
31535
|
-
offset: parseInt(input[2], 16),
|
|
31536
|
-
size: parseInt(input[3], 16),
|
|
31537
|
-
object: (member ? member[1] : (0, import_node_path42.basename)(path115)).replace(/^lib\w*?__/, ""),
|
|
31538
|
-
section: split ? split[2] : "",
|
|
31539
|
-
symbols: []
|
|
31540
|
-
};
|
|
31541
|
-
(kind === "DATA" ? data : code).push(previous);
|
|
31542
31774
|
}
|
|
31543
31775
|
return { segments, data: partition ? data.flatMap(symbolPieces) : data, code };
|
|
31544
31776
|
}
|
|
@@ -32684,6 +32916,7 @@ function patchSwiftrtObject(src) {
|
|
|
32684
32916
|
return buf;
|
|
32685
32917
|
}
|
|
32686
32918
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
32919
|
+
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
32687
32920
|
let pos = 8;
|
|
32688
32921
|
let numImportFuncs = 0;
|
|
32689
32922
|
let importsDlsym = false;
|
|
@@ -32719,10 +32952,10 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32719
32952
|
let [cnt, cp] = readULEB2(buf, p);
|
|
32720
32953
|
for (let i = 0; i < cnt; i++) {
|
|
32721
32954
|
const [mLen, m2] = readULEB2(buf, cp);
|
|
32722
|
-
const mName =
|
|
32955
|
+
const mName = rawBuf.toString("utf8", m2, m2 + mLen);
|
|
32723
32956
|
cp = m2 + mLen;
|
|
32724
32957
|
const [fLen, f2] = readULEB2(buf, cp);
|
|
32725
|
-
const fName =
|
|
32958
|
+
const fName = rawBuf.toString("utf8", f2, f2 + fLen);
|
|
32726
32959
|
cp = f2 + fLen;
|
|
32727
32960
|
const kind = buf[cp++];
|
|
32728
32961
|
if (kind === 0) {
|
|
@@ -32802,7 +33035,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32802
33035
|
}
|
|
32803
33036
|
} else if (id === 0) {
|
|
32804
33037
|
const [nLen, np] = readULEB2(buf, p);
|
|
32805
|
-
const name3 =
|
|
33038
|
+
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
32806
33039
|
const cp = np + nLen;
|
|
32807
33040
|
if (name3 === "linking") {
|
|
32808
33041
|
let [, lp] = readULEB2(buf, cp);
|
|
@@ -32815,7 +33048,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32815
33048
|
let cur = p2;
|
|
32816
33049
|
for (let i = 0; i < cnt; i++) {
|
|
32817
33050
|
const [sLen, s2] = readULEB2(buf, cur);
|
|
32818
|
-
segNames.push(
|
|
33051
|
+
segNames.push(rawBuf.toString("utf8", s2, s2 + sLen));
|
|
32819
33052
|
cur = s2 + sLen;
|
|
32820
33053
|
const [, s3] = readULEB2(buf, cur);
|
|
32821
33054
|
const [fl, s4] = readULEB2(buf, s3);
|
|
@@ -32855,7 +33088,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32855
33088
|
let sName = "";
|
|
32856
33089
|
if (!isUndef || isExplicitName) {
|
|
32857
33090
|
const [sLen, c4] = readULEB2(buf, cur);
|
|
32858
|
-
sName =
|
|
33091
|
+
sName = rawBuf.toString("utf8", c4, c4 + sLen);
|
|
32859
33092
|
cur = c4 + sLen;
|
|
32860
33093
|
} else if (kind === 0) {
|
|
32861
33094
|
sName = importFuncNames[el] ?? "";
|
|
@@ -32871,7 +33104,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32871
33104
|
symNames.push(sName);
|
|
32872
33105
|
} else if (kind === 1) {
|
|
32873
33106
|
const [sLen, c3] = readULEB2(buf, cur);
|
|
32874
|
-
const sName =
|
|
33107
|
+
const sName = rawBuf.toString("utf8", c3, c3 + sLen);
|
|
32875
33108
|
cur = c3 + sLen;
|
|
32876
33109
|
if (!isUndef) {
|
|
32877
33110
|
const [segIdx, c4] = readULEB2(buf, cur);
|
|
@@ -32986,9 +33219,21 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
32986
33219
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
32987
33220
|
let ownerSymIdx = -1;
|
|
32988
33221
|
const topList = segTopSyms.get(lo);
|
|
32989
|
-
if (topList) {
|
|
32990
|
-
|
|
32991
|
-
|
|
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
|
+
}
|
|
32992
33237
|
}
|
|
32993
33238
|
if (ownerSymIdx !== -1) {
|
|
32994
33239
|
let list2 = symDataRelocs.get(ownerSymIdx);
|
|
@@ -33243,54 +33488,151 @@ function localizeDefinedWasmSymbols(bytes, names) {
|
|
|
33243
33488
|
return output;
|
|
33244
33489
|
}
|
|
33245
33490
|
function guestWasmSymbols(bytes) {
|
|
33246
|
-
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
|
+
}
|
|
33247
33623
|
return {
|
|
33248
|
-
importsDlsym
|
|
33249
|
-
undefined: [
|
|
33250
|
-
...new Set(
|
|
33251
|
-
object7.symNames.filter(
|
|
33252
|
-
(name3, index) => name3 && (object7.symFlags[index] & 16) !== 0
|
|
33253
|
-
)
|
|
33254
|
-
)
|
|
33255
|
-
],
|
|
33624
|
+
importsDlsym,
|
|
33625
|
+
undefined: [...undefinedSyms],
|
|
33256
33626
|
// a wasm tag is one module entity unified by name across the link, as the
|
|
33257
33627
|
// main module owns it for dynamic images, so no image scope applies.
|
|
33258
|
-
tags: [
|
|
33259
|
-
|
|
33260
|
-
object7.symNames.filter((name3, index) => name3 && object7.symKind[index] === 4)
|
|
33261
|
-
)
|
|
33262
|
-
],
|
|
33263
|
-
globals: [
|
|
33264
|
-
...new Set(
|
|
33265
|
-
object7.symNames.filter(
|
|
33266
|
-
(name3, index) => name3 && (object7.symKind[index] === 2 || object7.symKind[index] === 5)
|
|
33267
|
-
)
|
|
33268
|
-
)
|
|
33269
|
-
],
|
|
33628
|
+
tags: [...tags],
|
|
33629
|
+
globals: [...globals],
|
|
33270
33630
|
// an undefined function imported from a module other than env is supplied
|
|
33271
33631
|
// by the host, whatever linker symbol names it.
|
|
33272
|
-
hostImports: [...
|
|
33273
|
-
weakUndefined: [
|
|
33274
|
-
|
|
33275
|
-
|
|
33276
|
-
(name3, index) => name3 && (object7.symFlags[index] & 19) === 17
|
|
33277
|
-
)
|
|
33278
|
-
)
|
|
33279
|
-
],
|
|
33280
|
-
defined: [
|
|
33281
|
-
...new Set(
|
|
33282
|
-
object7.symNames.filter(
|
|
33283
|
-
(name3, index) => name3 && (object7.symFlags[index] & 16) === 0 && (object7.symFlags[index] & 3) !== 2
|
|
33284
|
-
)
|
|
33285
|
-
)
|
|
33286
|
-
],
|
|
33287
|
-
weakDefined: [
|
|
33288
|
-
...new Set(
|
|
33289
|
-
object7.symNames.filter(
|
|
33290
|
-
(name3, index) => name3 && (object7.symFlags[index] & 19) === 1
|
|
33291
|
-
)
|
|
33292
|
-
)
|
|
33293
|
-
]
|
|
33632
|
+
hostImports: [...hostImports],
|
|
33633
|
+
weakUndefined: [...weakUndefined],
|
|
33634
|
+
defined: [...defined],
|
|
33635
|
+
weakDefined: [...weakDefined]
|
|
33294
33636
|
};
|
|
33295
33637
|
}
|
|
33296
33638
|
function sdkObjectName(archive, member, ordinal) {
|
|
@@ -33807,9 +34149,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33807
34149
|
for (const entry of waiting) tryActivateConformance(entry);
|
|
33808
34150
|
}
|
|
33809
34151
|
};
|
|
34152
|
+
const checkedProtocolTriggers = /* @__PURE__ */ new Set();
|
|
33810
34153
|
const checkProtocolTrigger = (rawSymName) => {
|
|
33811
34154
|
if (!rawSymName) return;
|
|
33812
34155
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
34156
|
+
if (checkedProtocolTriggers.has(sName)) return;
|
|
34157
|
+
checkedProtocolTriggers.add(sName);
|
|
33813
34158
|
if (knownProtocols.has(sName)) {
|
|
33814
34159
|
markProtocolLive(sName);
|
|
33815
34160
|
return;
|
|
@@ -33842,6 +34187,43 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33842
34187
|
}
|
|
33843
34188
|
}
|
|
33844
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
|
+
};
|
|
33845
34227
|
const markTypeLive = (obj, pref) => {
|
|
33846
34228
|
const set2 = liveTypes.get(obj);
|
|
33847
34229
|
if (set2.has(pref)) return;
|
|
@@ -33855,22 +34237,10 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33855
34237
|
const outer = pref.slice(0, n);
|
|
33856
34238
|
if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer);
|
|
33857
34239
|
}
|
|
33858
|
-
const
|
|
33859
|
-
for (
|
|
33860
|
-
|
|
33861
|
-
|
|
33862
|
-
}
|
|
33863
|
-
}
|
|
33864
|
-
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
33865
|
-
if (p === pref) {
|
|
33866
|
-
markFuncLive(obj, lf);
|
|
33867
|
-
}
|
|
33868
|
-
}
|
|
33869
|
-
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
33870
|
-
if (p === pref && classSym.startsWith("._OBJC_CLASS_")) {
|
|
33871
|
-
markObjCClassLive(classSym.slice("._OBJC_CLASS_".length));
|
|
33872
|
-
}
|
|
33873
|
-
}
|
|
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);
|
|
33874
34244
|
};
|
|
33875
34245
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
33876
34246
|
if (!rawSymName) return;
|
|
@@ -33895,11 +34265,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33895
34265
|
}
|
|
33896
34266
|
}
|
|
33897
34267
|
}
|
|
33898
|
-
if (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o")) {
|
|
33899
|
-
|
|
33900
|
-
|
|
33901
|
-
|
|
33902
|
-
|
|
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);
|
|
33903
34274
|
}
|
|
33904
34275
|
}
|
|
33905
34276
|
};
|
|
@@ -33992,7 +34363,8 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
33992
34363
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
33993
34364
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
33994
34365
|
for (const name3 of obj.symNames) {
|
|
33995
|
-
|
|
34366
|
+
if (!name3 || !name3.startsWith("_c_") || !name3.endsWith("__load")) continue;
|
|
34367
|
+
const loaded3 = name3.match(/^_c_(\w+)__load$/)?.[1];
|
|
33996
34368
|
if (!loaded3) continue;
|
|
33997
34369
|
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded3}`);
|
|
33998
34370
|
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
@@ -34140,14 +34512,30 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
34140
34512
|
const keepObjCClassesNamedInSegment = (obj, segIdx) => {
|
|
34141
34513
|
const range3 = obj.segPayloadRanges[segIdx];
|
|
34142
34514
|
if (!range3) return;
|
|
34515
|
+
const [rangeStart, rangeEnd] = range3;
|
|
34516
|
+
if (rangeEnd - rangeStart < 4) return;
|
|
34143
34517
|
let bytes = objectBytes.get(obj);
|
|
34144
34518
|
if (!bytes) objectBytes.set(obj, bytes = import_node_fs44.default.readFileSync(obj.file));
|
|
34145
|
-
|
|
34146
|
-
|
|
34147
|
-
const
|
|
34148
|
-
|
|
34149
|
-
|
|
34150
|
-
|
|
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)}`;
|
|
34151
34539
|
for (const provider of lazyProviders.get(symbol2) ?? []) {
|
|
34152
34540
|
eagerDynamicObjects.add(provider);
|
|
34153
34541
|
extractObject(provider);
|
|
@@ -35124,6 +35512,10 @@ var init_nativeDyldTableContract = __esm({
|
|
|
35124
35512
|
|
|
35125
35513
|
// src/swift-guest-image-ledger.ts
|
|
35126
35514
|
function readNumber(bytes, position) {
|
|
35515
|
+
if (position < bytes.length) {
|
|
35516
|
+
const first = bytes[position];
|
|
35517
|
+
if (first < 128) return [first, position + 1];
|
|
35518
|
+
}
|
|
35127
35519
|
let value = 0;
|
|
35128
35520
|
let shift = 0;
|
|
35129
35521
|
for (; ; ) {
|
|
@@ -35135,6 +35527,7 @@ function readNumber(bytes, position) {
|
|
|
35135
35527
|
}
|
|
35136
35528
|
}
|
|
35137
35529
|
function encodeNumber(value) {
|
|
35530
|
+
if (value < 128) return Buffer.from([value]);
|
|
35138
35531
|
const bytes = [];
|
|
35139
35532
|
do {
|
|
35140
35533
|
let byte = value % 128;
|
|
@@ -35156,6 +35549,9 @@ function encodedString(value) {
|
|
|
35156
35549
|
const bytes = Buffer.from(value);
|
|
35157
35550
|
return Buffer.concat([encodeNumber(bytes.length), bytes]);
|
|
35158
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
|
+
}
|
|
35159
35555
|
function llvmType(value) {
|
|
35160
35556
|
switch (value) {
|
|
35161
35557
|
case 127:
|
|
@@ -35171,11 +35567,12 @@ function llvmType(value) {
|
|
|
35171
35567
|
}
|
|
35172
35568
|
}
|
|
35173
35569
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
|
|
35174
|
-
if (
|
|
35175
|
-
|
|
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);
|
|
35176
35572
|
const { sdkLookupOnly, sdkProduct } = options2;
|
|
35177
35573
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
35178
|
-
const
|
|
35574
|
+
const rewrite = binding !== void 0;
|
|
35575
|
+
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
35179
35576
|
const types2 = [];
|
|
35180
35577
|
const functionTypes = [];
|
|
35181
35578
|
const definitions = [];
|
|
@@ -35189,45 +35586,74 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35189
35586
|
const usedSymbols = /* @__PURE__ */ new Set();
|
|
35190
35587
|
let position = 8;
|
|
35191
35588
|
while (position < bytes.length) {
|
|
35589
|
+
const headerStart2 = position;
|
|
35192
35590
|
const id = bytes[position++];
|
|
35193
|
-
|
|
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;
|
|
35194
35600
|
const end = start + size2;
|
|
35195
35601
|
if (end > bytes.length) throw new Error("invalid wasm section");
|
|
35196
35602
|
position = end;
|
|
35197
|
-
if (
|
|
35198
|
-
|
|
35199
|
-
|
|
35603
|
+
if (id > 3) {
|
|
35604
|
+
if (sections) sections.push(bytes.subarray(headerStart2, end));
|
|
35605
|
+
continue;
|
|
35606
|
+
}
|
|
35607
|
+
let offset = start;
|
|
35200
35608
|
const number3 = () => {
|
|
35201
|
-
|
|
35202
|
-
|
|
35203
|
-
|
|
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
|
+
}
|
|
35204
35625
|
};
|
|
35205
35626
|
const string7 = () => {
|
|
35206
|
-
const
|
|
35207
|
-
|
|
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;
|
|
35208
35632
|
return value;
|
|
35209
35633
|
};
|
|
35634
|
+
let rewrittenSection;
|
|
35210
35635
|
if (id === 1) {
|
|
35211
35636
|
const count = number3();
|
|
35212
35637
|
for (let i = 0; i < count; i++) {
|
|
35213
|
-
if (
|
|
35638
|
+
if (bytes[offset++] !== 96) throw new Error("unsupported wasm type");
|
|
35214
35639
|
const parameterCount = number3();
|
|
35215
|
-
|
|
35216
|
-
|
|
35217
|
-
|
|
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++];
|
|
35218
35643
|
const resultCount = number3();
|
|
35219
|
-
|
|
35220
|
-
|
|
35221
|
-
|
|
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++];
|
|
35222
35647
|
types2.push({ parameters, results });
|
|
35223
35648
|
}
|
|
35224
35649
|
} else if (id === 2) {
|
|
35225
35650
|
const count = number3();
|
|
35226
|
-
const
|
|
35651
|
+
const importWriter = rewrite ? new ByteWriter(size2 + 64) : void 0;
|
|
35652
|
+
importWriter?.uleb(count);
|
|
35227
35653
|
for (let i = 0; i < count; i++) {
|
|
35228
35654
|
const module2 = string7();
|
|
35229
35655
|
const name3 = string7();
|
|
35230
|
-
const kind =
|
|
35656
|
+
const kind = bytes[offset++];
|
|
35231
35657
|
const typeStart = offset;
|
|
35232
35658
|
let functionType2 = -1;
|
|
35233
35659
|
if (kind === 0) {
|
|
@@ -35235,7 +35661,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35235
35661
|
functionTypes.push(functionType2);
|
|
35236
35662
|
functionImportNames.push(name3);
|
|
35237
35663
|
} else if (kind === 1) {
|
|
35238
|
-
const referenceType =
|
|
35664
|
+
const referenceType = bytes[offset++];
|
|
35239
35665
|
if (referenceType !== 112 && referenceType !== 111)
|
|
35240
35666
|
throw new Error("unsupported table type");
|
|
35241
35667
|
const flags = number3();
|
|
@@ -35254,11 +35680,15 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35254
35680
|
} else throw new Error("unsupported wasm import");
|
|
35255
35681
|
const isDlsym = instrumentDynamicLookups && module2 === "env" && name3 === "dlsym" && kind === 0;
|
|
35256
35682
|
const isDlerror = instrumentDynamicLookups && module2 === "env" && name3 === "dlerror" && kind === 0;
|
|
35257
|
-
if (
|
|
35258
|
-
|
|
35259
|
-
|
|
35260
|
-
|
|
35261
|
-
|
|
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
|
+
}
|
|
35262
35692
|
}
|
|
35263
35693
|
if (isDlsym || isDlerror) {
|
|
35264
35694
|
const type = types2[functionType2];
|
|
@@ -35268,17 +35698,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35268
35698
|
}
|
|
35269
35699
|
if (isDlsym) usesDlsym = true;
|
|
35270
35700
|
if (isDlerror) usesDlerror = true;
|
|
35271
|
-
|
|
35272
|
-
|
|
35273
|
-
|
|
35274
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding
|
|
35275
|
-
)
|
|
35276
|
-
|
|
35277
|
-
|
|
35278
|
-
|
|
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
|
+
}
|
|
35279
35709
|
}
|
|
35280
|
-
if (offset !==
|
|
35281
|
-
if (
|
|
35710
|
+
if (offset !== end) throw new Error("invalid wasm import section");
|
|
35711
|
+
if (importWriter) rewrittenSection = importWriter.finish();
|
|
35282
35712
|
} else if (id === 3) {
|
|
35283
35713
|
const count = number3();
|
|
35284
35714
|
for (let i = 0; i < count; i++) functionTypes.push(number3());
|
|
@@ -35287,43 +35717,40 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35287
35717
|
if (sectionName === "linking") {
|
|
35288
35718
|
const version2 = number3();
|
|
35289
35719
|
if (version2 !== 2) throw new Error("unsupported wasm linking version");
|
|
35290
|
-
const subsections = [];
|
|
35720
|
+
const subsections = rewrite ? [] : void 0;
|
|
35291
35721
|
let objcLoader;
|
|
35292
|
-
while (offset <
|
|
35293
|
-
const kind =
|
|
35722
|
+
while (offset < end) {
|
|
35723
|
+
const kind = bytes[offset++];
|
|
35294
35724
|
const length = number3();
|
|
35295
35725
|
const stop = offset + length;
|
|
35296
|
-
if (stop >
|
|
35297
|
-
|
|
35298
|
-
if (kind === 7 && !sdkLookupOnly) {
|
|
35299
|
-
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);
|
|
35300
35730
|
const count = number3();
|
|
35301
|
-
|
|
35731
|
+
comdatWriter.uleb(count);
|
|
35302
35732
|
for (let i = 0; i < count; i++) {
|
|
35303
35733
|
const group = string7();
|
|
35304
35734
|
const begin = offset;
|
|
35305
35735
|
number3();
|
|
35306
35736
|
const members2 = number3();
|
|
35307
35737
|
for (let member = 0; member < members2 * 2; member++) number3();
|
|
35308
|
-
|
|
35309
|
-
|
|
35310
|
-
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
35311
|
-
),
|
|
35312
|
-
section2.subarray(begin, offset)
|
|
35738
|
+
comdatWriter.string(
|
|
35739
|
+
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
35313
35740
|
);
|
|
35741
|
+
comdatWriter.bytes(bytes, begin, offset);
|
|
35314
35742
|
}
|
|
35315
35743
|
if (offset !== stop) throw new Error("invalid comdat subsection");
|
|
35316
|
-
|
|
35317
|
-
|
|
35318
|
-
if (kind === 8) {
|
|
35319
|
-
const
|
|
35320
|
-
|
|
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;
|
|
35321
35749
|
const count = number3();
|
|
35322
|
-
entries2.push(encodeNumber(count));
|
|
35323
35750
|
let added = 0;
|
|
35324
35751
|
for (let i = 0; i < count; i++) {
|
|
35325
35752
|
const begin = offset;
|
|
35326
|
-
const symbolKind =
|
|
35753
|
+
const symbolKind = bytes[offset++];
|
|
35327
35754
|
const flags = number3();
|
|
35328
35755
|
const flagsEnd = offset;
|
|
35329
35756
|
let index = -1;
|
|
@@ -35351,25 +35778,43 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35351
35778
|
}
|
|
35352
35779
|
} else if (symbolKind === 3) number3();
|
|
35353
35780
|
else throw new Error("unsupported wasm symbol kind");
|
|
35354
|
-
if (symbolKind === 0)
|
|
35781
|
+
if (!rewrite && symbolKind === 0)
|
|
35355
35782
|
functionSymbols[i] = name3 || functionImportNames[index];
|
|
35356
|
-
if (!sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
35783
|
+
if (rewrite && !sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
35357
35784
|
objcLoader = i;
|
|
35358
35785
|
}
|
|
35359
35786
|
const alias = names.get(name3);
|
|
35360
|
-
if (flags & 16 && symbolKind === 1 && alias)
|
|
35361
|
-
|
|
35362
|
-
|
|
35363
|
-
|
|
35364
|
-
|
|
35365
|
-
|
|
35366
|
-
|
|
35367
|
-
|
|
35368
|
-
|
|
35369
|
-
|
|
35370
|
-
|
|
35371
|
-
|
|
35372
|
-
|
|
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
|
+
}
|
|
35373
35818
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
35374
35819
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
35375
35820
|
throw new Error(`unsupported symbol ${name3}`);
|
|
@@ -35383,63 +35828,73 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35383
35828
|
hidden: (flags & 4) !== 0,
|
|
35384
35829
|
type
|
|
35385
35830
|
});
|
|
35386
|
-
|
|
35387
|
-
entries2.push(section2.subarray(begin, offset));
|
|
35388
|
-
extraEntries.push(
|
|
35389
|
-
section2.subarray(begin, begin + 1),
|
|
35390
|
-
encodeNumber(flags & ~32),
|
|
35391
|
-
section2.subarray(flagsEnd, nameStart),
|
|
35392
|
-
encodedString(alias),
|
|
35393
|
-
section2.subarray(nameEnd, offset)
|
|
35394
|
-
);
|
|
35395
|
-
added++;
|
|
35396
|
-
} else {
|
|
35397
|
-
entries2.push(
|
|
35398
|
-
section2.subarray(begin, nameStart),
|
|
35399
|
-
encodedString(alias),
|
|
35400
|
-
section2.subarray(nameEnd, offset)
|
|
35401
|
-
);
|
|
35402
|
-
}
|
|
35403
|
-
} else entries2.push(section2.subarray(begin, offset));
|
|
35831
|
+
}
|
|
35404
35832
|
}
|
|
35405
35833
|
if (offset !== stop) throw new Error("invalid symbol subsection");
|
|
35406
|
-
|
|
35407
|
-
|
|
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
|
+
});
|
|
35408
35858
|
}
|
|
35409
35859
|
offset = stop;
|
|
35410
|
-
|
|
35411
|
-
|
|
35412
|
-
|
|
35413
|
-
|
|
35414
|
-
|
|
35415
|
-
|
|
35416
|
-
|
|
35417
|
-
|
|
35418
|
-
|
|
35419
|
-
|
|
35420
|
-
|
|
35421
|
-
|
|
35422
|
-
|
|
35423
|
-
|
|
35424
|
-
content
|
|
35425
|
-
|
|
35426
|
-
|
|
35427
|
-
|
|
35428
|
-
|
|
35429
|
-
|
|
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);
|
|
35430
35893
|
}
|
|
35431
|
-
if (entryStart !== content.length)
|
|
35432
|
-
throw new Error("invalid init functions subsection");
|
|
35433
|
-
content = Buffer.concat(entries2);
|
|
35434
35894
|
}
|
|
35435
|
-
|
|
35436
|
-
Buffer.from([subsection.kind]),
|
|
35437
|
-
encodeNumber(content.length),
|
|
35438
|
-
content
|
|
35439
|
-
);
|
|
35895
|
+
rewrittenSection = linkingWriter.finish();
|
|
35440
35896
|
}
|
|
35441
|
-
|
|
35442
|
-
} else if (!sections && sectionName.startsWith("reloc.")) {
|
|
35897
|
+
} else if (!rewrite && sectionName.startsWith("reloc.")) {
|
|
35443
35898
|
number3();
|
|
35444
35899
|
for (let count = number3(); count > 0; count--) {
|
|
35445
35900
|
const type = number3();
|
|
@@ -35449,18 +35904,27 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
35449
35904
|
if (name3 !== void 0 && TABLE_INDEX_RELOCATIONS.has(type))
|
|
35450
35905
|
addressTaken.add(name3);
|
|
35451
35906
|
}
|
|
35452
|
-
if (offset !==
|
|
35453
|
-
|
|
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));
|
|
35454
35919
|
}
|
|
35455
35920
|
}
|
|
35456
|
-
sections?.push(Buffer.from([id]), encodeNumber(section2.length), section2);
|
|
35457
35921
|
}
|
|
35458
35922
|
return {
|
|
35459
35923
|
bytes: sections ? Buffer.concat(sections) : bytes,
|
|
35460
35924
|
definitions,
|
|
35461
35925
|
functionImports,
|
|
35462
35926
|
usesDlsym,
|
|
35463
|
-
usedSymbols
|
|
35927
|
+
usedSymbols,
|
|
35464
35928
|
addressTaken: [...addressTaken]
|
|
35465
35929
|
};
|
|
35466
35930
|
}
|
|
@@ -35549,36 +36013,51 @@ function createGuestImageLedger(input) {
|
|
|
35549
36013
|
}
|
|
35550
36014
|
}
|
|
35551
36015
|
}
|
|
35552
|
-
|
|
35553
|
-
for (const definition2 of definitions)
|
|
35554
|
-
|
|
35555
|
-
|
|
35556
|
-
|
|
35557
|
-
|
|
35558
|
-
|
|
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
|
+
}
|
|
35559
36040
|
const preserveCanonical = /* @__PURE__ */ new Set();
|
|
35560
36041
|
const definitionsByName = Map.groupBy(definitions, (definition2) => definition2.name);
|
|
35561
|
-
|
|
36042
|
+
if (symbolIndices.has("__cxa_throw")) {
|
|
36043
|
+
const name3 = "__cxa_throw";
|
|
35562
36044
|
const matching = definitionsByName.get(name3) ?? [];
|
|
35563
|
-
if (new Set(matching.map((definition2) => definition2.image)).size
|
|
35564
|
-
|
|
35565
|
-
|
|
35566
|
-
|
|
35567
|
-
|
|
35568
|
-
|
|
35569
|
-
|
|
35570
|
-
|
|
35571
|
-
|
|
35572
|
-
|
|
35573
|
-
|
|
35574
|
-
|
|
35575
|
-
|
|
35576
|
-
|
|
35577
|
-
);
|
|
35578
|
-
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
35579
|
-
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);
|
|
35580
36060
|
}
|
|
35581
|
-
preserveCanonical.add(name3);
|
|
35582
36061
|
}
|
|
35583
36062
|
for (const name3 of [
|
|
35584
36063
|
"dlsym",
|
|
@@ -35590,40 +36069,76 @@ function createGuestImageLedger(input) {
|
|
|
35590
36069
|
])
|
|
35591
36070
|
preserveCanonical.add(name3);
|
|
35592
36071
|
for (const name3 of input.commandLineSymbols ?? []) preserveCanonical.add(name3);
|
|
35593
|
-
const
|
|
35594
|
-
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();
|
|
35595
36102
|
for (const caller of input.callers) {
|
|
35596
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
35597
|
-
const seen = /* @__PURE__ */ new Map();
|
|
35598
36103
|
const scope2 = [caller.image, ...caller.next];
|
|
35599
36104
|
if (input.systemImage !== void 0 && !scope2.includes(input.systemImage))
|
|
35600
36105
|
scope2.push(input.systemImage);
|
|
35601
|
-
|
|
35602
|
-
|
|
35603
|
-
|
|
35604
|
-
|
|
35605
|
-
|
|
35606
|
-
|
|
35607
|
-
|
|
35608
|
-
|
|
35609
|
-
|
|
35610
|
-
|
|
35611
|
-
|
|
35612
|
-
|
|
35613
|
-
|
|
35614
|
-
|
|
35615
|
-
|
|
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;
|
|
35616
36128
|
}
|
|
35617
36129
|
}
|
|
35618
|
-
|
|
36130
|
+
cache.set(name3, null);
|
|
36131
|
+
return void 0;
|
|
36132
|
+
});
|
|
35619
36133
|
}
|
|
35620
36134
|
const startup = /* @__PURE__ */ new Map();
|
|
36135
|
+
const unitsByPath = new Map(units.map((unit2) => [unit2.object.path, unit2]));
|
|
35621
36136
|
for (const binding of input.directBindings ?? []) {
|
|
35622
|
-
const unit2 =
|
|
36137
|
+
const unit2 = unitsByPath.get(binding.object);
|
|
35623
36138
|
const matches = (definitionsByName.get(binding.symbol) ?? []).filter(
|
|
35624
36139
|
(definition2) => definition2.object === binding.providerObject && definition2.image === binding.providerImage
|
|
35625
36140
|
);
|
|
35626
|
-
if (!unit2 || !unit2.usedSymbols.
|
|
36141
|
+
if (!unit2 || !unit2.usedSymbols.has(binding.symbol) || matches.length !== 1)
|
|
35627
36142
|
throw new Error(`invalid startup binding ${binding.object} ${binding.symbol}`);
|
|
35628
36143
|
const bindings = startup.get(binding.object) ?? /* @__PURE__ */ new Map();
|
|
35629
36144
|
if (bindings.has(binding.symbol))
|
|
@@ -35664,11 +36179,11 @@ function createGuestImageLedger(input) {
|
|
|
35664
36179
|
}
|
|
35665
36180
|
}
|
|
35666
36181
|
const objects = units.map(({ image, object: object7, aliases, functionImports }) => {
|
|
35667
|
-
const shared =
|
|
36182
|
+
const shared = sharedLookupByImage.get(image);
|
|
35668
36183
|
const own2 = startup.get(object7.path);
|
|
35669
36184
|
const bindings = new Map(own2);
|
|
35670
36185
|
const weak = input.sdkWeakReferences?.get(object7.path);
|
|
35671
|
-
const binding = (name3) => bindings.get(name3) ?? shared
|
|
36186
|
+
const binding = (name3) => bindings.get(name3) ?? shared(name3) ?? (weak?.has(name3) ? void 0 : sdkGlobalBindings.get(name3));
|
|
35672
36187
|
for (const [name3, type] of functionImports) {
|
|
35673
36188
|
const alias = binding(name3);
|
|
35674
36189
|
const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
|
|
@@ -35933,7 +36448,7 @@ function nameGuestImageAliases(wasm, symbols) {
|
|
|
35933
36448
|
}
|
|
35934
36449
|
return Buffer.concat(parts);
|
|
35935
36450
|
}
|
|
35936
|
-
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;
|
|
35937
36452
|
var init_swift_guest_image_ledger = __esm({
|
|
35938
36453
|
"src/swift-guest-image-ledger.ts"() {
|
|
35939
36454
|
"use strict";
|
|
@@ -35941,6 +36456,57 @@ var init_swift_guest_image_ledger = __esm({
|
|
|
35941
36456
|
init_nativeWasmContract();
|
|
35942
36457
|
init_swift_sdk_image_wasm();
|
|
35943
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
|
+
};
|
|
35944
36510
|
OBJC_INIT_RECORD = ".objc_init";
|
|
35945
36511
|
TABLE_INDEX_RELOCATIONS = /* @__PURE__ */ new Set([1, 2, 12, 18, 19, 24]);
|
|
35946
36512
|
GUEST_DYLD_VALUES_SECTION = "peach_dyld_values";
|
|
@@ -36392,8 +36958,11 @@ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
36392
36958
|
function guestDyldValueRange(map2) {
|
|
36393
36959
|
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
36394
36960
|
let found;
|
|
36395
|
-
for (
|
|
36396
|
-
|
|
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);
|
|
36397
36966
|
const match = /^\s*([\da-f]+)\s+[\da-f]+\s+([\da-f]+)\s/.exec(line);
|
|
36398
36967
|
if (!match) throw new Error("unreadable dyld values map line");
|
|
36399
36968
|
if (found) throw new Error("link map has several dyld value sections");
|
|
@@ -36446,7 +37015,7 @@ var init_swift_guest_link_plan = __esm({
|
|
|
36446
37015
|
});
|
|
36447
37016
|
|
|
36448
37017
|
// src/swift-guest-manifest.ts
|
|
36449
|
-
function selectedGuestManifestInputs(plan, selection, identities) {
|
|
37018
|
+
function selectedGuestManifestInputs(plan, selection, identities, readSelected) {
|
|
36450
37019
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
36451
37020
|
const archives = /* @__PURE__ */ new Map();
|
|
36452
37021
|
const images = /* @__PURE__ */ new Map();
|
|
@@ -36457,19 +37026,29 @@ function selectedGuestManifestInputs(plan, selection, identities) {
|
|
|
36457
37026
|
throw new Error(`selected input has no logical identity: ${item.artifact}`);
|
|
36458
37027
|
let bytes;
|
|
36459
37028
|
let memberIdentity = null;
|
|
36460
|
-
if (item.member === null)
|
|
36461
|
-
|
|
36462
|
-
|
|
36463
|
-
if (
|
|
36464
|
-
|
|
36465
|
-
|
|
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];
|
|
36466
37051
|
}
|
|
36467
|
-
const matching = members2.filter((member) => member.name === item.member);
|
|
36468
|
-
if (matching.length !== 1)
|
|
36469
|
-
throw new Error(
|
|
36470
|
-
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
36471
|
-
);
|
|
36472
|
-
bytes = matching[0].bytes;
|
|
36473
37052
|
const origin = artifact.memberOrigins?.get(item.member);
|
|
36474
37053
|
if (artifact.memberOrigins && !origin)
|
|
36475
37054
|
throw new Error(
|
|
@@ -36561,7 +37140,7 @@ var init_swift_guest_manifest = __esm({
|
|
|
36561
37140
|
function isSwiftGuestImageManifest(value) {
|
|
36562
37141
|
const uint = (value2, maximum) => typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 && value2 <= maximum;
|
|
36563
37142
|
const text7 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
36564
|
-
const name3 = (value2) => text7(value2) &&
|
|
37143
|
+
const name3 = (value2) => text7(value2) && Buffer.byteLength(value2, "utf8") <= 16;
|
|
36565
37144
|
const version2 = (value2) => isRecord(value2) && uint(value2.major, 65535) && uint(value2.minor, 255) && uint(value2.patch, 255);
|
|
36566
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))
|
|
36567
37146
|
return false;
|
|
@@ -36875,27 +37454,25 @@ function planGuestProjectionRegions(images, capacities, spans) {
|
|
|
36875
37454
|
function finalizeGuestProjectionStorage(options2) {
|
|
36876
37455
|
const owner = options2.owners.get(options2.projectionObject);
|
|
36877
37456
|
if (owner === void 0) throw new Error("guest projection object has no image owner");
|
|
37457
|
+
const ranges = [];
|
|
36878
37458
|
const spans = guestLinkedSpans(
|
|
36879
37459
|
options2.map,
|
|
36880
37460
|
options2.linked,
|
|
36881
37461
|
options2.optimized,
|
|
36882
37462
|
options2.owners,
|
|
36883
37463
|
options2.sectionOwners,
|
|
36884
|
-
options2.sdkSpans !== void 0
|
|
37464
|
+
options2.sdkSpans !== void 0,
|
|
37465
|
+
{
|
|
37466
|
+
trackedObject: options2.projectionObject,
|
|
37467
|
+
trackedObjectOwner: owner,
|
|
37468
|
+
trackedLinearSpans: ranges
|
|
37469
|
+
}
|
|
36885
37470
|
);
|
|
36886
37471
|
const images = planGuestProjectionRegions(
|
|
36887
37472
|
options2.reserved.images,
|
|
36888
37473
|
options2.reserved.capacities,
|
|
36889
37474
|
options2.sdkSpans ? [...spans, ...options2.sdkSpans] : spans
|
|
36890
37475
|
);
|
|
36891
|
-
const ranges = guestLinkedSpans(
|
|
36892
|
-
options2.map,
|
|
36893
|
-
options2.linked,
|
|
36894
|
-
options2.optimized,
|
|
36895
|
-
/* @__PURE__ */ new Map([[options2.projectionObject, owner]]),
|
|
36896
|
-
void 0,
|
|
36897
|
-
options2.sdkSpans !== void 0
|
|
36898
|
-
).filter((span) => span.space === "linear-memory");
|
|
36899
37476
|
const result = Buffer.from(options2.optimized);
|
|
36900
37477
|
const data = guestWasmDataSegments(options2.optimized, options2.sdkSpans === void 0);
|
|
36901
37478
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -37963,7 +38540,7 @@ function occurrences(plan, args) {
|
|
|
37963
38540
|
throw new Error("guest plan does not match linker inputs");
|
|
37964
38541
|
return found;
|
|
37965
38542
|
}
|
|
37966
|
-
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
38543
|
+
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace, archiveCache) {
|
|
37967
38544
|
const rows = whyExtract.trimEnd().split("\n");
|
|
37968
38545
|
if (rows.shift() !== "reference extracted symbol")
|
|
37969
38546
|
throw new Error("invalid wasm-ld extraction report");
|
|
@@ -37978,8 +38555,38 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
37978
38555
|
for (const file of extracted)
|
|
37979
38556
|
if (!traced.has(file))
|
|
37980
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
|
+
}
|
|
37981
38588
|
const result = [];
|
|
37982
|
-
for (const { artifact, lazy, whole } of
|
|
38589
|
+
for (const { artifact, lazy, whole } of foundOccurrences) {
|
|
37983
38590
|
if (artifact.kind === "object") {
|
|
37984
38591
|
if (!lazy && !traced.has(artifact.path))
|
|
37985
38592
|
throw new Error(`eager guest input is absent from link trace ${artifact.path}`);
|
|
@@ -37987,15 +38594,21 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
37987
38594
|
result.push({ artifact: artifact.path, member: null });
|
|
37988
38595
|
continue;
|
|
37989
38596
|
}
|
|
37990
|
-
const
|
|
37991
|
-
const
|
|
37992
|
-
|
|
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();
|
|
37993
38605
|
for (const member of members2) {
|
|
37994
|
-
|
|
38606
|
+
memberCounts.set(member.name, (memberCounts.get(member.name) ?? 0) + 1);
|
|
38607
|
+
if (whole || nameSet.has(member.name))
|
|
37995
38608
|
result.push({ artifact: artifact.path, member: member.name });
|
|
37996
38609
|
}
|
|
37997
38610
|
for (const name3 of names)
|
|
37998
|
-
if (
|
|
38611
|
+
if (memberCounts.get(name3) !== 1)
|
|
37999
38612
|
throw new Error(
|
|
38000
38613
|
`ambiguous or unsupported archive member ${artifact.path}(${name3})`
|
|
38001
38614
|
);
|
|
@@ -38072,14 +38685,25 @@ function linkGuestImages(options2) {
|
|
|
38072
38685
|
}
|
|
38073
38686
|
const archives = /* @__PURE__ */ new Map();
|
|
38074
38687
|
const memberBytes = /* @__PURE__ */ new Map();
|
|
38688
|
+
const objectBytes = /* @__PURE__ */ new Map();
|
|
38075
38689
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
38076
38690
|
const providerSymbol = "__peach_dlsym_from_image";
|
|
38077
38691
|
const readSelected = (item) => {
|
|
38078
|
-
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
|
+
}
|
|
38079
38700
|
let byName2 = memberBytes.get(item.artifact);
|
|
38080
38701
|
if (!byName2) {
|
|
38081
|
-
|
|
38082
|
-
|
|
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
|
+
}
|
|
38083
38707
|
byName2 = /* @__PURE__ */ new Map();
|
|
38084
38708
|
for (const member of members2)
|
|
38085
38709
|
if (!byName2.has(member.name))
|
|
@@ -38103,7 +38727,13 @@ function linkGuestImages(options2) {
|
|
|
38103
38727
|
`--why-extract=${whyPath}`,
|
|
38104
38728
|
`--Map=${mapPath}`
|
|
38105
38729
|
]);
|
|
38106
|
-
return selectedGuestLinkInputs(
|
|
38730
|
+
return selectedGuestLinkInputs(
|
|
38731
|
+
plan,
|
|
38732
|
+
args,
|
|
38733
|
+
import_node_fs49.default.readFileSync(whyPath, "utf8"),
|
|
38734
|
+
trace,
|
|
38735
|
+
archives
|
|
38736
|
+
);
|
|
38107
38737
|
};
|
|
38108
38738
|
const needsProvider = (item) => {
|
|
38109
38739
|
if (!artifacts.get(item.artifact).instrumentDynamicLookups) return false;
|
|
@@ -38143,7 +38773,7 @@ function linkGuestImages(options2) {
|
|
|
38143
38773
|
)
|
|
38144
38774
|
]);
|
|
38145
38775
|
const originalOwnership = identity2(plan);
|
|
38146
|
-
const resolved = options2.resolvePlan(selected, plan);
|
|
38776
|
+
const resolved = options2.resolvePlan(selected, plan, readSelected);
|
|
38147
38777
|
if (identity2(resolved) !== originalOwnership)
|
|
38148
38778
|
throw new Error("resolved guest scopes changed input ownership");
|
|
38149
38779
|
plan = resolved;
|
|
@@ -38197,6 +38827,7 @@ function linkGuestImages(options2) {
|
|
|
38197
38827
|
}
|
|
38198
38828
|
}
|
|
38199
38829
|
let discoveryRegions;
|
|
38830
|
+
let liveSymbols;
|
|
38200
38831
|
if (discoveryProjection && options2.projection) {
|
|
38201
38832
|
const owners = /* @__PURE__ */ new Map([[discoveryProjection, options2.projection.image]]);
|
|
38202
38833
|
for (const item of selected)
|
|
@@ -38205,10 +38836,15 @@ function linkGuestImages(options2) {
|
|
|
38205
38836
|
selectedGuestInputImage(artifacts.get(item.artifact), item.member)
|
|
38206
38837
|
);
|
|
38207
38838
|
const wasm = import_node_fs49.default.readFileSync(discovery);
|
|
38839
|
+
liveSymbols = /* @__PURE__ */ new Set();
|
|
38208
38840
|
discoveryRegions = guestProjectionRegionCounts(
|
|
38209
38841
|
plan.images.length,
|
|
38210
|
-
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners
|
|
38842
|
+
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners, void 0, false, {
|
|
38843
|
+
collectSymbols: liveSymbols
|
|
38844
|
+
})
|
|
38211
38845
|
);
|
|
38846
|
+
} else {
|
|
38847
|
+
liveSymbols = linkedMapSymbols(guestLinkLines(mapPath));
|
|
38212
38848
|
}
|
|
38213
38849
|
const ledger = createGuestImageLedger({
|
|
38214
38850
|
images: plan.images.map((image) => ({
|
|
@@ -38217,7 +38853,7 @@ function linkGuestImages(options2) {
|
|
|
38217
38853
|
})),
|
|
38218
38854
|
callers: plan.callers,
|
|
38219
38855
|
symbols: plan.symbols,
|
|
38220
|
-
liveSymbols
|
|
38856
|
+
liveSymbols,
|
|
38221
38857
|
commandLineSymbols: commandLineSymbols(args),
|
|
38222
38858
|
directBindings: plan.directBindings,
|
|
38223
38859
|
registerAppTables: sdkCallers !== void 0,
|
|
@@ -38349,7 +38985,8 @@ function linkGuestImages(options2) {
|
|
|
38349
38985
|
const selectedInputs = selectedGuestManifestInputs(
|
|
38350
38986
|
plan,
|
|
38351
38987
|
selected,
|
|
38352
|
-
projection.identities
|
|
38988
|
+
projection.identities,
|
|
38989
|
+
readSelected
|
|
38353
38990
|
);
|
|
38354
38991
|
const images = projection.images.map(
|
|
38355
38992
|
(image) => createGuestImageManifest({
|
|
@@ -38359,6 +38996,9 @@ function linkGuestImages(options2) {
|
|
|
38359
38996
|
regions: []
|
|
38360
38997
|
})
|
|
38361
38998
|
);
|
|
38999
|
+
objectBytes.clear();
|
|
39000
|
+
memberBytes.clear();
|
|
39001
|
+
archives.clear();
|
|
38362
39002
|
if (!discoveryRegions) throw new Error("guest projection layout object missing");
|
|
38363
39003
|
const regionsBefore = discoveryRegions;
|
|
38364
39004
|
const ledgerPieces = guestProjectionRegionCapacity([import_node_fs49.default.readFileSync(ledgerObject)], 0);
|
|
@@ -38452,10 +39092,47 @@ ${changed.join("\n")}`
|
|
|
38452
39092
|
}
|
|
38453
39093
|
function linkedMapSymbols(lines) {
|
|
38454
39094
|
const names = /* @__PURE__ */ new Set();
|
|
38455
|
-
const symbol2 = /^ +\S+ +[0-9a-f]+ +[0-9a-f]+ {9,}([^\s/<]\S*)/;
|
|
38456
39095
|
for (const line of lines) {
|
|
38457
|
-
const
|
|
38458
|
-
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));
|
|
38459
39136
|
}
|
|
38460
39137
|
return names;
|
|
38461
39138
|
}
|
|
@@ -38554,7 +39231,7 @@ function discoverGuestLinkInputs(options2) {
|
|
|
38554
39231
|
import_node_fs49.default.mkdirSync(options2.directory, { recursive: true });
|
|
38555
39232
|
const why = import_node_path47.default.join(options2.directory, "preselection-why.txt");
|
|
38556
39233
|
const response = import_node_path47.default.join(options2.directory, "preselection.rsp");
|
|
38557
|
-
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");
|
|
38558
39235
|
const flags = [
|
|
38559
39236
|
...withOutput(args, output, true),
|
|
38560
39237
|
...options2.objects,
|
|
@@ -38652,7 +39329,7 @@ function prepareGuestRuntimeInputs(options2) {
|
|
|
38652
39329
|
});
|
|
38653
39330
|
return { args, selected, originalSelection, archives, sdkProducts, archiveArtifacts };
|
|
38654
39331
|
}
|
|
38655
|
-
function selectedGuestSymbolInputs(plan, selected) {
|
|
39332
|
+
function selectedGuestSymbolInputs(plan, selected, readSelected) {
|
|
38656
39333
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
38657
39334
|
const archives = /* @__PURE__ */ new Map();
|
|
38658
39335
|
const symbols = /* @__PURE__ */ new Set();
|
|
@@ -38668,22 +39345,27 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
38668
39345
|
if (!artifact) throw new Error(`selected symbol input has no owner ${item.artifact}`);
|
|
38669
39346
|
let bytes;
|
|
38670
39347
|
let name3 = item.artifact;
|
|
38671
|
-
if (item.member === null)
|
|
38672
|
-
|
|
38673
|
-
|
|
38674
|
-
if (
|
|
38675
|
-
|
|
38676
|
-
|
|
38677
|
-
|
|
38678
|
-
)
|
|
38679
|
-
|
|
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;
|
|
38680
39368
|
}
|
|
38681
|
-
const matching = members2.get(item.member) ?? [];
|
|
38682
|
-
if (matching.length !== 1)
|
|
38683
|
-
throw new Error(
|
|
38684
|
-
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
38685
|
-
);
|
|
38686
|
-
bytes = matching[0].bytes;
|
|
38687
39369
|
name3 += `(${item.member})`;
|
|
38688
39370
|
}
|
|
38689
39371
|
if (owners.has(name3)) throw new Error(`duplicate selected symbol input ${name3}`);
|
|
@@ -38696,9 +39378,9 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
38696
39378
|
for (const symbol2 of names.tags) tags.add(symbol2);
|
|
38697
39379
|
for (const symbol2 of names.defined) {
|
|
38698
39380
|
definitions.add(symbol2);
|
|
38699
|
-
|
|
39381
|
+
let objects = definitionObjects.get(symbol2);
|
|
39382
|
+
if (!objects) definitionObjects.set(symbol2, objects = /* @__PURE__ */ new Set());
|
|
38700
39383
|
objects.add(name3);
|
|
38701
|
-
definitionObjects.set(symbol2, objects);
|
|
38702
39384
|
}
|
|
38703
39385
|
}
|
|
38704
39386
|
return {
|
|
@@ -38719,7 +39401,7 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38719
39401
|
if (!symbols.length) return { bindings: [], directBindings: [] };
|
|
38720
39402
|
import_node_fs49.default.mkdirSync(options2.directory, { recursive: true });
|
|
38721
39403
|
const response = import_node_path47.default.join(options2.directory, "scope-trace.rsp");
|
|
38722
|
-
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");
|
|
38723
39405
|
const args = [
|
|
38724
39406
|
...withOutput(normalizedGuestLinkArgs(options2.args), output, true),
|
|
38725
39407
|
...options2.objects,
|
|
@@ -38737,55 +39419,76 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38737
39419
|
import_node_fs49.default.closeSync(traceOutput);
|
|
38738
39420
|
}
|
|
38739
39421
|
const records = /* @__PURE__ */ new Map();
|
|
38740
|
-
const
|
|
38741
|
-
const
|
|
38742
|
-
|
|
38743
|
-
|
|
38744
|
-
|
|
38745
|
-
|
|
38746
|
-
const
|
|
38747
|
-
|
|
38748
|
-
|
|
38749
|
-
|
|
38750
|
-
|
|
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);
|
|
38751
39440
|
if (object7 === "<internal>") {
|
|
38752
|
-
if (
|
|
39441
|
+
if (!isRef) record4.physicalModule = true;
|
|
38753
39442
|
} else {
|
|
38754
39443
|
const image = options2.owners.get(object7);
|
|
38755
39444
|
if (image === void 0)
|
|
38756
39445
|
throw new Error(`traced guest object has no owner ${object7}`);
|
|
38757
|
-
(
|
|
38758
|
-
object7,
|
|
38759
|
-
image
|
|
38760
|
-
);
|
|
39446
|
+
(isRef ? record4.references : record4.providers).set(object7, image);
|
|
38761
39447
|
}
|
|
38762
|
-
|
|
38763
|
-
};
|
|
38764
|
-
for (const line of guestLinkLines(tracePath)) consume(line);
|
|
39448
|
+
}
|
|
38765
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);
|
|
38766
39454
|
const result = [];
|
|
38767
39455
|
const directBindings = [];
|
|
38768
39456
|
for (const symbol2 of symbols) {
|
|
38769
39457
|
const record4 = records.get(symbol2);
|
|
38770
39458
|
if (!record4 || !record4.references.size) continue;
|
|
38771
39459
|
if (!record4.providers.size && options2.hostImports.has(symbol2)) continue;
|
|
38772
|
-
const startupReferences = [
|
|
38773
|
-
|
|
38774
|
-
|
|
38775
|
-
const
|
|
38776
|
-
|
|
38777
|
-
|
|
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
|
+
}
|
|
38778
39472
|
for (const [, caller] of startupReferences)
|
|
38779
39473
|
if (!callers.has(caller))
|
|
38780
39474
|
throw new Error(`guest image has no caller scope ${caller}`);
|
|
38781
39475
|
if (startupReferences.length && !record4.physicalModule) {
|
|
38782
|
-
const
|
|
38783
|
-
|
|
39476
|
+
const candidates2 = options2.definitionObjects.get(symbol2);
|
|
39477
|
+
const candidateSize = candidates2?.size ?? 0;
|
|
39478
|
+
if (candidateSize > 1 || record4.providers.size > 1)
|
|
38784
39479
|
throw new Error(`ambiguous startup provider ${symbol2}`);
|
|
38785
|
-
|
|
38786
|
-
|
|
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}`);
|
|
38787
39490
|
if (record4.providers.size === 1) {
|
|
38788
|
-
const [providerObject, providerImage] =
|
|
39491
|
+
const [providerObject, providerImage] = record4.providers.entries().next().value;
|
|
38789
39492
|
if (options2.weakDefinitions.get(providerObject)?.has(symbol2))
|
|
38790
39493
|
throw new Error(`weak startup provider ${symbol2}`);
|
|
38791
39494
|
for (const [object7] of startupReferences)
|
|
@@ -38793,28 +39496,34 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38793
39496
|
}
|
|
38794
39497
|
if (!otherReferences.length) continue;
|
|
38795
39498
|
}
|
|
38796
|
-
if (!record4.providers.size && !record4.physicalModule &&
|
|
38797
|
-
(object7) => options2.weakReferences.get(object7)?.has(symbol2)
|
|
38798
|
-
))
|
|
38799
|
-
continue;
|
|
39499
|
+
if (!record4.providers.size && !record4.physicalModule && allWeakRefs) continue;
|
|
38800
39500
|
const providerImages = new Set(record4.providers.values());
|
|
38801
|
-
const
|
|
38802
|
-
|
|
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) {
|
|
38803
39507
|
const image = options2.owners.get(object7);
|
|
38804
|
-
|
|
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
|
+
}
|
|
38805
39516
|
}
|
|
38806
|
-
|
|
38807
|
-
const copyImages = new Set(copies.map((copy) => copy.image));
|
|
38808
|
-
const strongImages = new Set(
|
|
38809
|
-
copies.filter((copy) => !copy.weak).map((copy) => copy.image)
|
|
38810
|
-
);
|
|
39517
|
+
}
|
|
38811
39518
|
const interposed = !record4.physicalModule && copyImages.size > 1;
|
|
38812
39519
|
const providerCount = interposed ? 1 : providerImages.size + Number(record4.physicalModule);
|
|
38813
39520
|
if (!providerCount) continue;
|
|
38814
39521
|
if (providerCount !== 1)
|
|
38815
39522
|
throw new Error(`guest symbol has ambiguous provider ${symbol2}`);
|
|
38816
|
-
const scopedReferences = record4.physicalModule ?
|
|
38817
|
-
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;
|
|
38818
39527
|
for (const [object7, caller] of scopedReferences) {
|
|
38819
39528
|
const scope2 = callers.get(caller);
|
|
38820
39529
|
if (!scope2) throw new Error(`guest image has no caller scope ${caller}`);
|
|
@@ -38822,18 +39531,35 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38822
39531
|
result.push({ symbol: symbol2, caller, provider: { kind: "physical-module" } });
|
|
38823
39532
|
continue;
|
|
38824
39533
|
}
|
|
38825
|
-
|
|
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
|
+
}
|
|
38826
39556
|
if (provider === void 0) {
|
|
38827
39557
|
if (options2.weakReferences.get(object7)?.has(symbol2)) continue;
|
|
38828
39558
|
throw new Error(`guest scope ${caller} omits every provider of ${symbol2}`);
|
|
38829
39559
|
}
|
|
38830
39560
|
if (caller === provider) continue;
|
|
38831
|
-
if (
|
|
38832
|
-
|
|
38833
|
-
))
|
|
38834
|
-
continue;
|
|
38835
|
-
if (!scope2.includes(provider)) {
|
|
38836
|
-
const candidates = options2.definitionObjects.get(symbol2) ?? /* @__PURE__ */ new Set();
|
|
39561
|
+
if (weakDefinerImages?.has(caller)) continue;
|
|
39562
|
+
if (!callerSets.get(caller).has(provider)) {
|
|
38837
39563
|
const traced = [...record4.providers.keys()];
|
|
38838
39564
|
const strongTraced = traced.filter(
|
|
38839
39565
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
@@ -38841,16 +39567,17 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
38841
39567
|
const providers = strongTraced.length === 1 ? strongTraced : traced;
|
|
38842
39568
|
if (options2.weakReferences.get(object7)?.has(symbol2) && !providers.some((provider2) => options2.systemProviders.has(provider2)))
|
|
38843
39569
|
continue;
|
|
38844
|
-
const
|
|
39570
|
+
const candidateSet = candidates ?? /* @__PURE__ */ new Set();
|
|
39571
|
+
const equivalentCopies = providers.length === 1 && candidateSet.has(providers[0]) && [...candidateSet].every(
|
|
38845
39572
|
(definer) => options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
38846
39573
|
);
|
|
38847
|
-
const strongCandidates = [...
|
|
39574
|
+
const strongCandidates = [...candidateSet].filter(
|
|
38848
39575
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
38849
39576
|
);
|
|
38850
|
-
const soleCandidate =
|
|
38851
|
-
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
|
|
38852
39579
|
// scope, the root image and its dependency closure, as in elf.
|
|
38853
|
-
provider === 0 ||
|
|
39580
|
+
provider === 0 || rootScope?.has(provider) || !options2.weakReferences.get(object7)?.has(symbol2) && options2.frameworkProviders.get(object7)?.has(providers[0]))))
|
|
38854
39581
|
throw new Error(
|
|
38855
39582
|
`guest scope ${caller} omits traced provider ${provider} for ${symbol2}`
|
|
38856
39583
|
);
|
|
@@ -44712,9 +45439,9 @@ async function compileGuestLink(options2) {
|
|
|
44712
45439
|
}
|
|
44713
45440
|
};
|
|
44714
45441
|
},
|
|
44715
|
-
resolvePlan: (selected, plan) => {
|
|
45442
|
+
resolvePlan: (selected, plan, readSelected) => {
|
|
44716
45443
|
if (!prepared) throw new Error("guest runtime selection is unavailable");
|
|
44717
|
-
const scope2 = selectedGuestSymbolInputs(plan, selected);
|
|
45444
|
+
const scope2 = selectedGuestSymbolInputs(plan, selected, readSelected);
|
|
44718
45445
|
const owners = new Map(scope2.owners);
|
|
44719
45446
|
owners.set(import_node_path58.default.join(directory2, "projection-discovery.o"), 0);
|
|
44720
45447
|
const providersByImage = Map.groupBy(scope2.owners, ([, image]) => image);
|
|
@@ -52393,7 +53120,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
52393
53120
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
52394
53121
|
MULTI_MANIFEST_VERSION = 76;
|
|
52395
53122
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
52396
|
-
compilerSourceDigest = true ? "
|
|
53123
|
+
compilerSourceDigest = true ? "7b91fa4405159335b5484c82700e001e4c27abf15621b724ea8af4edea693f66" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
|
|
52397
53124
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
52398
53125
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
52399
53126
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|