Skip to content

Commit f04e181

Browse files
committed
Move get_syscall_mapper to POSIX
1 parent e2dc1e8 commit f04e181

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

qiling/os/posix/posix.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
from qiling.exception import QlErrorSyscallNotFound
2727
from qiling.os.os import QlOs
2828
from qiling.os.posix.const import NR_OPEN, errors
29-
from qiling.utils import ql_get_module_function, ql_syscall_mapping_function
29+
from qiling.utils import ql_get_module_function
3030

3131
SYSCALL_PREF: str = f'ql_syscall_'
3232

@@ -137,7 +137,7 @@ def __init__(self, ql: Qiling):
137137
}[self.ql.arch.type](self.ql.arch)
138138

139139
# select syscall mapping function based on emulated OS and architecture
140-
self.syscall_mapper = ql_syscall_mapping_function(self.type, self.ql.arch.type)
140+
self.syscall_mapper = self.__get_syscall_mapper(self.ql.arch.type)
141141

142142
self._fd = QlFileDes()
143143

@@ -150,6 +150,14 @@ def __init__(self, ql: Qiling):
150150

151151
self._shms = {}
152152

153+
def __get_syscall_mapper(self, archtype: QL_ARCH):
154+
qlos_path = f'.os.{self.type.name.lower()}.map_syscall'
155+
qlos_func = 'get_syscall_mapper'
156+
157+
func = ql_get_module_function(qlos_path, qlos_func)
158+
159+
return func(archtype)
160+
153161
@QlOs.stdin.setter
154162
def stdin(self, stream: TextIO) -> None:
155163
self._stdin = stream

qiling/utils.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,6 @@ def ql_get_module_function(module_name: str, function_name: str):
8484

8585
return module_function
8686

87-
# This function is extracted from os_setup (QlOsPosix) so I put it here.
88-
def ql_syscall_mapping_function(ostype: QL_OS, archtype: QL_ARCH):
89-
qlos_name = ostype.name
90-
qlos_path = f'qiling.os.{qlos_name.lower()}.map_syscall'
91-
qlos_func = 'get_syscall_mapper'
92-
93-
func = ql_get_module_function(qlos_path, qlos_func)
94-
95-
return func(archtype)
9687

9788
def __emu_env_from_pathname(path: str) -> Tuple[Optional[QL_ARCH], Optional[QL_OS], Optional[QL_ENDIAN]]:
9889
if os.path.isdir(path) and path.endswith('.kext'):

0 commit comments

Comments
 (0)