88from typing import Callable
99from unicorn import UcError
1010
11+ from qiling import Qiling
1112from qiling .os .posix .posix import QlOsPosix
1213from qiling .os .qnx .const import NTO_SIDE_CHANNEL , SYSMGR_PID , SYSMGR_CHID , SYSMGR_COID
1314from qiling .os .qnx .helpers import QnxConn
2021from qiling .os .posix .posix import QlOsPosix
2122
2223class QlOsQnx (QlOsPosix ):
23- def __init__ (self , ql ):
24+ def __init__ (self , ql : Qiling ):
2425 super (QlOsQnx , self ).__init__ (ql )
2526
2627 self .ql = ql
@@ -60,11 +61,12 @@ def load(self):
6061 if self .ql .code :
6162 return
6263
63- if self .ql .archtype != QL_ARCH .ARM :
64- return
65-
66- self .ql .arch .enable_vfp ()
67- self .ql .hook_intno (self .hook_syscall , 2 )
64+ # ARM
65+ if self .ql .archtype == QL_ARCH .ARM :
66+ self .ql .arch .enable_vfp ()
67+ self .ql .hook_intno (self .hook_syscall , 2 )
68+ #self.thread_class = thread.QlLinuxARMThread
69+ self .ql .arch .init_get_tls ()
6870
6971
7072 def hook_syscall (self , intno = None , int = None ):
@@ -98,15 +100,15 @@ def run(self):
98100 if self .ql .entry_point is not None :
99101 self .ql .loader .elf_entry = self .ql .entry_point
100102
101- self .cpupage_addr = int (self .ql .os .profile .get ("OS32" , "cpupage_address" ), 16 )
102- self .cpupage_tls_addr = int (self .ql .os .profile .get ("OS32" , "cpupage_tls_address" ), 16 )
103- self .tls_data_addr = int (self .ql .os .profile .get ("OS32" , "tls_data_address" ), 16 )
104-
105- self . syspage_addr = int (self .ql .os . profile . get ( "OS32" , "syspage_address" ), 16 )
103+ self .cpupage_addr = int (self .ql .os .profile .get ("OS32" , "cpupage_address" ), 16 )
104+ self .cpupage_tls_addr = int (self .ql .os .profile .get ("OS32" , "cpupage_tls_address" ), 16 )
105+ self .tls_data_addr = int (self .ql .os .profile .get ("OS32" , "tls_data_address" ), 16 )
106+ self . syspage_addr = int ( self . ql . os . profile . get ( "OS32" , "syspage_address" ), 16 )
107+ syspage_path = os . path . join (self .ql .rootfs , "syspage.bin" )
106108
107109 self .ql .mem .map (self .syspage_addr , 0x4000 , info = "[syspage_mem]" )
108110
109- syspage_path = os . path . join ( self . ql . rootfs , "syspage.bin" )
111+
110112 with open (syspage_path , "rb" ) as sp :
111113 self .ql .mem .write (self .syspage_addr , sp .read ())
112114
@@ -130,9 +132,13 @@ def run(self):
130132 self .ql .emu_start (self .entry_point , (self .entry_point + len (self .ql .code )), self .ql .timeout , self .ql .count )
131133 else :
132134 if self .ql .loader .elf_entry != self .ql .loader .entry_point :
133- self .ql .emu_start (self .ql .loader .entry_point , self .ql .loader .elf_entry , self .ql .timeout )
135+ entry_address = self .ql .loader .elf_entry
136+ if self .ql .archtype == QL_ARCH .ARM and entry_address & 1 == 1 :
137+ entry_address -= 1
138+ self .ql .emu_start (self .ql .loader .entry_point , entry_address , self .ql .timeout )
134139 self .run_function_after_load ()
135- self .ql .enable_lib_patch ()
140+ self .ql .loader .skip_exit_check = False
141+ self .ql .write_exit_trap ()
136142
137143 self .ql .emu_start (self .ql .loader .elf_entry , self .exit_point , self .ql .timeout , self .ql .count )
138144
0 commit comments