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
package/dist-lib/skills.cjs
CHANGED
|
@@ -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;
|
|
@@ -35538,13 +35538,13 @@ var init_swift_standin_digest = __esm({
|
|
|
35538
35538
|
STANDIN_DIGEST_ENTRYPOINTS = ["swift-standins.ts", "swift-objc-compile.ts"];
|
|
35539
35539
|
SPECIFIER = /from\s*['"]([^'"]+)['"]|import\s*\(\s*['"]([^'"]+)['"]\s*\)/g;
|
|
35540
35540
|
standinSourceDigest = (srcDir = __sootsim_import_meta_dirname) => sourceClosureDigest(srcDir, STANDIN_DIGEST_ENTRYPOINTS);
|
|
35541
|
-
STANDIN_SOURCE_DIGEST = true ? "
|
|
35541
|
+
STANDIN_SOURCE_DIGEST = true ? "a3bcdfe9c9957355a59c2c26155470c89a2abb30907aeeaaf1de8463aa74fc8c" : standinSourceDigest();
|
|
35542
35542
|
}
|
|
35543
35543
|
});
|
|
35544
35544
|
|
|
35545
35545
|
// src/expo-native-compiler-digest.ts
|
|
35546
35546
|
function expoNativeCompilerDigestValue() {
|
|
35547
|
-
return true ? "
|
|
35547
|
+
return true ? "a8b60651de79588c6c5143dd2545ccd8e3b858acd992f46b35ba3de883118ac5" : expoNativeCompilerDigest(__sootsim_import_meta_dirname);
|
|
35548
35548
|
}
|
|
35549
35549
|
var import_node_crypto12;
|
|
35550
35550
|
var init_expo_native_compiler_digest = __esm({
|
|
@@ -57252,6 +57252,7 @@ function stageOverlaySlot(realRoot, stagingRoot, relPath) {
|
|
|
57252
57252
|
const segment2 = segments[i];
|
|
57253
57253
|
for (const entry of (0, import_node_fs53.readdirSync)(real)) {
|
|
57254
57254
|
if (entry === segment2 || i === 0 && entry === SWIFT_CACHE_HOLD_MARKER) continue;
|
|
57255
|
+
if (mirror === stagingRoot && entry === "configuration") continue;
|
|
57255
57256
|
const dest = import_node_path51.default.join(mirror, entry);
|
|
57256
57257
|
if (!import_node_fs53.default.lstatSync(dest, { throwIfNoEntry: false })) {
|
|
57257
57258
|
import_node_fs53.default.symlinkSync(import_node_path51.default.join(real, entry), dest);
|
|
@@ -57286,7 +57287,7 @@ function swiftSharedSdkViewOptions(moduleRoot, distribution, toolchainBin, sdk2)
|
|
|
57286
57287
|
const stdint = import_node_path51.default.join(overlay, "include/stdint.h");
|
|
57287
57288
|
const key2 = JSON.stringify([
|
|
57288
57289
|
// bump the recipe when the transformation changes; bundling changes function text.
|
|
57289
|
-
"
|
|
57290
|
+
"v39",
|
|
57290
57291
|
[...WEAKEN_FOUNDATION_SYMS],
|
|
57291
57292
|
toolchainBin,
|
|
57292
57293
|
sdk2,
|
|
@@ -58918,24 +58919,56 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
58918
58919
|
const code = sections.get(10);
|
|
58919
58920
|
if (code) {
|
|
58920
58921
|
let pos = code[0];
|
|
58921
|
-
|
|
58922
|
-
|
|
58922
|
+
const codeStart = code[0];
|
|
58923
|
+
const codeEnd = code[1];
|
|
58924
|
+
let count = 0;
|
|
58925
|
+
{
|
|
58926
|
+
let shift = 0;
|
|
58927
|
+
for (; ; ) {
|
|
58928
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
58929
|
+
const byte = bytes[pos++];
|
|
58930
|
+
count += (byte & 127) * 2 ** shift;
|
|
58931
|
+
if (!(byte & 128)) break;
|
|
58932
|
+
shift += 7;
|
|
58933
|
+
}
|
|
58934
|
+
}
|
|
58923
58935
|
for (let i = 0; i < count; i++) {
|
|
58924
58936
|
const prefix = pos;
|
|
58925
|
-
let size2;
|
|
58926
|
-
|
|
58927
|
-
|
|
58937
|
+
let size2 = 0;
|
|
58938
|
+
const b0 = bytes[pos++];
|
|
58939
|
+
if (b0 < 128) {
|
|
58940
|
+
size2 = b0;
|
|
58941
|
+
} else {
|
|
58942
|
+
size2 = b0 & 127;
|
|
58943
|
+
let shift = 7;
|
|
58944
|
+
for (; ; ) {
|
|
58945
|
+
if (pos >= codeEnd || shift > 28) throw new Error("invalid wasm integer");
|
|
58946
|
+
const byte = bytes[pos++];
|
|
58947
|
+
size2 += (byte & 127) * 2 ** shift;
|
|
58948
|
+
if (!(byte & 128)) break;
|
|
58949
|
+
shift += 7;
|
|
58950
|
+
}
|
|
58951
|
+
}
|
|
58952
|
+
functionsByCodeOffset.set(prefix - codeStart, imports2 + i);
|
|
58928
58953
|
if (imports2 + i === startFunction) startup = bytes.subarray(pos, pos + size2);
|
|
58929
58954
|
pos += size2;
|
|
58930
|
-
if (pos >
|
|
58955
|
+
if (pos > codeEnd) throw new Error("invalid wasm code");
|
|
58931
58956
|
}
|
|
58932
|
-
if (pos !==
|
|
58957
|
+
if (pos !== codeEnd) throw new Error("invalid wasm code section");
|
|
58933
58958
|
}
|
|
58934
58959
|
const functionsByTableSlot = /* @__PURE__ */ new Map();
|
|
58935
58960
|
const elements = sections.get(9);
|
|
58936
58961
|
if (elements) {
|
|
58937
58962
|
let pos = elements[0];
|
|
58963
|
+
const elemEnd = elements[1];
|
|
58938
58964
|
const read = () => {
|
|
58965
|
+
if (pos < elemEnd) {
|
|
58966
|
+
const b0 = bytes[pos];
|
|
58967
|
+
if (b0 < 128) {
|
|
58968
|
+
pos++;
|
|
58969
|
+
return b0;
|
|
58970
|
+
}
|
|
58971
|
+
}
|
|
58939
58972
|
const [value, next] = number(bytes, pos);
|
|
58940
58973
|
pos = next;
|
|
58941
58974
|
return value;
|
|
@@ -58965,7 +58998,7 @@ function layout(bytes, readData = true, requireExports = true) {
|
|
|
58965
58998
|
functionsByTableSlot.set(slot, read());
|
|
58966
58999
|
}
|
|
58967
59000
|
}
|
|
58968
|
-
if (pos !==
|
|
59001
|
+
if (pos !== elemEnd) throw new Error("invalid wasm element section");
|
|
58969
59002
|
}
|
|
58970
59003
|
const data = [];
|
|
58971
59004
|
const passive = /* @__PURE__ */ new Map();
|
|
@@ -59030,36 +59063,141 @@ function guestWasmDataSegments(bytes, requireExports = true) {
|
|
|
59030
59063
|
length: segment2.bytes.length
|
|
59031
59064
|
}));
|
|
59032
59065
|
}
|
|
59033
|
-
function
|
|
59066
|
+
function isMapSpace(code) {
|
|
59067
|
+
return code === 32 || code >= 9 && code <= 13;
|
|
59068
|
+
}
|
|
59069
|
+
function isMapHex(code) {
|
|
59070
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
59071
|
+
}
|
|
59072
|
+
function mapHexDigit(code) {
|
|
59073
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
59074
|
+
}
|
|
59075
|
+
function* stringLines(text7) {
|
|
59076
|
+
let start = 0;
|
|
59077
|
+
for (let end = text7.indexOf("\n"); end !== -1; end = text7.indexOf("\n", start)) {
|
|
59078
|
+
yield text7.slice(start, end);
|
|
59079
|
+
start = end + 1;
|
|
59080
|
+
}
|
|
59081
|
+
yield text7.slice(start);
|
|
59082
|
+
}
|
|
59083
|
+
function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PURE__ */ new Map(), importsLayout = false, extra) {
|
|
59034
59084
|
const unchanged = before === after;
|
|
59035
59085
|
const original = layout(before, !unchanged, !importsLayout);
|
|
59036
59086
|
const optimized = unchanged ? original : layout(after, true, !importsLayout);
|
|
59087
|
+
const collectSymbols = extra?.collectSymbols;
|
|
59088
|
+
const trackedObject = extra?.trackedObject;
|
|
59089
|
+
const trackedObjectOwner = extra?.trackedObjectOwner;
|
|
59090
|
+
const trackedLinearSpans = extra?.trackedLinearSpans;
|
|
59091
|
+
const hasSectionOwners = sectionOwners.size > 0;
|
|
59037
59092
|
let codeOffset;
|
|
59038
59093
|
let outputSection = "";
|
|
59039
59094
|
const codeOwners = /* @__PURE__ */ new Map();
|
|
59040
59095
|
const pieces = [];
|
|
59041
|
-
|
|
59042
|
-
|
|
59043
|
-
|
|
59044
|
-
|
|
59045
|
-
|
|
59046
|
-
|
|
59047
|
-
|
|
59096
|
+
const lines = typeof map2 === "string" ? stringLines(map2) : map2;
|
|
59097
|
+
for (const line of lines) {
|
|
59098
|
+
const lineLen = line.length;
|
|
59099
|
+
let pos = 0;
|
|
59100
|
+
let onlySpaces = true;
|
|
59101
|
+
while (pos < lineLen) {
|
|
59102
|
+
const ch = line.charCodeAt(pos);
|
|
59103
|
+
if (!isMapSpace(ch)) break;
|
|
59104
|
+
if (ch !== 32) onlySpaces = false;
|
|
59105
|
+
pos++;
|
|
59106
|
+
}
|
|
59107
|
+
const leadingSpaces = pos;
|
|
59108
|
+
if (pos >= lineLen) continue;
|
|
59109
|
+
const addrStart = pos;
|
|
59110
|
+
while (pos < lineLen && !isMapSpace(line.charCodeAt(pos))) pos++;
|
|
59111
|
+
const addrEnd = pos;
|
|
59112
|
+
if (pos >= lineLen) continue;
|
|
59113
|
+
const s1 = pos;
|
|
59114
|
+
while (pos < lineLen) {
|
|
59115
|
+
const ch = line.charCodeAt(pos);
|
|
59116
|
+
if (!isMapSpace(ch)) break;
|
|
59117
|
+
if (ch !== 32) onlySpaces = false;
|
|
59118
|
+
pos++;
|
|
59119
|
+
}
|
|
59120
|
+
if (pos === s1 || pos >= lineLen) continue;
|
|
59121
|
+
const offStart = pos;
|
|
59122
|
+
let offsetVal = 0;
|
|
59123
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
59124
|
+
offsetVal = offsetVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
59125
|
+
}
|
|
59126
|
+
if (pos === offStart || pos >= lineLen) continue;
|
|
59127
|
+
const s2 = pos;
|
|
59128
|
+
while (pos < lineLen) {
|
|
59129
|
+
const ch = line.charCodeAt(pos);
|
|
59130
|
+
if (!isMapSpace(ch)) break;
|
|
59131
|
+
if (ch !== 32) onlySpaces = false;
|
|
59132
|
+
pos++;
|
|
59133
|
+
}
|
|
59134
|
+
if (pos === s2 || pos >= lineLen) continue;
|
|
59135
|
+
const sizeStart = pos;
|
|
59136
|
+
let sizeVal = 0;
|
|
59137
|
+
while (pos < lineLen && isMapHex(line.charCodeAt(pos))) {
|
|
59138
|
+
sizeVal = sizeVal * 16 + mapHexDigit(line.charCodeAt(pos++));
|
|
59139
|
+
}
|
|
59140
|
+
if (pos === sizeStart || pos >= lineLen) continue;
|
|
59141
|
+
const indentStart = pos;
|
|
59142
|
+
while (pos < lineLen && line.charCodeAt(pos) === 32) pos++;
|
|
59143
|
+
const indentLen = pos - indentStart;
|
|
59144
|
+
if (indentLen === 0 || pos >= lineLen) continue;
|
|
59145
|
+
const firstCh = line.charCodeAt(pos);
|
|
59146
|
+
if (isMapSpace(firstCh)) continue;
|
|
59147
|
+
const sourceStart = pos;
|
|
59148
|
+
if (collectSymbols && onlySpaces && leadingSpaces > 0 && indentLen >= 9 && firstCh !== 47 && firstCh !== 60) {
|
|
59149
|
+
let symEnd = sourceStart + 1;
|
|
59150
|
+
while (symEnd < lineLen && !isMapSpace(line.charCodeAt(symEnd))) symEnd++;
|
|
59151
|
+
collectSymbols.add(line.slice(sourceStart, symEnd));
|
|
59152
|
+
}
|
|
59153
|
+
const isDash = addrEnd - addrStart === 1 && line.charCodeAt(addrStart) === 45;
|
|
59154
|
+
if (isDash && indentLen === 1) {
|
|
59155
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
59156
|
+
outputSection = line.slice(sourceStart);
|
|
59157
|
+
if (outputSection === "CODE") codeOffset = offsetVal;
|
|
59048
59158
|
continue;
|
|
59049
59159
|
}
|
|
59050
|
-
|
|
59160
|
+
if (sizeVal === 0) continue;
|
|
59161
|
+
const separator = line.indexOf(":(", sourceStart);
|
|
59051
59162
|
if (separator < 0) continue;
|
|
59052
|
-
|
|
59053
|
-
|
|
59054
|
-
|
|
59055
|
-
|
|
59056
|
-
if (
|
|
59057
|
-
|
|
59163
|
+
if (line.indexOf("\r", sourceStart) >= 0) continue;
|
|
59164
|
+
let hasLineSep = false;
|
|
59165
|
+
for (let i = sourceStart; i < lineLen; i++) {
|
|
59166
|
+
const ch = line.charCodeAt(i);
|
|
59167
|
+
if (ch === 8232 || ch === 8233) {
|
|
59168
|
+
hasLineSep = true;
|
|
59169
|
+
break;
|
|
59170
|
+
}
|
|
59171
|
+
}
|
|
59172
|
+
if (hasLineSep) continue;
|
|
59173
|
+
const objectPath = line.slice(sourceStart, separator);
|
|
59174
|
+
let image = hasSectionOwners ? sectionOwners.get(line.slice(sourceStart)) : void 0;
|
|
59175
|
+
if (image === void 0) image = owners.get(objectPath);
|
|
59176
|
+
if (!isDash) {
|
|
59177
|
+
if (outputSection === "DATA") {
|
|
59178
|
+
let addressVal = 0;
|
|
59179
|
+
let allHex = true;
|
|
59180
|
+
for (let i = addrStart; i < addrEnd; i++) {
|
|
59181
|
+
const ch = line.charCodeAt(i);
|
|
59182
|
+
if (isMapHex(ch)) addressVal = addressVal * 16 + mapHexDigit(ch);
|
|
59183
|
+
else {
|
|
59184
|
+
allHex = false;
|
|
59185
|
+
break;
|
|
59186
|
+
}
|
|
59187
|
+
}
|
|
59188
|
+
if (!allHex) addressVal = parseInt(line.slice(addrStart, addrEnd), 16);
|
|
59189
|
+
pieces.push({
|
|
59190
|
+
image,
|
|
59191
|
+
address: addressVal,
|
|
59192
|
+
length: sizeVal,
|
|
59193
|
+
tracked: trackedObject !== void 0 && objectPath === trackedObject
|
|
59194
|
+
});
|
|
59195
|
+
}
|
|
59058
59196
|
continue;
|
|
59059
59197
|
}
|
|
59060
59198
|
if (image === void 0 || outputSection !== "CODE") continue;
|
|
59061
59199
|
if (codeOffset === void 0) throw new Error("link map has no code section");
|
|
59062
|
-
const index = original.functionsByCodeOffset.get(
|
|
59200
|
+
const index = original.functionsByCodeOffset.get(offsetVal - codeOffset);
|
|
59063
59201
|
if (index === void 0) throw new Error("link map function has no wasm body");
|
|
59064
59202
|
const existing = codeOwners.get(index);
|
|
59065
59203
|
if (existing !== void 0 && existing !== image)
|
|
@@ -59068,12 +59206,23 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
59068
59206
|
}
|
|
59069
59207
|
pieces.sort((a, b) => a.address - b.address);
|
|
59070
59208
|
const spans = [];
|
|
59071
|
-
for (
|
|
59072
|
-
|
|
59209
|
+
for (let index = 0; index < pieces.length; index++) {
|
|
59210
|
+
const piece = pieces[index];
|
|
59211
|
+
const { image, address, length, tracked } = piece;
|
|
59212
|
+
if (image === void 0 && !tracked) continue;
|
|
59073
59213
|
let next = index + 1;
|
|
59074
59214
|
while (next < pieces.length && pieces[next].address < address + length) next++;
|
|
59075
59215
|
const end = pieces[next]?.address ?? address + length;
|
|
59076
|
-
|
|
59216
|
+
const spanLength = end - address;
|
|
59217
|
+
if (image !== void 0)
|
|
59218
|
+
spans.push({ image, space: "linear-memory", address, length: spanLength });
|
|
59219
|
+
if (tracked && trackedLinearSpans && trackedObjectOwner !== void 0)
|
|
59220
|
+
trackedLinearSpans.push({
|
|
59221
|
+
image: trackedObjectOwner,
|
|
59222
|
+
space: "linear-memory",
|
|
59223
|
+
address,
|
|
59224
|
+
length: spanLength
|
|
59225
|
+
});
|
|
59077
59226
|
}
|
|
59078
59227
|
const optimizedOwners = /* @__PURE__ */ new Map();
|
|
59079
59228
|
const dataAt = (module2, start, length) => {
|
|
@@ -59112,7 +59261,7 @@ function guestLinkedSpans(map2, before, after, owners, sectionOwners = /* @__PUR
|
|
|
59112
59261
|
throw new Error(`optimization changed linked data at ${span.address}`);
|
|
59113
59262
|
}
|
|
59114
59263
|
let previous;
|
|
59115
|
-
for (const span of
|
|
59264
|
+
for (const span of spans) {
|
|
59116
59265
|
if (previous && span.address < previous.address + previous.length && span.image !== previous.image)
|
|
59117
59266
|
throw new Error("linked data belongs to multiple images");
|
|
59118
59267
|
if (!previous || span.address + span.length > previous.address + previous.length)
|
|
@@ -59294,6 +59443,20 @@ var init_swift_guest_linked_spans = __esm({
|
|
|
59294
59443
|
});
|
|
59295
59444
|
|
|
59296
59445
|
// src/swift-sdk-image-map.ts
|
|
59446
|
+
function isHexChar(code) {
|
|
59447
|
+
return code >= 48 && code <= 57 || code >= 97 && code <= 102;
|
|
59448
|
+
}
|
|
59449
|
+
function hexDigit(code) {
|
|
59450
|
+
return code <= 57 ? code - 48 : code - 87;
|
|
59451
|
+
}
|
|
59452
|
+
function hasLineBreak(line, from) {
|
|
59453
|
+
if (line.indexOf("\r", from) >= 0) return true;
|
|
59454
|
+
for (let i = from; i < line.length; i++) {
|
|
59455
|
+
const ch = line.charCodeAt(i);
|
|
59456
|
+
if (ch === 8232 || ch === 8233) return true;
|
|
59457
|
+
}
|
|
59458
|
+
return false;
|
|
59459
|
+
}
|
|
59297
59460
|
function readWasmLinkMap(file, partition) {
|
|
59298
59461
|
const segments = /* @__PURE__ */ new Map();
|
|
59299
59462
|
const data = [];
|
|
@@ -59301,48 +59464,117 @@ function readWasmLinkMap(file, partition) {
|
|
|
59301
59464
|
let kind = "";
|
|
59302
59465
|
let segment2 = "";
|
|
59303
59466
|
let previous;
|
|
59304
|
-
const hex = (value) => value === "-" ? -1 : parseInt(value, 16);
|
|
59305
59467
|
for (const line of guestLinkLines(file)) {
|
|
59306
|
-
const
|
|
59307
|
-
|
|
59308
|
-
|
|
59309
|
-
|
|
59310
|
-
|
|
59311
|
-
|
|
59312
|
-
|
|
59313
|
-
|
|
59468
|
+
const length = line.length;
|
|
59469
|
+
let pos = 0;
|
|
59470
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
59471
|
+
if (pos >= length) continue;
|
|
59472
|
+
const leadingSpaces = pos;
|
|
59473
|
+
let address = -1;
|
|
59474
|
+
if (line.charCodeAt(pos) === 45) {
|
|
59475
|
+
pos++;
|
|
59476
|
+
} else {
|
|
59477
|
+
const start = pos;
|
|
59478
|
+
let value = 0;
|
|
59479
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
59480
|
+
value = value * 16 + hexDigit(line.charCodeAt(pos++));
|
|
59481
|
+
}
|
|
59482
|
+
if (pos === start) continue;
|
|
59483
|
+
address = value;
|
|
59314
59484
|
}
|
|
59315
|
-
const
|
|
59316
|
-
|
|
59317
|
-
|
|
59485
|
+
const s1 = pos;
|
|
59486
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
59487
|
+
if (pos === s1 || pos >= length) continue;
|
|
59488
|
+
const offStart = pos;
|
|
59489
|
+
let offset = 0;
|
|
59490
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
59491
|
+
offset = offset * 16 + hexDigit(line.charCodeAt(pos++));
|
|
59492
|
+
}
|
|
59493
|
+
if (pos === offStart) continue;
|
|
59494
|
+
const s2 = pos;
|
|
59495
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
59496
|
+
if (pos === s2 || pos >= length) continue;
|
|
59497
|
+
const sizeStart = pos;
|
|
59498
|
+
let size2 = 0;
|
|
59499
|
+
while (pos < length && isHexChar(line.charCodeAt(pos))) {
|
|
59500
|
+
size2 = size2 * 16 + hexDigit(line.charCodeAt(pos++));
|
|
59501
|
+
}
|
|
59502
|
+
if (pos === sizeStart || pos >= length) continue;
|
|
59503
|
+
const indentStart = pos;
|
|
59504
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
59505
|
+
const indent2 = pos - indentStart;
|
|
59506
|
+
if (indent2 === 0 || pos >= length) continue;
|
|
59507
|
+
if (indent2 === 17) {
|
|
59508
|
+
if (previous) {
|
|
59509
|
+
const first = line.charCodeAt(pos);
|
|
59510
|
+
if (first > 32 && !hasLineBreak(line, pos)) {
|
|
59511
|
+
previous.symbols.push({
|
|
59512
|
+
name: line.slice(pos),
|
|
59513
|
+
address,
|
|
59514
|
+
size: size2
|
|
59515
|
+
});
|
|
59516
|
+
}
|
|
59517
|
+
}
|
|
59318
59518
|
continue;
|
|
59319
59519
|
}
|
|
59320
|
-
if (
|
|
59321
|
-
|
|
59322
|
-
|
|
59323
|
-
|
|
59324
|
-
|
|
59325
|
-
|
|
59520
|
+
if (indent2 === 1) {
|
|
59521
|
+
let hasWhitespace = false;
|
|
59522
|
+
for (let i = pos; i < length; i++) {
|
|
59523
|
+
const ch = line.charCodeAt(i);
|
|
59524
|
+
if (ch <= 32) {
|
|
59525
|
+
hasWhitespace = true;
|
|
59526
|
+
break;
|
|
59527
|
+
}
|
|
59528
|
+
}
|
|
59529
|
+
if (hasWhitespace) continue;
|
|
59530
|
+
if (address < 0 && leadingSpaces > 0) {
|
|
59531
|
+
kind = line.slice(pos);
|
|
59532
|
+
} else if (kind === "DATA" && address >= 0) {
|
|
59533
|
+
segment2 = line.slice(pos);
|
|
59534
|
+
segments.set(segment2, { address, size: size2 });
|
|
59326
59535
|
}
|
|
59536
|
+
continue;
|
|
59537
|
+
}
|
|
59538
|
+
if (indent2 === 9 && (kind === "DATA" || kind === "CODE")) {
|
|
59539
|
+
const first = line.charCodeAt(pos);
|
|
59540
|
+
if (first !== 47 && first !== 60) continue;
|
|
59541
|
+
if (hasLineBreak(line, pos)) continue;
|
|
59542
|
+
const name3 = line.slice(pos);
|
|
59543
|
+
let filePath = name3;
|
|
59544
|
+
let section2 = "";
|
|
59545
|
+
if (name3.charCodeAt(name3.length - 1) === 41) {
|
|
59546
|
+
const splitAt = name3.indexOf(":(");
|
|
59547
|
+
if (splitAt >= 0) {
|
|
59548
|
+
filePath = name3.slice(0, splitAt);
|
|
59549
|
+
section2 = name3.slice(splitAt + 2, -1);
|
|
59550
|
+
}
|
|
59551
|
+
}
|
|
59552
|
+
let objectName;
|
|
59553
|
+
if (filePath.charCodeAt(filePath.length - 1) === 41) {
|
|
59554
|
+
const open = filePath.lastIndexOf("(");
|
|
59555
|
+
if (open >= 0 && open + 1 < filePath.length - 1) {
|
|
59556
|
+
const close = filePath.indexOf(")", open + 1);
|
|
59557
|
+
if (close === filePath.length - 1) {
|
|
59558
|
+
objectName = filePath.slice(open + 1, -1);
|
|
59559
|
+
}
|
|
59560
|
+
}
|
|
59561
|
+
}
|
|
59562
|
+
if (objectName === void 0) objectName = (0, import_node_path56.basename)(filePath);
|
|
59563
|
+
if (objectName.startsWith("lib") && objectName.includes("__")) {
|
|
59564
|
+
objectName = objectName.replace(/^lib\w*?__/, "");
|
|
59565
|
+
}
|
|
59566
|
+
previous = {
|
|
59567
|
+
inputFile: filePath,
|
|
59568
|
+
segment: segment2,
|
|
59569
|
+
address,
|
|
59570
|
+
offset,
|
|
59571
|
+
size: size2,
|
|
59572
|
+
object: objectName,
|
|
59573
|
+
section: section2,
|
|
59574
|
+
symbols: []
|
|
59575
|
+
};
|
|
59576
|
+
(kind === "DATA" ? data : code).push(previous);
|
|
59327
59577
|
}
|
|
59328
|
-
if (kind !== "DATA" && kind !== "CODE") continue;
|
|
59329
|
-
const input = /^ *([0-9a-f]+|-) +([0-9a-f]+) +([0-9a-f]+) {9}([/<].*)$/.exec(line);
|
|
59330
|
-
if (!input) continue;
|
|
59331
|
-
const name3 = input[4];
|
|
59332
|
-
const split = /^(.*?):\((.*)\)$/s.exec(name3);
|
|
59333
|
-
const path189 = split ? split[1] : name3;
|
|
59334
|
-
const member = /\(([^()]+)\)$/.exec(path189);
|
|
59335
|
-
previous = {
|
|
59336
|
-
inputFile: path189,
|
|
59337
|
-
segment: segment2,
|
|
59338
|
-
address: hex(input[1]),
|
|
59339
|
-
offset: parseInt(input[2], 16),
|
|
59340
|
-
size: parseInt(input[3], 16),
|
|
59341
|
-
object: (member ? member[1] : (0, import_node_path56.basename)(path189)).replace(/^lib\w*?__/, ""),
|
|
59342
|
-
section: split ? split[2] : "",
|
|
59343
|
-
symbols: []
|
|
59344
|
-
};
|
|
59345
|
-
(kind === "DATA" ? data : code).push(previous);
|
|
59346
59578
|
}
|
|
59347
59579
|
return { segments, data: partition ? data.flatMap(symbolPieces) : data, code };
|
|
59348
59580
|
}
|
|
@@ -60488,6 +60720,7 @@ function patchSwiftrtObject(src) {
|
|
|
60488
60720
|
return buf;
|
|
60489
60721
|
}
|
|
60490
60722
|
function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
60723
|
+
const rawBuf = Buffer.isBuffer(buf) ? buf : Buffer.from(buf.buffer, buf.byteOffset, buf.byteLength);
|
|
60491
60724
|
let pos = 8;
|
|
60492
60725
|
let numImportFuncs = 0;
|
|
60493
60726
|
let importsDlsym = false;
|
|
@@ -60523,10 +60756,10 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60523
60756
|
let [cnt, cp] = readULEB2(buf, p);
|
|
60524
60757
|
for (let i = 0; i < cnt; i++) {
|
|
60525
60758
|
const [mLen, m2] = readULEB2(buf, cp);
|
|
60526
|
-
const mName =
|
|
60759
|
+
const mName = rawBuf.toString("utf8", m2, m2 + mLen);
|
|
60527
60760
|
cp = m2 + mLen;
|
|
60528
60761
|
const [fLen, f2] = readULEB2(buf, cp);
|
|
60529
|
-
const fName =
|
|
60762
|
+
const fName = rawBuf.toString("utf8", f2, f2 + fLen);
|
|
60530
60763
|
cp = f2 + fLen;
|
|
60531
60764
|
const kind = buf[cp++];
|
|
60532
60765
|
if (kind === 0) {
|
|
@@ -60606,7 +60839,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60606
60839
|
}
|
|
60607
60840
|
} else if (id === 0) {
|
|
60608
60841
|
const [nLen, np] = readULEB2(buf, p);
|
|
60609
|
-
const name3 =
|
|
60842
|
+
const name3 = rawBuf.toString("utf8", np, np + nLen);
|
|
60610
60843
|
const cp = np + nLen;
|
|
60611
60844
|
if (name3 === "linking") {
|
|
60612
60845
|
let [, lp] = readULEB2(buf, cp);
|
|
@@ -60619,7 +60852,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60619
60852
|
let cur = p2;
|
|
60620
60853
|
for (let i = 0; i < cnt; i++) {
|
|
60621
60854
|
const [sLen, s2] = readULEB2(buf, cur);
|
|
60622
|
-
segNames.push(
|
|
60855
|
+
segNames.push(rawBuf.toString("utf8", s2, s2 + sLen));
|
|
60623
60856
|
cur = s2 + sLen;
|
|
60624
60857
|
const [, s3] = readULEB2(buf, cur);
|
|
60625
60858
|
const [fl, s4] = readULEB2(buf, s3);
|
|
@@ -60659,7 +60892,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60659
60892
|
let sName = "";
|
|
60660
60893
|
if (!isUndef || isExplicitName) {
|
|
60661
60894
|
const [sLen, c4] = readULEB2(buf, cur);
|
|
60662
|
-
sName =
|
|
60895
|
+
sName = rawBuf.toString("utf8", c4, c4 + sLen);
|
|
60663
60896
|
cur = c4 + sLen;
|
|
60664
60897
|
} else if (kind === 0) {
|
|
60665
60898
|
sName = importFuncNames[el] ?? "";
|
|
@@ -60675,7 +60908,7 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60675
60908
|
symNames.push(sName);
|
|
60676
60909
|
} else if (kind === 1) {
|
|
60677
60910
|
const [sLen, c3] = readULEB2(buf, cur);
|
|
60678
|
-
const sName =
|
|
60911
|
+
const sName = rawBuf.toString("utf8", c3, c3 + sLen);
|
|
60679
60912
|
cur = c3 + sLen;
|
|
60680
60913
|
if (!isUndef) {
|
|
60681
60914
|
const [segIdx, c4] = readULEB2(buf, cur);
|
|
@@ -60790,9 +61023,21 @@ function parseWasmObjectBytes(file, buf, isDist, symbolFlagOffsets) {
|
|
|
60790
61023
|
const offInSeg = ro - (sPayloadStarts[lo] ?? 0);
|
|
60791
61024
|
let ownerSymIdx = -1;
|
|
60792
61025
|
const topList = segTopSyms.get(lo);
|
|
60793
|
-
if (topList) {
|
|
60794
|
-
|
|
60795
|
-
|
|
61026
|
+
if (topList && topList.length > 0) {
|
|
61027
|
+
let tLo = 0;
|
|
61028
|
+
let tHi = topList.length - 1;
|
|
61029
|
+
while (tLo <= tHi) {
|
|
61030
|
+
const tMid = tLo + tHi >> 1;
|
|
61031
|
+
const top = topList[tMid];
|
|
61032
|
+
if (offInSeg < top.off) {
|
|
61033
|
+
tHi = tMid - 1;
|
|
61034
|
+
} else if (offInSeg >= top.end) {
|
|
61035
|
+
tLo = tMid + 1;
|
|
61036
|
+
} else {
|
|
61037
|
+
ownerSymIdx = top.symIdx;
|
|
61038
|
+
break;
|
|
61039
|
+
}
|
|
61040
|
+
}
|
|
60796
61041
|
}
|
|
60797
61042
|
if (ownerSymIdx !== -1) {
|
|
60798
61043
|
let list2 = symDataRelocs.get(ownerSymIdx);
|
|
@@ -61047,54 +61292,151 @@ function localizeDefinedWasmSymbols(bytes, names) {
|
|
|
61047
61292
|
return output;
|
|
61048
61293
|
}
|
|
61049
61294
|
function guestWasmSymbols(bytes) {
|
|
61050
|
-
const
|
|
61295
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
61296
|
+
let cur = 8;
|
|
61297
|
+
const readU = () => {
|
|
61298
|
+
const b0 = bytes[cur++];
|
|
61299
|
+
if (b0 < 128) return b0;
|
|
61300
|
+
let res = b0 & 127;
|
|
61301
|
+
let shift = 7;
|
|
61302
|
+
while (true) {
|
|
61303
|
+
const byte = bytes[cur++];
|
|
61304
|
+
res |= (byte & 127) << shift;
|
|
61305
|
+
if ((byte & 128) === 0) return res;
|
|
61306
|
+
shift += 7;
|
|
61307
|
+
}
|
|
61308
|
+
};
|
|
61309
|
+
let importsDlsym = false;
|
|
61310
|
+
const importFuncNames = [];
|
|
61311
|
+
const importFuncModules = [];
|
|
61312
|
+
const importGlobalNames = [];
|
|
61313
|
+
const importTableNames = [];
|
|
61314
|
+
const importEventNames = [];
|
|
61315
|
+
const undefinedSyms = /* @__PURE__ */ new Set();
|
|
61316
|
+
const tags = /* @__PURE__ */ new Set();
|
|
61317
|
+
const globals = /* @__PURE__ */ new Set();
|
|
61318
|
+
const hostImports = /* @__PURE__ */ new Set();
|
|
61319
|
+
const weakUndefined = /* @__PURE__ */ new Set();
|
|
61320
|
+
const defined = /* @__PURE__ */ new Set();
|
|
61321
|
+
const weakDefined = /* @__PURE__ */ new Set();
|
|
61322
|
+
while (cur < bytes.length) {
|
|
61323
|
+
const id = bytes[cur++];
|
|
61324
|
+
const sz = readU();
|
|
61325
|
+
const end = cur + sz;
|
|
61326
|
+
if (id === 2) {
|
|
61327
|
+
const cnt = readU();
|
|
61328
|
+
for (let i = 0; i < cnt; i++) {
|
|
61329
|
+
const mLen = readU();
|
|
61330
|
+
const mName = rawBuf.toString("utf8", cur, cur + mLen);
|
|
61331
|
+
cur += mLen;
|
|
61332
|
+
const fLen = readU();
|
|
61333
|
+
const fName = rawBuf.toString("utf8", cur, cur + fLen);
|
|
61334
|
+
cur += fLen;
|
|
61335
|
+
const kind = bytes[cur++];
|
|
61336
|
+
if (kind === 0) {
|
|
61337
|
+
readU();
|
|
61338
|
+
importFuncNames.push(fName);
|
|
61339
|
+
importFuncModules.push(mName);
|
|
61340
|
+
if (mName === "env" && fName === "dlsym") importsDlsym = true;
|
|
61341
|
+
} else if (kind === 1) {
|
|
61342
|
+
cur++;
|
|
61343
|
+
const fl = readU();
|
|
61344
|
+
readU();
|
|
61345
|
+
if (fl & 1) readU();
|
|
61346
|
+
importTableNames.push(fName);
|
|
61347
|
+
} else if (kind === 2) {
|
|
61348
|
+
const fl = readU();
|
|
61349
|
+
readU();
|
|
61350
|
+
if (fl & 1) readU();
|
|
61351
|
+
} else if (kind === 3) {
|
|
61352
|
+
cur += 2;
|
|
61353
|
+
importGlobalNames.push(fName);
|
|
61354
|
+
} else if (kind === 4) {
|
|
61355
|
+
cur++;
|
|
61356
|
+
readU();
|
|
61357
|
+
importEventNames.push(fName);
|
|
61358
|
+
}
|
|
61359
|
+
}
|
|
61360
|
+
} else if (id === 0) {
|
|
61361
|
+
const nLen = readU();
|
|
61362
|
+
if (nLen === 7 && bytes[cur] === 108 && rawBuf.toString("utf8", cur, cur + nLen) === "linking") {
|
|
61363
|
+
cur += nLen;
|
|
61364
|
+
readU();
|
|
61365
|
+
while (cur < end) {
|
|
61366
|
+
const subId = bytes[cur++];
|
|
61367
|
+
const subLen = readU();
|
|
61368
|
+
const subEnd = cur + subLen;
|
|
61369
|
+
if (subId === 8) {
|
|
61370
|
+
const cnt = readU();
|
|
61371
|
+
for (let i = 0; i < cnt; i++) {
|
|
61372
|
+
const kind = bytes[cur++];
|
|
61373
|
+
const fl = readU();
|
|
61374
|
+
const isUndef = (fl & 16) !== 0;
|
|
61375
|
+
const isExplicitName = (fl & 64) !== 0;
|
|
61376
|
+
let sName = "";
|
|
61377
|
+
if (kind === 0 || kind === 2 || kind === 4 || kind === 5) {
|
|
61378
|
+
const el = readU();
|
|
61379
|
+
if (!isUndef || isExplicitName) {
|
|
61380
|
+
const sLen = readU();
|
|
61381
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
61382
|
+
cur += sLen;
|
|
61383
|
+
} else if (kind === 0) {
|
|
61384
|
+
sName = importFuncNames[el] ?? "";
|
|
61385
|
+
} else if (kind === 2) {
|
|
61386
|
+
sName = importGlobalNames[el] ?? "";
|
|
61387
|
+
} else if (kind === 4) {
|
|
61388
|
+
sName = importEventNames[el] ?? "";
|
|
61389
|
+
} else if (kind === 5) {
|
|
61390
|
+
sName = importTableNames[el] ?? "";
|
|
61391
|
+
}
|
|
61392
|
+
if (isUndef && kind === 0 && importFuncModules[el] !== "env")
|
|
61393
|
+
hostImports.add(sName);
|
|
61394
|
+
} else if (kind === 1) {
|
|
61395
|
+
const sLen = readU();
|
|
61396
|
+
sName = rawBuf.toString("utf8", cur, cur + sLen);
|
|
61397
|
+
cur += sLen;
|
|
61398
|
+
if (!isUndef) {
|
|
61399
|
+
readU();
|
|
61400
|
+
readU();
|
|
61401
|
+
readU();
|
|
61402
|
+
}
|
|
61403
|
+
} else if (kind === 3) {
|
|
61404
|
+
readU();
|
|
61405
|
+
}
|
|
61406
|
+
if (sName) {
|
|
61407
|
+
if (isUndef) {
|
|
61408
|
+
undefinedSyms.add(sName);
|
|
61409
|
+
if ((fl & 19) === 17) weakUndefined.add(sName);
|
|
61410
|
+
} else if ((fl & 3) !== 2) {
|
|
61411
|
+
defined.add(sName);
|
|
61412
|
+
if ((fl & 19) === 1) weakDefined.add(sName);
|
|
61413
|
+
}
|
|
61414
|
+
if (kind === 4) tags.add(sName);
|
|
61415
|
+
else if (kind === 2 || kind === 5) globals.add(sName);
|
|
61416
|
+
}
|
|
61417
|
+
}
|
|
61418
|
+
break;
|
|
61419
|
+
}
|
|
61420
|
+
cur = subEnd;
|
|
61421
|
+
}
|
|
61422
|
+
break;
|
|
61423
|
+
}
|
|
61424
|
+
}
|
|
61425
|
+
cur = end;
|
|
61426
|
+
}
|
|
61051
61427
|
return {
|
|
61052
|
-
importsDlsym
|
|
61053
|
-
undefined: [
|
|
61054
|
-
...new Set(
|
|
61055
|
-
object8.symNames.filter(
|
|
61056
|
-
(name3, index) => name3 && (object8.symFlags[index] & 16) !== 0
|
|
61057
|
-
)
|
|
61058
|
-
)
|
|
61059
|
-
],
|
|
61428
|
+
importsDlsym,
|
|
61429
|
+
undefined: [...undefinedSyms],
|
|
61060
61430
|
// a wasm tag is one module entity unified by name across the link, as the
|
|
61061
61431
|
// main module owns it for dynamic images, so no image scope applies.
|
|
61062
|
-
tags: [
|
|
61063
|
-
|
|
61064
|
-
object8.symNames.filter((name3, index) => name3 && object8.symKind[index] === 4)
|
|
61065
|
-
)
|
|
61066
|
-
],
|
|
61067
|
-
globals: [
|
|
61068
|
-
...new Set(
|
|
61069
|
-
object8.symNames.filter(
|
|
61070
|
-
(name3, index) => name3 && (object8.symKind[index] === 2 || object8.symKind[index] === 5)
|
|
61071
|
-
)
|
|
61072
|
-
)
|
|
61073
|
-
],
|
|
61432
|
+
tags: [...tags],
|
|
61433
|
+
globals: [...globals],
|
|
61074
61434
|
// an undefined function imported from a module other than env is supplied
|
|
61075
61435
|
// by the host, whatever linker symbol names it.
|
|
61076
|
-
hostImports: [...
|
|
61077
|
-
weakUndefined: [
|
|
61078
|
-
|
|
61079
|
-
|
|
61080
|
-
(name3, index) => name3 && (object8.symFlags[index] & 19) === 17
|
|
61081
|
-
)
|
|
61082
|
-
)
|
|
61083
|
-
],
|
|
61084
|
-
defined: [
|
|
61085
|
-
...new Set(
|
|
61086
|
-
object8.symNames.filter(
|
|
61087
|
-
(name3, index) => name3 && (object8.symFlags[index] & 16) === 0 && (object8.symFlags[index] & 3) !== 2
|
|
61088
|
-
)
|
|
61089
|
-
)
|
|
61090
|
-
],
|
|
61091
|
-
weakDefined: [
|
|
61092
|
-
...new Set(
|
|
61093
|
-
object8.symNames.filter(
|
|
61094
|
-
(name3, index) => name3 && (object8.symFlags[index] & 19) === 1
|
|
61095
|
-
)
|
|
61096
|
-
)
|
|
61097
|
-
]
|
|
61436
|
+
hostImports: [...hostImports],
|
|
61437
|
+
weakUndefined: [...weakUndefined],
|
|
61438
|
+
defined: [...defined],
|
|
61439
|
+
weakDefined: [...weakDefined]
|
|
61098
61440
|
};
|
|
61099
61441
|
}
|
|
61100
61442
|
function sdkObjectName(archive, member, ordinal) {
|
|
@@ -61611,9 +61953,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61611
61953
|
for (const entry of waiting) tryActivateConformance(entry);
|
|
61612
61954
|
}
|
|
61613
61955
|
};
|
|
61956
|
+
const checkedProtocolTriggers = /* @__PURE__ */ new Set();
|
|
61614
61957
|
const checkProtocolTrigger = (rawSymName) => {
|
|
61615
61958
|
if (!rawSymName) return;
|
|
61616
61959
|
const sName = rawSymName.startsWith(".Lgot.") ? rawSymName.slice(6) : rawSymName;
|
|
61960
|
+
if (checkedProtocolTriggers.has(sName)) return;
|
|
61961
|
+
checkedProtocolTriggers.add(sName);
|
|
61617
61962
|
if (knownProtocols.has(sName)) {
|
|
61618
61963
|
markProtocolLive(sName);
|
|
61619
61964
|
return;
|
|
@@ -61646,6 +61991,43 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61646
61991
|
}
|
|
61647
61992
|
}
|
|
61648
61993
|
};
|
|
61994
|
+
const typeIndexes = /* @__PURE__ */ new Map();
|
|
61995
|
+
const getTypeIndex = (obj) => {
|
|
61996
|
+
let idx = typeIndexes.get(obj);
|
|
61997
|
+
if (idx) return idx;
|
|
61998
|
+
const mnByPrefix = /* @__PURE__ */ new Map();
|
|
61999
|
+
for (let i = 0; i < obj.symNames.length; i++) {
|
|
62000
|
+
const name3 = obj.symNames[i];
|
|
62001
|
+
if ((obj.symFlags[i] & 16) === 0 && name3.startsWith("$s") && name3.endsWith("Mn")) {
|
|
62002
|
+
const pref = name3.slice(0, -2);
|
|
62003
|
+
let list2 = mnByPrefix.get(pref);
|
|
62004
|
+
if (!list2) mnByPrefix.set(pref, list2 = []);
|
|
62005
|
+
list2.push(i);
|
|
62006
|
+
}
|
|
62007
|
+
}
|
|
62008
|
+
const objcRegByPrefix = /* @__PURE__ */ new Map();
|
|
62009
|
+
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
62010
|
+
let list2 = objcRegByPrefix.get(p);
|
|
62011
|
+
if (!list2) objcRegByPrefix.set(p, list2 = []);
|
|
62012
|
+
list2.push(lf);
|
|
62013
|
+
}
|
|
62014
|
+
const objcClassByPrefix = /* @__PURE__ */ new Map();
|
|
62015
|
+
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
62016
|
+
if (!classSym.startsWith("._OBJC_CLASS_")) continue;
|
|
62017
|
+
let list2 = objcClassByPrefix.get(p);
|
|
62018
|
+
if (!list2) objcClassByPrefix.set(p, list2 = []);
|
|
62019
|
+
list2.push(classSym.slice("._OBJC_CLASS_".length));
|
|
62020
|
+
}
|
|
62021
|
+
let minPrefLen = Infinity;
|
|
62022
|
+
let maxPrefLen = 0;
|
|
62023
|
+
for (const p of obj.typePrefixesInObj) {
|
|
62024
|
+
if (p.length < minPrefLen) minPrefLen = p.length;
|
|
62025
|
+
if (p.length > maxPrefLen) maxPrefLen = p.length;
|
|
62026
|
+
}
|
|
62027
|
+
idx = { mnByPrefix, objcRegByPrefix, objcClassByPrefix, minPrefLen, maxPrefLen };
|
|
62028
|
+
typeIndexes.set(obj, idx);
|
|
62029
|
+
return idx;
|
|
62030
|
+
};
|
|
61649
62031
|
const markTypeLive = (obj, pref) => {
|
|
61650
62032
|
const set2 = liveTypes.get(obj);
|
|
61651
62033
|
if (set2.has(pref)) return;
|
|
@@ -61659,22 +62041,10 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61659
62041
|
const outer = pref.slice(0, n);
|
|
61660
62042
|
if (obj.typePrefixesInObj.has(outer)) markTypeLive(obj, outer);
|
|
61661
62043
|
}
|
|
61662
|
-
const
|
|
61663
|
-
for (
|
|
61664
|
-
|
|
61665
|
-
|
|
61666
|
-
}
|
|
61667
|
-
}
|
|
61668
|
-
for (const [lf, p] of obj.objcRegisterFuncToTypePrefix) {
|
|
61669
|
-
if (p === pref) {
|
|
61670
|
-
markFuncLive(obj, lf);
|
|
61671
|
-
}
|
|
61672
|
-
}
|
|
61673
|
-
for (const [classSym, p] of obj.objcClassSymToTypePrefix) {
|
|
61674
|
-
if (p === pref && classSym.startsWith("._OBJC_CLASS_")) {
|
|
61675
|
-
markObjCClassLive(classSym.slice("._OBJC_CLASS_".length));
|
|
61676
|
-
}
|
|
61677
|
-
}
|
|
62044
|
+
const idx = getTypeIndex(obj);
|
|
62045
|
+
for (const i of idx.mnByPrefix.get(pref) ?? []) activateSymbolInObj(obj, i);
|
|
62046
|
+
for (const lf of idx.objcRegByPrefix.get(pref) ?? []) markFuncLive(obj, lf);
|
|
62047
|
+
for (const cls of idx.objcClassByPrefix.get(pref) ?? []) markObjCClassLive(cls);
|
|
61678
62048
|
};
|
|
61679
62049
|
const checkTypeTrigger = (obj, rawSymName) => {
|
|
61680
62050
|
if (!rawSymName) return;
|
|
@@ -61699,11 +62069,12 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61699
62069
|
}
|
|
61700
62070
|
}
|
|
61701
62071
|
}
|
|
61702
|
-
if (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o")) {
|
|
61703
|
-
|
|
61704
|
-
|
|
61705
|
-
|
|
61706
|
-
|
|
62072
|
+
if (obj.typePrefixesInObj.size > 0 && (obj.file.endsWith("libswiftCore__Swift.o") || obj.file.endsWith("libswift_Concurrency___Concurrency.o"))) {
|
|
62073
|
+
const { minPrefLen, maxPrefLen } = getTypeIndex(obj);
|
|
62074
|
+
const hi = Math.min(sName.length, maxPrefLen);
|
|
62075
|
+
for (let n = minPrefLen; n <= hi; n++) {
|
|
62076
|
+
const cand = sName.slice(0, n);
|
|
62077
|
+
if (obj.typePrefixesInObj.has(cand)) markTypeLive(obj, cand);
|
|
61707
62078
|
}
|
|
61708
62079
|
}
|
|
61709
62080
|
};
|
|
@@ -61796,7 +62167,8 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61796
62167
|
for (const fIdx of obj.rootFuncs) markFuncLive(obj, fIdx);
|
|
61797
62168
|
for (const sIdx of obj.rootSegs) markSegLive(obj, sIdx);
|
|
61798
62169
|
for (const name3 of obj.symNames) {
|
|
61799
|
-
|
|
62170
|
+
if (!name3 || !name3.startsWith("_c_") || !name3.endsWith("__load")) continue;
|
|
62171
|
+
const loaded4 = name3.match(/^_c_(\w+)__load$/)?.[1];
|
|
61800
62172
|
if (!loaded4) continue;
|
|
61801
62173
|
const classSym = obj.symNames.indexOf(`._OBJC_CLASS_${loaded4}`);
|
|
61802
62174
|
if (classSym !== -1 && (obj.symFlags[classSym] & 16) === 0)
|
|
@@ -61944,14 +62316,30 @@ function pruneSwiftWasmLink(directory2, toolchainBin, moduleRoot, staticClangTar
|
|
|
61944
62316
|
const keepObjCClassesNamedInSegment = (obj, segIdx) => {
|
|
61945
62317
|
const range3 = obj.segPayloadRanges[segIdx];
|
|
61946
62318
|
if (!range3) return;
|
|
62319
|
+
const [rangeStart, rangeEnd] = range3;
|
|
62320
|
+
if (rangeEnd - rangeStart < 4) return;
|
|
61947
62321
|
let bytes = objectBytes.get(obj);
|
|
61948
62322
|
if (!bytes) objectBytes.set(obj, bytes = import_node_fs58.default.readFileSync(obj.file));
|
|
61949
|
-
|
|
61950
|
-
|
|
61951
|
-
const
|
|
61952
|
-
|
|
61953
|
-
|
|
61954
|
-
|
|
62323
|
+
let pos = rangeStart;
|
|
62324
|
+
while (pos < rangeEnd - 3) {
|
|
62325
|
+
const at = bytes.indexOf("So", pos);
|
|
62326
|
+
if (at < 0 || at >= rangeEnd - 2) break;
|
|
62327
|
+
let digitEnd = at + 2;
|
|
62328
|
+
let length = 0;
|
|
62329
|
+
while (digitEnd < rangeEnd) {
|
|
62330
|
+
const ch = bytes[digitEnd];
|
|
62331
|
+
if (ch < 48 || ch > 57) break;
|
|
62332
|
+
length = length * 10 + (ch - 48);
|
|
62333
|
+
digitEnd++;
|
|
62334
|
+
}
|
|
62335
|
+
if (digitEnd === at + 2) {
|
|
62336
|
+
pos = at + 2;
|
|
62337
|
+
continue;
|
|
62338
|
+
}
|
|
62339
|
+
pos = digitEnd;
|
|
62340
|
+
const nameEnd = digitEnd + length;
|
|
62341
|
+
if (nameEnd >= rangeEnd || bytes[nameEnd] !== 67) continue;
|
|
62342
|
+
const symbol2 = `._OBJC_CLASS_${bytes.toString("latin1", digitEnd, nameEnd)}`;
|
|
61955
62343
|
for (const provider of lazyProviders.get(symbol2) ?? []) {
|
|
61956
62344
|
eagerDynamicObjects.add(provider);
|
|
61957
62345
|
extractObject(provider);
|
|
@@ -63045,6 +63433,10 @@ var init_nativeDyldTableContract = __esm({
|
|
|
63045
63433
|
|
|
63046
63434
|
// src/swift-guest-image-ledger.ts
|
|
63047
63435
|
function readNumber(bytes, position) {
|
|
63436
|
+
if (position < bytes.length) {
|
|
63437
|
+
const first = bytes[position];
|
|
63438
|
+
if (first < 128) return [first, position + 1];
|
|
63439
|
+
}
|
|
63048
63440
|
let value = 0;
|
|
63049
63441
|
let shift = 0;
|
|
63050
63442
|
for (; ; ) {
|
|
@@ -63056,6 +63448,7 @@ function readNumber(bytes, position) {
|
|
|
63056
63448
|
}
|
|
63057
63449
|
}
|
|
63058
63450
|
function encodeNumber(value) {
|
|
63451
|
+
if (value < 128) return Buffer.from([value]);
|
|
63059
63452
|
const bytes = [];
|
|
63060
63453
|
do {
|
|
63061
63454
|
let byte = value % 128;
|
|
@@ -63077,6 +63470,9 @@ function encodedString(value) {
|
|
|
63077
63470
|
const bytes = Buffer.from(value);
|
|
63078
63471
|
return Buffer.concat([encodeNumber(bytes.length), bytes]);
|
|
63079
63472
|
}
|
|
63473
|
+
function isWasmMagic(bytes) {
|
|
63474
|
+
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;
|
|
63475
|
+
}
|
|
63080
63476
|
function llvmType(value) {
|
|
63081
63477
|
switch (value) {
|
|
63082
63478
|
case 127:
|
|
@@ -63092,11 +63488,12 @@ function llvmType(value) {
|
|
|
63092
63488
|
}
|
|
63093
63489
|
}
|
|
63094
63490
|
function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLookups, preserveCanonical, options2 = {}) {
|
|
63095
|
-
if (
|
|
63096
|
-
|
|
63491
|
+
if (!isWasmMagic(bytes)) throw new Error("expected wasm object");
|
|
63492
|
+
const rawBuf = Buffer.isBuffer(bytes) ? bytes : Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
63097
63493
|
const { sdkLookupOnly, sdkProduct } = options2;
|
|
63098
63494
|
const comdatScope = sdkProduct === void 0 ? callerAlias : `${callerAlias}:${sdkProduct}`;
|
|
63099
|
-
const
|
|
63495
|
+
const rewrite = binding !== void 0;
|
|
63496
|
+
const sections = rewrite ? [bytes.subarray(0, 8)] : void 0;
|
|
63100
63497
|
const types2 = [];
|
|
63101
63498
|
const functionTypes = [];
|
|
63102
63499
|
const definitions = [];
|
|
@@ -63110,45 +63507,74 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63110
63507
|
const usedSymbols = /* @__PURE__ */ new Set();
|
|
63111
63508
|
let position = 8;
|
|
63112
63509
|
while (position < bytes.length) {
|
|
63510
|
+
const headerStart2 = position;
|
|
63113
63511
|
const id = bytes[position++];
|
|
63114
|
-
|
|
63512
|
+
let size2 = 0;
|
|
63513
|
+
if (position < bytes.length && bytes[position] < 128) {
|
|
63514
|
+
size2 = bytes[position++];
|
|
63515
|
+
} else {
|
|
63516
|
+
const [val, next] = readNumber(bytes, position);
|
|
63517
|
+
size2 = val;
|
|
63518
|
+
position = next;
|
|
63519
|
+
}
|
|
63520
|
+
const start = position;
|
|
63115
63521
|
const end = start + size2;
|
|
63116
63522
|
if (end > bytes.length) throw new Error("invalid wasm section");
|
|
63117
63523
|
position = end;
|
|
63118
|
-
if (
|
|
63119
|
-
|
|
63120
|
-
|
|
63524
|
+
if (id > 3) {
|
|
63525
|
+
if (sections) sections.push(bytes.subarray(headerStart2, end));
|
|
63526
|
+
continue;
|
|
63527
|
+
}
|
|
63528
|
+
let offset = start;
|
|
63121
63529
|
const number4 = () => {
|
|
63122
|
-
|
|
63123
|
-
|
|
63124
|
-
|
|
63530
|
+
if (offset < end) {
|
|
63531
|
+
const first = bytes[offset];
|
|
63532
|
+
if (first < 128) {
|
|
63533
|
+
offset++;
|
|
63534
|
+
return first;
|
|
63535
|
+
}
|
|
63536
|
+
}
|
|
63537
|
+
let value = 0;
|
|
63538
|
+
let shift = 0;
|
|
63539
|
+
for (; ; ) {
|
|
63540
|
+
if (offset >= end || shift > 63) throw new Error("invalid wasm integer");
|
|
63541
|
+
const byte = bytes[offset++];
|
|
63542
|
+
value += (byte & 127) * 2 ** shift;
|
|
63543
|
+
if (!(byte & 128)) return value;
|
|
63544
|
+
shift += 7;
|
|
63545
|
+
}
|
|
63125
63546
|
};
|
|
63126
63547
|
const string8 = () => {
|
|
63127
|
-
const
|
|
63128
|
-
|
|
63548
|
+
const length = number4();
|
|
63549
|
+
const strEnd = offset + length;
|
|
63550
|
+
if (strEnd > end) throw new Error("invalid wasm string");
|
|
63551
|
+
const value = rawBuf.toString("utf8", offset, strEnd);
|
|
63552
|
+
offset = strEnd;
|
|
63129
63553
|
return value;
|
|
63130
63554
|
};
|
|
63555
|
+
let rewrittenSection;
|
|
63131
63556
|
if (id === 1) {
|
|
63132
63557
|
const count = number4();
|
|
63133
63558
|
for (let i = 0; i < count; i++) {
|
|
63134
|
-
if (
|
|
63559
|
+
if (bytes[offset++] !== 96) throw new Error("unsupported wasm type");
|
|
63135
63560
|
const parameterCount = number4();
|
|
63136
|
-
|
|
63137
|
-
|
|
63138
|
-
|
|
63561
|
+
if (offset + parameterCount > end) throw new Error("invalid wasm type");
|
|
63562
|
+
const parameters = new Array(parameterCount);
|
|
63563
|
+
for (let p = 0; p < parameterCount; p++) parameters[p] = bytes[offset++];
|
|
63139
63564
|
const resultCount = number4();
|
|
63140
|
-
|
|
63141
|
-
|
|
63142
|
-
|
|
63565
|
+
if (offset + resultCount > end) throw new Error("invalid wasm type");
|
|
63566
|
+
const results = new Array(resultCount);
|
|
63567
|
+
for (let r = 0; r < resultCount; r++) results[r] = bytes[offset++];
|
|
63143
63568
|
types2.push({ parameters, results });
|
|
63144
63569
|
}
|
|
63145
63570
|
} else if (id === 2) {
|
|
63146
63571
|
const count = number4();
|
|
63147
|
-
const
|
|
63572
|
+
const importWriter = rewrite ? new ByteWriter(size2 + 64) : void 0;
|
|
63573
|
+
importWriter?.uleb(count);
|
|
63148
63574
|
for (let i = 0; i < count; i++) {
|
|
63149
63575
|
const module2 = string8();
|
|
63150
63576
|
const name3 = string8();
|
|
63151
|
-
const kind =
|
|
63577
|
+
const kind = bytes[offset++];
|
|
63152
63578
|
const typeStart = offset;
|
|
63153
63579
|
let functionType2 = -1;
|
|
63154
63580
|
if (kind === 0) {
|
|
@@ -63156,7 +63582,7 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63156
63582
|
functionTypes.push(functionType2);
|
|
63157
63583
|
functionImportNames.push(name3);
|
|
63158
63584
|
} else if (kind === 1) {
|
|
63159
|
-
const referenceType =
|
|
63585
|
+
const referenceType = bytes[offset++];
|
|
63160
63586
|
if (referenceType !== 112 && referenceType !== 111)
|
|
63161
63587
|
throw new Error("unsupported table type");
|
|
63162
63588
|
const flags = number4();
|
|
@@ -63175,11 +63601,15 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63175
63601
|
} else throw new Error("unsupported wasm import");
|
|
63176
63602
|
const isDlsym = instrumentDynamicLookups && module2 === "env" && name3 === "dlsym" && kind === 0;
|
|
63177
63603
|
const isDlerror = instrumentDynamicLookups && module2 === "env" && name3 === "dlerror" && kind === 0;
|
|
63178
|
-
if (
|
|
63179
|
-
|
|
63180
|
-
|
|
63181
|
-
|
|
63182
|
-
|
|
63604
|
+
if (!rewrite) {
|
|
63605
|
+
if (module2 === "env" && names.has(name3)) {
|
|
63606
|
+
usedSymbols.add(name3);
|
|
63607
|
+
if (kind === 0) {
|
|
63608
|
+
const type = types2[functionType2];
|
|
63609
|
+
if (!type) throw new Error(`missing import type for ${name3}`);
|
|
63610
|
+
functionImports.set(name3, type);
|
|
63611
|
+
}
|
|
63612
|
+
}
|
|
63183
63613
|
}
|
|
63184
63614
|
if (isDlsym || isDlerror) {
|
|
63185
63615
|
const type = types2[functionType2];
|
|
@@ -63189,17 +63619,17 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63189
63619
|
}
|
|
63190
63620
|
if (isDlsym) usesDlsym = true;
|
|
63191
63621
|
if (isDlerror) usesDlerror = true;
|
|
63192
|
-
|
|
63193
|
-
|
|
63194
|
-
|
|
63195
|
-
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding
|
|
63196
|
-
)
|
|
63197
|
-
|
|
63198
|
-
|
|
63199
|
-
|
|
63622
|
+
if (importWriter && binding) {
|
|
63623
|
+
importWriter.string(module2);
|
|
63624
|
+
importWriter.string(
|
|
63625
|
+
isDlsym ? callerAlias : isDlerror ? dlerrorAlias : module2 === "env" && name3 !== "dlsym" && name3 !== "dlerror" ? binding(name3) ?? name3 : name3
|
|
63626
|
+
);
|
|
63627
|
+
importWriter.byte(kind);
|
|
63628
|
+
importWriter.bytes(bytes, typeStart, offset);
|
|
63629
|
+
}
|
|
63200
63630
|
}
|
|
63201
|
-
if (offset !==
|
|
63202
|
-
if (
|
|
63631
|
+
if (offset !== end) throw new Error("invalid wasm import section");
|
|
63632
|
+
if (importWriter) rewrittenSection = importWriter.finish();
|
|
63203
63633
|
} else if (id === 3) {
|
|
63204
63634
|
const count = number4();
|
|
63205
63635
|
for (let i = 0; i < count; i++) functionTypes.push(number4());
|
|
@@ -63208,43 +63638,40 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63208
63638
|
if (sectionName === "linking") {
|
|
63209
63639
|
const version2 = number4();
|
|
63210
63640
|
if (version2 !== 2) throw new Error("unsupported wasm linking version");
|
|
63211
|
-
const subsections = [];
|
|
63641
|
+
const subsections = rewrite ? [] : void 0;
|
|
63212
63642
|
let objcLoader;
|
|
63213
|
-
while (offset <
|
|
63214
|
-
const kind =
|
|
63643
|
+
while (offset < end) {
|
|
63644
|
+
const kind = bytes[offset++];
|
|
63215
63645
|
const length = number4();
|
|
63216
63646
|
const stop2 = offset + length;
|
|
63217
|
-
if (stop2 >
|
|
63218
|
-
|
|
63219
|
-
if (kind === 7 && !sdkLookupOnly) {
|
|
63220
|
-
const
|
|
63647
|
+
if (stop2 > end) throw new Error("invalid linking subsection");
|
|
63648
|
+
const contentStart = offset;
|
|
63649
|
+
if (kind === 7 && rewrite && !sdkLookupOnly) {
|
|
63650
|
+
const comdatWriter = new ByteWriter(length + 64);
|
|
63221
63651
|
const count = number4();
|
|
63222
|
-
|
|
63652
|
+
comdatWriter.uleb(count);
|
|
63223
63653
|
for (let i = 0; i < count; i++) {
|
|
63224
63654
|
const group = string8();
|
|
63225
63655
|
const begin = offset;
|
|
63226
63656
|
number4();
|
|
63227
63657
|
const members2 = number4();
|
|
63228
63658
|
for (let member = 0; member < members2 * 2; member++) number4();
|
|
63229
|
-
|
|
63230
|
-
|
|
63231
|
-
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
63232
|
-
),
|
|
63233
|
-
section2.subarray(begin, offset)
|
|
63659
|
+
comdatWriter.string(
|
|
63660
|
+
group === OBJC_INIT_RECORD ? group : `${comdatScope}:${group}`
|
|
63234
63661
|
);
|
|
63662
|
+
comdatWriter.bytes(bytes, begin, offset);
|
|
63235
63663
|
}
|
|
63236
63664
|
if (offset !== stop2) throw new Error("invalid comdat subsection");
|
|
63237
|
-
|
|
63238
|
-
|
|
63239
|
-
if (kind === 8) {
|
|
63240
|
-
const
|
|
63241
|
-
|
|
63665
|
+
const buf = comdatWriter.finish();
|
|
63666
|
+
subsections.push({ kind, parts: [buf], byteLength: buf.length });
|
|
63667
|
+
} else if (kind === 8) {
|
|
63668
|
+
const entryWriter = rewrite ? new ByteWriter(length + 128) : void 0;
|
|
63669
|
+
let extraWriter;
|
|
63242
63670
|
const count = number4();
|
|
63243
|
-
entries2.push(encodeNumber(count));
|
|
63244
63671
|
let added = 0;
|
|
63245
63672
|
for (let i = 0; i < count; i++) {
|
|
63246
63673
|
const begin = offset;
|
|
63247
|
-
const symbolKind =
|
|
63674
|
+
const symbolKind = bytes[offset++];
|
|
63248
63675
|
const flags = number4();
|
|
63249
63676
|
const flagsEnd = offset;
|
|
63250
63677
|
let index = -1;
|
|
@@ -63272,25 +63699,43 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63272
63699
|
}
|
|
63273
63700
|
} else if (symbolKind === 3) number4();
|
|
63274
63701
|
else throw new Error("unsupported wasm symbol kind");
|
|
63275
|
-
if (symbolKind === 0)
|
|
63702
|
+
if (!rewrite && symbolKind === 0)
|
|
63276
63703
|
functionSymbols[i] = name3 || functionImportNames[index];
|
|
63277
|
-
if (!sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
63704
|
+
if (rewrite && !sdkLookupOnly && name3 === OBJC_LOAD_FUNCTION && symbolKind === 0 && !(flags & 16)) {
|
|
63278
63705
|
objcLoader = i;
|
|
63279
63706
|
}
|
|
63280
63707
|
const alias = names.get(name3);
|
|
63281
|
-
if (flags & 16 && symbolKind === 1 && alias)
|
|
63282
|
-
|
|
63283
|
-
|
|
63284
|
-
|
|
63285
|
-
|
|
63286
|
-
|
|
63287
|
-
|
|
63288
|
-
|
|
63289
|
-
|
|
63290
|
-
|
|
63291
|
-
|
|
63292
|
-
|
|
63293
|
-
|
|
63708
|
+
if (!rewrite && flags & 16 && symbolKind === 1 && alias)
|
|
63709
|
+
usedSymbols.add(name3);
|
|
63710
|
+
if (entryWriter && binding) {
|
|
63711
|
+
if ((name3 === "dlsym" && usesDlsym || name3 === "dlerror" && usesDlerror) && flags & 16 && flags & 64 && symbolKind === 0) {
|
|
63712
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
63713
|
+
entryWriter.string(name3 === "dlsym" ? callerAlias : dlerrorAlias);
|
|
63714
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
63715
|
+
} else if (flags & 16 && name3 !== "dlsym" && name3 !== "dlerror" && binding(name3) !== void 0) {
|
|
63716
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
63717
|
+
entryWriter.string(binding(name3));
|
|
63718
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
63719
|
+
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
63720
|
+
if (symbolKind !== 0 && symbolKind !== 1)
|
|
63721
|
+
throw new Error(`unsupported symbol ${name3}`);
|
|
63722
|
+
if (preserveCanonical.has(name3)) {
|
|
63723
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
63724
|
+
extraWriter ??= new ByteWriter(256);
|
|
63725
|
+
extraWriter.byte(bytes[begin]);
|
|
63726
|
+
extraWriter.uleb(flags & ~32);
|
|
63727
|
+
extraWriter.bytes(bytes, flagsEnd, nameStart);
|
|
63728
|
+
extraWriter.string(alias);
|
|
63729
|
+
extraWriter.bytes(bytes, nameEnd, offset);
|
|
63730
|
+
added++;
|
|
63731
|
+
} else {
|
|
63732
|
+
entryWriter.bytes(bytes, begin, nameStart);
|
|
63733
|
+
entryWriter.string(alias);
|
|
63734
|
+
entryWriter.bytes(bytes, nameEnd, offset);
|
|
63735
|
+
}
|
|
63736
|
+
} else {
|
|
63737
|
+
entryWriter.bytes(bytes, begin, offset);
|
|
63738
|
+
}
|
|
63294
63739
|
} else if (alias && !(flags & 16) && (flags & 3) !== 2) {
|
|
63295
63740
|
if (symbolKind !== 0 && symbolKind !== 1)
|
|
63296
63741
|
throw new Error(`unsupported symbol ${name3}`);
|
|
@@ -63304,63 +63749,73 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63304
63749
|
hidden: (flags & 4) !== 0,
|
|
63305
63750
|
type
|
|
63306
63751
|
});
|
|
63307
|
-
|
|
63308
|
-
entries2.push(section2.subarray(begin, offset));
|
|
63309
|
-
extraEntries.push(
|
|
63310
|
-
section2.subarray(begin, begin + 1),
|
|
63311
|
-
encodeNumber(flags & ~32),
|
|
63312
|
-
section2.subarray(flagsEnd, nameStart),
|
|
63313
|
-
encodedString(alias),
|
|
63314
|
-
section2.subarray(nameEnd, offset)
|
|
63315
|
-
);
|
|
63316
|
-
added++;
|
|
63317
|
-
} else {
|
|
63318
|
-
entries2.push(
|
|
63319
|
-
section2.subarray(begin, nameStart),
|
|
63320
|
-
encodedString(alias),
|
|
63321
|
-
section2.subarray(nameEnd, offset)
|
|
63322
|
-
);
|
|
63323
|
-
}
|
|
63324
|
-
} else entries2.push(section2.subarray(begin, offset));
|
|
63752
|
+
}
|
|
63325
63753
|
}
|
|
63326
63754
|
if (offset !== stop2) throw new Error("invalid symbol subsection");
|
|
63327
|
-
|
|
63328
|
-
|
|
63755
|
+
if (entryWriter) {
|
|
63756
|
+
const countBytes = encodeNumber(count + added);
|
|
63757
|
+
const entryBuf = entryWriter.finish();
|
|
63758
|
+
if (extraWriter) {
|
|
63759
|
+
const extraBuf = extraWriter.finish();
|
|
63760
|
+
subsections.push({
|
|
63761
|
+
kind,
|
|
63762
|
+
parts: [countBytes, entryBuf, extraBuf],
|
|
63763
|
+
byteLength: countBytes.length + entryBuf.length + extraBuf.length
|
|
63764
|
+
});
|
|
63765
|
+
} else {
|
|
63766
|
+
subsections.push({
|
|
63767
|
+
kind,
|
|
63768
|
+
parts: [countBytes, entryBuf],
|
|
63769
|
+
byteLength: countBytes.length + entryBuf.length
|
|
63770
|
+
});
|
|
63771
|
+
}
|
|
63772
|
+
}
|
|
63773
|
+
} else if (subsections) {
|
|
63774
|
+
subsections.push({
|
|
63775
|
+
kind,
|
|
63776
|
+
parts: [bytes.subarray(contentStart, stop2)],
|
|
63777
|
+
byteLength: length
|
|
63778
|
+
});
|
|
63329
63779
|
}
|
|
63330
63780
|
offset = stop2;
|
|
63331
|
-
|
|
63332
|
-
|
|
63333
|
-
|
|
63334
|
-
|
|
63335
|
-
|
|
63336
|
-
|
|
63337
|
-
|
|
63338
|
-
|
|
63339
|
-
|
|
63340
|
-
|
|
63341
|
-
|
|
63342
|
-
|
|
63343
|
-
|
|
63344
|
-
|
|
63345
|
-
content
|
|
63346
|
-
|
|
63347
|
-
|
|
63348
|
-
|
|
63349
|
-
|
|
63350
|
-
|
|
63781
|
+
}
|
|
63782
|
+
if (subsections) {
|
|
63783
|
+
const linkingWriter = new ByteWriter(size2 + 128);
|
|
63784
|
+
linkingWriter.string(sectionName);
|
|
63785
|
+
linkingWriter.uleb(version2);
|
|
63786
|
+
for (const subsection of subsections) {
|
|
63787
|
+
if (subsection.kind === 6 && objcLoader !== void 0) {
|
|
63788
|
+
const content = subsection.parts[0];
|
|
63789
|
+
const [count, entriesStart] = readNumber(content, 0);
|
|
63790
|
+
const initWriter = new ByteWriter(content.length + 16);
|
|
63791
|
+
initWriter.bytes(content, 0, entriesStart);
|
|
63792
|
+
let entryStart = entriesStart;
|
|
63793
|
+
for (let i = 0; i < count; i++) {
|
|
63794
|
+
const [, symbolStart] = readNumber(content, entryStart);
|
|
63795
|
+
const [symbol2, entryEnd] = readNumber(content, symbolStart);
|
|
63796
|
+
if (symbol2 === objcLoader) {
|
|
63797
|
+
initWriter.uleb(1);
|
|
63798
|
+
initWriter.bytes(content, symbolStart, entryEnd);
|
|
63799
|
+
} else {
|
|
63800
|
+
initWriter.bytes(content, entryStart, entryEnd);
|
|
63801
|
+
}
|
|
63802
|
+
entryStart = entryEnd;
|
|
63803
|
+
}
|
|
63804
|
+
if (entryStart !== content.length)
|
|
63805
|
+
throw new Error("invalid init functions subsection");
|
|
63806
|
+
const initBuf = initWriter.finish();
|
|
63807
|
+
linkingWriter.byte(subsection.kind);
|
|
63808
|
+
linkingWriter.uleb(initBuf.length);
|
|
63809
|
+
linkingWriter.bytes(initBuf);
|
|
63810
|
+
} else {
|
|
63811
|
+
linkingWriter.byte(subsection.kind);
|
|
63812
|
+
linkingWriter.uleb(subsection.byteLength);
|
|
63813
|
+
for (const part of subsection.parts) linkingWriter.bytes(part);
|
|
63351
63814
|
}
|
|
63352
|
-
|
|
63353
|
-
|
|
63354
|
-
content = Buffer.concat(entries2);
|
|
63355
|
-
}
|
|
63356
|
-
parts2.push(
|
|
63357
|
-
Buffer.from([subsection.kind]),
|
|
63358
|
-
encodeNumber(content.length),
|
|
63359
|
-
content
|
|
63360
|
-
);
|
|
63815
|
+
}
|
|
63816
|
+
rewrittenSection = linkingWriter.finish();
|
|
63361
63817
|
}
|
|
63362
|
-
|
|
63363
|
-
} else if (!sections && sectionName.startsWith("reloc.")) {
|
|
63818
|
+
} else if (!rewrite && sectionName.startsWith("reloc.")) {
|
|
63364
63819
|
number4();
|
|
63365
63820
|
for (let count = number4(); count > 0; count--) {
|
|
63366
63821
|
const type = number4();
|
|
@@ -63370,18 +63825,27 @@ function rewriteObject(bytes, names, callerAlias, binding, instrumentDynamicLook
|
|
|
63370
63825
|
if (name3 !== void 0 && TABLE_INDEX_RELOCATIONS.has(type))
|
|
63371
63826
|
addressTaken.add(name3);
|
|
63372
63827
|
}
|
|
63373
|
-
if (offset !==
|
|
63374
|
-
|
|
63828
|
+
if (offset !== end) throw new Error(`invalid relocation section ${sectionName}`);
|
|
63829
|
+
}
|
|
63830
|
+
}
|
|
63831
|
+
if (sections) {
|
|
63832
|
+
if (rewrittenSection) {
|
|
63833
|
+
sections.push(
|
|
63834
|
+
Buffer.from([id]),
|
|
63835
|
+
encodeNumber(rewrittenSection.length),
|
|
63836
|
+
rewrittenSection
|
|
63837
|
+
);
|
|
63838
|
+
} else {
|
|
63839
|
+
sections.push(bytes.subarray(headerStart2, end));
|
|
63375
63840
|
}
|
|
63376
63841
|
}
|
|
63377
|
-
sections?.push(Buffer.from([id]), encodeNumber(section2.length), section2);
|
|
63378
63842
|
}
|
|
63379
63843
|
return {
|
|
63380
63844
|
bytes: sections ? Buffer.concat(sections) : bytes,
|
|
63381
63845
|
definitions,
|
|
63382
63846
|
functionImports,
|
|
63383
63847
|
usesDlsym,
|
|
63384
|
-
usedSymbols
|
|
63848
|
+
usedSymbols,
|
|
63385
63849
|
addressTaken: [...addressTaken]
|
|
63386
63850
|
};
|
|
63387
63851
|
}
|
|
@@ -63470,36 +63934,51 @@ function createGuestImageLedger(input) {
|
|
|
63470
63934
|
}
|
|
63471
63935
|
}
|
|
63472
63936
|
}
|
|
63473
|
-
|
|
63474
|
-
for (const definition2 of definitions)
|
|
63475
|
-
|
|
63476
|
-
|
|
63477
|
-
|
|
63478
|
-
|
|
63479
|
-
|
|
63937
|
+
let hasNonAscii = false;
|
|
63938
|
+
for (const definition2 of definitions) {
|
|
63939
|
+
const s = definition2.name;
|
|
63940
|
+
for (let i = 0; i < s.length; i++) {
|
|
63941
|
+
if (s.charCodeAt(i) > 127) {
|
|
63942
|
+
hasNonAscii = true;
|
|
63943
|
+
break;
|
|
63944
|
+
}
|
|
63945
|
+
}
|
|
63946
|
+
if (hasNonAscii) break;
|
|
63947
|
+
}
|
|
63948
|
+
if (hasNonAscii) {
|
|
63949
|
+
const nameBytes = /* @__PURE__ */ new Map();
|
|
63950
|
+
for (const definition2 of definitions)
|
|
63951
|
+
if (!nameBytes.has(definition2.name))
|
|
63952
|
+
nameBytes.set(definition2.name, Buffer.from(definition2.name));
|
|
63953
|
+
definitions.sort(
|
|
63954
|
+
(a, b) => Buffer.compare(nameBytes.get(a.name), nameBytes.get(b.name)) || a.image - b.image
|
|
63955
|
+
);
|
|
63956
|
+
} else {
|
|
63957
|
+
definitions.sort(
|
|
63958
|
+
(a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : a.image - b.image
|
|
63959
|
+
);
|
|
63960
|
+
}
|
|
63480
63961
|
const preserveCanonical = /* @__PURE__ */ new Set();
|
|
63481
63962
|
const definitionsByName = Map.groupBy(definitions, (definition2) => definition2.name);
|
|
63482
|
-
|
|
63963
|
+
if (symbolIndices.has("__cxa_throw")) {
|
|
63964
|
+
const name3 = "__cxa_throw";
|
|
63483
63965
|
const matching2 = definitionsByName.get(name3) ?? [];
|
|
63484
|
-
if (new Set(matching2.map((definition2) => definition2.image)).size
|
|
63485
|
-
|
|
63486
|
-
|
|
63487
|
-
|
|
63488
|
-
|
|
63489
|
-
|
|
63490
|
-
|
|
63491
|
-
|
|
63492
|
-
|
|
63493
|
-
|
|
63494
|
-
|
|
63495
|
-
|
|
63496
|
-
|
|
63497
|
-
|
|
63498
|
-
);
|
|
63499
|
-
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
63500
|
-
throw new Error(`weak interposition scope excludes runtime for ${name3}`);
|
|
63966
|
+
if (new Set(matching2.map((definition2) => definition2.image)).size >= 2 && matching2.some((definition2) => definition2.weak)) {
|
|
63967
|
+
const weak = matching2.filter((definition2) => definition2.weak);
|
|
63968
|
+
const strong = matching2.filter((definition2) => !definition2.weak);
|
|
63969
|
+
if (weak.length !== 1 || strong.length !== 1)
|
|
63970
|
+
throw new Error(`unsupported weak interposition for ${name3}`);
|
|
63971
|
+
const [local] = weak;
|
|
63972
|
+
const [runtime] = strong;
|
|
63973
|
+
if (local.kind !== "function" || runtime.kind !== "function" || local.result !== runtime.result || local.parameters.join(",") !== runtime.parameters.join(","))
|
|
63974
|
+
throw new Error(`incompatible weak interposition for ${name3}`);
|
|
63975
|
+
for (const caller of input.callers) {
|
|
63976
|
+
const uses = caller.image === local.image || units.some((unit2) => unit2.image === caller.image && unit2.usedSymbols.has(name3));
|
|
63977
|
+
if (uses && caller.image !== runtime.image && !caller.next.includes(runtime.image))
|
|
63978
|
+
throw new Error(`weak interposition scope excludes runtime for ${name3}`);
|
|
63979
|
+
}
|
|
63980
|
+
preserveCanonical.add(name3);
|
|
63501
63981
|
}
|
|
63502
|
-
preserveCanonical.add(name3);
|
|
63503
63982
|
}
|
|
63504
63983
|
for (const name3 of [
|
|
63505
63984
|
"dlsym",
|
|
@@ -63511,40 +63990,76 @@ function createGuestImageLedger(input) {
|
|
|
63511
63990
|
])
|
|
63512
63991
|
preserveCanonical.add(name3);
|
|
63513
63992
|
for (const name3 of input.commandLineSymbols ?? []) preserveCanonical.add(name3);
|
|
63514
|
-
const
|
|
63515
|
-
const
|
|
63993
|
+
const imageAliases = /* @__PURE__ */ new Map();
|
|
63994
|
+
const imageWeakNames = /* @__PURE__ */ new Map();
|
|
63995
|
+
const singleOwnerByName = /* @__PURE__ */ new Map();
|
|
63996
|
+
for (const definition2 of definitions) {
|
|
63997
|
+
let aliases = imageAliases.get(definition2.image);
|
|
63998
|
+
if (!aliases) imageAliases.set(definition2.image, aliases = /* @__PURE__ */ new Map());
|
|
63999
|
+
const existing = aliases.get(definition2.name);
|
|
64000
|
+
if (existing === void 0) {
|
|
64001
|
+
aliases.set(definition2.name, definition2.alias);
|
|
64002
|
+
if (definition2.weak) {
|
|
64003
|
+
let weak = imageWeakNames.get(definition2.image);
|
|
64004
|
+
if (!weak) imageWeakNames.set(definition2.image, weak = /* @__PURE__ */ new Set());
|
|
64005
|
+
weak.add(definition2.name);
|
|
64006
|
+
}
|
|
64007
|
+
const owner = singleOwnerByName.get(definition2.name);
|
|
64008
|
+
if (owner === void 0)
|
|
64009
|
+
singleOwnerByName.set(definition2.name, {
|
|
64010
|
+
image: definition2.image,
|
|
64011
|
+
alias: definition2.alias
|
|
64012
|
+
});
|
|
64013
|
+
else if (owner !== null && owner.image !== definition2.image)
|
|
64014
|
+
singleOwnerByName.set(definition2.name, null);
|
|
64015
|
+
} else if (!definition2.weak && imageWeakNames.get(definition2.image)?.has(definition2.name)) {
|
|
64016
|
+
aliases.set(definition2.name, definition2.alias);
|
|
64017
|
+
imageWeakNames.get(definition2.image).delete(definition2.name);
|
|
64018
|
+
const owner = singleOwnerByName.get(definition2.name);
|
|
64019
|
+
if (owner && owner.image === definition2.image) owner.alias = definition2.alias;
|
|
64020
|
+
}
|
|
64021
|
+
}
|
|
64022
|
+
const sharedLookupByImage = /* @__PURE__ */ new Map();
|
|
63516
64023
|
for (const caller of input.callers) {
|
|
63517
|
-
const bindings = /* @__PURE__ */ new Map();
|
|
63518
|
-
const seen = /* @__PURE__ */ new Map();
|
|
63519
64024
|
const scope2 = [caller.image, ...caller.next];
|
|
63520
64025
|
if (input.systemImage !== void 0 && !scope2.includes(input.systemImage))
|
|
63521
64026
|
scope2.push(input.systemImage);
|
|
63522
|
-
|
|
63523
|
-
|
|
63524
|
-
|
|
63525
|
-
|
|
63526
|
-
|
|
63527
|
-
|
|
63528
|
-
|
|
63529
|
-
|
|
63530
|
-
|
|
63531
|
-
|
|
63532
|
-
|
|
63533
|
-
|
|
63534
|
-
|
|
63535
|
-
|
|
63536
|
-
|
|
64027
|
+
const scopeSet = new Set(scope2);
|
|
64028
|
+
const scopeMaps = [];
|
|
64029
|
+
const seenImages = /* @__PURE__ */ new Set();
|
|
64030
|
+
for (const image of scope2) {
|
|
64031
|
+
if (seenImages.has(image)) continue;
|
|
64032
|
+
seenImages.add(image);
|
|
64033
|
+
const aliases = imageAliases.get(image);
|
|
64034
|
+
if (aliases) scopeMaps.push(aliases);
|
|
64035
|
+
}
|
|
64036
|
+
const cache = /* @__PURE__ */ new Map();
|
|
64037
|
+
sharedLookupByImage.set(caller.image, (name3) => {
|
|
64038
|
+
if (preserveCanonical.has(name3)) return void 0;
|
|
64039
|
+
const single = singleOwnerByName.get(name3);
|
|
64040
|
+
if (single === void 0) return void 0;
|
|
64041
|
+
if (single !== null) return scopeSet.has(single.image) ? single.alias : void 0;
|
|
64042
|
+
const hit = cache.get(name3);
|
|
64043
|
+
if (hit !== void 0) return hit ?? void 0;
|
|
64044
|
+
for (const aliases of scopeMaps) {
|
|
64045
|
+
const alias = aliases.get(name3);
|
|
64046
|
+
if (alias !== void 0) {
|
|
64047
|
+
cache.set(name3, alias);
|
|
64048
|
+
return alias;
|
|
63537
64049
|
}
|
|
63538
64050
|
}
|
|
63539
|
-
|
|
64051
|
+
cache.set(name3, null);
|
|
64052
|
+
return void 0;
|
|
64053
|
+
});
|
|
63540
64054
|
}
|
|
63541
64055
|
const startup = /* @__PURE__ */ new Map();
|
|
64056
|
+
const unitsByPath = new Map(units.map((unit2) => [unit2.object.path, unit2]));
|
|
63542
64057
|
for (const binding of input.directBindings ?? []) {
|
|
63543
|
-
const unit2 =
|
|
64058
|
+
const unit2 = unitsByPath.get(binding.object);
|
|
63544
64059
|
const matches = (definitionsByName.get(binding.symbol) ?? []).filter(
|
|
63545
64060
|
(definition2) => definition2.object === binding.providerObject && definition2.image === binding.providerImage
|
|
63546
64061
|
);
|
|
63547
|
-
if (!unit2 || !unit2.usedSymbols.
|
|
64062
|
+
if (!unit2 || !unit2.usedSymbols.has(binding.symbol) || matches.length !== 1)
|
|
63548
64063
|
throw new Error(`invalid startup binding ${binding.object} ${binding.symbol}`);
|
|
63549
64064
|
const bindings = startup.get(binding.object) ?? /* @__PURE__ */ new Map();
|
|
63550
64065
|
if (bindings.has(binding.symbol))
|
|
@@ -63585,11 +64100,11 @@ function createGuestImageLedger(input) {
|
|
|
63585
64100
|
}
|
|
63586
64101
|
}
|
|
63587
64102
|
const objects = units.map(({ image, object: object8, aliases, functionImports }) => {
|
|
63588
|
-
const shared =
|
|
64103
|
+
const shared = sharedLookupByImage.get(image);
|
|
63589
64104
|
const own2 = startup.get(object8.path);
|
|
63590
64105
|
const bindings = new Map(own2);
|
|
63591
64106
|
const weak = input.sdkWeakReferences?.get(object8.path);
|
|
63592
|
-
const binding = (name3) => bindings.get(name3) ?? shared
|
|
64107
|
+
const binding = (name3) => bindings.get(name3) ?? shared(name3) ?? (weak?.has(name3) ? void 0 : sdkGlobalBindings.get(name3));
|
|
63593
64108
|
for (const [name3, type] of functionImports) {
|
|
63594
64109
|
const alias = binding(name3);
|
|
63595
64110
|
const provider = alias === void 0 ? void 0 : definitionsByAlias.get(alias);
|
|
@@ -63854,7 +64369,7 @@ function nameGuestImageAliases(wasm, symbols) {
|
|
|
63854
64369
|
}
|
|
63855
64370
|
return Buffer.concat(parts2);
|
|
63856
64371
|
}
|
|
63857
|
-
var import_node_crypto32, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
64372
|
+
var import_node_crypto32, ByteWriter, OBJC_INIT_RECORD, TABLE_INDEX_RELOCATIONS, GUEST_DYLD_VALUES_SECTION, GUEST_LAZY_FUNCTION_BASE, SDK_DYLD_RESOLVER;
|
|
63858
64373
|
var init_swift_guest_image_ledger = __esm({
|
|
63859
64374
|
"src/swift-guest-image-ledger.ts"() {
|
|
63860
64375
|
"use strict";
|
|
@@ -63862,6 +64377,57 @@ var init_swift_guest_image_ledger = __esm({
|
|
|
63862
64377
|
init_nativeWasmContract();
|
|
63863
64378
|
init_swift_sdk_image_wasm();
|
|
63864
64379
|
init_swiftSdkLinkContract();
|
|
64380
|
+
ByteWriter = class {
|
|
64381
|
+
buf;
|
|
64382
|
+
pos = 0;
|
|
64383
|
+
constructor(initialCapacity = 256) {
|
|
64384
|
+
this.buf = Buffer.allocUnsafe(Math.max(64, initialCapacity));
|
|
64385
|
+
}
|
|
64386
|
+
ensure(extra) {
|
|
64387
|
+
const needed = this.pos + extra;
|
|
64388
|
+
if (needed <= this.buf.length) return;
|
|
64389
|
+
let next = this.buf.length * 2;
|
|
64390
|
+
while (next < needed) next *= 2;
|
|
64391
|
+
const grown = Buffer.allocUnsafe(next);
|
|
64392
|
+
this.buf.copy(grown, 0, 0, this.pos);
|
|
64393
|
+
this.buf = grown;
|
|
64394
|
+
}
|
|
64395
|
+
byte(value) {
|
|
64396
|
+
this.ensure(1);
|
|
64397
|
+
this.buf[this.pos++] = value;
|
|
64398
|
+
}
|
|
64399
|
+
uleb(value) {
|
|
64400
|
+
this.ensure(10);
|
|
64401
|
+
let pos = this.pos;
|
|
64402
|
+
const buf = this.buf;
|
|
64403
|
+
do {
|
|
64404
|
+
let byte = value % 128;
|
|
64405
|
+
value = Math.floor(value / 128);
|
|
64406
|
+
if (value) byte |= 128;
|
|
64407
|
+
buf[pos++] = byte;
|
|
64408
|
+
} while (value);
|
|
64409
|
+
this.pos = pos;
|
|
64410
|
+
}
|
|
64411
|
+
bytes(source, start = 0, end = source.length) {
|
|
64412
|
+
const len = end - start;
|
|
64413
|
+
if (len <= 0) return;
|
|
64414
|
+
this.ensure(len);
|
|
64415
|
+
this.buf.set(source.subarray(start, end), this.pos);
|
|
64416
|
+
this.pos += len;
|
|
64417
|
+
}
|
|
64418
|
+
string(value) {
|
|
64419
|
+
const len = Buffer.byteLength(value, "utf8");
|
|
64420
|
+
this.uleb(len);
|
|
64421
|
+
if (len > 0) {
|
|
64422
|
+
this.ensure(len);
|
|
64423
|
+
this.buf.write(value, this.pos, len, "utf8");
|
|
64424
|
+
this.pos += len;
|
|
64425
|
+
}
|
|
64426
|
+
}
|
|
64427
|
+
finish() {
|
|
64428
|
+
return this.buf.subarray(0, this.pos);
|
|
64429
|
+
}
|
|
64430
|
+
};
|
|
63865
64431
|
OBJC_INIT_RECORD = ".objc_init";
|
|
63866
64432
|
TABLE_INDEX_RELOCATIONS = /* @__PURE__ */ new Set([1, 2, 12, 18, 19, 24]);
|
|
63867
64433
|
GUEST_DYLD_VALUES_SECTION = "peach_dyld_values";
|
|
@@ -64479,8 +65045,11 @@ function moveGuestDyldTable(map2, wasm, symbols, bindingValues = /* @__PURE__ */
|
|
|
64479
65045
|
function guestDyldValueRange(map2) {
|
|
64480
65046
|
const suffix = `:(${GUEST_DYLD_VALUES_SECTION})`;
|
|
64481
65047
|
let found2;
|
|
64482
|
-
for (
|
|
64483
|
-
|
|
65048
|
+
for (let at = map2.indexOf(suffix); at !== -1; at = map2.indexOf(suffix, at + suffix.length)) {
|
|
65049
|
+
const lineEnd = at + suffix.length;
|
|
65050
|
+
if (lineEnd < map2.length && map2.charCodeAt(lineEnd) !== 10) continue;
|
|
65051
|
+
const lineStart = map2.lastIndexOf("\n", at) + 1;
|
|
65052
|
+
const line = map2.slice(lineStart, lineEnd);
|
|
64484
65053
|
const match = /^\s*([\da-f]+)\s+[\da-f]+\s+([\da-f]+)\s/.exec(line);
|
|
64485
65054
|
if (!match) throw new Error("unreadable dyld values map line");
|
|
64486
65055
|
if (found2) throw new Error("link map has several dyld value sections");
|
|
@@ -64533,7 +65102,7 @@ var init_swift_guest_link_plan = __esm({
|
|
|
64533
65102
|
});
|
|
64534
65103
|
|
|
64535
65104
|
// src/swift-guest-manifest.ts
|
|
64536
|
-
function selectedGuestManifestInputs(plan, selection, identities) {
|
|
65105
|
+
function selectedGuestManifestInputs(plan, selection, identities, readSelected) {
|
|
64537
65106
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
64538
65107
|
const archives = /* @__PURE__ */ new Map();
|
|
64539
65108
|
const images = /* @__PURE__ */ new Map();
|
|
@@ -64544,19 +65113,29 @@ function selectedGuestManifestInputs(plan, selection, identities) {
|
|
|
64544
65113
|
throw new Error(`selected input has no logical identity: ${item.artifact}`);
|
|
64545
65114
|
let bytes;
|
|
64546
65115
|
let memberIdentity = null;
|
|
64547
|
-
if (item.member === null)
|
|
64548
|
-
|
|
64549
|
-
|
|
64550
|
-
if (
|
|
64551
|
-
|
|
64552
|
-
|
|
65116
|
+
if (item.member === null) {
|
|
65117
|
+
bytes = readSelected ? readSelected(item) : (0, import_node_fs60.readFileSync)(item.artifact);
|
|
65118
|
+
} else {
|
|
65119
|
+
if (readSelected) {
|
|
65120
|
+
bytes = readSelected(item);
|
|
65121
|
+
} else {
|
|
65122
|
+
let members2 = archives.get(item.artifact);
|
|
65123
|
+
if (!members2) {
|
|
65124
|
+
members2 = /* @__PURE__ */ new Map();
|
|
65125
|
+
for (const member of readArMembers((0, import_node_fs60.readFileSync)(item.artifact))) {
|
|
65126
|
+
let list2 = members2.get(member.name);
|
|
65127
|
+
if (!list2) members2.set(member.name, list2 = []);
|
|
65128
|
+
list2.push(member.bytes);
|
|
65129
|
+
}
|
|
65130
|
+
archives.set(item.artifact, members2);
|
|
65131
|
+
}
|
|
65132
|
+
const matching2 = members2.get(item.member);
|
|
65133
|
+
if (!matching2 || matching2.length !== 1)
|
|
65134
|
+
throw new Error(
|
|
65135
|
+
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
65136
|
+
);
|
|
65137
|
+
bytes = matching2[0];
|
|
64553
65138
|
}
|
|
64554
|
-
const matching2 = members2.filter((member) => member.name === item.member);
|
|
64555
|
-
if (matching2.length !== 1)
|
|
64556
|
-
throw new Error(
|
|
64557
|
-
`selected archive member is ambiguous: ${item.artifact}(${item.member})`
|
|
64558
|
-
);
|
|
64559
|
-
bytes = matching2[0].bytes;
|
|
64560
65139
|
const origin = artifact.memberOrigins?.get(item.member);
|
|
64561
65140
|
if (artifact.memberOrigins && !origin)
|
|
64562
65141
|
throw new Error(
|
|
@@ -64648,7 +65227,7 @@ var init_swift_guest_manifest = __esm({
|
|
|
64648
65227
|
function isSwiftGuestImageManifest(value) {
|
|
64649
65228
|
const uint = (value2, maximum) => typeof value2 === "number" && Number.isInteger(value2) && value2 >= 0 && value2 <= maximum;
|
|
64650
65229
|
const text7 = (value2) => typeof value2 === "string" && value2.length > 0 && value2.length <= 4096 && !value2.includes("\0");
|
|
64651
|
-
const name3 = (value2) => text7(value2) &&
|
|
65230
|
+
const name3 = (value2) => text7(value2) && Buffer.byteLength(value2, "utf8") <= 16;
|
|
64652
65231
|
const version2 = (value2) => isRecord(value2) && uint(value2.major, 65535) && uint(value2.minor, 255) && uint(value2.patch, 255);
|
|
64653
65232
|
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))
|
|
64654
65233
|
return false;
|
|
@@ -64962,27 +65541,25 @@ function planGuestProjectionRegions(images, capacities, spans) {
|
|
|
64962
65541
|
function finalizeGuestProjectionStorage(options2) {
|
|
64963
65542
|
const owner = options2.owners.get(options2.projectionObject);
|
|
64964
65543
|
if (owner === void 0) throw new Error("guest projection object has no image owner");
|
|
65544
|
+
const ranges = [];
|
|
64965
65545
|
const spans = guestLinkedSpans(
|
|
64966
65546
|
options2.map,
|
|
64967
65547
|
options2.linked,
|
|
64968
65548
|
options2.optimized,
|
|
64969
65549
|
options2.owners,
|
|
64970
65550
|
options2.sectionOwners,
|
|
64971
|
-
options2.sdkSpans !== void 0
|
|
65551
|
+
options2.sdkSpans !== void 0,
|
|
65552
|
+
{
|
|
65553
|
+
trackedObject: options2.projectionObject,
|
|
65554
|
+
trackedObjectOwner: owner,
|
|
65555
|
+
trackedLinearSpans: ranges
|
|
65556
|
+
}
|
|
64972
65557
|
);
|
|
64973
65558
|
const images = planGuestProjectionRegions(
|
|
64974
65559
|
options2.reserved.images,
|
|
64975
65560
|
options2.reserved.capacities,
|
|
64976
65561
|
options2.sdkSpans ? [...spans, ...options2.sdkSpans] : spans
|
|
64977
65562
|
);
|
|
64978
|
-
const ranges = guestLinkedSpans(
|
|
64979
|
-
options2.map,
|
|
64980
|
-
options2.linked,
|
|
64981
|
-
options2.optimized,
|
|
64982
|
-
/* @__PURE__ */ new Map([[options2.projectionObject, owner]]),
|
|
64983
|
-
void 0,
|
|
64984
|
-
options2.sdkSpans !== void 0
|
|
64985
|
-
).filter((span) => span.space === "linear-memory");
|
|
64986
65563
|
const result = Buffer.from(options2.optimized);
|
|
64987
65564
|
const data = guestWasmDataSegments(options2.optimized, options2.sdkSpans === void 0);
|
|
64988
65565
|
const locations = /* @__PURE__ */ new Map();
|
|
@@ -66050,7 +66627,7 @@ function occurrences(plan, args) {
|
|
|
66050
66627
|
throw new Error("guest plan does not match linker inputs");
|
|
66051
66628
|
return found2;
|
|
66052
66629
|
}
|
|
66053
|
-
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
66630
|
+
function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace, archiveCache) {
|
|
66054
66631
|
const rows = whyExtract.trimEnd().split("\n");
|
|
66055
66632
|
if (rows.shift() !== "reference extracted symbol")
|
|
66056
66633
|
throw new Error("invalid wasm-ld extraction report");
|
|
@@ -66065,8 +66642,38 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
66065
66642
|
for (const file of extracted)
|
|
66066
66643
|
if (!traced.has(file))
|
|
66067
66644
|
throw new Error(`extracted guest input is absent from link trace ${file}`);
|
|
66645
|
+
const foundOccurrences = occurrences(plan, args);
|
|
66646
|
+
const archivePaths = /* @__PURE__ */ new Set();
|
|
66647
|
+
for (const { artifact } of foundOccurrences)
|
|
66648
|
+
if (artifact.kind === "archive") archivePaths.add(artifact.path);
|
|
66649
|
+
const tracedMembers = /* @__PURE__ */ new Map();
|
|
66650
|
+
if (archivePaths.size > 0) {
|
|
66651
|
+
const archivePrefixes = [...archivePaths].map(
|
|
66652
|
+
(archivePath) => [archivePath, `${archivePath}(`]
|
|
66653
|
+
);
|
|
66654
|
+
for (const item of traced) {
|
|
66655
|
+
if (!item.endsWith(")")) continue;
|
|
66656
|
+
const open = item.lastIndexOf("(");
|
|
66657
|
+
if (open > 0) {
|
|
66658
|
+
const archivePath = item.slice(0, open);
|
|
66659
|
+
if (archivePaths.has(archivePath)) {
|
|
66660
|
+
let list2 = tracedMembers.get(archivePath);
|
|
66661
|
+
if (!list2) tracedMembers.set(archivePath, list2 = []);
|
|
66662
|
+
list2.push(item.slice(open + 1, -1));
|
|
66663
|
+
continue;
|
|
66664
|
+
}
|
|
66665
|
+
}
|
|
66666
|
+
for (const [archivePath, prefix] of archivePrefixes) {
|
|
66667
|
+
if (item.startsWith(prefix)) {
|
|
66668
|
+
let list2 = tracedMembers.get(archivePath);
|
|
66669
|
+
if (!list2) tracedMembers.set(archivePath, list2 = []);
|
|
66670
|
+
list2.push(item.slice(prefix.length, -1));
|
|
66671
|
+
}
|
|
66672
|
+
}
|
|
66673
|
+
}
|
|
66674
|
+
}
|
|
66068
66675
|
const result = [];
|
|
66069
|
-
for (const { artifact, lazy, whole } of
|
|
66676
|
+
for (const { artifact, lazy, whole } of foundOccurrences) {
|
|
66070
66677
|
if (artifact.kind === "object") {
|
|
66071
66678
|
if (!lazy && !traced.has(artifact.path))
|
|
66072
66679
|
throw new Error(`eager guest input is absent from link trace ${artifact.path}`);
|
|
@@ -66074,15 +66681,21 @@ function selectedGuestLinkInputs(plan, args, whyExtract, linkTrace) {
|
|
|
66074
66681
|
result.push({ artifact: artifact.path, member: null });
|
|
66075
66682
|
continue;
|
|
66076
66683
|
}
|
|
66077
|
-
const
|
|
66078
|
-
const
|
|
66079
|
-
|
|
66684
|
+
const names = tracedMembers.get(artifact.path) ?? [];
|
|
66685
|
+
const nameSet = new Set(names);
|
|
66686
|
+
let members2 = archiveCache?.get(artifact.path);
|
|
66687
|
+
if (!members2) {
|
|
66688
|
+
members2 = readArMembers(import_node_fs63.default.readFileSync(artifact.path));
|
|
66689
|
+
archiveCache?.set(artifact.path, members2);
|
|
66690
|
+
}
|
|
66691
|
+
const memberCounts = /* @__PURE__ */ new Map();
|
|
66080
66692
|
for (const member of members2) {
|
|
66081
|
-
|
|
66693
|
+
memberCounts.set(member.name, (memberCounts.get(member.name) ?? 0) + 1);
|
|
66694
|
+
if (whole || nameSet.has(member.name))
|
|
66082
66695
|
result.push({ artifact: artifact.path, member: member.name });
|
|
66083
66696
|
}
|
|
66084
66697
|
for (const name3 of names)
|
|
66085
|
-
if (
|
|
66698
|
+
if (memberCounts.get(name3) !== 1)
|
|
66086
66699
|
throw new Error(
|
|
66087
66700
|
`ambiguous or unsupported archive member ${artifact.path}(${name3})`
|
|
66088
66701
|
);
|
|
@@ -66159,14 +66772,25 @@ function linkGuestImages(options2) {
|
|
|
66159
66772
|
}
|
|
66160
66773
|
const archives = /* @__PURE__ */ new Map();
|
|
66161
66774
|
const memberBytes = /* @__PURE__ */ new Map();
|
|
66775
|
+
const objectBytes = /* @__PURE__ */ new Map();
|
|
66162
66776
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
66163
66777
|
const providerSymbol = "__peach_dlsym_from_image";
|
|
66164
66778
|
const readSelected = (item) => {
|
|
66165
|
-
if (item.member === null)
|
|
66779
|
+
if (item.member === null) {
|
|
66780
|
+
let bytes = objectBytes.get(item.artifact);
|
|
66781
|
+
if (!bytes) {
|
|
66782
|
+
bytes = import_node_fs63.default.readFileSync(item.artifact);
|
|
66783
|
+
objectBytes.set(item.artifact, bytes);
|
|
66784
|
+
}
|
|
66785
|
+
return bytes;
|
|
66786
|
+
}
|
|
66166
66787
|
let byName2 = memberBytes.get(item.artifact);
|
|
66167
66788
|
if (!byName2) {
|
|
66168
|
-
|
|
66169
|
-
|
|
66789
|
+
let members2 = archives.get(item.artifact);
|
|
66790
|
+
if (!members2) {
|
|
66791
|
+
members2 = readArMembers(import_node_fs63.default.readFileSync(item.artifact));
|
|
66792
|
+
archives.set(item.artifact, members2);
|
|
66793
|
+
}
|
|
66170
66794
|
byName2 = /* @__PURE__ */ new Map();
|
|
66171
66795
|
for (const member of members2)
|
|
66172
66796
|
if (!byName2.has(member.name))
|
|
@@ -66190,7 +66814,13 @@ function linkGuestImages(options2) {
|
|
|
66190
66814
|
`--why-extract=${whyPath}`,
|
|
66191
66815
|
`--Map=${mapPath}`
|
|
66192
66816
|
]);
|
|
66193
|
-
return selectedGuestLinkInputs(
|
|
66817
|
+
return selectedGuestLinkInputs(
|
|
66818
|
+
plan,
|
|
66819
|
+
args,
|
|
66820
|
+
import_node_fs63.default.readFileSync(whyPath, "utf8"),
|
|
66821
|
+
trace,
|
|
66822
|
+
archives
|
|
66823
|
+
);
|
|
66194
66824
|
};
|
|
66195
66825
|
const needsProvider = (item) => {
|
|
66196
66826
|
if (!artifacts.get(item.artifact).instrumentDynamicLookups) return false;
|
|
@@ -66230,7 +66860,7 @@ function linkGuestImages(options2) {
|
|
|
66230
66860
|
)
|
|
66231
66861
|
]);
|
|
66232
66862
|
const originalOwnership = identity2(plan);
|
|
66233
|
-
const resolved = options2.resolvePlan(selected, plan);
|
|
66863
|
+
const resolved = options2.resolvePlan(selected, plan, readSelected);
|
|
66234
66864
|
if (identity2(resolved) !== originalOwnership)
|
|
66235
66865
|
throw new Error("resolved guest scopes changed input ownership");
|
|
66236
66866
|
plan = resolved;
|
|
@@ -66284,6 +66914,7 @@ function linkGuestImages(options2) {
|
|
|
66284
66914
|
}
|
|
66285
66915
|
}
|
|
66286
66916
|
let discoveryRegions;
|
|
66917
|
+
let liveSymbols;
|
|
66287
66918
|
if (discoveryProjection && options2.projection) {
|
|
66288
66919
|
const owners = /* @__PURE__ */ new Map([[discoveryProjection, options2.projection.image]]);
|
|
66289
66920
|
for (const item of selected)
|
|
@@ -66292,10 +66923,15 @@ function linkGuestImages(options2) {
|
|
|
66292
66923
|
selectedGuestInputImage(artifacts.get(item.artifact), item.member)
|
|
66293
66924
|
);
|
|
66294
66925
|
const wasm = import_node_fs63.default.readFileSync(discovery);
|
|
66926
|
+
liveSymbols = /* @__PURE__ */ new Set();
|
|
66295
66927
|
discoveryRegions = guestProjectionRegionCounts(
|
|
66296
66928
|
plan.images.length,
|
|
66297
|
-
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners
|
|
66929
|
+
guestLinkedSpans(guestLinkLines(mapPath), wasm, wasm, owners, void 0, false, {
|
|
66930
|
+
collectSymbols: liveSymbols
|
|
66931
|
+
})
|
|
66298
66932
|
);
|
|
66933
|
+
} else {
|
|
66934
|
+
liveSymbols = linkedMapSymbols(guestLinkLines(mapPath));
|
|
66299
66935
|
}
|
|
66300
66936
|
const ledger = createGuestImageLedger({
|
|
66301
66937
|
images: plan.images.map((image) => ({
|
|
@@ -66304,7 +66940,7 @@ function linkGuestImages(options2) {
|
|
|
66304
66940
|
})),
|
|
66305
66941
|
callers: plan.callers,
|
|
66306
66942
|
symbols: plan.symbols,
|
|
66307
|
-
liveSymbols
|
|
66943
|
+
liveSymbols,
|
|
66308
66944
|
commandLineSymbols: commandLineSymbols(args),
|
|
66309
66945
|
directBindings: plan.directBindings,
|
|
66310
66946
|
registerAppTables: sdkCallers !== void 0,
|
|
@@ -66436,7 +67072,8 @@ function linkGuestImages(options2) {
|
|
|
66436
67072
|
const selectedInputs = selectedGuestManifestInputs(
|
|
66437
67073
|
plan,
|
|
66438
67074
|
selected,
|
|
66439
|
-
projection.identities
|
|
67075
|
+
projection.identities,
|
|
67076
|
+
readSelected
|
|
66440
67077
|
);
|
|
66441
67078
|
const images = projection.images.map(
|
|
66442
67079
|
(image) => createGuestImageManifest({
|
|
@@ -66446,6 +67083,9 @@ function linkGuestImages(options2) {
|
|
|
66446
67083
|
regions: []
|
|
66447
67084
|
})
|
|
66448
67085
|
);
|
|
67086
|
+
objectBytes.clear();
|
|
67087
|
+
memberBytes.clear();
|
|
67088
|
+
archives.clear();
|
|
66449
67089
|
if (!discoveryRegions) throw new Error("guest projection layout object missing");
|
|
66450
67090
|
const regionsBefore = discoveryRegions;
|
|
66451
67091
|
const ledgerPieces = guestProjectionRegionCapacity([import_node_fs63.default.readFileSync(ledgerObject)], 0);
|
|
@@ -66539,10 +67179,47 @@ ${changed2.join("\n")}`
|
|
|
66539
67179
|
}
|
|
66540
67180
|
function linkedMapSymbols(lines) {
|
|
66541
67181
|
const names = /* @__PURE__ */ new Set();
|
|
66542
|
-
const symbol2 = /^ +\S+ +[0-9a-f]+ +[0-9a-f]+ {9,}([^\s/<]\S*)/;
|
|
66543
67182
|
for (const line of lines) {
|
|
66544
|
-
const
|
|
66545
|
-
if (
|
|
67183
|
+
const length = line.length;
|
|
67184
|
+
if (length < 15 || line.charCodeAt(0) !== 32) continue;
|
|
67185
|
+
let pos = 1;
|
|
67186
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
67187
|
+
const c1 = pos;
|
|
67188
|
+
while (pos < length) {
|
|
67189
|
+
const ch = line.charCodeAt(pos);
|
|
67190
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
67191
|
+
pos++;
|
|
67192
|
+
}
|
|
67193
|
+
if (pos === c1 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
67194
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
67195
|
+
const c2 = pos;
|
|
67196
|
+
while (pos < length) {
|
|
67197
|
+
const ch = line.charCodeAt(pos);
|
|
67198
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
67199
|
+
pos++;
|
|
67200
|
+
}
|
|
67201
|
+
if (pos === c2 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
67202
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
67203
|
+
const c3 = pos;
|
|
67204
|
+
while (pos < length) {
|
|
67205
|
+
const ch = line.charCodeAt(pos);
|
|
67206
|
+
if (!(ch >= 48 && ch <= 57 || ch >= 97 && ch <= 102)) break;
|
|
67207
|
+
pos++;
|
|
67208
|
+
}
|
|
67209
|
+
if (pos === c3 || pos >= length || line.charCodeAt(pos) !== 32) continue;
|
|
67210
|
+
const sStart = pos;
|
|
67211
|
+
while (pos < length && line.charCodeAt(pos) === 32) pos++;
|
|
67212
|
+
if (pos - sStart < 9 || pos >= length) continue;
|
|
67213
|
+
const first = line.charCodeAt(pos);
|
|
67214
|
+
if (first === 47 || first === 60 || first === 32 || first >= 9 && first <= 13)
|
|
67215
|
+
continue;
|
|
67216
|
+
let end = pos + 1;
|
|
67217
|
+
while (end < length) {
|
|
67218
|
+
const ch = line.charCodeAt(end);
|
|
67219
|
+
if (ch === 32 || ch >= 9 && ch <= 13) break;
|
|
67220
|
+
end++;
|
|
67221
|
+
}
|
|
67222
|
+
names.add(line.slice(pos, end));
|
|
66546
67223
|
}
|
|
66547
67224
|
return names;
|
|
66548
67225
|
}
|
|
@@ -66641,7 +67318,7 @@ function discoverGuestLinkInputs(options2) {
|
|
|
66641
67318
|
import_node_fs63.default.mkdirSync(options2.directory, { recursive: true });
|
|
66642
67319
|
const why = import_node_path61.default.join(options2.directory, "preselection-why.txt");
|
|
66643
67320
|
const response = import_node_path61.default.join(options2.directory, "preselection.rsp");
|
|
66644
|
-
const output = import_node_path61.default.join(options2.directory, "preselection.wasm");
|
|
67321
|
+
const output = process.platform !== "win32" ? "/dev/null" : import_node_path61.default.join(options2.directory, "preselection.wasm");
|
|
66645
67322
|
const flags = [
|
|
66646
67323
|
...withOutput(args, output, true),
|
|
66647
67324
|
...options2.objects,
|
|
@@ -66739,7 +67416,7 @@ function prepareGuestRuntimeInputs(options2) {
|
|
|
66739
67416
|
});
|
|
66740
67417
|
return { args, selected, originalSelection, archives, sdkProducts, archiveArtifacts };
|
|
66741
67418
|
}
|
|
66742
|
-
function selectedGuestSymbolInputs(plan, selected) {
|
|
67419
|
+
function selectedGuestSymbolInputs(plan, selected, readSelected) {
|
|
66743
67420
|
const artifacts = new Map(plan.artifacts.map((artifact) => [artifact.path, artifact]));
|
|
66744
67421
|
const archives = /* @__PURE__ */ new Map();
|
|
66745
67422
|
const symbols = /* @__PURE__ */ new Set();
|
|
@@ -66755,22 +67432,27 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
66755
67432
|
if (!artifact) throw new Error(`selected symbol input has no owner ${item.artifact}`);
|
|
66756
67433
|
let bytes;
|
|
66757
67434
|
let name3 = item.artifact;
|
|
66758
|
-
if (item.member === null)
|
|
66759
|
-
|
|
66760
|
-
|
|
66761
|
-
if (
|
|
66762
|
-
|
|
66763
|
-
|
|
66764
|
-
|
|
66765
|
-
)
|
|
66766
|
-
|
|
67435
|
+
if (item.member === null) {
|
|
67436
|
+
bytes = readSelected ? readSelected(item) : import_node_fs63.default.readFileSync(item.artifact);
|
|
67437
|
+
} else {
|
|
67438
|
+
if (readSelected) {
|
|
67439
|
+
bytes = readSelected(item);
|
|
67440
|
+
} else {
|
|
67441
|
+
let members2 = archives.get(item.artifact);
|
|
67442
|
+
if (!members2) {
|
|
67443
|
+
members2 = Map.groupBy(
|
|
67444
|
+
readArMembers(import_node_fs63.default.readFileSync(item.artifact)),
|
|
67445
|
+
(member) => member.name
|
|
67446
|
+
);
|
|
67447
|
+
archives.set(item.artifact, members2);
|
|
67448
|
+
}
|
|
67449
|
+
const matching2 = members2.get(item.member) ?? [];
|
|
67450
|
+
if (matching2.length !== 1)
|
|
67451
|
+
throw new Error(
|
|
67452
|
+
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
67453
|
+
);
|
|
67454
|
+
bytes = matching2[0].bytes;
|
|
66767
67455
|
}
|
|
66768
|
-
const matching2 = members2.get(item.member) ?? [];
|
|
66769
|
-
if (matching2.length !== 1)
|
|
66770
|
-
throw new Error(
|
|
66771
|
-
`ambiguous selected symbol input ${item.artifact}(${item.member})`
|
|
66772
|
-
);
|
|
66773
|
-
bytes = matching2[0].bytes;
|
|
66774
67456
|
name3 += `(${item.member})`;
|
|
66775
67457
|
}
|
|
66776
67458
|
if (owners.has(name3)) throw new Error(`duplicate selected symbol input ${name3}`);
|
|
@@ -66783,9 +67465,9 @@ function selectedGuestSymbolInputs(plan, selected) {
|
|
|
66783
67465
|
for (const symbol2 of names.tags) tags.add(symbol2);
|
|
66784
67466
|
for (const symbol2 of names.defined) {
|
|
66785
67467
|
definitions.add(symbol2);
|
|
66786
|
-
|
|
67468
|
+
let objects = definitionObjects.get(symbol2);
|
|
67469
|
+
if (!objects) definitionObjects.set(symbol2, objects = /* @__PURE__ */ new Set());
|
|
66787
67470
|
objects.add(name3);
|
|
66788
|
-
definitionObjects.set(symbol2, objects);
|
|
66789
67471
|
}
|
|
66790
67472
|
}
|
|
66791
67473
|
return {
|
|
@@ -66806,7 +67488,7 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
66806
67488
|
if (!symbols.length) return { bindings: [], directBindings: [] };
|
|
66807
67489
|
import_node_fs63.default.mkdirSync(options2.directory, { recursive: true });
|
|
66808
67490
|
const response = import_node_path61.default.join(options2.directory, "scope-trace.rsp");
|
|
66809
|
-
const output = import_node_path61.default.join(options2.directory, "scope-trace.wasm");
|
|
67491
|
+
const output = process.platform !== "win32" ? "/dev/null" : import_node_path61.default.join(options2.directory, "scope-trace.wasm");
|
|
66810
67492
|
const args = [
|
|
66811
67493
|
...withOutput(normalizedGuestLinkArgs(options2.args), output, true),
|
|
66812
67494
|
...options2.objects,
|
|
@@ -66824,55 +67506,76 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
66824
67506
|
import_node_fs63.default.closeSync(traceOutput);
|
|
66825
67507
|
}
|
|
66826
67508
|
const records = /* @__PURE__ */ new Map();
|
|
66827
|
-
const
|
|
66828
|
-
const
|
|
66829
|
-
|
|
66830
|
-
|
|
66831
|
-
|
|
66832
|
-
|
|
66833
|
-
const
|
|
66834
|
-
|
|
66835
|
-
|
|
66836
|
-
|
|
66837
|
-
|
|
67509
|
+
for (const line of guestLinkLines(tracePath)) {
|
|
67510
|
+
const refSep = line.lastIndexOf(": reference to ");
|
|
67511
|
+
const defSep = line.lastIndexOf(": definition of ");
|
|
67512
|
+
if (refSep < 0 && defSep < 0) continue;
|
|
67513
|
+
const isRef = refSep > defSep;
|
|
67514
|
+
const sep4 = isRef ? refSep : defSep;
|
|
67515
|
+
const symbol2 = line.slice(sep4 + (isRef ? 15 : 16));
|
|
67516
|
+
if (!requested.has(symbol2) || options2.hostImports.has(symbol2)) continue;
|
|
67517
|
+
let record6 = records.get(symbol2);
|
|
67518
|
+
if (!record6) {
|
|
67519
|
+
record6 = {
|
|
67520
|
+
references: /* @__PURE__ */ new Map(),
|
|
67521
|
+
providers: /* @__PURE__ */ new Map(),
|
|
67522
|
+
physicalModule: false
|
|
67523
|
+
};
|
|
67524
|
+
records.set(symbol2, record6);
|
|
67525
|
+
}
|
|
67526
|
+
const object8 = line.slice(0, sep4);
|
|
66838
67527
|
if (object8 === "<internal>") {
|
|
66839
|
-
if (
|
|
67528
|
+
if (!isRef) record6.physicalModule = true;
|
|
66840
67529
|
} else {
|
|
66841
67530
|
const image = options2.owners.get(object8);
|
|
66842
67531
|
if (image === void 0)
|
|
66843
67532
|
throw new Error(`traced guest object has no owner ${object8}`);
|
|
66844
|
-
(
|
|
66845
|
-
object8,
|
|
66846
|
-
image
|
|
66847
|
-
);
|
|
67533
|
+
(isRef ? record6.references : record6.providers).set(object8, image);
|
|
66848
67534
|
}
|
|
66849
|
-
|
|
66850
|
-
};
|
|
66851
|
-
for (const line of guestLinkLines(tracePath)) consume(line);
|
|
67535
|
+
}
|
|
66852
67536
|
const callers = new Map(options2.callers.map((caller) => [caller.image, caller.next]));
|
|
67537
|
+
const callerSets = new Map(
|
|
67538
|
+
options2.callers.map((caller) => [caller.image, new Set(caller.next)])
|
|
67539
|
+
);
|
|
67540
|
+
const rootScope = callerSets.get(0);
|
|
66853
67541
|
const result = [];
|
|
66854
67542
|
const directBindings = [];
|
|
66855
67543
|
for (const symbol2 of symbols) {
|
|
66856
67544
|
const record6 = records.get(symbol2);
|
|
66857
67545
|
if (!record6 || !record6.references.size) continue;
|
|
66858
67546
|
if (!record6.providers.size && options2.hostImports.has(symbol2)) continue;
|
|
66859
|
-
const startupReferences = [
|
|
66860
|
-
|
|
66861
|
-
|
|
66862
|
-
const
|
|
66863
|
-
|
|
66864
|
-
|
|
67547
|
+
const startupReferences = [];
|
|
67548
|
+
const otherReferences = [];
|
|
67549
|
+
let allWeakRefs = true;
|
|
67550
|
+
for (const [object8, caller] of record6.references) {
|
|
67551
|
+
const isWeakRef = options2.weakReferences.get(object8)?.has(symbol2) === true;
|
|
67552
|
+
if (!isWeakRef) allWeakRefs = false;
|
|
67553
|
+
if (isWeakRef && options2.startupObjects.has(object8)) {
|
|
67554
|
+
startupReferences.push([object8, caller]);
|
|
67555
|
+
} else {
|
|
67556
|
+
otherReferences.push([object8, caller]);
|
|
67557
|
+
}
|
|
67558
|
+
}
|
|
66865
67559
|
for (const [, caller] of startupReferences)
|
|
66866
67560
|
if (!callers.has(caller))
|
|
66867
67561
|
throw new Error(`guest image has no caller scope ${caller}`);
|
|
66868
67562
|
if (startupReferences.length && !record6.physicalModule) {
|
|
66869
|
-
const
|
|
66870
|
-
|
|
67563
|
+
const candidates2 = options2.definitionObjects.get(symbol2);
|
|
67564
|
+
const candidateSize = candidates2?.size ?? 0;
|
|
67565
|
+
if (candidateSize > 1 || record6.providers.size > 1)
|
|
66871
67566
|
throw new Error(`ambiguous startup provider ${symbol2}`);
|
|
66872
|
-
|
|
66873
|
-
|
|
67567
|
+
let unproven = candidateSize !== record6.providers.size;
|
|
67568
|
+
if (!unproven && candidates2) {
|
|
67569
|
+
for (const object8 of record6.providers.keys()) {
|
|
67570
|
+
if (!candidates2.has(object8)) {
|
|
67571
|
+
unproven = true;
|
|
67572
|
+
break;
|
|
67573
|
+
}
|
|
67574
|
+
}
|
|
67575
|
+
}
|
|
67576
|
+
if (unproven) throw new Error(`unproven startup provider ${symbol2}`);
|
|
66874
67577
|
if (record6.providers.size === 1) {
|
|
66875
|
-
const [providerObject, providerImage] =
|
|
67578
|
+
const [providerObject, providerImage] = record6.providers.entries().next().value;
|
|
66876
67579
|
if (options2.weakDefinitions.get(providerObject)?.has(symbol2))
|
|
66877
67580
|
throw new Error(`weak startup provider ${symbol2}`);
|
|
66878
67581
|
for (const [object8] of startupReferences)
|
|
@@ -66880,28 +67583,34 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
66880
67583
|
}
|
|
66881
67584
|
if (!otherReferences.length) continue;
|
|
66882
67585
|
}
|
|
66883
|
-
if (!record6.providers.size && !record6.physicalModule &&
|
|
66884
|
-
(object8) => options2.weakReferences.get(object8)?.has(symbol2)
|
|
66885
|
-
))
|
|
66886
|
-
continue;
|
|
67586
|
+
if (!record6.providers.size && !record6.physicalModule && allWeakRefs) continue;
|
|
66887
67587
|
const providerImages = new Set(record6.providers.values());
|
|
66888
|
-
const
|
|
66889
|
-
|
|
67588
|
+
const candidates = options2.definitionObjects.get(symbol2);
|
|
67589
|
+
const copyImages = /* @__PURE__ */ new Set();
|
|
67590
|
+
const strongImages = /* @__PURE__ */ new Set();
|
|
67591
|
+
let weakDefinerImages;
|
|
67592
|
+
if (candidates) {
|
|
67593
|
+
for (const object8 of candidates) {
|
|
66890
67594
|
const image = options2.owners.get(object8);
|
|
66891
|
-
|
|
67595
|
+
if (image === void 0) continue;
|
|
67596
|
+
copyImages.add(image);
|
|
67597
|
+
if (options2.weakDefinitions.get(object8)?.has(symbol2)) {
|
|
67598
|
+
;
|
|
67599
|
+
(weakDefinerImages ??= /* @__PURE__ */ new Set()).add(image);
|
|
67600
|
+
} else {
|
|
67601
|
+
strongImages.add(image);
|
|
67602
|
+
}
|
|
66892
67603
|
}
|
|
66893
|
-
|
|
66894
|
-
const copyImages = new Set(copies.map((copy) => copy.image));
|
|
66895
|
-
const strongImages = new Set(
|
|
66896
|
-
copies.filter((copy) => !copy.weak).map((copy) => copy.image)
|
|
66897
|
-
);
|
|
67604
|
+
}
|
|
66898
67605
|
const interposed = !record6.physicalModule && copyImages.size > 1;
|
|
66899
67606
|
const providerCount = interposed ? 1 : providerImages.size + Number(record6.physicalModule);
|
|
66900
67607
|
if (!providerCount) continue;
|
|
66901
67608
|
if (providerCount !== 1)
|
|
66902
67609
|
throw new Error(`guest symbol has ambiguous provider ${symbol2}`);
|
|
66903
|
-
const scopedReferences = record6.physicalModule ?
|
|
66904
|
-
const
|
|
67610
|
+
const scopedReferences = record6.physicalModule ? record6.references : otherReferences;
|
|
67611
|
+
const firstProviderImage = providerImages.values().next().value;
|
|
67612
|
+
const uniqueProvider = strongImages.size > 1 ? void 0 : strongImages.values().next().value ?? firstProviderImage;
|
|
67613
|
+
let interposedByCaller;
|
|
66905
67614
|
for (const [object8, caller] of scopedReferences) {
|
|
66906
67615
|
const scope2 = callers.get(caller);
|
|
66907
67616
|
if (!scope2) throw new Error(`guest image has no caller scope ${caller}`);
|
|
@@ -66909,18 +67618,35 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
66909
67618
|
result.push({ symbol: symbol2, caller, provider: { kind: "physical-module" } });
|
|
66910
67619
|
continue;
|
|
66911
67620
|
}
|
|
66912
|
-
|
|
67621
|
+
let provider;
|
|
67622
|
+
if (interposed) {
|
|
67623
|
+
if (interposedByCaller?.has(caller)) {
|
|
67624
|
+
provider = interposedByCaller.get(caller);
|
|
67625
|
+
} else {
|
|
67626
|
+
if (copyImages.has(caller)) {
|
|
67627
|
+
provider = caller;
|
|
67628
|
+
} else {
|
|
67629
|
+
for (const image of scope2) {
|
|
67630
|
+
if (copyImages.has(image)) {
|
|
67631
|
+
provider = image;
|
|
67632
|
+
break;
|
|
67633
|
+
}
|
|
67634
|
+
}
|
|
67635
|
+
if (provider === void 0) provider = uniqueProvider;
|
|
67636
|
+
}
|
|
67637
|
+
;
|
|
67638
|
+
(interposedByCaller ??= /* @__PURE__ */ new Map()).set(caller, provider);
|
|
67639
|
+
}
|
|
67640
|
+
} else {
|
|
67641
|
+
provider = firstProviderImage;
|
|
67642
|
+
}
|
|
66913
67643
|
if (provider === void 0) {
|
|
66914
67644
|
if (options2.weakReferences.get(object8)?.has(symbol2)) continue;
|
|
66915
67645
|
throw new Error(`guest scope ${caller} omits every provider of ${symbol2}`);
|
|
66916
67646
|
}
|
|
66917
67647
|
if (caller === provider) continue;
|
|
66918
|
-
if (
|
|
66919
|
-
|
|
66920
|
-
))
|
|
66921
|
-
continue;
|
|
66922
|
-
if (!scope2.includes(provider)) {
|
|
66923
|
-
const candidates = options2.definitionObjects.get(symbol2) ?? /* @__PURE__ */ new Set();
|
|
67648
|
+
if (weakDefinerImages?.has(caller)) continue;
|
|
67649
|
+
if (!callerSets.get(caller).has(provider)) {
|
|
66924
67650
|
const traced = [...record6.providers.keys()];
|
|
66925
67651
|
const strongTraced = traced.filter(
|
|
66926
67652
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
@@ -66928,16 +67654,17 @@ function verifyGuestSymbolScopes(options2) {
|
|
|
66928
67654
|
const providers = strongTraced.length === 1 ? strongTraced : traced;
|
|
66929
67655
|
if (options2.weakReferences.get(object8)?.has(symbol2) && !providers.some((provider2) => options2.systemProviders.has(provider2)))
|
|
66930
67656
|
continue;
|
|
66931
|
-
const
|
|
67657
|
+
const candidateSet = candidates ?? /* @__PURE__ */ new Set();
|
|
67658
|
+
const equivalentCopies = providers.length === 1 && candidateSet.has(providers[0]) && [...candidateSet].every(
|
|
66932
67659
|
(definer) => options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
66933
67660
|
);
|
|
66934
|
-
const strongCandidates = [...
|
|
67661
|
+
const strongCandidates = [...candidateSet].filter(
|
|
66935
67662
|
(definer) => !options2.weakDefinitions.get(definer)?.has(symbol2)
|
|
66936
67663
|
);
|
|
66937
|
-
const soleCandidate =
|
|
66938
|
-
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !
|
|
67664
|
+
const soleCandidate = candidateSet.size === 1 || strongCandidates.length === 1 && strongCandidates[0] === providers[0];
|
|
67665
|
+
if (!equivalentCopies && (!soleCandidate || providers.length !== 1 || !candidateSet.has(providers[0]) || !(options2.systemProviders.has(providers[0]) || // a strong undefined reference binds through the process global
|
|
66939
67666
|
// scope, the root image and its dependency closure, as in elf.
|
|
66940
|
-
provider === 0 ||
|
|
67667
|
+
provider === 0 || rootScope?.has(provider) || !options2.weakReferences.get(object8)?.has(symbol2) && options2.frameworkProviders.get(object8)?.has(providers[0]))))
|
|
66941
67668
|
throw new Error(
|
|
66942
67669
|
`guest scope ${caller} omits traced provider ${provider} for ${symbol2}`
|
|
66943
67670
|
);
|
|
@@ -73071,9 +73798,9 @@ async function compileGuestLink(options2) {
|
|
|
73071
73798
|
}
|
|
73072
73799
|
};
|
|
73073
73800
|
},
|
|
73074
|
-
resolvePlan: (selected, plan) => {
|
|
73801
|
+
resolvePlan: (selected, plan, readSelected) => {
|
|
73075
73802
|
if (!prepared) throw new Error("guest runtime selection is unavailable");
|
|
73076
|
-
const scope2 = selectedGuestSymbolInputs(plan, selected);
|
|
73803
|
+
const scope2 = selectedGuestSymbolInputs(plan, selected, readSelected);
|
|
73077
73804
|
const owners = new Map(scope2.owners);
|
|
73078
73805
|
owners.set(import_node_path72.default.join(directory2, "projection-discovery.o"), 0);
|
|
73079
73806
|
const providersByImage = Map.groupBy(scope2.owners, ([, image]) => image);
|
|
@@ -80749,7 +81476,7 @@ ${wasmThreadLinkFlags.map((flag) => ` "-Xlinker", ${JSON.stringify(flag
|
|
|
80749
81476
|
REACTOR_FLAG = '"-Xclang-linker", "-mexec-model=reactor",\n';
|
|
80750
81477
|
MULTI_MANIFEST_VERSION = 76;
|
|
80751
81478
|
SWIFT_HEADER_PRODUCTS_TARGET = "PeachHeaderProducts";
|
|
80752
|
-
compilerSourceDigest = true ? "
|
|
81479
|
+
compilerSourceDigest = true ? "7b91fa4405159335b5484c82700e001e4c27abf15621b724ea8af4edea693f66" : swiftCompilerSourceDigest2(__sootsim_import_meta_dirname);
|
|
80753
81480
|
nativeCxxCompilerFlags = ["-fno-cxx-modules"];
|
|
80754
81481
|
MODULE_MAP_RESPONSE_FILE_RUN = 16;
|
|
80755
81482
|
cFlagArray = (flags) => JSON.stringify(withoutGlogModuleMap(flags));
|
|
@@ -137793,7 +138520,7 @@ function eventBindings(name3, source) {
|
|
|
137793
138520
|
});
|
|
137794
138521
|
continue;
|
|
137795
138522
|
}
|
|
137796
|
-
const call = /emitter->(\w+)\(
|
|
138523
|
+
const call = /emitter->(\w+)\(\s*\{([^}]*)\}\s*\)/.exec(body);
|
|
137797
138524
|
if (!call) throw new Error(`${name3}: unmapped event block ${property2}`);
|
|
137798
138525
|
const fields = [...call[2].matchAll(/\.(\w+) = ([^,]+)/g)].map(
|
|
137799
138526
|
([, field2, expression]) => {
|
|
@@ -137835,18 +138562,20 @@ function configuration(name3, source) {
|
|
|
137835
138562
|
}
|
|
137836
138563
|
function arrayBindings(name3, body) {
|
|
137837
138564
|
const bindings = /* @__PURE__ */ new Map();
|
|
137838
|
-
for (const [, prop, element] of body.matchAll(
|
|
137839
|
-
/for \(const auto &
|
|
138565
|
+
for (const [, item, prop, variable, element] of body.matchAll(
|
|
138566
|
+
/for \(const auto &(\w+) : next\.(\w+)\) \[(\w+) addObject:(.*?)\];/g
|
|
137840
138567
|
)) {
|
|
137841
|
-
if (element ===
|
|
137842
|
-
bindings.set(prop, []);
|
|
138568
|
+
if (element === `RCTNSStringFromString(${item})`) {
|
|
138569
|
+
bindings.set(variable, { prop, fields: [] });
|
|
137843
138570
|
continue;
|
|
137844
138571
|
}
|
|
137845
138572
|
const fields = [
|
|
137846
|
-
...element.matchAll(
|
|
138573
|
+
...element.matchAll(
|
|
138574
|
+
new RegExp(`@"(\\w+)" ?: (RCTNSStringFromString|@)\\(${item}\\.\\w+\\)`, "g")
|
|
138575
|
+
)
|
|
137847
138576
|
].map(([, name4, kind]) => ({ name: name4, defaultValue: kind === "@" ? 0 : "" }));
|
|
137848
138577
|
if (!fields.length) throw new Error(`${name3}: unmapped array ${prop}`);
|
|
137849
|
-
bindings.set(prop, fields);
|
|
138578
|
+
bindings.set(variable, { prop, fields });
|
|
137850
138579
|
}
|
|
137851
138580
|
return bindings;
|
|
137852
138581
|
}
|
|
@@ -137866,13 +138595,17 @@ function componentViews(one, selected) {
|
|
|
137866
138595
|
return [{ name: name3, props, commands, source, file: (0, import_node_path151.join)(folder, file) }];
|
|
137867
138596
|
});
|
|
137868
138597
|
}
|
|
137869
|
-
function swiftGuestControls(one, names) {
|
|
138598
|
+
function swiftGuestControls(one, names, linkedGroups) {
|
|
137870
138599
|
const watched = [(0, import_node_path151.join)(one, "schema.json")];
|
|
137871
138600
|
const defines = /* @__PURE__ */ new Set();
|
|
137872
138601
|
const views = componentViews(one, names);
|
|
137873
|
-
const
|
|
138602
|
+
const groupDefines = linkedGroups && new Set(linkedGroups.map((group) => `ONE_GROUP_${group.toUpperCase()}`));
|
|
138603
|
+
const entries2 = views.flatMap(({ name: name3, props, source, file }) => {
|
|
137874
138604
|
const { viewClass, guard, update } = configuration(name3, source);
|
|
137875
|
-
if (guard)
|
|
138605
|
+
if (guard) {
|
|
138606
|
+
if (groupDefines && !groupDefines.has(guard)) return [];
|
|
138607
|
+
defines.add(guard);
|
|
138608
|
+
}
|
|
137876
138609
|
const arrays = arrayBindings(name3, update);
|
|
137877
138610
|
const swift = (0, import_node_path151.join)((0, import_node_path151.dirname)(file), viewClass + ".swift");
|
|
137878
138611
|
const declaration = (0, import_node_fs150.readFileSync)(swift, "utf8");
|
|
@@ -137894,38 +138627,41 @@ function swiftGuestControls(one, names) {
|
|
|
137894
138627
|
}
|
|
137895
138628
|
const withLabel = /^(\w+)With([A-Z])(\w*)$/.exec(first);
|
|
137896
138629
|
const args = selector.map(({ label, expression }, index) => {
|
|
137897
|
-
const
|
|
138630
|
+
const array9 = arrays.get(expression);
|
|
137898
138631
|
let value;
|
|
137899
138632
|
if (expression === "OneNativeStyleDictionary(next.swiftStyle)") value = "style";
|
|
137900
138633
|
else if (expression === "boundedHeight")
|
|
137901
138634
|
value = 'spec["boundedHeight"] as? Bool ?? false';
|
|
137902
138635
|
else if (/^@"[^"]*"$/.test(expression)) value = expression.slice(1);
|
|
137903
|
-
else if (fields
|
|
137904
|
-
const entries3 = fields.map(
|
|
137905
|
-
({ name: name4, defaultValue: defaultValue2 }) => `"${name4}": row["${name4}"]
|
|
138636
|
+
else if (array9?.fields.length) {
|
|
138637
|
+
const entries3 = array9.fields.map(
|
|
138638
|
+
({ name: name4, defaultValue: defaultValue2 }) => `"${name4}": row["${name4}"] as? ${typeof defaultValue2 === "number" ? "Double" : "String"} ?? ${JSON.stringify(defaultValue2)}`
|
|
137906
138639
|
).join(", ");
|
|
137907
|
-
value = `(spec["${
|
|
137908
|
-
} else if (
|
|
138640
|
+
value = `(spec["${array9.prop}"] as? [Spec] ?? []).map { row in [${entries3}] }`;
|
|
138641
|
+
} else if (array9) value = `spec["${array9.prop}"] as? [String] ?? []`;
|
|
137909
138642
|
else {
|
|
137910
|
-
const prop = /\bnext\.(\w+)/.exec(expression)?.[1];
|
|
138643
|
+
const prop = /\bnext\.(\w+)/.exec(expression)?.[1] ?? "";
|
|
137911
138644
|
const types2 = {
|
|
137912
|
-
string:
|
|
137913
|
-
boolean: "Bool
|
|
137914
|
-
Double: "Double
|
|
137915
|
-
Int32: "Int
|
|
138645
|
+
string: ["String", ""],
|
|
138646
|
+
boolean: ["Bool", false],
|
|
138647
|
+
Double: ["Double", 0],
|
|
138648
|
+
Int32: ["Int", 0]
|
|
137916
138649
|
};
|
|
137917
|
-
const
|
|
138650
|
+
const field2 = props[prop];
|
|
138651
|
+
const type = field2?.type;
|
|
137918
138652
|
if (type === "ColorValue") value = `spec["${prop}"].flatMap(oneControlColor)`;
|
|
137919
|
-
else if (type && types2[type])
|
|
137920
|
-
|
|
138653
|
+
else if (type && types2[type]) {
|
|
138654
|
+
const [swiftType, implicitDefault] = types2[type];
|
|
138655
|
+
value = `spec["${prop}"] as? ${swiftType} ?? ${JSON.stringify(field2.default ?? implicitDefault)}`;
|
|
138656
|
+
} else throw new Error(`${name3}: unmapped guest argument ${expression}`);
|
|
137921
138657
|
}
|
|
137922
138658
|
const argLabel = index ? label : withLabel ? withLabel[2].toLowerCase() + withLabel[3] : "";
|
|
137923
138659
|
return argLabel ? argLabel + ": " + value : value;
|
|
137924
138660
|
});
|
|
137925
138661
|
const call = `view.${withLabel?.[1] ?? first}(${args.join(", ")})`;
|
|
137926
|
-
const array8 = selector[0].expression;
|
|
138662
|
+
const array8 = arrays.get(selector[0].expression)?.prop;
|
|
137927
138663
|
lines.push(
|
|
137928
|
-
|
|
138664
|
+
array8 ? ` if previous == nil || (spec["${array8}"] as? NSArray) != (previous?["${array8}"] as? NSArray) { ${call} }` : ` ${call}`
|
|
137929
138665
|
);
|
|
137930
138666
|
}
|
|
137931
138667
|
for (const { property: property2, parameters, fields, event, sync } of eventBindings(
|
|
@@ -138030,14 +138766,13 @@ function excludedGroupSource(source, defines) {
|
|
|
138030
138766
|
}
|
|
138031
138767
|
return false;
|
|
138032
138768
|
}
|
|
138033
|
-
async function oneNativeControlsPackage(appRoot) {
|
|
138769
|
+
async function oneNativeControlsPackage(appRoot, linkedGroups) {
|
|
138034
138770
|
const iosDir = resolveOneNativeAppleIosDir(appRoot);
|
|
138035
|
-
const generated = swiftGuestControls(
|
|
138036
|
-
|
|
138037
|
-
"OneNativeLabel",
|
|
138038
|
-
|
|
138039
|
-
|
|
138040
|
-
]);
|
|
138771
|
+
const generated = swiftGuestControls(
|
|
138772
|
+
import_node_path152.default.dirname(iosDir),
|
|
138773
|
+
["OneNativeButton", "OneNativeLabel", "OneNativeText", "OneNativeImage"],
|
|
138774
|
+
linkedGroups
|
|
138775
|
+
);
|
|
138041
138776
|
const sources = {};
|
|
138042
138777
|
const paths = /* @__PURE__ */ new Map();
|
|
138043
138778
|
const defines = /* @__PURE__ */ new Set([...ONE_SDK_DEFINES, ...generated.defines]);
|
|
@@ -143170,7 +143905,7 @@ var init_nitro_superset = __esm({
|
|
|
143170
143905
|
init_nitroContract();
|
|
143171
143906
|
init_swift_standin_digest();
|
|
143172
143907
|
NITRO_SUPERSET_ENTRY_NAME = "superset";
|
|
143173
|
-
NITRO_COMPILER_DIGEST = true ? "
|
|
143908
|
+
NITRO_COMPILER_DIGEST = true ? "ffe0ab1580ebcb5a184764bfb3b3650342c8644057a95423913e7078c208f318" : nitroCompilerSourceDigest(__sootsim_import_meta_dirname, STANDIN_SOURCE_DIGEST2);
|
|
143174
143909
|
nitroSupersetLock = parseLock(nitro_superset_lock_default);
|
|
143175
143910
|
nitroSupersetKey = (inputs2) => nativeEntryKey({ ...inputs2, compiler: NITRO_COMPILER_DIGEST });
|
|
143176
143911
|
published3 = /* @__PURE__ */ new Map();
|
|
@@ -155877,8 +156612,14 @@ var init_privacy = __esm({
|
|
|
155877
156612
|
// ../peach-globals/src/event-identity.ts
|
|
155878
156613
|
function eventUuid(timestamp2 = Date.now()) {
|
|
155879
156614
|
const time = timestamp2.toString(16).padStart(12, "0");
|
|
155880
|
-
const
|
|
155881
|
-
|
|
156615
|
+
const bytes = crypto.getRandomValues(new Uint8Array(10));
|
|
156616
|
+
bytes[0] = bytes[0] & 15 | 112;
|
|
156617
|
+
bytes[2] = bytes[2] & 63 | 128;
|
|
156618
|
+
let hex = "";
|
|
156619
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
156620
|
+
hex += bytes[i].toString(16).padStart(2, "0");
|
|
156621
|
+
}
|
|
156622
|
+
return `${time.slice(0, 8)}-${time.slice(8)}-${hex.slice(0, 4)}-${hex.slice(4, 8)}-${hex.slice(8)}`;
|
|
155882
156623
|
}
|
|
155883
156624
|
var init_event_identity = __esm({
|
|
155884
156625
|
"../peach-globals/src/event-identity.ts"() {
|