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;
|
|
@@ -22162,6 +22162,7 @@ function stageOverlaySlot(realRoot, stagingRoot, relPath) {
|
|
|
22162
22162
|
const segment3 = segments[i];
|
|
22163
22163
|
for (const entry of (0, import_node_fs24.readdirSync)(real)) {
|
|
22164
22164
|
if (entry === segment3 || i === 0 && entry === SWIFT_CACHE_HOLD_MARKER) continue;
|
|
22165
|
+
if (mirror === stagingRoot && entry === "configuration") continue;
|
|
22165
22166
|
const dest = import_node_path22.default.join(mirror, entry);
|
|
22166
22167
|
if (!import_node_fs24.default.lstatSync(dest, { throwIfNoEntry: false })) {
|
|
22167
22168
|
import_node_fs24.default.symlinkSync(import_node_path22.default.join(real, entry), dest);
|
|
@@ -22196,7 +22197,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk2)
|
|
|
22196
22197
|
const stdint = import_node_path22.default.join(overlay, "include/stdint.h");
|
|
22197
22198
|
const key2 = JSON.stringify([
|
|
22198
22199
|
// bump the recipe when the transformation changes; bundling changes function text.
|
|
22199
|
-
"
|
|
22200
|
+
"v39",
|
|
22200
22201
|
[...WEAKEN_FOUNDATION_SYMS],
|
|
22201
22202
|
toolchainBin,
|
|
22202
22203
|
sdk2,
|
|
@@ -23828,24 +23829,56 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
23828
23829
|
const code = sections.get(10);
|
|
23829
23830
|
if (code) {
|
|
23830
23831
|
let pos = code[0];
|
|
23831
|
-
|
|
23832
|
-
|
|
23832
|
+
const codeStart = code[0];
|
|
23833
|
+
const codeEnd = code[1];
|
|
23834
|
+
let count = 0;
|
|
23835
|
+
{
|
|
23836
|
+
let shift = 0;
|
|
23837
|
+
for (; ; ) {
|
|
23838
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
23839
|
+
const byte = bytes[pos++];
|
|
23840
|
+
count += (byte & 127) * 2 ** shift;
|
|
23841
|
+
if (!(byte & 128)) break;
|
|
23842
|
+
shift += 7;
|
|
23843
|
+
}
|
|
23844
|
+
}
|
|
23833
23845
|
for (let i = 0; i < count; i++) {
|
|
23834
23846
|
const prefix = pos;
|
|
23835
|
-
let size2;
|
|
23836
|
-
|
|
23837
|
-
|
|
23847
|
+
let size2 = 0;
|
|
23848
|
+
const b0 = bytes[pos++];
|
|
23849
|
+
if (b0 < 128) {
|
|
23850
|
+
size2 = b0;
|
|
23851
|
+
} else {
|
|
23852
|
+
size2 = b0 & 127;
|
|
23853
|
+
let shift = 7;
|
|
23854
|
+
for (; ; ) {
|
|
23855
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
23856
|
+
const byte = bytes[pos++];
|
|
23857
|
+
size2 += (byte & 127) * 2 ** shift;
|
|
23858
|
+
if (!(byte & 128)) break;
|
|
23859
|
+
shift += 7;
|
|
23860
|
+
}
|
|
23861
|
+
}
|
|
23862
|
+
functionsByCodeOffset.set(prefix - codeStart, imports2 + i);
|
|
23838
23863
|
if (imports2 + i === startFunction) startup = bytes.subarray(pos, pos + size2);
|
|
23839
23864
|
pos += size2;
|
|
23840
|
-
if (pos >
|
|
23865
|
+
if (pos > codeEnd) throw new Error("invalid wasm code");
|
|
23841
23866
|
}
|
|
23842
|
-
if (pos !==
|
|
23867
|
+
if (pos !== codeEnd) throw new Error("invalid wasm code section");
|
|
23843
23868
|
}
|
|
23844
23869
|
const functionsByTableSlot = /* @__PURE__ */ new Map();
|
|
23845
23870
|
const elements = sections.get(9);
|
|
23846
23871
|
if (elements) {
|
|
23847
23872
|
let pos = elements[0];
|
|
23873
|
+
const elemEnd = elements[1];
|
|
23848
23874
|
const read = () => {
|
|
23875
|
+
if (pos < elemEnd) {
|
|
23876
|
+
const b0 = bytes[pos];
|
|
23877
|
+
if (b0 < 128) {
|
|
23878
|
+
pos++;
|
|
23879
|
+
return b0;
|
|
23880
|
+
}
|
|
23881
|
+
}
|
|
23849
23882
|
const [value, next] = number(bytes, pos);
|
|
23850
23883
|
pos = next;
|
|
23851
23884
|
return value;
|
|
@@ -23875,7 +23908,7 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
23875
23908
|
functionsByTableSlot.set(slot, read());
|
|
23876
23909
|
}
|
|
23877
23910
|
}
|
|
23878
|
-
if (pos !==
|
|
23911
|
+
if (pos !== elemEnd) throw new Error("invalid wasm element section");
|
|
23879
23912
|
}
|
|
23880
23913
|
const data = [];
|
|
23881
23914
|
const passive = /* @__PURE__ */ new Map();
|
|
@@ -23940,36 +23973,141 @@ function guestWasmDataSegments(bytes, requireExports = true) {
|
|
|
23940
23973
|
length: segment3.bytes.length
|
|
23941
23974
|
}));
|
|
23942
23975
|
}
|
|
23943
|
-
function
|
|
23976
|
+
function isMapSpace(code) {
|
|
23977
|
+
return code === 32 || code >= 9 && code <= 13;
|
|
23978
|
+
}
|
|
23979
|
+
function isMapHex(code) {
|
|
23980
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
23981
|
+
}
|
|
23982
|
+
function mapHexDigit(code) {
|
|
23983
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
23984
|
+
}
|
|
23985
|
+
function* stringLines(text7) {
|
|
23986
|
+
let start = 0;
|
|
23987
|
+
for (let end = text7.indexOf("\n"); end !== -1; end = text7.indexOf("\n", start)) {
|
|
23988
|
+
yield text7.slice(start, end);
|
|
23989
|
+
start = end + 1;
|
|
23990
|
+
}
|
|
23991
|
+
yield text7.slice(start);
|
|
23992
|
+
}
|
|
23993
|
+
function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PURE__ */ new Map(), importsLayout = false, extra) {
|
|
23944
23994
|
const unchanged = before === after;
|
|
23945
23995
|
const original = layout(before, !unchanged, !importsLayout);
|
|
23946
23996
|
const optimized = unchanged ? original : layout(after, true, !importsLayout);
|
|
23997
|
+
const collectSymbols = extra?.collectSymbols;
|
|
23998
|
+
const trackedObject = extra?.trackedObject;
|
|
23999
|
+
const trackedObjectOwner = extra?.trackedObjectOwner;
|
|
24000
|
+
const trackedLinearSpans = extra?.trackedLinearSpans;
|
|
24001
|
+
const hasSectionOwners = sectionOwners.size > 0;
|
|
23947
24002
|
let codeOffset;
|
|
23948
24003
|
let outputSection = "";
|
|
23949
24004
|
const codeOwners = /* @__PURE__ */ new Map();
|
|
23950
24005
|
const pieces = [];
|
|
23951
|
-
|
|
23952
|
-
|
|
23953
|
-
|
|
23954
|
-
|
|
23955
|
-
|
|
23956
|
-
|
|
23957
|
-
|
|
24006
|
+
const lines = typeof map2 === "string" ? stringLines(map2) : map2;
|
|
24007
|
+
for (const line of lines) {
|
|
24008
|
+
const lineLen = line.length;
|
|
24009
|
+
let pos = 0;
|
|
24010
|
+
let onlySpaces = true;
|
|
24011
|
+
while (pos < lineLen) {
|
|
24012
|
+
const ch = line.charCodeAt(pos);
|
|
24013
|
+
if (!isMapSpace(ch)) break;
|
|
24014
|
+
if (ch !== 32) onlySpaces = false;
|
|
24015
|
+
pos++;
|
|
24016
|
+
}
|
|
24017
|
+
const leadingSpaces = pos;
|
|
24018
|
+
if (pos >= lineLen) continue;
|
|
24019
|
+
const addrStart = pos;
|
|
24020
|
+
while (pos < lineLen && !isMapSpace(line.charCodeAt(pos))) pos++;
|
|
24021
|
+
const addrEnd = pos;
|
|
24022
|
+
if (pos >= lineLen) continue;
|
|
24023
|
+
const s1 = pos;
|
|
24024
|
+
while (pos < lineLen) {
|
|
24025
|
+
const ch = line.charCodeAt(pos);
|
|
24026
|
+
if (!isMapSpace(ch)) break;
|
|
24027
|
+
if (ch !== 32) onlySpaces = false;
|
|
24028
|
+
pos++;
|
|
24029
|
+
}
|
|
24030
|
+
if (pos === s1 || pos >= lineLen) continue;
|
|
24031
|
+
const offStart = pos;
|
|
24032
|
+
let offsetVal = 0;
|
|
24033
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
24034
|
+
offsetVal = offsetVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
24035
|
+
}
|
|
24036
|
+
if (pos === offStart || pos >= lineLen) continue;
|
|
24037
|
+
const s2 = pos;
|
|
24038
|
+
while (pos < lineLen) {
|
|
24039
|
+
const ch = line.charCodeAt(pos);
|
|
24040
|
+
if (!isMapSpace(ch)) break;
|
|
24041
|
+
if (ch !== 32) onlySpaces = false;
|
|
24042
|
+
pos++;
|
|
24043
|
+
}
|
|
24044
|
+
if (pos === s2 || pos >= lineLen) continue;
|
|
24045
|
+
const sizeStart = pos;
|
|
24046
|
+
let sizeVal = 0;
|
|
24047
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
24048
|
+
sizeVal = sizeVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
24049
|
+
}
|
|
24050
|
+
if (pos === sizeStart || pos >= lineLen) continue;
|
|
24051
|
+
const indentStart = pos;
|
|
24052
|
+
while (pos < lineLen && line.charCodeAt(pos) === 32) pos++;
|
|
24053
|
+
const indentLen = pos - indentStart;
|
|
24054
|
+
if (indentLen === 0 || pos >= lineLen) continue;
|
|
24055
|
+
const firstCh = line.charCodeAt(pos);
|
|
24056
|
+
if (isMapSpace(firstCh)) continue;
|
|
24057
|
+
const sourceStart = pos;
|
|
24058
|
+
if (collectSymbols && onlySpaces && leadingSpaces > 0 && indentLen >= 9 && firstCh !== 47 && firstCh !== 60) {
|
|
24059
|
+
let symEnd = sourceStart + 1;
|
|
24060
|
+
while (symEnd < lineLen && !isMapSpace(line.charCodeAt(symEnd))) symEnd++;
|
|
24061
|
+
collectSymbols.add(line.slice(sourceStart, symEnd));
|
|
24062
|
+
}
|
|
24063
|
+
const isDash = addrEnd - addrStart === 1 && line.charCodeAt(addrStart) === 45;
|
|
24064
|
+
if (isDash && indentLen === 1) {
|
|
24065
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
24066
|
+
outputSection = line.slice(sourceStart);
|
|
24067
|
+
if (outputSection === "CODE") codeOffset = offsetVal;
|
|
23958
24068
|
continue;
|
|
23959
24069
|
}
|
|
23960
|
-
|
|
24070
|
+
if (sizeVal === 0) continue;
|
|
24071
|
+
const separator = line.indexOf(":(", sourceStart);
|
|
23961
24072
|
if (separator < 0) continue;
|
|
23962
|
-
|
|
23963
|
-
|
|
23964
|
-
|
|
23965
|
-
|
|
23966
|
-
if (
|
|
23967
|
-
|
|
24073
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
24074
|
+
let hasLineSep = false;
|
|
24075
|
+
for (let i = sourceStart; i < lineLen; i++) {
|
|
24076
|
+
const ch = line.charCodeAt(i);
|
|
24077
|
+
if (ch === 8232 || ch === 8233) {
|
|
24078
|
+
hasLineSep = true;
|
|
24079
|
+
break;
|
|
24080
|
+
}
|
|
24081
|
+
}
|
|
24082
|
+
if (hasLineSep) continue;
|
|
24083
|
+
const objectPath = line.slice(sourceStart, separator);
|
|
24084
|
+
let image = hasSectionOwners ? sectionOwners.get(line.slice(sourceStart)) : void 0;
|
|
24085
|
+
if (image === void 0) image = owners.get(objectPath);
|
|
24086
|
+
if (!isDash) {
|
|
24087
|
+
if (outputSection === "DATA") {
|
|
24088
|
+
let addressVal = 0;
|
|
24089
|
+
let allHex = true;
|
|
24090
|
+
for (let i = addrStart; i < addrEnd; i++) {
|
|
24091
|
+
const ch = line.charCodeAt(i);
|
|
24092
|
+
if (isMapHex(ch)) addressVal = addressVal * 16 + mapHexDigit(ch);
|
|
24093
|
+
else {
|
|
24094
|
+
allHex = false;
|
|
24095
|
+
break;
|
|
24096
|
+
}
|
|
24097
|
+
}
|
|
24098
|
+
if (!allHex) addressVal = parseInt(line.slice(addrStart, addrEnd), 16);
|
|
24099
|
+
pieces.push({
|
|
24100
|
+
image,
|
|
24101
|
+
address: addressVal,
|
|
24102
|
+
length: sizeVal,
|
|
24103
|
+
tracked: trackedObject !== void 0 && objectPath === trackedObject
|
|
24104
|
+
});
|
|
24105
|
+
}
|
|
23968
24106
|
continue;
|
|
23969
24107
|
}
|
|
23970
24108
|
if (image === void 0 || outputSection !== "CODE") continue;
|
|
23971
24109
|
if (codeOffset === void 0) throw new Error("link map has no code section");
|
|
23972
|
-
const index = original.functionsByCodeOffset.get(
|
|
24110
|
+
const index = original.functionsByCodeOffset.get(offsetVal - codeOffset);
|
|
23973
24111
|
if (index === void 0) throw new Error("link map function has no wasm body");
|
|
23974
24112
|
const existing = codeOwners.get(index);
|
|
23975
24113
|
if (existing !== void 0 && existing !== image)
|
|
@@ -23978,12 +24116,23 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
23978
24116
|
}
|
|
23979
24117
|
pieces.sort((a, b) => a.address - b.address);
|
|
23980
24118
|
const spans = [];
|
|
23981
|
-
for (
|
|
23982
|
-
|
|
24119
|
+
for (let index = 0; index < pieces.length; index++) {
|
|
24120
|
+
const piece = pieces[index];
|
|
24121
|
+
const { image, address, length, tracked } = piece;
|
|
24122
|
+
if (image === void 0 && !tracked) continue;
|
|
23983
24123
|
let next = index + 1;
|
|
23984
24124
|
while (next < pieces.length && pieces[next].address < address + length) next++;
|
|
23985
24125
|
const end = pieces[next]?.address ?? address + length;
|
|
23986
|
-
|
|
24126
|
+
const spanLength = end - address;
|
|
24127
|
+
if (image !== void 0)
|
|
24128
|
+
spans.push({ image, space: "linear-memory", address, length: spanLength });
|
|
24129
|
+
if (tracked && trackedLinearSpans && trackedObjectOwner !== void 0)
|
|
24130
|
+
trackedLinearSpans.push({
|
|
24131
|
+
image: trackedObjectOwner,
|
|
24132
|
+
space: "linear-memory",
|
|
24133
|
+
address,
|
|
24134
|
+
length: spanLength
|
|
24135
|
+
});
|
|
23987
24136
|
}
|
|
23988
24137
|
const optimizedOwners = /* @__PURE__ */ new Map();
|
|
23989
24138
|
const dataAt = (module2, start, length) => {
|
|
@@ -24022,7 +24171,7 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
24022
24171
|
throw new Error(`optimization changed linked data at ${span.address}`);
|
|
24023
24172
|
}
|
|
24024
24173
|
let previous;
|
|
24025
|
-
for (const span of
|
|
24174
|
+
for (const span of spans) {
|
|
24026
24175
|
if (previous && span.address < previous.address + previous.length && span.image !== previous.image)
|
|
24027
24176
|
throw new Error("linked data belongs to multiple images");
|
|
24028
24177
|
if (!previous || span.address + span.length > previous.address + previous.length)
|
|
@@ -24204,6 +24353,20 @@ var init_swift_guest_linked_spans = __esm({
|
|
|
24204
24353
|
});
|
|
24205
24354
|
|
|
24206
24355
|
// src/swift-sdk-image-map.ts
|
|
24356
|
+
function isHexChar(code) {
|
|
24357
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
24358
|
+
}
|
|
24359
|
+
function hexDigit(code) {
|
|
24360
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
24361
|
+
}
|
|
24362
|
+
function hasLineBreak(line, from) {
|
|
24363
|
+
if (line.indexOf("\r", from) >= 0) return true;
|
|
24364
|
+
for (let i = from; i < line.length; i++) {
|
|
24365
|
+
const ch = line.charCodeAt(i);
|
|
24366
|
+
if (ch === 8232 || ch === 8233) return true;
|
|
24367
|
+
}
|
|
24368
|
+
return false;
|
|
24369
|
+
}
|
|
24207
24370
|
function readWasmLinkMap(file, partition) {
|
|
24208
24371
|
const segments = /* @__PURE__ */ new Map();
|
|
24209
24372
|
const data = [];
|
|
@@ -24211,48 +24374,117 @@ function readWasmLinkMap(file, partition) {
|
|
|
24211
24374
|
let kind = "";
|
|
24212
24375
|
let segment3 = "";
|
|
24213
24376
|
let previous;
|
|
24214
|
-
const hex = (value) => value === "-" ? -1 : parseInt(value, 16);
|
|
24215
24377
|
for (const line of guestLinkLines(file)) {
|
|
24216
|
-
const
|
|
24217
|
-
|
|
24218
|
-
|
|
24219
|
-
|
|
24220
|
-
|
|
24221
|
-
|
|
24222
|
-
|
|
24378
|
+
const length = line.length;
|
|
24379
|
+
let pos = 0;
|
|
24380
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
24381
|
+
if (pos >= length) continue;
|
|
24382
|
+
const leadingSpaces = pos;
|
|
24383
|
+
let address = -1;
|
|
24384
|
+
if (line.charCodeAt(pos) === 45) {
|
|
24385
|
+
pos++;
|
|
24386
|
+
} else {
|
|
24387
|
+
const start = pos;
|
|
24388
|
+
let value = 0;
|
|
24389
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
24390
|
+
value = value * 16 + hexDigit(line.charCodeAt(pos++));
|
|
24391
|
+
}
|
|
24392
|
+
if (pos === start) continue;
|
|
24393
|
+
address = value;
|
|
24394
|
+
}
|
|
24395
|
+
const s1 = pos;
|
|
24396
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
24397
|
+
if (pos === s1 || pos >= length) continue;
|
|
24398
|
+
const offStart = pos;
|
|
24399
|
+
let offset = 0;
|
|
24400
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
24401
|
+
offset = offset * 16 + hexDigit(line.charCodeAt(pos++));
|
|
24402
|
+
}
|
|
24403
|
+
if (pos === offStart) continue;
|
|
24404
|
+
const s2 = pos;
|
|
24405
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
24406
|
+
if (pos === s2 || pos >= length) continue;
|
|
24407
|
+
const sizeStart = pos;
|
|
24408
|
+
let size2 = 0;
|
|
24409
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
24410
|
+
size2 = size2 * 16 + hexDigit(line.charCodeAt(pos++));
|
|
24411
|
+
}
|
|
24412
|
+
if (pos === sizeStart || pos >= length) continue;
|
|
24413
|
+
const indentStart = pos;
|
|
24414
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
24415
|
+
const indent2 = pos - indentStart;
|
|
24416
|
+
if (indent2 === 0 || pos >= length) continue;
|
|
24417
|
+
if (indent2 === 17) {
|
|
24418
|
+
if (previous) {
|
|
24419
|
+
const first = line.charCodeAt(pos);
|
|
24420
|
+
if (first > 32 && !hasLineBreak(line, pos)) {
|
|
24421
|
+
previous.symbols.push({
|
|
24422
|
+
name: line.slice(pos),
|
|
24423
|
+
address,
|
|
24424
|
+
size: size2
|
|
24425
|
+
});
|
|
24426
|
+
}
|
|
24427
|
+
}
|
|
24223
24428
|
continue;
|
|
24224
24429
|
}
|
|
24225
|
-
|
|
24226
|
-
|
|
24227
|
-
|
|
24430
|
+
if (indent2 === 1) {
|
|
24431
|
+
let hasWhitespace = false;
|
|
24432
|
+
for (let i = pos; i < length; i++) {
|
|
24433
|
+
const ch = line.charCodeAt(i);
|
|
24434
|
+
if (ch <= 32) {
|
|
24435
|
+
hasWhitespace = true;
|
|
24436
|
+
break;
|
|
24437
|
+
}
|
|
24438
|
+
}
|
|
24439
|
+
if (hasWhitespace) continue;
|
|
24440
|
+
if (address < 0 && leadingSpaces > 0) {
|
|
24441
|
+
kind = line.slice(pos);
|
|
24442
|
+
} else if (kind === "DATA" && address >= 0) {
|
|
24443
|
+
segment3 = line.slice(pos);
|
|
24444
|
+
segments.set(segment3, { address, size: size2 });
|
|
24445
|
+
}
|
|
24228
24446
|
continue;
|
|
24229
24447
|
}
|
|
24230
|
-
if (kind === "DATA") {
|
|
24231
|
-
const
|
|
24232
|
-
if (
|
|
24233
|
-
|
|
24234
|
-
|
|
24235
|
-
|
|
24448
|
+
if (indent2 === 9 && (kind === "DATA" || kind === "CODE")) {
|
|
24449
|
+
const first = line.charCodeAt(pos);
|
|
24450
|
+
if (first !== 47 && first !== 60) continue;
|
|
24451
|
+
if (hasLineBreak(line, pos)) continue;
|
|
24452
|
+
const name3 = line.slice(pos);
|
|
24453
|
+
let filePath = name3;
|
|
24454
|
+
let section2 = "";
|
|
24455
|
+
if (name3.charCodeAt(name3.length - 1) === 41) {
|
|
24456
|
+
const splitAt = name3.indexOf(":(");
|
|
24457
|
+
if (splitAt >= 0) {
|
|
24458
|
+
filePath = name3.slice(0, splitAt);
|
|
24459
|
+
section2 = name3.slice(splitAt + 2, -1);
|
|
24460
|
+
}
|
|
24461
|
+
}
|
|
24462
|
+
let objectName;
|
|
24463
|
+
if (filePath.charCodeAt(filePath.length - 1) === 41) {
|
|
24464
|
+
const open = filePath.lastIndexOf("(");
|
|
24465
|
+
if (open >= 0 && open + 1 < filePath.length - 1) {
|
|
24466
|
+
const close = filePath.indexOf(")", open + 1);
|
|
24467
|
+
if (close === filePath.length - 1) {
|
|
24468
|
+
objectName = filePath.slice(open + 1, -1);
|
|
24469
|
+
}
|
|
24470
|
+
}
|
|
24471
|
+
}
|
|
24472
|
+
if (objectName === void 0) objectName = (0, import_node_path27.basename)(filePath);
|
|
24473
|
+
if (objectName.startsWith("lib") && objectName.includes("__")) {
|
|
24474
|
+
objectName = objectName.replace(/^lib\w*?__/, "");
|
|
24236
24475
|
}
|
|
24476
|
+
previous = {
|
|
24477
|
+
inputFile: filePath,
|
|
24478
|
+
segment: segment3,
|
|
24479
|
+
address,
|
|
24480
|
+
offset,
|
|
24481
|
+
size: size2,
|
|
24482
|
+
object: objectName,
|
|
24483
|
+
section: section2,
|
|
24484
|
+
symbols: []
|
|
24485
|
+
};
|
|
24486
|
+
(kind === "DATA" ? data : code).push(previous);
|
|
24237
24487
|
}
|
|
24238
|
-
if (kind !== "DATA" && kind !== "CODE") continue;
|
|
24239
|
-
const input = /^ *([0-9a-f]+|-) +([0-9a-f]+) +([0-9a-f]+) {9}([/<].*)$/.exec(line);
|
|
24240
|
-
if (!input) continue;
|
|
24241
|
-
const name3 = input[4];
|
|
24242
|
-
const split = /^(.*?):\((.*)\)$/s.exec(name3);
|
|
24243
|
-
const path138 = split ? split[1] : name3;
|
|
24244
|
-
const member = /\(([^()]+)\)$/.exec(path138);
|
|
24245
|
-
previous = {
|
|
24246
|
-
inputFile: path138,
|
|
24247
|
-
segment: segment3,
|
|
24248
|
-
address: hex(input[1]),
|
|
24249
|
-
offset: parseInt(input[2], 16),
|
|
24250
|
-
size: parseInt(input[3], 16),
|
|
24251
|
-
object: (member ? member[1] : (0, import_node_path27.basename)(path138)).replace(/^lib\w*?__/, ""),
|
|
24252
|
-
section: split ? split[2] : "",
|
|
24253
|
-
symbols: []
|
|
24254
|
-
};
|
|
24255
|
-
(kind === "DATA" ? data : code).push(previous);
|
|
24256
24488
|
}
|
|
24257
24489
|
return { segments, data: partition ? data.flatMap(symbolPieces) : data, code };
|
|
24258
24490
|
}
|
|
@@ -25398,6 +25630,7 @@ function patchSwiftrtObject(src) {
|
|
|
25398
25630
|
return buf;
|
|
25399
25631
|
}
|
|
25400
25632
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
25633
|
+
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
25401
25634
|
let pos = 8;
|
|
25402
25635
|
let numImportFuncs = 0;
|
|
25403
25636
|
let importsDlsym = false;
|
|
@@ -25433,10 +25666,10 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25433
25666
|
let [cnt, cp] = readULEB2(buf, p);
|
|
25434
25667
|
for (let i = 0; i < cnt; i++) {
|
|
25435
25668
|
const [mLen, m2] = readULEB2(buf, cp);
|
|
25436
|
-
const mName =
|
|
25669
|
+
const mName = rawBuf.toString("utf8", m2, m2 + mLen);
|
|
25437
25670
|
cp = m2 + mLen;
|
|
25438
25671
|
const [fLen, f2] = readULEB2(buf, cp);
|
|
25439
|
-
const fName =
|
|
25672
|
+
const fName = rawBuf.toString("utf8", f2, f2 + fLen);
|
|
25440
25673
|
cp = f2 + fLen;
|
|
25441
25674
|
const kind = buf[cp++];
|
|
25442
25675
|
if (kind === 0) {
|
|
@@ -25516,7 +25749,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25516
25749
|
}
|
|
25517
25750
|
} else if (id === 0) {
|
|
25518
25751
|
const [nLen, np] = readULEB2(buf, p);
|
|
25519
|
-
const name3 =
|
|
25752
|
+
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
25520
25753
|
const cp = np + nLen;
|
|
25521
25754
|
if (name3 === "linking") {
|
|
25522
25755
|
let [, lp] = readULEB2(buf, cp);
|
|
@@ -25529,7 +25762,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25529
25762
|
let cur = p2;
|
|
25530
25763
|
for (let i = 0; i < cnt; i++) {
|
|
25531
25764
|
const [sLen, s2] = readULEB2(buf, cur);
|
|
25532
|
-
segNames.push(
|
|
25765
|
+
segNames.push(rawBuf.toString("utf8", s2, s2 + sLen));
|
|
25533
25766
|
cur = s2 + sLen;
|
|
25534
25767
|
const [, s3] = readULEB2(buf, cur);
|
|
25535
25768
|
const [fl, s4] = readULEB2(buf, s3);
|
|
@@ -25569,7 +25802,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25569
25802
|
let sName = "";
|
|
25570
25803
|
if (!isUndef || isExplicitName) {
|
|
25571
25804
|
const [sLen, c4] = readULEB2(buf, cur);
|
|
25572
|
-
sName =
|
|
25805
|
+
sName = rawBuf.toString("utf8", c4, c4 + sLen);
|
|
25573
25806
|
cur = c4 + sLen;
|
|
25574
25807
|
} else if (kind === 0) {
|
|
25575
25808
|
sName = importFuncNames[el] ?? "";
|
|
@@ -25585,7 +25818,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25585
25818
|
symNames.push(sName);
|
|
25586
25819
|
} else if (kind === 1) {
|
|
25587
25820
|
const [sLen, c3] = readULEB2(buf, cur);
|
|
25588
|
-
const sName =
|
|
25821
|
+
const sName = rawBuf.toString("utf8", c3, c3 + sLen);
|
|
25589
25822
|
cur = c3 + sLen;
|
|
25590
25823
|
if (!isUndef) {
|
|
25591
25824
|
const [segIdx, c4] = readULEB2(buf, cur);
|
|
@@ -25700,9 +25933,21 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
25700
25933
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
25701
25934
|
let ownerSymIdx = -1;
|
|
25702
25935
|
const topList = segTopSyms.get(lo);
|
|
25703
|
-
if (topList) {
|
|
25704
|
-
|
|
25705
|
-
|
|
25936
|
+
if (topList && topList.length > 0) {
|
|
25937
|
+
let tLo = 0;
|
|
25938
|
+
let tHi = topList.length - 1;
|
|
25939
|
+
while (tLo <= tHi) {
|
|
25940
|
+
const tMid = tLo + tHi >> 1;
|
|
25941
|
+
const top = topList[tMid];
|
|
25942
|
+
if (offInSeg < top.off) {
|
|
25943
|
+
tHi = tMid - 1;
|
|
25944
|
+
} else if (offInSeg >= top.end) {
|
|
25945
|
+
tLo = tMid + 1;
|
|
25946
|
+
} else {
|
|
25947
|
+
ownerSymIdx = top.symIdx;
|
|
25948
|
+
break;
|
|
25949
|
+
}
|
|
25950
|
+
}
|
|
25706
25951
|
}
|
|
25707
25952
|
if (ownerSymIdx !== -1) {
|
|
25708
25953
|
let list2 = symDataRelocs.get(ownerSymIdx);
|
|
@@ -25957,54 +26202,151 @@ function localizeDefinedWasmSymbols(bytes, names) {
|
|
|
25957
26202
|
return output;
|
|
25958
26203
|
}
|
|
25959
26204
|
function guestWasmSymbols(bytes) {
|
|
25960
|
-
const
|
|
26205
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
26206
|
+
let cur = 8;
|
|
26207
|
+
const readU = () => {
|
|
26208
|
+
const b0 = bytes[cur++];
|
|
26209
|
+
if (b0 < 128) return b0;
|
|
26210
|
+
let res = b0 & 127;
|
|
26211
|
+
let shift = 7;
|
|
26212
|
+
while (true) {
|
|
26213
|
+
const byte = bytes[cur++];
|
|
26214
|
+
res |= (byte & 127) << shift;
|
|
26215
|
+
if ((byte & 128) === 0) return res;
|
|
26216
|
+
shift += 7;
|
|
26217
|
+
}
|
|
26218
|
+
};
|
|
26219
|
+
let importsDlsym = false;
|
|
26220
|
+
const importFuncNames = [];
|
|
26221
|
+
const importFuncModules = [];
|
|
26222
|
+
const importGlobalNames = [];
|
|
26223
|
+
const importTableNames = [];
|
|
26224
|
+
const importEventNames = [];
|
|
26225
|
+
const undefinedSyms = /* @__PURE__ */ new Set();
|
|
26226
|
+
const tags = /* @__PURE__ */ new Set();
|
|
26227
|
+
const globals = /* @__PURE__ */ new Set();
|
|
26228
|
+
const hostImports = /* @__PURE__ */ new Set();
|
|
26229
|
+
const weakUndefined = /* @__PURE__ */ new Set();
|
|
26230
|
+
const defined = /* @__PURE__ */ new Set();
|
|
26231
|
+
const weakDefined = /* @__PURE__ */ new Set();
|
|
26232
|
+
while (cur < bytes.length) {
|
|
26233
|
+
const id = bytes[cur++];
|
|
26234
|
+
const sz = readU();
|
|
26235
|
+
const end = cur + sz;
|
|
26236
|
+
if (id === 2) {
|
|
26237
|
+
const cnt = readU();
|
|
26238
|
+
for (let i = 0; i < cnt; i++) {
|
|
26239
|
+
const mLen = readU();
|
|
26240
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
26241
|
+
cur += mLen;
|
|
26242
|
+
const fLen = readU();
|
|
26243
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
26244
|
+
cur += fLen;
|
|
26245
|
+
const kind = bytes[cur++];
|
|
26246
|
+
if (kind === 0) {
|
|
26247
|
+
readU();
|
|
26248
|
+
importFuncNames.push(fName);
|
|
26249
|
+
importFuncModules.push(mName);
|
|
26250
|
+
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
26251
|
+
} else if (kind === 1) {
|
|
26252
|
+
cur++;
|
|
26253
|
+
const fl = readU();
|
|
26254
|
+
readU();
|
|
26255
|
+
if (fl & 1) readU();
|
|
26256
|
+
importTableNames.push(fName);
|
|
26257
|
+
} else if (kind === 2) {
|
|
26258
|
+
const fl = readU();
|
|
26259
|
+
readU();
|
|
26260
|
+
if (fl & 1) readU();
|
|
26261
|
+
} else if (kind === 3) {
|
|
26262
|
+
cur += 2;
|
|
26263
|
+
importGlobalNames.push(fName);
|
|
26264
|
+
} else if (kind === 4) {
|
|
26265
|
+
cur++;
|
|
26266
|
+
readU();
|
|
26267
|
+
importEventNames.push(fName);
|
|
26268
|
+
}
|
|
26269
|
+
}
|
|
26270
|
+
} else if (id === 0) {
|
|
26271
|
+
const nLen = readU();
|
|
26272
|
+
if (nLen === 7 && bytes[cur] === 108 && rawBuf.toString("utf8", cur, cur + nLen) === "linking") {
|
|
26273
|
+
cur += nLen;
|
|
26274
|
+
readU();
|
|
26275
|
+
while (cur < end) {
|
|
26276
|
+
const subId = bytes[cur++];
|
|
26277
|
+
const subLen = readU();
|
|
26278
|
+
const subEnd = cur + subLen;
|
|
26279
|
+
if (subId === 8) {
|
|
26280
|
+
const cnt = readU();
|
|
26281
|
+
for (let i = 0; i < cnt; i++) {
|
|
26282
|
+
const kind = bytes[cur++];
|
|
26283
|
+
const fl = readU();
|
|
26284
|
+
const isUndef = (fl & 16) !== 0;
|
|
26285
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
26286
|
+
let sName = "";
|
|
26287
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
26288
|
+
const el = readU();
|
|
26289
|
+
if (!isUndef || isExplicitName) {
|
|
26290
|
+
const sLen = readU();
|
|
26291
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
26292
|
+
cur += sLen;
|
|
26293
|
+
} else if (kind === 0) {
|
|
26294
|
+
sName = importFuncNames[el] ?? "";
|
|
26295
|
+
} else if (kind === 2) {
|
|
26296
|
+
sName = importGlobalNames[el] ?? "";
|
|
26297
|
+
} else if (kind === 4) {
|
|
26298
|
+
sName = importEventNames[el] ?? "";
|
|
26299
|
+
} else if (kind === 5) {
|
|
26300
|
+
sName = importTableNames[el] ?? "";
|
|
26301
|
+
}
|
|
26302
|
+
if (isUndef && kind === 0 && importFuncModules[el] !== "env")
|
|
26303
|
+
hostImports.add(sName);
|
|
26304
|
+
} else if (kind === 1) {
|
|
26305
|
+
const sLen = readU();
|
|
26306
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
26307
|
+
cur += sLen;
|
|
26308
|
+
if (!isUndef) {
|
|
26309
|
+
readU();
|
|
26310
|
+
readU();
|
|
26311
|
+
readU();
|
|
26312
|
+
}
|
|
26313
|
+
} else if (kind === 3) {
|
|
26314
|
+
readU();
|
|
26315
|
+
}
|
|
26316
|
+
if (sName) {
|
|
26317
|
+
if (isUndef) {
|
|
26318
|
+
undefinedSyms.add(sName);
|
|
26319
|
+
if ((fl & 19) === 17) weakUndefined.add(sName);
|
|
26320
|
+
} else if ((fl & 3) !== 2) {
|
|
26321
|
+
defined.add(sName);
|
|
26322
|
+
if ((fl & 19) === 1) weakDefined.add(sName);
|
|
26323
|
+
}
|
|
26324
|
+
if (kind === 4) tags.add(sName);
|
|
26325
|
+
else if (kind === 2 || kind === 5) globals.add(sName);
|
|
26326
|
+
}
|
|
26327
|
+
}
|
|
26328
|
+
break;
|
|
26329
|
+
}
|
|
26330
|
+
cur = subEnd;
|
|
26331
|
+
}
|
|
26332
|
+
break;
|
|
26333
|
+
}
|
|
26334
|
+
}
|
|
26335
|
+
cur = end;
|
|
26336
|
+
}
|
|
25961
26337
|
return {
|
|
25962
|
-
importsDlsym
|
|
25963
|
-
undefined: [
|
|
25964
|
-
...new Set(
|
|
25965
|
-
object7.symNames.filter(
|
|
25966
|
-
(name3, index) => name3 && (object7.symFlags[index] & 16) !== 0
|
|
25967
|
-
)
|
|
25968
|
-
)
|
|
25969
|
-
],
|
|
26338
|
+
importsDlsym,
|
|
26339
|
+
undefined: [...undefinedSyms],
|
|
25970
26340
|
// a wasm tag is one module entity unified by name across the link, as the
|
|
25971
26341
|
// main module owns it for dynamic images, so no image scope applies.
|
|
25972
|
-
tags: [
|
|
25973
|
-
|
|
25974
|
-
object7.symNames.filter((name3, index) => name3 && object7.symKind[index] === 4)
|
|
25975
|
-
)
|
|
25976
|
-
],
|
|
25977
|
-
globals: [
|
|
25978
|
-
...new Set(
|
|
25979
|
-
object7.symNames.filter(
|
|
25980
|
-
(name3, index) => name3 && (object7.symKind[index] === 2 || object7.symKind[index] === 5)
|
|
25981
|
-
)
|
|
25982
|
-
)
|
|
25983
|
-
],
|
|
26342
|
+
tags: [...tags],
|
|
26343
|
+
globals: [...globals],
|
|
25984
26344
|
// an undefined function imported from a module other than env is supplied
|
|
25985
26345
|
// by the host, whatever linker symbol names it.
|
|
25986
|
-
hostImports: [...
|
|
25987
|
-
weakUndefined: [
|
|
25988
|
-
|
|
25989
|
-
|
|
25990
|
-
(name3, index) => name3 && (object7.symFlags[index] & 19) === 17
|
|
25991
|
-
)
|
|
25992
|
-
)
|
|
25993
|
-
],
|
|
25994
|
-
defined: [
|
|
25995
|
-
...new Set(
|
|
25996
|
-
object7.symNames.filter(
|
|
25997
|
-
(name3, index) => name3 && (object7.symFlags[index] & 16) === 0 && (object7.symFlags[index] & 3) !== 2
|
|
25998
|
-
)
|
|
25999
|
-
)
|
|
26000
|
-
],
|
|
26001
|
-
weakDefined: [
|
|
26002
|
-
...new Set(
|
|
26003
|
-
object7.symNames.filter(
|
|
26004
|
-
(name3, index) => name3 && (object7.symFlags[index] & 19) === 1
|
|
26005
|
-
)
|
|
26006
|
-
)
|
|
26007
|
-
]
|
|
26346
|
+
hostImports: [...hostImports],
|
|
26347
|
+
weakUndefined: [...weakUndefined],
|
|
26348
|
+
defined: [...defined],
|
|
26349
|
+
weakDefined: [...weakDefined]
|
|
26008
26350
|
};
|
|
26009
26351
|
}
|
|
26010
26352
|
function sdkObjectName(archive, member, ordinal) {
|
|
@@ -26521,9 +26863,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
26521
26863
|
for (const entry of waiting) tryActivateConformance(entry);
|
|
26522
26864
|
}
|
|
26523
26865
|
};
|
|
26866
|
+
const checkedProtocolTriggers = /* @__PURE__ */ new Set();
|
|
26524
26867
|
const checkProtocolTrigger = (rawSymName) => {
|
|
26525
26868
|
if (!rawSymName) return;
|
|
26526
26869
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
26870
|
+
if (checkedProtocolTriggers.has(sName)) return;
|
|
26871
|
+
checkedProtocolTriggers.add(sName);
|
|
26527
26872
|
if (knownProtocols.has(sName)) {
|
|
26528
26873
|
markProtocolLive(sName);
|
|
26529
26874
|
return;
|
|
@@ -26556,6 +26901,43 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
26556
26901
|
}
|
|
26557
26902
|
}
|
|
26558
26903
|
};
|
|
26904
|
+
const typeIndexes = /* @__PURE__ */ new Map();
|
|
26905
|
+
const getTypeIndex = (obj) => {
|
|
26906
|
+
let idx = typeIndexes.get(obj);
|
|
26907
|
+
if (idx) return idx;
|
|
26908
|
+
const mnByPrefix = /* @__PURE__ */ new Map();
|
|
26909
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
26910
|
+
const name3 = obj.symNames[i];
|
|
26911
|
+
if ((obj.symFlags[i] & 16) === 0 && name3.startsWith("$s") && name3.endsWith("Mn")) {
|
|
26912
|
+
const pref = name3.slice(0, -2);
|
|
26913
|
+
let list2 = mnByPrefix.get(pref);
|
|
26914
|
+
if (!list2) mnByPrefix.set(pref, list2 = []);
|
|
26915
|
+
list2.push(i);
|
|
26916
|
+
}
|
|
26917
|
+
}
|
|
26918
|
+
const objcRegByPrefix = /* @__PURE__ */ new Map();
|
|
26919
|
+
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
26920
|
+
let list2 = objcRegByPrefix.get(p);
|
|
26921
|
+
if (!list2) objcRegByPrefix.set(p, list2 = []);
|
|
26922
|
+
list2.push(lf);
|
|
26923
|
+
}
|
|
26924
|
+
const objcClassByPrefix = /* @__PURE__ */ new Map();
|
|
26925
|
+
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
26926
|
+
if (!classSym.startsWith("._OBJC_CLASS_")) continue;
|
|
26927
|
+
let list2 = objcClassByPrefix.get(p);
|
|
26928
|
+
if (!list2) objcClassByPrefix.set(p, list2 = []);
|
|
26929
|
+
list2.push(classSym.slice("._OBJC_CLASS_".length));
|
|
26930
|
+
}
|
|
26931
|
+
let minPrefLen = Infinity;
|
|
26932
|
+
let maxPrefLen = 0;
|
|
26933
|
+
for (const p of obj.typePrefixesInObj) {
|
|
26934
|
+
if (p.length < minPrefLen) minPrefLen = p.length;
|
|
26935
|
+
if (p.length > maxPrefLen) maxPrefLen = p.length;
|
|
26936
|
+
}
|
|
26937
|
+
idx = { mnByPrefix, objcRegByPrefix, objcClassByPrefix, minPrefLen, maxPrefLen };
|
|
26938
|
+
typeIndexes.set(obj, idx);
|
|
26939
|
+
return idx;
|
|
26940
|
+
};
|
|
26559
26941
|
const markTypeLive = (obj, pref) => {
|
|
26560
26942
|
const set2 = liveTypes.get(obj);
|
|
26561
26943
|
if (set2.has(pref)) return;
|
|
@@ -26569,22 +26951,10 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
26569
26951
|
const outer = pref.slice(0, n);
|
|
26570
26952
|
if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer);
|
|
26571
26953
|
}
|
|
26572
|
-
const
|
|
26573
|
-
for (
|
|
26574
|
-
|
|
26575
|
-
|
|
26576
|
-
}
|
|
26577
|
-
}
|
|
26578
|
-
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
26579
|
-
if (p === pref) {
|
|
26580
|
-
markFuncLive(obj, lf);
|
|
26581
|
-
}
|
|
26582
|
-
}
|
|
26583
|
-
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
26584
|
-
if (p === pref && classSym.startsWith("._OBJC_CLASS_")) {
|
|
26585
|
-
markObjCClassLive(classSym.slice("._OBJC_CLASS_".length));
|
|
26586
|
-
}
|
|
26587
|
-
}
|
|
26954
|
+
const idx = getTypeIndex(obj);
|
|
26955
|
+
for (const i of idx.mnByPrefix.get(pref) ?? []) activateSymbolInObj(obj, i);
|
|
26956
|
+
for (const lf of idx.objcRegByPrefix.get(pref) ?? []) markFuncLive(obj, lf);
|
|
26957
|
+
for (const cls of idx.objcClassByPrefix.get(pref) ?? []) markObjCClassLive(cls);
|
|
26588
26958
|
};
|
|
26589
26959
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
26590
26960
|
if (!rawSymName) return;
|
|
@@ -26609,11 +26979,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
26609
26979
|
}
|
|
26610
26980
|
}
|
|
26611
26981
|
}
|
|
26612
|
-
if (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o")) {
|
|
26613
|
-
|
|
26614
|
-
|
|
26615
|
-
|
|
26616
|
-
|
|
26982
|
+
if (obj.typePrefixesInObj.size > 0 && (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o"))) {
|
|
26983
|
+
const { minPrefLen, maxPrefLen } = getTypeIndex(obj);
|
|
26984
|
+
const hi = Math.min(sName.length, maxPrefLen);
|
|
26985
|
+
for (let n = minPrefLen; n <= hi; n++) {
|
|
26986
|
+
const cand = sName.slice(0, n);
|
|
26987
|
+
if (obj.typePrefixesInObj.has(cand)) markTypeLive(obj, cand);
|
|
26617
26988
|
}
|
|
26618
26989
|
}
|
|
26619
26990
|
};
|
|
@@ -26706,7 +27077,8 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
26706
27077
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
26707
27078
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
26708
27079
|
for (const name3 of obj.symNames) {
|
|
26709
|
-
|
|
27080
|
+
if (!name3 || !name3.startsWith("_c_") || !name3.endsWith("__load")) continue;
|
|
27081
|
+
const loaded4 = name3.match(/^_c_(\w+)__load$/)?.[1];
|
|
26710
27082
|
if (!loaded4) continue;
|
|
26711
27083
|
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded4}`);
|
|
26712
27084
|
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
@@ -26854,14 +27226,30 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
26854
27226
|
const keepObjCClassesNamedInSegment = (obj, segIdx) => {
|
|
26855
27227
|
const range3 = obj.segPayloadRanges[segIdx];
|
|
26856
27228
|
if (!range3) return;
|
|
27229
|
+
const [rangeStart, rangeEnd] = range3;
|
|
27230
|
+
if (rangeEnd - rangeStart < 4) return;
|
|
26857
27231
|
let bytes = objectBytes.get(obj);
|
|
26858
27232
|
if (!bytes) objectBytes.set(obj, bytes = import_node_fs29.default.readFileSync(obj.file));
|
|
26859
|
-
|
|
26860
|
-
|
|
26861
|
-
const
|
|
26862
|
-
|
|
26863
|
-
|
|
26864
|
-
|
|
27233
|
+
let pos = rangeStart;
|
|
27234
|
+
while (pos < rangeEnd - 3) {
|
|
27235
|
+
const at = bytes.indexOf("So", pos);
|
|
27236
|
+
if (at < 0 || at >= rangeEnd - 2) break;
|
|
27237
|
+
let digitEnd = at + 2;
|
|
27238
|
+
let length = 0;
|
|
27239
|
+
while (digitEnd < rangeEnd) {
|
|
27240
|
+
const ch = bytes[digitEnd];
|
|
27241
|
+
if (ch < 48 || ch > 57) break;
|
|
27242
|
+
length = length * 10 + (ch - 48);
|
|
27243
|
+
digitEnd++;
|
|
27244
|
+
}
|
|
27245
|
+
if (digitEnd === at + 2) {
|
|
27246
|
+
pos = at + 2;
|
|
27247
|
+
continue;
|
|
27248
|
+
}
|
|
27249
|
+
pos = digitEnd;
|
|
27250
|
+
const nameEnd = digitEnd + length;
|
|
27251
|
+
if (nameEnd >= rangeEnd || bytes[nameEnd] !== 67) continue;
|
|
27252
|
+
const symbol2 = `._OBJC_CLASS_${bytes.toString("latin1", digitEnd, nameEnd)}`;
|
|
26865
27253
|
for (const provider of lazyProviders.get(symbol2) ?? []) {
|
|
26866
27254
|
eagerDynamicObjects.add(provider);
|
|
26867
27255
|
extractObject(provider);
|
|
@@ -27838,6 +28226,10 @@ var init_nativeDyldTableContract = __esm({
|
|
|
27838
28226
|
|
|
27839
28227
|
// src/swift-guest-image-ledger.ts
|
|
27840
28228
|
function readNumber(bytes, position) {
|
|
28229
|
+
if (position < bytes.length) {
|
|
28230
|
+
const first = bytes[position];
|
|
28231
|
+
if (first < 128) return [first, position + 1];
|
|
28232
|
+
}
|
|
27841
28233
|
let value = 0;
|
|
27842
28234
|
let shift = 0;
|
|
27843
28235
|
for (; ; ) {
|
|
@@ -27849,6 +28241,7 @@ function readNumber(bytes, position) {
|
|
|
27849
28241
|
}
|
|
27850
28242
|
}
|
|
27851
28243
|
function encodeNumber(value) {
|
|
28244
|
+
if (value < 128) return Buffer.from([value]);
|
|
27852
28245
|
const bytes = [];
|
|
27853
28246
|
do {
|
|
27854
28247
|
let byte = value % 128;
|
|
@@ -27870,6 +28263,9 @@ function encodedString(value) {
|
|
|
27870
28263
|
const bytes = Buffer.from(value);
|
|
27871
28264
|
return Buffer.concat([encodeNumber(bytes.length), bytes]);
|
|
27872
28265
|
}
|
|
28266
|
+
function isWasmMagic(bytes) {
|
|
28267
|
+
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;
|
|
28268
|
+
}
|
|
27873
28269
|
function llvmType(value) {
|
|
27874
28270
|
switch (value) {
|
|
27875
28271
|
case 127:
|
|
@@ -27885,11 +28281,12 @@ function llvmType(value) {
|
|
|
27885
28281
|
}
|
|
27886
28282
|
}
|
|
27887
28283
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
|
|
27888
|
-
if (
|
|
27889
|
-
|
|
28284
|
+
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
28285
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
27890
28286
|
const { sdkLookupOnly, sdkProduct } = options2;
|
|
27891
28287
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
27892
|
-
const
|
|
28288
|
+
const rewrite = binding !== void 0;
|
|
28289
|
+
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
27893
28290
|
const types2 = [];
|
|
27894
28291
|
const functionTypes = [];
|
|
27895
28292
|
const definitions = [];
|
|
@@ -27903,45 +28300,74 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
27903
28300
|
const usedSymbols = /* @__PURE__ */ new Set();
|
|
27904
28301
|
let position = 8;
|
|
27905
28302
|
while (position < bytes.length) {
|
|
28303
|
+
const headerStart2 = position;
|
|
27906
28304
|
const id = bytes[position++];
|
|
27907
|
-
|
|
28305
|
+
let size2 = 0;
|
|
28306
|
+
if (position < bytes.length && bytes[position] < 128) {
|
|
28307
|
+
size2 = bytes[position++];
|
|
28308
|
+
} else {
|
|
28309
|
+
const [val, next] = readNumber(bytes, position);
|
|
28310
|
+
size2 = val;
|
|
28311
|
+
position = next;
|
|
28312
|
+
}
|
|
28313
|
+
const start = position;
|
|
27908
28314
|
const end = start + size2;
|
|
27909
28315
|
if (end > bytes.length) throw new Error("invalid wasm section");
|
|
27910
28316
|
position = end;
|
|
27911
|
-
if (
|
|
27912
|
-
|
|
27913
|
-
|
|
28317
|
+
if (id > 3) {
|
|
28318
|
+
if (sections) sections.push(bytes.subarray(headerStart2, end));
|
|
28319
|
+
continue;
|
|
28320
|
+
}
|
|
28321
|
+
let offset = start;
|
|
27914
28322
|
const number3 = () => {
|
|
27915
|
-
|
|
27916
|
-
|
|
27917
|
-
|
|
28323
|
+
if (offset < end) {
|
|
28324
|
+
const first = bytes[offset];
|
|
28325
|
+
if (first < 128) {
|
|
28326
|
+
offset++;
|
|
28327
|
+
return first;
|
|
28328
|
+
}
|
|
28329
|
+
}
|
|
28330
|
+
let value = 0;
|
|
28331
|
+
let shift = 0;
|
|
28332
|
+
for (; ; ) {
|
|
28333
|
+
if (offset >= end || shift > 63) throw new Error("invalid wasm integer");
|
|
28334
|
+
const byte = bytes[offset++];
|
|
28335
|
+
value += (byte & 127) * 2 ** shift;
|
|
28336
|
+
if (!(byte & 128)) return value;
|
|
28337
|
+
shift += 7;
|
|
28338
|
+
}
|
|
27918
28339
|
};
|
|
27919
28340
|
const string7 = () => {
|
|
27920
|
-
const
|
|
27921
|
-
|
|
28341
|
+
const length = number3();
|
|
28342
|
+
const strEnd = offset + length;
|
|
28343
|
+
if (strEnd > end) throw new Error("invalid wasm string");
|
|
28344
|
+
const value = rawBuf.toString("utf8", offset, strEnd);
|
|
28345
|
+
offset = strEnd;
|
|
27922
28346
|
return value;
|
|
27923
28347
|
};
|
|
28348
|
+
let rewrittenSection;
|
|
27924
28349
|
if (id === 1) {
|
|
27925
28350
|
const count = number3();
|
|
27926
28351
|
for (let i = 0; i < count; i++) {
|
|
27927
|
-
if (
|
|
28352
|
+
if (bytes[offset++] !== 96) throw new Error("unsupported wasm type");
|
|
27928
28353
|
const parameterCount = number3();
|
|
27929
|
-
|
|
27930
|
-
|
|
27931
|
-
|
|
28354
|
+
if (offset + parameterCount > end) throw new Error("invalid wasm type");
|
|
28355
|
+
const parameters = new Array(parameterCount);
|
|
28356
|
+
for (let p = 0; p < parameterCount; p++) parameters[p] = bytes[offset++];
|
|
27932
28357
|
const resultCount = number3();
|
|
27933
|
-
|
|
27934
|
-
|
|
27935
|
-
|
|
28358
|
+
if (offset + resultCount > end) throw new Error("invalid wasm type");
|
|
28359
|
+
const results = new Array(resultCount);
|
|
28360
|
+
for (let r = 0; r < resultCount; r++) results[r] = bytes[offset++];
|
|
27936
28361
|
types2.push({ parameters, results });
|
|
27937
28362
|
}
|
|
27938
28363
|
} else if (id === 2) {
|
|
27939
28364
|
const count = number3();
|
|
27940
|
-
const
|
|
28365
|
+
const importWriter = rewrite ? new ByteWriter(size2 + 64) : void 0;
|
|
28366
|
+
importWriter?.uleb(count);
|
|
27941
28367
|
for (let i = 0; i < count; i++) {
|
|
27942
28368
|
const module2 = string7();
|
|
27943
28369
|
const name3 = string7();
|
|
27944
|
-
const kind =
|
|
28370
|
+
const kind = bytes[offset++];
|
|
27945
28371
|
const typeStart = offset;
|
|
27946
28372
|
let functionType2 = -1;
|
|
27947
28373
|
if (kind === 0) {
|
|
@@ -27949,7 +28375,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
27949
28375
|
functionTypes.push(functionType2);
|
|
27950
28376
|
functionImportNames.push(name3);
|
|
27951
28377
|
} else if (kind === 1) {
|
|
27952
|
-
const referenceType =
|
|
28378
|
+
const referenceType = bytes[offset++];
|
|
27953
28379
|
if (referenceType !== 112 && referenceType !== 111)
|
|
27954
28380
|
throw new Error("unsupported table type");
|
|
27955
28381
|
const flags = number3();
|
|
@@ -27968,11 +28394,15 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
27968
28394
|
} else throw new Error("unsupported wasm import");
|
|
27969
28395
|
const isDlsym = instrumentDynamicLookups && module2 === "env" && name3 === "dlsym" && kind === 0;
|
|
27970
28396
|
const isDlerror = instrumentDynamicLookups && module2 === "env" && name3 === "dlerror" && kind === 0;
|
|
27971
|
-
if (
|
|
27972
|
-
|
|
27973
|
-
|
|
27974
|
-
|
|
27975
|
-
|
|
28397
|
+
if (!rewrite) {
|
|
28398
|
+
if (module2 === "env" && names.has(name3)) {
|
|
28399
|
+
usedSymbols.add(name3);
|
|
28400
|
+
if (kind === 0) {
|
|
28401
|
+
const type = types2[functionType2];
|
|
28402
|
+
if (!type) throw new Error(`missing import type for ${name3}`);
|
|
28403
|
+
functionImports.set(name3, type);
|
|
28404
|
+
}
|
|
28405
|
+
}
|
|
27976
28406
|
}
|
|
27977
28407
|
if (isDlsym || isDlerror) {
|
|
27978
28408
|
const type = types2[functionType2];
|
|
@@ -27982,17 +28412,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
27982
28412
|
}
|
|
27983
28413
|
if (isDlsym) usesDlsym = true;
|
|
27984
28414
|
if (isDlerror) usesDlerror = true;
|
|
27985
|
-
|
|
27986
|
-
|
|
27987
|
-
|
|
27988
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding
|
|
27989
|
-
)
|
|
27990
|
-
|
|
27991
|
-
|
|
27992
|
-
|
|
28415
|
+
if (importWriter && binding) {
|
|
28416
|
+
importWriter.string(module2);
|
|
28417
|
+
importWriter.string(
|
|
28418
|
+
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
|
|
28419
|
+
);
|
|
28420
|
+
importWriter.byte(kind);
|
|
28421
|
+
importWriter.bytes(bytes, typeStart, offset);
|
|
28422
|
+
}
|
|
27993
28423
|
}
|
|
27994
|
-
if (offset !==
|
|
27995
|
-
if (
|
|
28424
|
+
if (offset !== end) throw new Error("invalid wasm import section");
|
|
28425
|
+
if (importWriter) rewrittenSection = importWriter.finish();
|
|
27996
28426
|
} else if (id === 3) {
|
|
27997
28427
|
const count = number3();
|
|
27998
28428
|
for (let i = 0; i < count; i++) functionTypes.push(number3());
|
|
@@ -28001,43 +28431,40 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28001
28431
|
if (sectionName === "linking") {
|
|
28002
28432
|
const version2 = number3();
|
|
28003
28433
|
if (version2 !== 2) throw new Error("unsupported wasm linking version");
|
|
28004
|
-
const subsections = [];
|
|
28434
|
+
const subsections = rewrite ? [] : void 0;
|
|
28005
28435
|
let objcLoader;
|
|
28006
|
-
while (offset <
|
|
28007
|
-
const kind =
|
|
28436
|
+
while (offset < end) {
|
|
28437
|
+
const kind = bytes[offset++];
|
|
28008
28438
|
const length = number3();
|
|
28009
28439
|
const stop = offset + length;
|
|
28010
|
-
if (stop >
|
|
28011
|
-
|
|
28012
|
-
if (kind === 7 && !sdkLookupOnly) {
|
|
28013
|
-
const
|
|
28440
|
+
if (stop > end) throw new Error("invalid linking subsection");
|
|
28441
|
+
const contentStart = offset;
|
|
28442
|
+
if (kind === 7 && rewrite && !sdkLookupOnly) {
|
|
28443
|
+
const comdatWriter = new ByteWriter(length + 64);
|
|
28014
28444
|
const count = number3();
|
|
28015
|
-
|
|
28445
|
+
comdatWriter.uleb(count);
|
|
28016
28446
|
for (let i = 0; i < count; i++) {
|
|
28017
28447
|
const group = string7();
|
|
28018
28448
|
const begin = offset;
|
|
28019
28449
|
number3();
|
|
28020
28450
|
const members2 = number3();
|
|
28021
28451
|
for (let member = 0; member < members2 * 2; member++) number3();
|
|
28022
|
-
|
|
28023
|
-
|
|
28024
|
-
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
28025
|
-
),
|
|
28026
|
-
section2.subarray(begin, offset)
|
|
28452
|
+
comdatWriter.string(
|
|
28453
|
+
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
28027
28454
|
);
|
|
28455
|
+
comdatWriter.bytes(bytes, begin, offset);
|
|
28028
28456
|
}
|
|
28029
28457
|
if (offset !== stop) throw new Error("invalid comdat subsection");
|
|
28030
|
-
|
|
28031
|
-
|
|
28032
|
-
if (kind === 8) {
|
|
28033
|
-
const
|
|
28034
|
-
|
|
28458
|
+
const buf = comdatWriter.finish();
|
|
28459
|
+
subsections.push({ kind, parts: [buf], byteLength: buf.length });
|
|
28460
|
+
} else if (kind === 8) {
|
|
28461
|
+
const entryWriter = rewrite ? new ByteWriter(length + 128) : void 0;
|
|
28462
|
+
let extraWriter;
|
|
28035
28463
|
const count = number3();
|
|
28036
|
-
entries2.push(encodeNumber(count));
|
|
28037
28464
|
let added = 0;
|
|
28038
28465
|
for (let i = 0; i < count; i++) {
|
|
28039
28466
|
const begin = offset;
|
|
28040
|
-
const symbolKind =
|
|
28467
|
+
const symbolKind = bytes[offset++];
|
|
28041
28468
|
const flags = number3();
|
|
28042
28469
|
const flagsEnd = offset;
|
|
28043
28470
|
let index = -1;
|
|
@@ -28065,25 +28492,43 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28065
28492
|
}
|
|
28066
28493
|
} else if (symbolKind === 3) number3();
|
|
28067
28494
|
else throw new Error("unsupported wasm symbol kind");
|
|
28068
|
-
if (symbolKind === 0)
|
|
28495
|
+
if (!rewrite && symbolKind === 0)
|
|
28069
28496
|
functionSymbols[i] = name3 || functionImportNames[index];
|
|
28070
|
-
if (!sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
28497
|
+
if (rewrite && !sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
28071
28498
|
objcLoader = i;
|
|
28072
28499
|
}
|
|
28073
28500
|
const alias = names.get(name3);
|
|
28074
|
-
if (flags & 16 && symbolKind === 1 && alias)
|
|
28075
|
-
|
|
28076
|
-
|
|
28077
|
-
|
|
28078
|
-
|
|
28079
|
-
|
|
28080
|
-
|
|
28081
|
-
|
|
28082
|
-
|
|
28083
|
-
|
|
28084
|
-
|
|
28085
|
-
|
|
28086
|
-
|
|
28501
|
+
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
28502
|
+
usedSymbols.add(name3);
|
|
28503
|
+
if (entryWriter && binding) {
|
|
28504
|
+
if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
28505
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
28506
|
+
entryWriter.string(name3 === "dlsym" ? callerAlias : dlerrorAlias);
|
|
28507
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
28508
|
+
} else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
|
|
28509
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
28510
|
+
entryWriter.string(binding(name3));
|
|
28511
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
28512
|
+
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
28513
|
+
if (symbolKind !== 0 && symbolKind !== 1)
|
|
28514
|
+
throw new Error(`unsupported symbol ${name3}`);
|
|
28515
|
+
if (preserveCanonical.has(name3)) {
|
|
28516
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
28517
|
+
extraWriter ??= new ByteWriter(256);
|
|
28518
|
+
extraWriter.byte(bytes[begin]);
|
|
28519
|
+
extraWriter.uleb(flags & ~32);
|
|
28520
|
+
extraWriter.bytes(bytes, flagsEnd, nameStart);
|
|
28521
|
+
extraWriter.string(alias);
|
|
28522
|
+
extraWriter.bytes(bytes, nameEnd, offset);
|
|
28523
|
+
added++;
|
|
28524
|
+
} else {
|
|
28525
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
28526
|
+
entryWriter.string(alias);
|
|
28527
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
28528
|
+
}
|
|
28529
|
+
} else {
|
|
28530
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
28531
|
+
}
|
|
28087
28532
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
28088
28533
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
28089
28534
|
throw new Error(`unsupported symbol ${name3}`);
|
|
@@ -28097,63 +28542,73 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28097
28542
|
hidden: (flags & 4) !== 0,
|
|
28098
28543
|
type
|
|
28099
28544
|
});
|
|
28100
|
-
|
|
28101
|
-
entries2.push(section2.subarray(begin, offset));
|
|
28102
|
-
extraEntries.push(
|
|
28103
|
-
section2.subarray(begin, begin + 1),
|
|
28104
|
-
encodeNumber(flags & ~32),
|
|
28105
|
-
section2.subarray(flagsEnd, nameStart),
|
|
28106
|
-
encodedString(alias),
|
|
28107
|
-
section2.subarray(nameEnd, offset)
|
|
28108
|
-
);
|
|
28109
|
-
added++;
|
|
28110
|
-
} else {
|
|
28111
|
-
entries2.push(
|
|
28112
|
-
section2.subarray(begin, nameStart),
|
|
28113
|
-
encodedString(alias),
|
|
28114
|
-
section2.subarray(nameEnd, offset)
|
|
28115
|
-
);
|
|
28116
|
-
}
|
|
28117
|
-
} else entries2.push(section2.subarray(begin, offset));
|
|
28545
|
+
}
|
|
28118
28546
|
}
|
|
28119
28547
|
if (offset !== stop) throw new Error("invalid symbol subsection");
|
|
28120
|
-
|
|
28121
|
-
|
|
28548
|
+
if (entryWriter) {
|
|
28549
|
+
const countBytes = encodeNumber(count + added);
|
|
28550
|
+
const entryBuf = entryWriter.finish();
|
|
28551
|
+
if (extraWriter) {
|
|
28552
|
+
const extraBuf = extraWriter.finish();
|
|
28553
|
+
subsections.push({
|
|
28554
|
+
kind,
|
|
28555
|
+
parts: [countBytes, entryBuf, extraBuf],
|
|
28556
|
+
byteLength: countBytes.length + entryBuf.length + extraBuf.length
|
|
28557
|
+
});
|
|
28558
|
+
} else {
|
|
28559
|
+
subsections.push({
|
|
28560
|
+
kind,
|
|
28561
|
+
parts: [countBytes, entryBuf],
|
|
28562
|
+
byteLength: countBytes.length + entryBuf.length
|
|
28563
|
+
});
|
|
28564
|
+
}
|
|
28565
|
+
}
|
|
28566
|
+
} else if (subsections) {
|
|
28567
|
+
subsections.push({
|
|
28568
|
+
kind,
|
|
28569
|
+
parts: [bytes.subarray(contentStart, stop)],
|
|
28570
|
+
byteLength: length
|
|
28571
|
+
});
|
|
28122
28572
|
}
|
|
28123
28573
|
offset = stop;
|
|
28124
|
-
|
|
28125
|
-
|
|
28126
|
-
|
|
28127
|
-
|
|
28128
|
-
|
|
28129
|
-
|
|
28130
|
-
|
|
28131
|
-
|
|
28132
|
-
|
|
28133
|
-
|
|
28134
|
-
|
|
28135
|
-
|
|
28136
|
-
|
|
28137
|
-
|
|
28138
|
-
content
|
|
28139
|
-
|
|
28140
|
-
|
|
28141
|
-
|
|
28142
|
-
|
|
28143
|
-
|
|
28574
|
+
}
|
|
28575
|
+
if (subsections) {
|
|
28576
|
+
const linkingWriter = new ByteWriter(size2 + 128);
|
|
28577
|
+
linkingWriter.string(sectionName);
|
|
28578
|
+
linkingWriter.uleb(version2);
|
|
28579
|
+
for (const subsection of subsections) {
|
|
28580
|
+
if (subsection.kind === 6 && objcLoader !== void 0) {
|
|
28581
|
+
const content = subsection.parts[0];
|
|
28582
|
+
const [count, entriesStart] = readNumber(content, 0);
|
|
28583
|
+
const initWriter = new ByteWriter(content.length + 16);
|
|
28584
|
+
initWriter.bytes(content, 0, entriesStart);
|
|
28585
|
+
let entryStart = entriesStart;
|
|
28586
|
+
for (let i = 0; i < count; i++) {
|
|
28587
|
+
const [, symbolStart] = readNumber(content, entryStart);
|
|
28588
|
+
const [symbol2, entryEnd] = readNumber(content, symbolStart);
|
|
28589
|
+
if (symbol2 === objcLoader) {
|
|
28590
|
+
initWriter.uleb(1);
|
|
28591
|
+
initWriter.bytes(content, symbolStart, entryEnd);
|
|
28592
|
+
} else {
|
|
28593
|
+
initWriter.bytes(content, entryStart, entryEnd);
|
|
28594
|
+
}
|
|
28595
|
+
entryStart = entryEnd;
|
|
28596
|
+
}
|
|
28597
|
+
if (entryStart !== content.length)
|
|
28598
|
+
throw new Error("invalid init functions subsection");
|
|
28599
|
+
const initBuf = initWriter.finish();
|
|
28600
|
+
linkingWriter.byte(subsection.kind);
|
|
28601
|
+
linkingWriter.uleb(initBuf.length);
|
|
28602
|
+
linkingWriter.bytes(initBuf);
|
|
28603
|
+
} else {
|
|
28604
|
+
linkingWriter.byte(subsection.kind);
|
|
28605
|
+
linkingWriter.uleb(subsection.byteLength);
|
|
28606
|
+
for (const part of subsection.parts) linkingWriter.bytes(part);
|
|
28144
28607
|
}
|
|
28145
|
-
if (entryStart !== content.length)
|
|
28146
|
-
throw new Error("invalid init functions subsection");
|
|
28147
|
-
content = Buffer.concat(entries2);
|
|
28148
28608
|
}
|
|
28149
|
-
|
|
28150
|
-
Buffer.from([subsection.kind]),
|
|
28151
|
-
encodeNumber(content.length),
|
|
28152
|
-
content
|
|
28153
|
-
);
|
|
28609
|
+
rewrittenSection = linkingWriter.finish();
|
|
28154
28610
|
}
|
|
28155
|
-
|
|
28156
|
-
} else if (!sections && sectionName.startsWith("reloc.")) {
|
|
28611
|
+
} else if (!rewrite && sectionName.startsWith("reloc.")) {
|
|
28157
28612
|
number3();
|
|
28158
28613
|
for (let count = number3(); count > 0; count--) {
|
|
28159
28614
|
const type = number3();
|
|
@@ -28163,18 +28618,27 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
28163
28618
|
if (name3 !== void 0 && TABLE_INDEX_RELOCATIONS.has(type))
|
|
28164
28619
|
addressTaken.add(name3);
|
|
28165
28620
|
}
|
|
28166
|
-
if (offset !==
|
|
28167
|
-
|
|
28621
|
+
if (offset !== end) throw new Error(`invalid relocation section ${sectionName}`);
|
|
28622
|
+
}
|
|
28623
|
+
}
|
|
28624
|
+
if (sections) {
|
|
28625
|
+
if (rewrittenSection) {
|
|
28626
|
+
sections.push(
|
|
28627
|
+
Buffer.from([id]),
|
|
28628
|
+
encodeNumber(rewrittenSection.length),
|
|
28629
|
+
rewrittenSection
|
|
28630
|
+
);
|
|
28631
|
+
} else {
|
|
28632
|
+
sections.push(bytes.subarray(headerStart2, end));
|
|
28168
28633
|
}
|
|
28169
28634
|
}
|
|
28170
|
-
sections?.push(Buffer.from([id]), encodeNumber(section2.length), section2);
|
|
28171
28635
|
}
|
|
28172
28636
|
return {
|
|
28173
28637
|
bytes: sections ? Buffer.concat(sections) : bytes,
|
|
28174
28638
|
definitions,
|
|
28175
28639
|
functionImports,
|
|
28176
28640
|
usesDlsym,
|
|
28177
|
-
usedSymbols
|
|
28641
|
+
usedSymbols,
|
|
28178
28642
|
addressTaken: [...addressTaken]
|
|
28179
28643
|
};
|
|
28180
28644
|
}
|
|
@@ -28263,36 +28727,51 @@ function createGuestImageLedger(input) {
|
|
|
28263
28727
|
}
|
|
28264
28728
|
}
|
|
28265
28729
|
}
|
|
28266
|
-
|
|
28267
|
-
for (const definition2 of definitions)
|
|
28268
|
-
|
|
28269
|
-
|
|
28270
|
-
|
|
28271
|
-
|
|
28272
|
-
|
|
28730
|
+
let hasNonAscii = false;
|
|
28731
|
+
for (const definition2 of definitions) {
|
|
28732
|
+
const s = definition2.name;
|
|
28733
|
+
for (let i = 0; i < s.length; i++) {
|
|
28734
|
+
if (s.charCodeAt(i) > 127) {
|
|
28735
|
+
hasNonAscii = true;
|
|
28736
|
+
break;
|
|
28737
|
+
}
|
|
28738
|
+
}
|
|
28739
|
+
if (hasNonAscii) break;
|
|
28740
|
+
}
|
|
28741
|
+
if (hasNonAscii) {
|
|
28742
|
+
const nameBytes = /* @__PURE__ */ new Map();
|
|
28743
|
+
for (const definition2 of definitions)
|
|
28744
|
+
if (!nameBytes.has(definition2.name))
|
|
28745
|
+
nameBytes.set(definition2.name, Buffer.from(definition2.name));
|
|
28746
|
+
definitions.sort(
|
|
28747
|
+
(a, b) => Buffer.compare(nameBytes.get(a.name), nameBytes.get(b.name)) || a.image - b.image
|
|
28748
|
+
);
|
|
28749
|
+
} else {
|
|
28750
|
+
definitions.sort(
|
|
28751
|
+
(a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : a.image - b.image
|
|
28752
|
+
);
|
|
28753
|
+
}
|
|
28273
28754
|
const preserveCanonical = /* @__PURE__ */ new Set();
|
|
28274
28755
|
const definitionsByName = Map.groupBy(definitions, (definition2) => definition2.name);
|
|
28275
|
-
|
|
28756
|
+
if (symbolIndices.has("__cxa_throw")) {
|
|
28757
|
+
const name3 = "__cxa_throw";
|
|
28276
28758
|
const matching2 = definitionsByName.get(name3) ?? [];
|
|
28277
|
-
if (new Set(matching2.map((definition2) => definition2.image)).size
|
|
28278
|
-
|
|
28279
|
-
|
|
28280
|
-
|
|
28281
|
-
|
|
28282
|
-
|
|
28283
|
-
|
|
28284
|
-
|
|
28285
|
-
|
|
28286
|
-
|
|
28287
|
-
|
|
28288
|
-
|
|
28289
|
-
|
|
28290
|
-
|
|
28291
|
-
);
|
|
28292
|
-
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
28293
|
-
throw new Error(`weak interposition scope excludes runtime for ${name3}`);
|
|
28759
|
+
if (new Set(matching2.map((definition2) => definition2.image)).size >= 2 && matching2.some((definition2) => definition2.weak)) {
|
|
28760
|
+
const weak = matching2.filter((definition2) => definition2.weak);
|
|
28761
|
+
const strong = matching2.filter((definition2) => !definition2.weak);
|
|
28762
|
+
if (weak.length !== 1 || strong.length !== 1)
|
|
28763
|
+
throw new Error(`unsupported weak interposition for ${name3}`);
|
|
28764
|
+
const [local] = weak;
|
|
28765
|
+
const [runtime] = strong;
|
|
28766
|
+
if (local.kind !== "function" || runtime.kind !== "function" || local.result !== runtime.result || local.parameters.join(",") !== runtime.parameters.join(","))
|
|
28767
|
+
throw new Error(`incompatible weak interposition for ${name3}`);
|
|
28768
|
+
for (const caller of input.callers) {
|
|
28769
|
+
const uses = caller.image === local.image || units.some((unit2) => unit2.image === caller.image && unit2.usedSymbols.has(name3));
|
|
28770
|
+
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
28771
|
+
throw new Error(`weak interposition scope excludes runtime for ${name3}`);
|
|
28772
|
+
}
|
|
28773
|
+
preserveCanonical.add(name3);
|
|
28294
28774
|
}
|
|
28295
|
-
preserveCanonical.add(name3);
|
|
28296
28775
|
}
|
|
28297
28776
|
for (const name3 of [
|
|
28298
28777
|
"dlsym",
|
|
@@ -28304,40 +28783,76 @@ function createGuestImageLedger(input) {
|
|
|
28304
28783
|
])
|
|
28305
28784
|
preserveCanonical.add(name3);
|
|
28306
28785
|
for (const name3 of input.commandLineSymbols ?? []) preserveCanonical.add(name3);
|
|
28307
|
-
const
|
|
28308
|
-
const
|
|
28786
|
+
const imageAliases = /* @__PURE__ */ new Map();
|
|
28787
|
+
const imageWeakNames = /* @__PURE__ */ new Map();
|
|
28788
|
+
const singleOwnerByName = /* @__PURE__ */ new Map();
|
|
28789
|
+
for (const definition2 of definitions) {
|
|
28790
|
+
let aliases = imageAliases.get(definition2.image);
|
|
28791
|
+
if (!aliases) imageAliases.set(definition2.image, aliases = /* @__PURE__ */ new Map());
|
|
28792
|
+
const existing = aliases.get(definition2.name);
|
|
28793
|
+
if (existing === void 0) {
|
|
28794
|
+
aliases.set(definition2.name, definition2.alias);
|
|
28795
|
+
if (definition2.weak) {
|
|
28796
|
+
let weak = imageWeakNames.get(definition2.image);
|
|
28797
|
+
if (!weak) imageWeakNames.set(definition2.image, weak = /* @__PURE__ */ new Set());
|
|
28798
|
+
weak.add(definition2.name);
|
|
28799
|
+
}
|
|
28800
|
+
const owner = singleOwnerByName.get(definition2.name);
|
|
28801
|
+
if (owner === void 0)
|
|
28802
|
+
singleOwnerByName.set(definition2.name, {
|
|
28803
|
+
image: definition2.image,
|
|
28804
|
+
alias: definition2.alias
|
|
28805
|
+
});
|
|
28806
|
+
else if (owner !== null && owner.image !== definition2.image)
|
|
28807
|
+
singleOwnerByName.set(definition2.name, null);
|
|
28808
|
+
} else if (!definition2.weak && imageWeakNames.get(definition2.image)?.has(definition2.name)) {
|
|
28809
|
+
aliases.set(definition2.name, definition2.alias);
|
|
28810
|
+
imageWeakNames.get(definition2.image).delete(definition2.name);
|
|
28811
|
+
const owner = singleOwnerByName.get(definition2.name);
|
|
28812
|
+
if (owner && owner.image === definition2.image) owner.alias = definition2.alias;
|
|
28813
|
+
}
|
|
28814
|
+
}
|
|
28815
|
+
const sharedLookupByImage = /* @__PURE__ */ new Map();
|
|
28309
28816
|
for (const caller of input.callers) {
|
|
28310
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
28311
|
-
const seen = /* @__PURE__ */ new Map();
|
|
28312
28817
|
const scope2 = [caller.image, ...caller.next];
|
|
28313
28818
|
if (input.systemImage !== void 0 && !scope2.includes(input.systemImage))
|
|
28314
28819
|
scope2.push(input.systemImage);
|
|
28315
|
-
|
|
28316
|
-
|
|
28317
|
-
|
|
28318
|
-
|
|
28319
|
-
|
|
28320
|
-
|
|
28321
|
-
|
|
28322
|
-
|
|
28323
|
-
|
|
28324
|
-
|
|
28325
|
-
|
|
28326
|
-
|
|
28327
|
-
|
|
28328
|
-
|
|
28329
|
-
|
|
28820
|
+
const scopeSet = new Set(scope2);
|
|
28821
|
+
const scopeMaps = [];
|
|
28822
|
+
const seenImages = /* @__PURE__ */ new Set();
|
|
28823
|
+
for (const image of scope2) {
|
|
28824
|
+
if (seenImages.has(image)) continue;
|
|
28825
|
+
seenImages.add(image);
|
|
28826
|
+
const aliases = imageAliases.get(image);
|
|
28827
|
+
if (aliases) scopeMaps.push(aliases);
|
|
28828
|
+
}
|
|
28829
|
+
const cache = /* @__PURE__ */ new Map();
|
|
28830
|
+
sharedLookupByImage.set(caller.image, (name3) => {
|
|
28831
|
+
if (preserveCanonical.has(name3)) return void 0;
|
|
28832
|
+
const single = singleOwnerByName.get(name3);
|
|
28833
|
+
if (single === void 0) return void 0;
|
|
28834
|
+
if (single !== null) return scopeSet.has(single.image) ? single.alias : void 0;
|
|
28835
|
+
const hit = cache.get(name3);
|
|
28836
|
+
if (hit !== void 0) return hit ?? void 0;
|
|
28837
|
+
for (const aliases of scopeMaps) {
|
|
28838
|
+
const alias = aliases.get(name3);
|
|
28839
|
+
if (alias !== void 0) {
|
|
28840
|
+
cache.set(name3, alias);
|
|
28841
|
+
return alias;
|
|
28330
28842
|
}
|
|
28331
28843
|
}
|
|
28332
|
-
|
|
28844
|
+
cache.set(name3, null);
|
|
28845
|
+
return void 0;
|
|
28846
|
+
});
|
|
28333
28847
|
}
|
|
28334
28848
|
const startup = /* @__PURE__ */ new Map();
|
|
28849
|
+
const unitsByPath = new Map(units.map((unit2) => [unit2.object.path, unit2]));
|
|
28335
28850
|
for (const binding of input.directBindings ?? []) {
|
|
28336
|
-
const unit2 =
|
|
28851
|
+
const unit2 = unitsByPath.get(binding.object);
|
|
28337
28852
|
const matches = (definitionsByName.get(binding.symbol) ?? []).filter(
|
|
28338
28853
|
(definition2) => definition2.object === binding.providerObject && definition2.image === binding.providerImage
|
|
28339
28854
|
);
|
|
28340
|
-
if (!unit2 || !unit2.usedSymbols.
|
|
28855
|
+
if (!unit2 || !unit2.usedSymbols.has(binding.symbol) || matches.length !== 1)
|
|
28341
28856
|
throw new Error(`invalid startup binding ${binding.object} ${binding.symbol}`);
|
|
28342
28857
|
const bindings = startup.get(binding.object) ?? /* @__PURE__ */ new Map();
|
|
28343
28858
|
if (bindings.has(binding.symbol))
|
|
@@ -28378,11 +28893,11 @@ function createGuestImageLedger(input) {
|
|
|
28378
28893
|
}
|
|
28379
28894
|
}
|
|
28380
28895
|
const objects = units.map(({ image, object: object7, aliases, functionImports }) => {
|
|
28381
|
-
const shared =
|
|
28896
|
+
const shared = sharedLookupByImage.get(image);
|
|
28382
28897
|
const own2 = startup.get(object7.path);
|
|
28383
28898
|
const bindings = new Map(own2);
|
|
28384
28899
|
const weak = input.sdkWeakReferences?.get(object7.path);
|
|
28385
|
-
const binding = (name3) => bindings.get(name3) ?? shared
|
|
28900
|
+
const binding = (name3) => bindings.get(name3) ?? shared(name3) ?? (weak?.has(name3) ? void 0 : sdkGlobalBindings.get(name3));
|
|
28386
28901
|
for (const [name3, type] of functionImports) {
|
|
28387
28902
|
const alias = binding(name3);
|
|
28388
28903
|
const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
|
|
@@ -28647,7 +29162,7 @@ function nameGuestImageAliases(wasm, symbols) {
|
|
|
28647
29162
|
}
|
|
28648
29163
|
return Buffer.concat(parts);
|
|
28649
29164
|
}
|
|
28650
|
-
var import_node_crypto16, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
29165
|
+
var import_node_crypto16, ByteWriter, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
28651
29166
|
var init_swift_guest_image_ledger = __esm({
|
|
28652
29167
|
"src/swift-guest-image-ledger.ts"() {
|
|
28653
29168
|
"use strict";
|
|
@@ -28655,6 +29170,57 @@ var init_swift_guest_image_ledger = __esm({
|
|
|
28655
29170
|
init_nativeWasmContract();
|
|
28656
29171
|
init_swift_sdk_image_wasm();
|
|
28657
29172
|
init_swiftSdkLinkContract();
|
|
29173
|
+
ByteWriter = class {
|
|
29174
|
+
buf;
|
|
29175
|
+
pos = 0;
|
|
29176
|
+
constructor(initialCapacity = 256) {
|
|
29177
|
+
this.buf = Buffer.allocUnsafe(Math.max(64, initialCapacity));
|
|
29178
|
+
}
|
|
29179
|
+
ensure(extra) {
|
|
29180
|
+
const needed = this.pos + extra;
|
|
29181
|
+
if (needed <= this.buf.length) return;
|
|
29182
|
+
let next = this.buf.length * 2;
|
|
29183
|
+
while (next < needed) next *= 2;
|
|
29184
|
+
const grown = Buffer.allocUnsafe(next);
|
|
29185
|
+
this.buf.copy(grown, 0, 0, this.pos);
|
|
29186
|
+
this.buf = grown;
|
|
29187
|
+
}
|
|
29188
|
+
byte(value) {
|
|
29189
|
+
this.ensure(1);
|
|
29190
|
+
this.buf[this.pos++] = value;
|
|
29191
|
+
}
|
|
29192
|
+
uleb(value) {
|
|
29193
|
+
this.ensure(10);
|
|
29194
|
+
let pos = this.pos;
|
|
29195
|
+
const buf = this.buf;
|
|
29196
|
+
do {
|
|
29197
|
+
let byte = value % 128;
|
|
29198
|
+
value = Math.floor(value / 128);
|
|
29199
|
+
if (value) byte |= 128;
|
|
29200
|
+
buf[pos++] = byte;
|
|
29201
|
+
} while (value);
|
|
29202
|
+
this.pos = pos;
|
|
29203
|
+
}
|
|
29204
|
+
bytes(source, start = 0, end = source.length) {
|
|
29205
|
+
const len = end - start;
|
|
29206
|
+
if (len <= 0) return;
|
|
29207
|
+
this.ensure(len);
|
|
29208
|
+
this.buf.set(source.subarray(start, end), this.pos);
|
|
29209
|
+
this.pos += len;
|
|
29210
|
+
}
|
|
29211
|
+
string(value) {
|
|
29212
|
+
const len = Buffer.byteLength(value, "utf8");
|
|
29213
|
+
this.uleb(len);
|
|
29214
|
+
if (len > 0) {
|
|
29215
|
+
this.ensure(len);
|
|
29216
|
+
this.buf.write(value, this.pos, len, "utf8");
|
|
29217
|
+
this.pos += len;
|
|
29218
|
+
}
|
|
29219
|
+
}
|
|
29220
|
+
finish() {
|
|
29221
|
+
return this.buf.subarray(0, this.pos);
|
|
29222
|
+
}
|
|
29223
|
+
};
|
|
28658
29224
|
OBJC_INIT_RECORD = ".objc_init";
|
|
28659
29225
|
TABLE_INDEX_RELOCATIONS = /* @__PURE__ */ new Set([1, 2, 12, 18, 19, 24]);
|
|
28660
29226
|
GUEST_DYLD_VALUES_SECTION = "peach_dyld_values";
|
|
@@ -29106,8 +29672,11 @@ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
29106
29672
|
function guestDyldValueRange(map2) {
|
|
29107
29673
|
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
29108
29674
|
let found;
|
|
29109
|
-
for (
|
|
29110
|
-
|
|
29675
|
+
for (let at = map2.indexOf(suffix); at !== -1; at = map2.indexOf(suffix, at + suffix.length)) {
|
|
29676
|
+
const lineEnd = at + suffix.length;
|
|
29677
|
+
if (lineEnd < map2.length && map2.charCodeAt(lineEnd) !== 10) continue;
|
|
29678
|
+
const lineStart = map2.lastIndexOf("\n", at) + 1;
|
|
29679
|
+
const line = map2.slice(lineStart, lineEnd);
|
|
29111
29680
|
const match = /^\s*([\da-f]+)\s+[\da-f]+\s+([\da-f]+)\s/.exec(line);
|
|
29112
29681
|
if (!match) throw new Error("unreadable dyld values map line");
|
|
29113
29682
|
if (found) throw new Error("link map has several dyld value sections");
|
|
@@ -29160,7 +29729,7 @@ var init_swift_guest_link_plan = __esm({
|
|
|
29160
29729
|
});
|
|
29161
29730
|
|
|
29162
29731
|
// src/swift-guest-manifest.ts
|
|
29163
|
-
function selectedGuestManifestInputs(plan, selection, identities) {
|
|
29732
|
+
function selectedGuestManifestInputs(plan, selection, identities, readSelected) {
|
|
29164
29733
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
29165
29734
|
const archives = /* @__PURE__ */ new Map();
|
|
29166
29735
|
const images = /* @__PURE__ */ new Map();
|
|
@@ -29171,19 +29740,29 @@ function selectedGuestManifestInputs(plan, selection, identities) {
|
|
|
29171
29740
|
throw new Error(`selected input has no logical identity: ${item.artifact}`);
|
|
29172
29741
|
let bytes;
|
|
29173
29742
|
let memberIdentity = null;
|
|
29174
|
-
if (item.member === null)
|
|
29175
|
-
|
|
29176
|
-
|
|
29177
|
-
if (
|
|
29178
|
-
|
|
29179
|
-
|
|
29743
|
+
if (item.member === null) {
|
|
29744
|
+
bytes = readSelected ? readSelected(item) : (0, import_node_fs31.readFileSync)(item.artifact);
|
|
29745
|
+
} else {
|
|
29746
|
+
if (readSelected) {
|
|
29747
|
+
bytes = readSelected(item);
|
|
29748
|
+
} else {
|
|
29749
|
+
let members2 = archives.get(item.artifact);
|
|
29750
|
+
if (!members2) {
|
|
29751
|
+
members2 = /* @__PURE__ */ new Map();
|
|
29752
|
+
for (const member of readArMembers((0, import_node_fs31.readFileSync)(item.artifact))) {
|
|
29753
|
+
let list2 = members2.get(member.name);
|
|
29754
|
+
if (!list2) members2.set(member.name, list2 = []);
|
|
29755
|
+
list2.push(member.bytes);
|
|
29756
|
+
}
|
|
29757
|
+
archives.set(item.artifact, members2);
|
|
29758
|
+
}
|
|
29759
|
+
const matching2 = members2.get(item.member);
|
|
29760
|
+
if (!matching2 || matching2.length !== 1)
|
|
29761
|
+
throw new Error(
|
|
29762
|
+
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
29763
|
+
);
|
|
29764
|
+
bytes = matching2[0];
|
|
29180
29765
|
}
|
|
29181
|
-
const matching2 = members2.filter((member) => member.name === item.member);
|
|
29182
|
-
if (matching2.length !== 1)
|
|
29183
|
-
throw new Error(
|
|
29184
|
-
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
29185
|
-
);
|
|
29186
|
-
bytes = matching2[0].bytes;
|
|
29187
29766
|
const origin = artifact.memberOrigins?.get(item.member);
|
|
29188
29767
|
if (artifact.memberOrigins && !origin)
|
|
29189
29768
|
throw new Error(
|
|
@@ -29275,7 +29854,7 @@ var init_swift_guest_manifest = __esm({
|
|
|
29275
29854
|
function isSwiftGuestImageManifest(value) {
|
|
29276
29855
|
const uint = (value2, maximum) => typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 && value2 <= maximum;
|
|
29277
29856
|
const text7 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
29278
|
-
const name3 = (value2) => text7(value2) &&
|
|
29857
|
+
const name3 = (value2) => text7(value2) && Buffer.byteLength(value2, "utf8") <= 16;
|
|
29279
29858
|
const version2 = (value2) => isRecord(value2) && uint(value2.major, 65535) && uint(value2.minor, 255) && uint(value2.patch, 255);
|
|
29280
29859
|
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))
|
|
29281
29860
|
return false;
|
|
@@ -29589,27 +30168,25 @@ function planGuestProjectionRegions(images, capacities, spans) {
|
|
|
29589
30168
|
function finalizeGuestProjectionStorage(options2) {
|
|
29590
30169
|
const owner = options2.owners.get(options2.projectionObject);
|
|
29591
30170
|
if (owner === void 0) throw new Error("guest projection object has no image owner");
|
|
30171
|
+
const ranges = [];
|
|
29592
30172
|
const spans = guestLinkedSpans(
|
|
29593
30173
|
options2.map,
|
|
29594
30174
|
options2.linked,
|
|
29595
30175
|
options2.optimized,
|
|
29596
30176
|
options2.owners,
|
|
29597
30177
|
options2.sectionOwners,
|
|
29598
|
-
options2.sdkSpans !== void 0
|
|
30178
|
+
options2.sdkSpans !== void 0,
|
|
30179
|
+
{
|
|
30180
|
+
trackedObject: options2.projectionObject,
|
|
30181
|
+
trackedObjectOwner: owner,
|
|
30182
|
+
trackedLinearSpans: ranges
|
|
30183
|
+
}
|
|
29599
30184
|
);
|
|
29600
30185
|
const images = planGuestProjectionRegions(
|
|
29601
30186
|
options2.reserved.images,
|
|
29602
30187
|
options2.reserved.capacities,
|
|
29603
30188
|
options2.sdkSpans ? [...spans, ...options2.sdkSpans] : spans
|
|
29604
30189
|
);
|
|
29605
|
-
const ranges = guestLinkedSpans(
|
|
29606
|
-
options2.map,
|
|
29607
|
-
options2.linked,
|
|
29608
|
-
options2.optimized,
|
|
29609
|
-
/* @__PURE__ */ new Map([[options2.projectionObject, owner]]),
|
|
29610
|
-
void 0,
|
|
29611
|
-
options2.sdkSpans !== void 0
|
|
29612
|
-
).filter((span) => span.space === "linear-memory");
|
|
29613
30190
|
const result = Buffer.from(options2.optimized);
|
|
29614
30191
|
const data = guestWasmDataSegments(options2.optimized, options2.sdkSpans === void 0);
|
|
29615
30192
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -30677,7 +31254,7 @@ function occurrences(plan, args) {
|
|
|
30677
31254
|
throw new Error("guest plan does not match linker inputs");
|
|
30678
31255
|
return found;
|
|
30679
31256
|
}
|
|
30680
|
-
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
31257
|
+
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace, archiveCache) {
|
|
30681
31258
|
const rows = whyExtract.trimEnd().split("\n");
|
|
30682
31259
|
if (rows.shift() !== "reference extracted symbol")
|
|
30683
31260
|
throw new Error("invalid wasm-ld extraction report");
|
|
@@ -30692,8 +31269,38 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
30692
31269
|
for (const file of extracted)
|
|
30693
31270
|
if (!traced.has(file))
|
|
30694
31271
|
throw new Error(`extracted guest input is absent from link trace ${file}`);
|
|
31272
|
+
const foundOccurrences = occurrences(plan, args);
|
|
31273
|
+
const archivePaths = /* @__PURE__ */ new Set();
|
|
31274
|
+
for (const { artifact } of foundOccurrences)
|
|
31275
|
+
if (artifact.kind === "archive") archivePaths.add(artifact.path);
|
|
31276
|
+
const tracedMembers = /* @__PURE__ */ new Map();
|
|
31277
|
+
if (archivePaths.size > 0) {
|
|
31278
|
+
const archivePrefixes = [...archivePaths].map(
|
|
31279
|
+
(archivePath) => [archivePath, `${archivePath}(`]
|
|
31280
|
+
);
|
|
31281
|
+
for (const item of traced) {
|
|
31282
|
+
if (!item.endsWith(")")) continue;
|
|
31283
|
+
const open = item.lastIndexOf("(");
|
|
31284
|
+
if (open > 0) {
|
|
31285
|
+
const archivePath = item.slice(0, open);
|
|
31286
|
+
if (archivePaths.has(archivePath)) {
|
|
31287
|
+
let list2 = tracedMembers.get(archivePath);
|
|
31288
|
+
if (!list2) tracedMembers.set(archivePath, list2 = []);
|
|
31289
|
+
list2.push(item.slice(open + 1, -1));
|
|
31290
|
+
continue;
|
|
31291
|
+
}
|
|
31292
|
+
}
|
|
31293
|
+
for (const [archivePath, prefix] of archivePrefixes) {
|
|
31294
|
+
if (item.startsWith(prefix)) {
|
|
31295
|
+
let list2 = tracedMembers.get(archivePath);
|
|
31296
|
+
if (!list2) tracedMembers.set(archivePath, list2 = []);
|
|
31297
|
+
list2.push(item.slice(prefix.length, -1));
|
|
31298
|
+
}
|
|
31299
|
+
}
|
|
31300
|
+
}
|
|
31301
|
+
}
|
|
30695
31302
|
const result = [];
|
|
30696
|
-
for (const { artifact, lazy, whole } of
|
|
31303
|
+
for (const { artifact, lazy, whole } of foundOccurrences) {
|
|
30697
31304
|
if (artifact.kind === "object") {
|
|
30698
31305
|
if (!lazy && !traced.has(artifact.path))
|
|
30699
31306
|
throw new Error(`eager guest input is absent from link trace ${artifact.path}`);
|
|
@@ -30701,15 +31308,21 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
30701
31308
|
result.push({ artifact: artifact.path, member: null });
|
|
30702
31309
|
continue;
|
|
30703
31310
|
}
|
|
30704
|
-
const
|
|
30705
|
-
const
|
|
30706
|
-
|
|
31311
|
+
const names = tracedMembers.get(artifact.path) ?? [];
|
|
31312
|
+
const nameSet = new Set(names);
|
|
31313
|
+
let members2 = archiveCache?.get(artifact.path);
|
|
31314
|
+
if (!members2) {
|
|
31315
|
+
members2 = readArMembers(import_node_fs34.default.readFileSync(artifact.path));
|
|
31316
|
+
archiveCache?.set(artifact.path, members2);
|
|
31317
|
+
}
|
|
31318
|
+
const memberCounts = /* @__PURE__ */ new Map();
|
|
30707
31319
|
for (const member of members2) {
|
|
30708
|
-
|
|
31320
|
+
memberCounts.set(member.name, (memberCounts.get(member.name) ?? 0) + 1);
|
|
31321
|
+
if (whole || nameSet.has(member.name))
|
|
30709
31322
|
result.push({ artifact: artifact.path, member: member.name });
|
|
30710
31323
|
}
|
|
30711
31324
|
for (const name3 of names)
|
|
30712
|
-
if (
|
|
31325
|
+
if (memberCounts.get(name3) !== 1)
|
|
30713
31326
|
throw new Error(
|
|
30714
31327
|
`ambiguous or unsupported archive member ${artifact.path}(${name3})`
|
|
30715
31328
|
);
|
|
@@ -30786,14 +31399,25 @@ function linkGuestImages(options2) {
|
|
|
30786
31399
|
}
|
|
30787
31400
|
const archives = /* @__PURE__ */ new Map();
|
|
30788
31401
|
const memberBytes = /* @__PURE__ */ new Map();
|
|
31402
|
+
const objectBytes = /* @__PURE__ */ new Map();
|
|
30789
31403
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
30790
31404
|
const providerSymbol = "__peach_dlsym_from_image";
|
|
30791
31405
|
const readSelected = (item) => {
|
|
30792
|
-
if (item.member === null)
|
|
31406
|
+
if (item.member === null) {
|
|
31407
|
+
let bytes = objectBytes.get(item.artifact);
|
|
31408
|
+
if (!bytes) {
|
|
31409
|
+
bytes = import_node_fs34.default.readFileSync(item.artifact);
|
|
31410
|
+
objectBytes.set(item.artifact, bytes);
|
|
31411
|
+
}
|
|
31412
|
+
return bytes;
|
|
31413
|
+
}
|
|
30793
31414
|
let byName2 = memberBytes.get(item.artifact);
|
|
30794
31415
|
if (!byName2) {
|
|
30795
|
-
|
|
30796
|
-
|
|
31416
|
+
let members2 = archives.get(item.artifact);
|
|
31417
|
+
if (!members2) {
|
|
31418
|
+
members2 = readArMembers(import_node_fs34.default.readFileSync(item.artifact));
|
|
31419
|
+
archives.set(item.artifact, members2);
|
|
31420
|
+
}
|
|
30797
31421
|
byName2 = /* @__PURE__ */ new Map();
|
|
30798
31422
|
for (const member of members2)
|
|
30799
31423
|
if (!byName2.has(member.name))
|
|
@@ -30817,7 +31441,13 @@ function linkGuestImages(options2) {
|
|
|
30817
31441
|
`--why-extract=${whyPath}`,
|
|
30818
31442
|
`--Map=${mapPath}`
|
|
30819
31443
|
]);
|
|
30820
|
-
return selectedGuestLinkInputs(
|
|
31444
|
+
return selectedGuestLinkInputs(
|
|
31445
|
+
plan,
|
|
31446
|
+
args,
|
|
31447
|
+
import_node_fs34.default.readFileSync(whyPath, "utf8"),
|
|
31448
|
+
trace,
|
|
31449
|
+
archives
|
|
31450
|
+
);
|
|
30821
31451
|
};
|
|
30822
31452
|
const needsProvider = (item) => {
|
|
30823
31453
|
if (!artifacts.get(item.artifact).instrumentDynamicLookups) return false;
|
|
@@ -30857,7 +31487,7 @@ function linkGuestImages(options2) {
|
|
|
30857
31487
|
)
|
|
30858
31488
|
]);
|
|
30859
31489
|
const originalOwnership = identity2(plan);
|
|
30860
|
-
const resolved = options2.resolvePlan(selected, plan);
|
|
31490
|
+
const resolved = options2.resolvePlan(selected, plan, readSelected);
|
|
30861
31491
|
if (identity2(resolved) !== originalOwnership)
|
|
30862
31492
|
throw new Error("resolved guest scopes changed input ownership");
|
|
30863
31493
|
plan = resolved;
|
|
@@ -30911,6 +31541,7 @@ function linkGuestImages(options2) {
|
|
|
30911
31541
|
}
|
|
30912
31542
|
}
|
|
30913
31543
|
let discoveryRegions;
|
|
31544
|
+
let liveSymbols;
|
|
30914
31545
|
if (discoveryProjection && options2.projection) {
|
|
30915
31546
|
const owners = /* @__PURE__ */ new Map([[discoveryProjection, options2.projection.image]]);
|
|
30916
31547
|
for (const item of selected)
|
|
@@ -30919,10 +31550,15 @@ function linkGuestImages(options2) {
|
|
|
30919
31550
|
selectedGuestInputImage(artifacts.get(item.artifact), item.member)
|
|
30920
31551
|
);
|
|
30921
31552
|
const wasm = import_node_fs34.default.readFileSync(discovery);
|
|
31553
|
+
liveSymbols = /* @__PURE__ */ new Set();
|
|
30922
31554
|
discoveryRegions = guestProjectionRegionCounts(
|
|
30923
31555
|
plan.images.length,
|
|
30924
|
-
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners
|
|
31556
|
+
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners, void 0, false, {
|
|
31557
|
+
collectSymbols: liveSymbols
|
|
31558
|
+
})
|
|
30925
31559
|
);
|
|
31560
|
+
} else {
|
|
31561
|
+
liveSymbols = linkedMapSymbols(guestLinkLines(mapPath));
|
|
30926
31562
|
}
|
|
30927
31563
|
const ledger = createGuestImageLedger({
|
|
30928
31564
|
images: plan.images.map((image) => ({
|
|
@@ -30931,7 +31567,7 @@ function linkGuestImages(options2) {
|
|
|
30931
31567
|
})),
|
|
30932
31568
|
callers: plan.callers,
|
|
30933
31569
|
symbols: plan.symbols,
|
|
30934
|
-
liveSymbols
|
|
31570
|
+
liveSymbols,
|
|
30935
31571
|
commandLineSymbols: commandLineSymbols(args),
|
|
30936
31572
|
directBindings: plan.directBindings,
|
|
30937
31573
|
registerAppTables: sdkCallers !== void 0,
|
|
@@ -31063,7 +31699,8 @@ function linkGuestImages(options2) {
|
|
|
31063
31699
|
const selectedInputs = selectedGuestManifestInputs(
|
|
31064
31700
|
plan,
|
|
31065
31701
|
selected,
|
|
31066
|
-
projection.identities
|
|
31702
|
+
projection.identities,
|
|
31703
|
+
readSelected
|
|
31067
31704
|
);
|
|
31068
31705
|
const images = projection.images.map(
|
|
31069
31706
|
(image) => createGuestImageManifest({
|
|
@@ -31073,6 +31710,9 @@ function linkGuestImages(options2) {
|
|
|
31073
31710
|
regions: []
|
|
31074
31711
|
})
|
|
31075
31712
|
);
|
|
31713
|
+
objectBytes.clear();
|
|
31714
|
+
memberBytes.clear();
|
|
31715
|
+
archives.clear();
|
|
31076
31716
|
if (!discoveryRegions) throw new Error("guest projection layout object missing");
|
|
31077
31717
|
const regionsBefore = discoveryRegions;
|
|
31078
31718
|
const ledgerPieces = guestProjectionRegionCapacity([import_node_fs34.default.readFileSync(ledgerObject)], 0);
|
|
@@ -31166,10 +31806,47 @@ ${changed.join("\n")}`
|
|
|
31166
31806
|
}
|
|
31167
31807
|
function linkedMapSymbols(lines) {
|
|
31168
31808
|
const names = /* @__PURE__ */ new Set();
|
|
31169
|
-
const symbol2 = /^ +\S+ +[0-9a-f]+ +[0-9a-f]+ {9,}([^\s/<]\S*)/;
|
|
31170
31809
|
for (const line of lines) {
|
|
31171
|
-
const
|
|
31172
|
-
if (
|
|
31810
|
+
const length = line.length;
|
|
31811
|
+
if (length < 15 || line.charCodeAt(0) !== 32) continue;
|
|
31812
|
+
let pos = 1;
|
|
31813
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
31814
|
+
const c1 = pos;
|
|
31815
|
+
while (pos < length) {
|
|
31816
|
+
const ch = line.charCodeAt(pos);
|
|
31817
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
31818
|
+
pos++;
|
|
31819
|
+
}
|
|
31820
|
+
if (pos === c1 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
31821
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
31822
|
+
const c2 = pos;
|
|
31823
|
+
while (pos < length) {
|
|
31824
|
+
const ch = line.charCodeAt(pos);
|
|
31825
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
31826
|
+
pos++;
|
|
31827
|
+
}
|
|
31828
|
+
if (pos === c2 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
31829
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
31830
|
+
const c3 = pos;
|
|
31831
|
+
while (pos < length) {
|
|
31832
|
+
const ch = line.charCodeAt(pos);
|
|
31833
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
31834
|
+
pos++;
|
|
31835
|
+
}
|
|
31836
|
+
if (pos === c3 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
31837
|
+
const sStart = pos;
|
|
31838
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
31839
|
+
if (pos - sStart < 9 || pos >= length) continue;
|
|
31840
|
+
const first = line.charCodeAt(pos);
|
|
31841
|
+
if (first === 47 || first === 60 || first === 32 || first >= 9 && first <= 13)
|
|
31842
|
+
continue;
|
|
31843
|
+
let end = pos + 1;
|
|
31844
|
+
while (end < length) {
|
|
31845
|
+
const ch = line.charCodeAt(end);
|
|
31846
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
31847
|
+
end++;
|
|
31848
|
+
}
|
|
31849
|
+
names.add(line.slice(pos, end));
|
|
31173
31850
|
}
|
|
31174
31851
|
return names;
|
|
31175
31852
|
}
|
|
@@ -31268,7 +31945,7 @@ function discoverGuestLinkInputs(options2) {
|
|
|
31268
31945
|
import_node_fs34.default.mkdirSync(options2.directory, { recursive: true });
|
|
31269
31946
|
const why = import_node_path32.default.join(options2.directory, "preselection-why.txt");
|
|
31270
31947
|
const response = import_node_path32.default.join(options2.directory, "preselection.rsp");
|
|
31271
|
-
const output = import_node_path32.default.join(options2.directory, "preselection.wasm");
|
|
31948
|
+
const output = process.platform !== "win32" ? "/dev/null" : import_node_path32.default.join(options2.directory, "preselection.wasm");
|
|
31272
31949
|
const flags = [
|
|
31273
31950
|
...withOutput(args, output, true),
|
|
31274
31951
|
...options2.objects,
|
|
@@ -31366,7 +32043,7 @@ function prepareGuestRuntimeInputs(options2) {
|
|
|
31366
32043
|
});
|
|
31367
32044
|
return { args, selected, originalSelection, archives, sdkProducts, archiveArtifacts };
|
|
31368
32045
|
}
|
|
31369
|
-
function selectedGuestSymbolInputs(plan, selected) {
|
|
32046
|
+
function selectedGuestSymbolInputs(plan, selected, readSelected) {
|
|
31370
32047
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
31371
32048
|
const archives = /* @__PURE__ */ new Map();
|
|
31372
32049
|
const symbols = /* @__PURE__ */ new Set();
|
|
@@ -31382,22 +32059,27 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
31382
32059
|
if (!artifact) throw new Error(`selected symbol input has no owner ${item.artifact}`);
|
|
31383
32060
|
let bytes;
|
|
31384
32061
|
let name3 = item.artifact;
|
|
31385
|
-
if (item.member === null)
|
|
31386
|
-
|
|
31387
|
-
|
|
31388
|
-
if (
|
|
31389
|
-
|
|
31390
|
-
|
|
31391
|
-
|
|
31392
|
-
)
|
|
31393
|
-
|
|
32062
|
+
if (item.member === null) {
|
|
32063
|
+
bytes = readSelected ? readSelected(item) : import_node_fs34.default.readFileSync(item.artifact);
|
|
32064
|
+
} else {
|
|
32065
|
+
if (readSelected) {
|
|
32066
|
+
bytes = readSelected(item);
|
|
32067
|
+
} else {
|
|
32068
|
+
let members2 = archives.get(item.artifact);
|
|
32069
|
+
if (!members2) {
|
|
32070
|
+
members2 = Map.groupBy(
|
|
32071
|
+
readArMembers(import_node_fs34.default.readFileSync(item.artifact)),
|
|
32072
|
+
(member) => member.name
|
|
32073
|
+
);
|
|
32074
|
+
archives.set(item.artifact, members2);
|
|
32075
|
+
}
|
|
32076
|
+
const matching2 = members2.get(item.member) ?? [];
|
|
32077
|
+
if (matching2.length !== 1)
|
|
32078
|
+
throw new Error(
|
|
32079
|
+
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
32080
|
+
);
|
|
32081
|
+
bytes = matching2[0].bytes;
|
|
31394
32082
|
}
|
|
31395
|
-
const matching2 = members2.get(item.member) ?? [];
|
|
31396
|
-
if (matching2.length !== 1)
|
|
31397
|
-
throw new Error(
|
|
31398
|
-
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
31399
|
-
);
|
|
31400
|
-
bytes = matching2[0].bytes;
|
|
31401
32083
|
name3 += `(${item.member})`;
|
|
31402
32084
|
}
|
|
31403
32085
|
if (owners.has(name3)) throw new Error(`duplicate selected symbol input ${name3}`);
|
|
@@ -31410,9 +32092,9 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
31410
32092
|
for (const symbol2 of names.tags) tags.add(symbol2);
|
|
31411
32093
|
for (const symbol2 of names.defined) {
|
|
31412
32094
|
definitions.add(symbol2);
|
|
31413
|
-
|
|
32095
|
+
let objects = definitionObjects.get(symbol2);
|
|
32096
|
+
if (!objects) definitionObjects.set(symbol2, objects = /* @__PURE__ */ new Set());
|
|
31414
32097
|
objects.add(name3);
|
|
31415
|
-
definitionObjects.set(symbol2, objects);
|
|
31416
32098
|
}
|
|
31417
32099
|
}
|
|
31418
32100
|
return {
|
|
@@ -31433,7 +32115,7 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
31433
32115
|
if (!symbols.length) return { bindings: [], directBindings: [] };
|
|
31434
32116
|
import_node_fs34.default.mkdirSync(options2.directory, { recursive: true });
|
|
31435
32117
|
const response = import_node_path32.default.join(options2.directory, "scope-trace.rsp");
|
|
31436
|
-
const output = import_node_path32.default.join(options2.directory, "scope-trace.wasm");
|
|
32118
|
+
const output = process.platform !== "win32" ? "/dev/null" : import_node_path32.default.join(options2.directory, "scope-trace.wasm");
|
|
31437
32119
|
const args = [
|
|
31438
32120
|
...withOutput(normalizedGuestLinkArgs(options2.args), output, true),
|
|
31439
32121
|
...options2.objects,
|
|
@@ -31451,55 +32133,76 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
31451
32133
|
import_node_fs34.default.closeSync(traceOutput);
|
|
31452
32134
|
}
|
|
31453
32135
|
const records = /* @__PURE__ */ new Map();
|
|
31454
|
-
const
|
|
31455
|
-
const
|
|
31456
|
-
|
|
31457
|
-
|
|
31458
|
-
|
|
31459
|
-
|
|
31460
|
-
const
|
|
31461
|
-
|
|
31462
|
-
|
|
31463
|
-
|
|
31464
|
-
|
|
32136
|
+
for (const line of guestLinkLines(tracePath)) {
|
|
32137
|
+
const refSep = line.lastIndexOf(": reference to ");
|
|
32138
|
+
const defSep = line.lastIndexOf(": definition of ");
|
|
32139
|
+
if (refSep < 0 && defSep < 0) continue;
|
|
32140
|
+
const isRef = refSep > defSep;
|
|
32141
|
+
const sep3 = isRef ? refSep : defSep;
|
|
32142
|
+
const symbol2 = line.slice(sep3 + (isRef ? 15 : 16));
|
|
32143
|
+
if (!requested.has(symbol2) || options2.hostImports.has(symbol2)) continue;
|
|
32144
|
+
let record5 = records.get(symbol2);
|
|
32145
|
+
if (!record5) {
|
|
32146
|
+
record5 = {
|
|
32147
|
+
references: /* @__PURE__ */ new Map(),
|
|
32148
|
+
providers: /* @__PURE__ */ new Map(),
|
|
32149
|
+
physicalModule: false
|
|
32150
|
+
};
|
|
32151
|
+
records.set(symbol2, record5);
|
|
32152
|
+
}
|
|
32153
|
+
const object7 = line.slice(0, sep3);
|
|
31465
32154
|
if (object7 === "<internal>") {
|
|
31466
|
-
if (
|
|
32155
|
+
if (!isRef) record5.physicalModule = true;
|
|
31467
32156
|
} else {
|
|
31468
32157
|
const image = options2.owners.get(object7);
|
|
31469
32158
|
if (image === void 0)
|
|
31470
32159
|
throw new Error(`traced guest object has no owner ${object7}`);
|
|
31471
|
-
(
|
|
31472
|
-
object7,
|
|
31473
|
-
image
|
|
31474
|
-
);
|
|
32160
|
+
(isRef ? record5.references : record5.providers).set(object7, image);
|
|
31475
32161
|
}
|
|
31476
|
-
|
|
31477
|
-
};
|
|
31478
|
-
for (const line of guestLinkLines(tracePath)) consume(line);
|
|
32162
|
+
}
|
|
31479
32163
|
const callers = new Map(options2.callers.map((caller) => [caller.image, caller.next]));
|
|
32164
|
+
const callerSets = new Map(
|
|
32165
|
+
options2.callers.map((caller) => [caller.image, new Set(caller.next)])
|
|
32166
|
+
);
|
|
32167
|
+
const rootScope = callerSets.get(0);
|
|
31480
32168
|
const result = [];
|
|
31481
32169
|
const directBindings = [];
|
|
31482
32170
|
for (const symbol2 of symbols) {
|
|
31483
32171
|
const record5 = records.get(symbol2);
|
|
31484
32172
|
if (!record5 || !record5.references.size) continue;
|
|
31485
32173
|
if (!record5.providers.size && options2.hostImports.has(symbol2)) continue;
|
|
31486
|
-
const startupReferences = [
|
|
31487
|
-
|
|
31488
|
-
|
|
31489
|
-
const
|
|
31490
|
-
|
|
31491
|
-
|
|
32174
|
+
const startupReferences = [];
|
|
32175
|
+
const otherReferences = [];
|
|
32176
|
+
let allWeakRefs = true;
|
|
32177
|
+
for (const [object7, caller] of record5.references) {
|
|
32178
|
+
const isWeakRef = options2.weakReferences.get(object7)?.has(symbol2) === true;
|
|
32179
|
+
if (!isWeakRef) allWeakRefs = false;
|
|
32180
|
+
if (isWeakRef && options2.startupObjects.has(object7)) {
|
|
32181
|
+
startupReferences.push([object7, caller]);
|
|
32182
|
+
} else {
|
|
32183
|
+
otherReferences.push([object7, caller]);
|
|
32184
|
+
}
|
|
32185
|
+
}
|
|
31492
32186
|
for (const [, caller] of startupReferences)
|
|
31493
32187
|
if (!callers.has(caller))
|
|
31494
32188
|
throw new Error(`guest image has no caller scope ${caller}`);
|
|
31495
32189
|
if (startupReferences.length && !record5.physicalModule) {
|
|
31496
|
-
const
|
|
31497
|
-
|
|
32190
|
+
const candidates2 = options2.definitionObjects.get(symbol2);
|
|
32191
|
+
const candidateSize = candidates2?.size ?? 0;
|
|
32192
|
+
if (candidateSize > 1 || record5.providers.size > 1)
|
|
31498
32193
|
throw new Error(`ambiguous startup provider ${symbol2}`);
|
|
31499
|
-
|
|
31500
|
-
|
|
32194
|
+
let unproven = candidateSize !== record5.providers.size;
|
|
32195
|
+
if (!unproven && candidates2) {
|
|
32196
|
+
for (const object7 of record5.providers.keys()) {
|
|
32197
|
+
if (!candidates2.has(object7)) {
|
|
32198
|
+
unproven = true;
|
|
32199
|
+
break;
|
|
32200
|
+
}
|
|
32201
|
+
}
|
|
32202
|
+
}
|
|
32203
|
+
if (unproven) throw new Error(`unproven startup provider ${symbol2}`);
|
|
31501
32204
|
if (record5.providers.size === 1) {
|
|
31502
|
-
const [providerObject, providerImage] =
|
|
32205
|
+
const [providerObject, providerImage] = record5.providers.entries().next().value;
|
|
31503
32206
|
if (options2.weakDefinitions.get(providerObject)?.has(symbol2))
|
|
31504
32207
|
throw new Error(`weak startup provider ${symbol2}`);
|
|
31505
32208
|
for (const [object7] of startupReferences)
|
|
@@ -31507,28 +32210,34 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
31507
32210
|
}
|
|
31508
32211
|
if (!otherReferences.length) continue;
|
|
31509
32212
|
}
|
|
31510
|
-
if (!record5.providers.size && !record5.physicalModule &&
|
|
31511
|
-
(object7) => options2.weakReferences.get(object7)?.has(symbol2)
|
|
31512
|
-
))
|
|
31513
|
-
continue;
|
|
32213
|
+
if (!record5.providers.size && !record5.physicalModule && allWeakRefs) continue;
|
|
31514
32214
|
const providerImages = new Set(record5.providers.values());
|
|
31515
|
-
const
|
|
31516
|
-
|
|
32215
|
+
const candidates = options2.definitionObjects.get(symbol2);
|
|
32216
|
+
const copyImages = /* @__PURE__ */ new Set();
|
|
32217
|
+
const strongImages = /* @__PURE__ */ new Set();
|
|
32218
|
+
let weakDefinerImages;
|
|
32219
|
+
if (candidates) {
|
|
32220
|
+
for (const object7 of candidates) {
|
|
31517
32221
|
const image = options2.owners.get(object7);
|
|
31518
|
-
|
|
32222
|
+
if (image === void 0) continue;
|
|
32223
|
+
copyImages.add(image);
|
|
32224
|
+
if (options2.weakDefinitions.get(object7)?.has(symbol2)) {
|
|
32225
|
+
;
|
|
32226
|
+
(weakDefinerImages ??= /* @__PURE__ */ new Set()).add(image);
|
|
32227
|
+
} else {
|
|
32228
|
+
strongImages.add(image);
|
|
32229
|
+
}
|
|
31519
32230
|
}
|
|
31520
|
-
|
|
31521
|
-
const copyImages = new Set(copies.map((copy) => copy.image));
|
|
31522
|
-
const strongImages = new Set(
|
|
31523
|
-
copies.filter((copy) => !copy.weak).map((copy) => copy.image)
|
|
31524
|
-
);
|
|
32231
|
+
}
|
|
31525
32232
|
const interposed = !record5.physicalModule && copyImages.size > 1;
|
|
31526
32233
|
const providerCount = interposed ? 1 : providerImages.size + Number(record5.physicalModule);
|
|
31527
32234
|
if (!providerCount) continue;
|
|
31528
32235
|
if (providerCount !== 1)
|
|
31529
32236
|
throw new Error(`guest symbol has ambiguous provider ${symbol2}`);
|
|
31530
|
-
const scopedReferences = record5.physicalModule ?
|
|
31531
|
-
const
|
|
32237
|
+
const scopedReferences = record5.physicalModule ? record5.references : otherReferences;
|
|
32238
|
+
const firstProviderImage = providerImages.values().next().value;
|
|
32239
|
+
const uniqueProvider = strongImages.size > 1 ? void 0 : strongImages.values().next().value ?? firstProviderImage;
|
|
32240
|
+
let interposedByCaller;
|
|
31532
32241
|
for (const [object7, caller] of scopedReferences) {
|
|
31533
32242
|
const scope2 = callers.get(caller);
|
|
31534
32243
|
if (!scope2) throw new Error(`guest image has no caller scope ${caller}`);
|
|
@@ -31536,18 +32245,35 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
31536
32245
|
result.push({ symbol: symbol2, caller, provider: { kind: "physical-module" } });
|
|
31537
32246
|
continue;
|
|
31538
32247
|
}
|
|
31539
|
-
|
|
32248
|
+
let provider;
|
|
32249
|
+
if (interposed) {
|
|
32250
|
+
if (interposedByCaller?.has(caller)) {
|
|
32251
|
+
provider = interposedByCaller.get(caller);
|
|
32252
|
+
} else {
|
|
32253
|
+
if (copyImages.has(caller)) {
|
|
32254
|
+
provider = caller;
|
|
32255
|
+
} else {
|
|
32256
|
+
for (const image of scope2) {
|
|
32257
|
+
if (copyImages.has(image)) {
|
|
32258
|
+
provider = image;
|
|
32259
|
+
break;
|
|
32260
|
+
}
|
|
32261
|
+
}
|
|
32262
|
+
if (provider === void 0) provider = uniqueProvider;
|
|
32263
|
+
}
|
|
32264
|
+
;
|
|
32265
|
+
(interposedByCaller ??= /* @__PURE__ */ new Map()).set(caller, provider);
|
|
32266
|
+
}
|
|
32267
|
+
} else {
|
|
32268
|
+
provider = firstProviderImage;
|
|
32269
|
+
}
|
|
31540
32270
|
if (provider === void 0) {
|
|
31541
32271
|
if (options2.weakReferences.get(object7)?.has(symbol2)) continue;
|
|
31542
32272
|
throw new Error(`guest scope ${caller} omits every provider of ${symbol2}`);
|
|
31543
32273
|
}
|
|
31544
32274
|
if (caller === provider) continue;
|
|
31545
|
-
if (
|
|
31546
|
-
|
|
31547
|
-
))
|
|
31548
|
-
continue;
|
|
31549
|
-
if (!scope2.includes(provider)) {
|
|
31550
|
-
const candidates = options2.definitionObjects.get(symbol2) ?? /* @__PURE__ */ new Set();
|
|
32275
|
+
if (weakDefinerImages?.has(caller)) continue;
|
|
32276
|
+
if (!callerSets.get(caller).has(provider)) {
|
|
31551
32277
|
const traced = [...record5.providers.keys()];
|
|
31552
32278
|
const strongTraced = traced.filter(
|
|
31553
32279
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
@@ -31555,16 +32281,17 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
31555
32281
|
const providers = strongTraced.length === 1 ? strongTraced : traced;
|
|
31556
32282
|
if (options2.weakReferences.get(object7)?.has(symbol2) && !providers.some((provider2) => options2.systemProviders.has(provider2)))
|
|
31557
32283
|
continue;
|
|
31558
|
-
const
|
|
32284
|
+
const candidateSet = candidates ?? /* @__PURE__ */ new Set();
|
|
32285
|
+
const equivalentCopies = providers.length === 1 && candidateSet.has(providers[0]) && [...candidateSet].every(
|
|
31559
32286
|
(definer) => options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
31560
32287
|
);
|
|
31561
|
-
const strongCandidates = [...
|
|
32288
|
+
const strongCandidates = [...candidateSet].filter(
|
|
31562
32289
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
31563
32290
|
);
|
|
31564
|
-
const soleCandidate =
|
|
31565
|
-
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !
|
|
32291
|
+
const soleCandidate = candidateSet.size === 1 || strongCandidates.length === 1 && strongCandidates[0] === providers[0];
|
|
32292
|
+
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !candidateSet.has(providers[0]) || !(options2.systemProviders.has(providers[0]) || // a strong undefined reference binds through the process global
|
|
31566
32293
|
// scope, the root image and its dependency closure, as in elf.
|
|
31567
|
-
provider === 0 ||
|
|
32294
|
+
provider === 0 || rootScope?.has(provider) || !options2.weakReferences.get(object7)?.has(symbol2) && options2.frameworkProviders.get(object7)?.has(providers[0]))))
|
|
31568
32295
|
throw new Error(
|
|
31569
32296
|
`guest scope ${caller} omits traced provider ${provider} for ${symbol2}`
|
|
31570
32297
|
);
|
|
@@ -37583,9 +38310,9 @@ async function compileGuestLink(options2) {
|
|
|
37583
38310
|
}
|
|
37584
38311
|
};
|
|
37585
38312
|
},
|
|
37586
|
-
resolvePlan: (selected, plan) => {
|
|
38313
|
+
resolvePlan: (selected, plan, readSelected) => {
|
|
37587
38314
|
if (!prepared) throw new Error("guest runtime selection is unavailable");
|
|
37588
|
-
const scope2 = selectedGuestSymbolInputs(plan, selected);
|
|
38315
|
+
const scope2 = selectedGuestSymbolInputs(plan, selected, readSelected);
|
|
37589
38316
|
const owners = new Map(scope2.owners);
|
|
37590
38317
|
owners.set(import_node_path43.default.join(directory2, "projection-discovery.o"), 0);
|
|
37591
38318
|
const providersByImage = Map.groupBy(scope2.owners, ([, image]) => image);
|
|
@@ -45282,7 +46009,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
45282
46009
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
45283
46010
|
MULTI_MANIFEST_VERSION = 76;
|
|
45284
46011
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
45285
|
-
compilerSourceDigest = true ? "
|
|
46012
|
+
compilerSourceDigest = true ? "7b91fa4405159335b5484c82700e001e4c27abf15621b724ea8af4edea693f66" : swiftCompilerSourceDigest(__sootsim_import_meta_dirname);
|
|
45286
46013
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
45287
46014
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
45288
46015
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
@@ -85718,7 +86445,7 @@ var init_swift_standin_digest = __esm({
|
|
|
85718
86445
|
STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
|
|
85719
86446
|
SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
85720
86447
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
|
|
85721
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
86448
|
+
STANDIN_SOURCE_DIGEST = true ? "a3bcdfe9c9957355a59c2c26155470c89a2abb30907aeeaaf1de8463aa74fc8c" : standinSourceDigest();
|
|
85722
86449
|
}
|
|
85723
86450
|
});
|
|
85724
86451
|
|
|
@@ -102162,7 +102889,7 @@ var init_nitro_superset = __esm({
|
|
|
102162
102889
|
init_nitroContract();
|
|
102163
102890
|
init_swift_standin_digest();
|
|
102164
102891
|
NITRO_SUPERSET_ENTRY_NAME = "superset";
|
|
102165
|
-
NITRO_COMPILER_DIGEST = true ? "
|
|
102892
|
+
NITRO_COMPILER_DIGEST = true ? "ffe0ab1580ebcb5a184764bfb3b3650342c8644057a95423913e7078c208f318" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
|
|
102166
102893
|
nitroSupersetLock = parseLock(nitro_superset_lock_default);
|
|
102167
102894
|
nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
|
|
102168
102895
|
published = /* @__PURE__ */ new Map();
|
|
@@ -103029,7 +103756,7 @@ var init_expo_eager_seam_contract = __esm({
|
|
|
103029
103756
|
|
|
103030
103757
|
// src/expo-native-compiler-digest.ts
|
|
103031
103758
|
function expoNativeCompilerDigestValue() {
|
|
103032
|
-
return true ? "
|
|
103759
|
+
return true ? "a8b60651de79588c6c5143dd2545ccd8e3b858acd992f46b35ba3de883118ac5" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
103033
103760
|
}
|
|
103034
103761
|
var import_node_crypto78;
|
|
103035
103762
|
var init_expo_native_compiler_digest = __esm({
|