fix(apple): validate physical slices and dylib platform compatibility

This commit is contained in:
morluto
2026-10-09 00:49:30 +08:00
parent 16f4609d68
commit 15f92f2988
15 changed files with 1019 additions and 95 deletions
+11
View File
@@ -10,6 +10,7 @@ export const LC = {
RPATH: 0x8000001c,
DYLD_ENVIRONMENT: 0x27,
CODE_SIGNATURE: 0x1d,
BUILD_VERSION: 0x32,
} as const;
export const CPU = {
@@ -75,6 +76,16 @@ export const codeSignatureCommand = (): Uint8Array => {
return bytes;
};
/** `build_version_command` carrying the producer's raw platform number. */
export const buildVersionCommand = (platform: number): Uint8Array => {
const bytes = new Uint8Array(24);
const view = new DataView(bytes.buffer);
view.setUint32(0, LC.BUILD_VERSION, true);
view.setUint32(4, bytes.length, true);
view.setUint32(8, platform, true);
return bytes;
};
/** A 64-bit (or 32-bit) little-endian Mach-O image made of the given commands. */
export const machoImage = (options: {
readonly cpu?: { readonly type: number; readonly subtype: number };