@isopodlabs/binary_libs 0.1.3 → 0.1.5
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/mach.d.ts +1 -1
- package/dist/mach.js +111 -55
- package/package.json +1 -1
package/dist/mach.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ declare class mach_stream extends binary.endianStream {
|
|
|
7
7
|
substream(offset: number, size?: number): mach_stream;
|
|
8
8
|
getmem(address: bigint, size: number): Uint8Array | Promise<Uint8Array> | undefined;
|
|
9
9
|
}
|
|
10
|
-
declare
|
|
10
|
+
export declare enum CMD {
|
|
11
11
|
SEGMENT = 1,// segment of this file to be mapped
|
|
12
12
|
SYMTAB = 2,// link-edit stab symbol table info
|
|
13
13
|
SYMSEG = 3,// link-edit gdb symbol table info (obsolete)
|
package/dist/mach.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.FATMachFile = exports.MachFile = void 0;
|
|
26
|
+
exports.FATMachFile = exports.MachFile = exports.CMD = void 0;
|
|
27
27
|
const binary = __importStar(require("@isopodlabs/binary"));
|
|
28
28
|
class mach_stream extends binary.endianStream {
|
|
29
29
|
base;
|
|
@@ -255,6 +255,62 @@ const fat_header = {
|
|
|
255
255
|
archs: binary.ArrayType(uint32, fat_arch)
|
|
256
256
|
};
|
|
257
257
|
const REQ_DYLD = 0x80000000;
|
|
258
|
+
var CMD;
|
|
259
|
+
(function (CMD) {
|
|
260
|
+
CMD[CMD["SEGMENT"] = 1] = "SEGMENT";
|
|
261
|
+
CMD[CMD["SYMTAB"] = 2] = "SYMTAB";
|
|
262
|
+
CMD[CMD["SYMSEG"] = 3] = "SYMSEG";
|
|
263
|
+
CMD[CMD["THREAD"] = 4] = "THREAD";
|
|
264
|
+
CMD[CMD["UNIXTHREAD"] = 5] = "UNIXTHREAD";
|
|
265
|
+
CMD[CMD["LOADFVMLIB"] = 6] = "LOADFVMLIB";
|
|
266
|
+
CMD[CMD["IDFVMLIB"] = 7] = "IDFVMLIB";
|
|
267
|
+
// IDENT = 0x08, // object identification info (obsolete)
|
|
268
|
+
CMD[CMD["FVMFILE"] = 9] = "FVMFILE";
|
|
269
|
+
// PREPAGE = 0x0a, // prepage command (internal use)
|
|
270
|
+
CMD[CMD["DYSYMTAB"] = 11] = "DYSYMTAB";
|
|
271
|
+
CMD[CMD["LOAD_DYLIB"] = 12] = "LOAD_DYLIB";
|
|
272
|
+
CMD[CMD["ID_DYLIB"] = 13] = "ID_DYLIB";
|
|
273
|
+
CMD[CMD["LOAD_DYLINKER"] = 14] = "LOAD_DYLINKER";
|
|
274
|
+
CMD[CMD["ID_DYLINKER"] = 15] = "ID_DYLINKER";
|
|
275
|
+
CMD[CMD["PREBOUND_DYLIB"] = 16] = "PREBOUND_DYLIB";
|
|
276
|
+
CMD[CMD["ROUTINES"] = 17] = "ROUTINES";
|
|
277
|
+
CMD[CMD["SUB_FRAMEWORK"] = 18] = "SUB_FRAMEWORK";
|
|
278
|
+
CMD[CMD["SUB_UMBRELLA"] = 19] = "SUB_UMBRELLA";
|
|
279
|
+
CMD[CMD["SUB_CLIENT"] = 20] = "SUB_CLIENT";
|
|
280
|
+
CMD[CMD["SUB_LIBRARY"] = 21] = "SUB_LIBRARY";
|
|
281
|
+
CMD[CMD["TWOLEVEL_HINTS"] = 22] = "TWOLEVEL_HINTS";
|
|
282
|
+
CMD[CMD["PREBIND_CKSUM"] = 23] = "PREBIND_CKSUM";
|
|
283
|
+
CMD[CMD["LOAD_WEAK_DYLIB"] = 2147483672] = "LOAD_WEAK_DYLIB";
|
|
284
|
+
CMD[CMD["SEGMENT_64"] = 25] = "SEGMENT_64";
|
|
285
|
+
CMD[CMD["ROUTINES_64"] = 26] = "ROUTINES_64";
|
|
286
|
+
CMD[CMD["UUID"] = 27] = "UUID";
|
|
287
|
+
CMD[CMD["RPATH"] = 2147483676] = "RPATH";
|
|
288
|
+
CMD[CMD["CODE_SIGNATURE"] = 29] = "CODE_SIGNATURE";
|
|
289
|
+
CMD[CMD["SEGMENT_SPLIT_INFO"] = 30] = "SEGMENT_SPLIT_INFO";
|
|
290
|
+
CMD[CMD["REEXPORT_DYLIB"] = 2147483679] = "REEXPORT_DYLIB";
|
|
291
|
+
CMD[CMD["LAZY_LOAD_DYLIB"] = 32] = "LAZY_LOAD_DYLIB";
|
|
292
|
+
CMD[CMD["ENCRYPTION_INFO"] = 33] = "ENCRYPTION_INFO";
|
|
293
|
+
CMD[CMD["DYLD_INFO"] = 34] = "DYLD_INFO";
|
|
294
|
+
CMD[CMD["DYLD_INFO_ONLY"] = 2147483682] = "DYLD_INFO_ONLY";
|
|
295
|
+
CMD[CMD["LOAD_UPWARD_DYLIB"] = 2147483683] = "LOAD_UPWARD_DYLIB";
|
|
296
|
+
CMD[CMD["VERSION_MIN_MACOSX"] = 36] = "VERSION_MIN_MACOSX";
|
|
297
|
+
CMD[CMD["VERSION_MIN_IPHONEOS"] = 37] = "VERSION_MIN_IPHONEOS";
|
|
298
|
+
CMD[CMD["FUNCTION_STARTS"] = 38] = "FUNCTION_STARTS";
|
|
299
|
+
CMD[CMD["DYLD_ENVIRONMENT"] = 39] = "DYLD_ENVIRONMENT";
|
|
300
|
+
CMD[CMD["MAIN"] = 2147483688] = "MAIN";
|
|
301
|
+
CMD[CMD["DATA_IN_CODE"] = 41] = "DATA_IN_CODE";
|
|
302
|
+
CMD[CMD["SOURCE_VERSION"] = 42] = "SOURCE_VERSION";
|
|
303
|
+
CMD[CMD["DYLIB_CODE_SIGN_DRS"] = 43] = "DYLIB_CODE_SIGN_DRS";
|
|
304
|
+
CMD[CMD["ENCRYPTION_INFO_64"] = 44] = "ENCRYPTION_INFO_64";
|
|
305
|
+
CMD[CMD["LINKER_OPTION"] = 45] = "LINKER_OPTION";
|
|
306
|
+
CMD[CMD["LINKER_OPTIMIZATION_HINT"] = 46] = "LINKER_OPTIMIZATION_HINT";
|
|
307
|
+
CMD[CMD["VERSION_MIN_TVOS"] = 47] = "VERSION_MIN_TVOS";
|
|
308
|
+
CMD[CMD["VERSION_MIN_WATCHOS"] = 48] = "VERSION_MIN_WATCHOS";
|
|
309
|
+
CMD[CMD["NOTE"] = 49] = "NOTE";
|
|
310
|
+
CMD[CMD["BUILD_VERSION"] = 50] = "BUILD_VERSION";
|
|
311
|
+
CMD[CMD["DYLD_EXPORTS_TRIE"] = 2147483699] = "DYLD_EXPORTS_TRIE";
|
|
312
|
+
CMD[CMD["DYLD_CHAINED_FIXUPS"] = 2147483700] = "DYLD_CHAINED_FIXUPS";
|
|
313
|
+
})(CMD || (exports.CMD = CMD = {}));
|
|
258
314
|
;
|
|
259
315
|
const str = {
|
|
260
316
|
get(s) {
|
|
@@ -810,94 +866,94 @@ function routines(bits) {
|
|
|
810
866
|
}
|
|
811
867
|
//const cmd_table : {[K in CMD]?: binary.TypeReader2} = {
|
|
812
868
|
const cmd_table = {
|
|
813
|
-
[
|
|
814
|
-
[
|
|
815
|
-
[
|
|
816
|
-
[
|
|
817
|
-
[
|
|
818
|
-
[
|
|
819
|
-
[
|
|
820
|
-
[
|
|
821
|
-
[
|
|
822
|
-
[
|
|
823
|
-
[
|
|
824
|
-
[
|
|
825
|
-
[
|
|
826
|
-
[
|
|
827
|
-
[
|
|
828
|
-
[
|
|
829
|
-
[
|
|
830
|
-
[
|
|
831
|
-
[
|
|
869
|
+
[CMD.SEGMENT]: segment(32),
|
|
870
|
+
[CMD.SEGMENT_64]: segment(64),
|
|
871
|
+
[CMD.LOADFVMLIB]: fvmlib,
|
|
872
|
+
[CMD.IDFVMLIB]: fvmlib,
|
|
873
|
+
[CMD.LOAD_DYLIB]: dylib,
|
|
874
|
+
[CMD.ID_DYLIB]: dylib,
|
|
875
|
+
[CMD.LOAD_WEAK_DYLIB]: dylib,
|
|
876
|
+
[CMD.REEXPORT_DYLIB]: dylib,
|
|
877
|
+
[CMD.LAZY_LOAD_DYLIB]: dylib,
|
|
878
|
+
[CMD.LOAD_UPWARD_DYLIB]: dylib,
|
|
879
|
+
[CMD.SUB_FRAMEWORK]: str,
|
|
880
|
+
[CMD.SUB_UMBRELLA]: str,
|
|
881
|
+
[CMD.SUB_CLIENT]: str,
|
|
882
|
+
[CMD.SUB_LIBRARY]: str,
|
|
883
|
+
[CMD.LOAD_DYLINKER]: str,
|
|
884
|
+
[CMD.ID_DYLINKER]: str,
|
|
885
|
+
[CMD.DYLD_ENVIRONMENT]: str,
|
|
886
|
+
[CMD.RPATH]: str,
|
|
887
|
+
[CMD.PREBOUND_DYLIB]: {
|
|
832
888
|
name: str,
|
|
833
889
|
nmodules: uint32,
|
|
834
890
|
linked_modules: str,
|
|
835
891
|
},
|
|
836
|
-
[
|
|
837
|
-
[
|
|
838
|
-
[
|
|
839
|
-
[
|
|
840
|
-
[
|
|
841
|
-
[
|
|
842
|
-
[
|
|
892
|
+
[CMD.THREAD]: thread_command,
|
|
893
|
+
[CMD.UNIXTHREAD]: thread_command,
|
|
894
|
+
[CMD.ROUTINES]: routines(32),
|
|
895
|
+
[CMD.ROUTINES_64]: routines(64),
|
|
896
|
+
[CMD.SYMTAB]: symtab,
|
|
897
|
+
[CMD.TWOLEVEL_HINTS]: count_table(hint),
|
|
898
|
+
[CMD.PREBIND_CKSUM]: {
|
|
843
899
|
cksum: uint32,
|
|
844
900
|
},
|
|
845
|
-
[
|
|
901
|
+
[CMD.UUID]: {
|
|
846
902
|
uuid: binary.Buffer(16),
|
|
847
903
|
},
|
|
848
|
-
[
|
|
849
|
-
[
|
|
850
|
-
[
|
|
851
|
-
[
|
|
852
|
-
[
|
|
853
|
-
[
|
|
854
|
-
[
|
|
855
|
-
[
|
|
856
|
-
[
|
|
904
|
+
[CMD.CODE_SIGNATURE]: blob,
|
|
905
|
+
[CMD.SEGMENT_SPLIT_INFO]: blob,
|
|
906
|
+
[CMD.FUNCTION_STARTS]: blobArray(binary.ULEB128),
|
|
907
|
+
[CMD.DATA_IN_CODE]: blobArray(data_in_code_entry),
|
|
908
|
+
[CMD.DYLIB_CODE_SIGN_DRS]: blob,
|
|
909
|
+
[CMD.LINKER_OPTIMIZATION_HINT]: blob,
|
|
910
|
+
[CMD.DYLD_EXPORTS_TRIE]: blob,
|
|
911
|
+
[CMD.DYLD_CHAINED_FIXUPS]: blob, //blobT(dyld_chained_fixups),
|
|
912
|
+
[CMD.ENCRYPTION_INFO]: {
|
|
857
913
|
cryptoff: uint32, // file offset of encrypted range
|
|
858
914
|
cryptsize: uint32, // file size of encrypted range
|
|
859
915
|
cryptid: uint32, // which enryption system, 0 means not-encrypted yet
|
|
860
916
|
},
|
|
861
|
-
[
|
|
917
|
+
[CMD.ENCRYPTION_INFO_64]: {
|
|
862
918
|
cryptoff: uint32, // file offset of encrypted range
|
|
863
919
|
cryptsize: uint32, // file size of encrypted range
|
|
864
920
|
cryptid: uint32, // which enryption system, 0 means not-encrypted yet
|
|
865
921
|
pad: uint32, // must be zero
|
|
866
922
|
},
|
|
867
|
-
[
|
|
868
|
-
[
|
|
869
|
-
[
|
|
870
|
-
[
|
|
871
|
-
[
|
|
872
|
-
[
|
|
873
|
-
[
|
|
923
|
+
[CMD.VERSION_MIN_MACOSX]: version_min,
|
|
924
|
+
[CMD.VERSION_MIN_IPHONEOS]: version_min,
|
|
925
|
+
[CMD.VERSION_MIN_TVOS]: version_min,
|
|
926
|
+
[CMD.VERSION_MIN_WATCHOS]: version_min,
|
|
927
|
+
[CMD.DYLD_INFO]: dyldinfo,
|
|
928
|
+
[CMD.DYLD_INFO_ONLY]: dyldinfo,
|
|
929
|
+
[CMD.SYMSEG]: blob, //OBSOLETE
|
|
874
930
|
// [CMD.IDENT]: {},//OBSOLETE
|
|
875
|
-
[
|
|
931
|
+
[CMD.FVMFILE]: {
|
|
876
932
|
name: str,
|
|
877
933
|
header_addr: uint32,
|
|
878
934
|
},
|
|
879
|
-
[
|
|
935
|
+
[CMD.MAIN]: {
|
|
880
936
|
entryoff: uint32, // file (__TEXT) offset of entry point
|
|
881
937
|
stacksize: uint32, // if not zero, initialize stack size
|
|
882
938
|
},
|
|
883
|
-
[
|
|
939
|
+
[CMD.SOURCE_VERSION]: {
|
|
884
940
|
version: binary.as(binary.UINT64_BE, binary.BitFields({ a: 24, b: 10, c: 10, d: 10, e: 10 })) // A.B.C.D.E packed as a24.b10.c10.d10.e10
|
|
885
941
|
},
|
|
886
|
-
[
|
|
942
|
+
[CMD.BUILD_VERSION]: {
|
|
887
943
|
platform: binary.asEnum(uint32, PLATFORM),
|
|
888
944
|
minos: version,
|
|
889
945
|
sdk: version,
|
|
890
946
|
tools: binary.objectWithNames(binary.ArrayType(uint32, { tool: binary.as(uint32, binary.Enum(TOOL)), version }), binary.field('tool')),
|
|
891
947
|
},
|
|
892
|
-
[
|
|
948
|
+
[CMD.LINKER_OPTION]: {
|
|
893
949
|
count: uint32, // number of strings following
|
|
894
950
|
},
|
|
895
|
-
[
|
|
951
|
+
[CMD.NOTE]: {
|
|
896
952
|
data_owner: fixed_string16, // owner name for this LC_NOTE
|
|
897
953
|
data: blob
|
|
898
954
|
},
|
|
899
955
|
// [CMD.PREPAGE]: {},
|
|
900
|
-
[
|
|
956
|
+
[CMD.DYSYMTAB]: {
|
|
901
957
|
localsym: index_table, // local symbols
|
|
902
958
|
extdefsym: index_table, // externally defined symbols
|
|
903
959
|
undefsym: index_table, // undefined symbols
|
|
@@ -956,7 +1012,7 @@ class MachFile {
|
|
|
956
1012
|
this.commands.push({ cmd: cmd.cmd, data: result });
|
|
957
1013
|
}
|
|
958
1014
|
this.header = h;
|
|
959
|
-
const funcs = this.getCommand(
|
|
1015
|
+
const funcs = this.getCommand(CMD.FUNCTION_STARTS);
|
|
960
1016
|
if (funcs) {
|
|
961
1017
|
const array = funcs.contents;
|
|
962
1018
|
const text = await this.getSegment('__TEXT');
|
|
@@ -973,9 +1029,9 @@ class MachFile {
|
|
|
973
1029
|
}
|
|
974
1030
|
getSegment(name) {
|
|
975
1031
|
for (const i of this.commands) {
|
|
976
|
-
if (i.cmd ===
|
|
1032
|
+
if (i.cmd === CMD.SEGMENT && i.data.segname === name)
|
|
977
1033
|
return i.data;
|
|
978
|
-
if (i.cmd ===
|
|
1034
|
+
if (i.cmd === CMD.SEGMENT_64 && i.data.segname === name)
|
|
979
1035
|
return i.data;
|
|
980
1036
|
;
|
|
981
1037
|
}
|
package/package.json
CHANGED