]> gitweb.factorcode.org Git - factor.git/commitdiff
macho: Update the structures for macho and add a unit test.
authorDoug Coleman <doug.coleman@gmail.com>
Mon, 25 Jun 2018 23:19:23 +0000 (16:19 -0700)
committerDoug Coleman <doug.coleman@gmail.com>
Tue, 26 Jun 2018 00:06:55 +0000 (17:06 -0700)
``vm-path dylib-exports`` passes on my machine now.

extra/macho/macho-tests.factor
extra/macho/macho.factor

index 76772f5bce18fa52262d45b44374cc6a94ceb1ad..d2616e8c26cadf62f4bf5f876153e53e9612631c 100644 (file)
@@ -32,3 +32,6 @@ cpu ppc? [
         ] with-mapped-macho
     ] unit-test
 ] unless
+
+! Throw an exception if the struct is not defined/handled
+{ } [ vm-path dylib-exports drop ] unit-test
index 06f49bc0b6ede933750b407f05ee59d2905b9cf4..83064ae9232e32b45978eadcb6df932645ae36ec 100644 (file)
@@ -128,6 +128,15 @@ CONSTANT: LC_LAZY_LOAD_DYLIB    0x20
 CONSTANT: LC_ENCRYPTION_INFO    0x21
 CONSTANT: LC_DYLD_INFO          0x22
 CONSTANT: LC_DYLD_INFO_ONLY     0x80000022
+CONSTANT: LC_LOAD_UPWARD_DYLIB 0x80000023
+CONSTANT: LC_VERSION_MIN_MACOSX 0x24
+CONSTANT: LC_VERSION_MIN_IPHONEOS 0x25
+CONSTANT: LC_FUNCTION_STARTS 0x26
+CONSTANT: LC_DYLD_ENVIRONMENT 0x27
+CONSTANT: LC_MAIN 0x80000028
+CONSTANT: LC_DATA_IN_CODE 0x29
+CONSTANT: LC_SOURCE_VERSION 0x2A
+CONSTANT: LC_DYLIB_CODE_SIGN_DRS 0x2B
 
 UNION-STRUCT: lc_str
     { offset    uint     }
@@ -448,6 +457,12 @@ STRUCT: dyld_info_command
     { export_off       uint }
     { export_size      uint } ;
 
+STRUCT: version_min_command
+    { cmd uint32_t }
+    { cmdsize uint32_t }
+    { version uint32_t }
+    { sdk uint32_t } ;
+
 CONSTANT: REBASE_TYPE_POINTER                     1
 CONSTANT: REBASE_TYPE_TEXT_ABSOLUTE32             2
 CONSTANT: REBASE_TYPE_TEXT_PCREL32                3
@@ -514,6 +529,22 @@ STRUCT: fvmfile_command
     { name           lc_str   }
     { header_addr    uint     } ;
 
+STRUCT: entry_point_command
+    { cmd uint32_t }
+    { cmdsize uint32_t }
+    { entryoff uint64_t }
+    { stacksize uint64_t } ;
+
+STRUCT: source_version_command
+    { cmd uint32_t }
+    { cmdsize uint32_t }
+    { version uint64_t } ;
+
+STRUCT: data_in_code_entry
+    { offset uint32_t }
+    { length uint16_t }
+    { kind uint16_t } ;
+
 ! machine.h
 CONSTANT: CPU_STATE_MAX       4
 CONSTANT: CPU_STATE_USER      0
@@ -881,6 +912,15 @@ TYPED: 64-bit? ( macho: mach_header_32/64 -- ? )
         { LC_SUB_CLIENT     [ sub_client_command     ] }
         { LC_DYLD_INFO      [ dyld_info_command      ] }
         { LC_DYLD_INFO_ONLY [ dyld_info_command      ] }
+        { LC_LOAD_UPWARD_DYLIB [ dylib_command ] }
+        { LC_VERSION_MIN_MACOSX [ version_min_command ] }
+        { LC_VERSION_MIN_IPHONEOS [ version_min_command ] }
+        { LC_FUNCTION_STARTS [ linkedit_data_command ] }
+        { LC_DYLD_ENVIRONMENT [ dylinker_command ] }
+        { LC_MAIN [ entry_point_command ] }
+        { LC_DATA_IN_CODE [ data_in_code_entry ] }
+        { LC_SOURCE_VERSION [ source_version_command ] }
+        { LC_DYLIB_CODE_SIGN_DRS [ linkedit_data_command ] }
     } case ;
 
 : read-command ( cmd -- next-cmd )