Skip to content

Commit 615979e

Browse files
committed
removed some really bad options and keep core cleaner
1 parent 44c305f commit 615979e

File tree

7 files changed

+31
-29
lines changed

7 files changed

+31
-29
lines changed

qiling/const.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ class QL_INTERCEPT(IntEnum):
6464

6565
QL_OS_BAREMETAL = (QL_OS.MCU,)
6666
QL_OS_INTERPRETER = (QL_OS.EVM,)
67-
QL_OS_ALL = QL_OS_POSIX + QL_OS_NONPID + (QL_OS.WINDOWS,)
6867

6968
QL_HOOK_BLOCK = 0b0001
7069
QL_CALL_BLOCK = 0b0010

qiling/core.py

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .hw.hw import QlHwManager
2020
from .loader.loader import QlLoader
2121

22-
from .const import QL_ARCH_ENDIAN, QL_ENDIAN, QL_VERBOSE, QL_OS_INTERPRETER, QL_OS_BAREMETAL, QL_OS_ALL
22+
from .const import QL_ARCH_ENDIAN, QL_ENDIAN, QL_VERBOSE, QL_OS_INTERPRETER, QL_OS_BAREMETAL
2323
from .exception import QlErrorFileNotFound, QlErrorArch, QlErrorOsType
2424
from .utils import *
2525
from .core_struct import QlCoreStructs
@@ -194,24 +194,19 @@ def __init__(
194194
##############
195195
# Components #
196196
##############
197-
if self.gpos or self.baremetal:
197+
if not self.interpreter:
198198
self._mem = component_setup("os", "memory", self)
199199
self._reg = component_setup("arch", "register", self)
200-
201-
if self.baremetal:
202-
self._hw = component_setup("hw", "hw", self)
200+
203201

204202
self._arch = arch_setup(self.archtype, self)
205203

206204
# Once we finish setting up arch layer, we can init QlCoreHooks.
207-
self.uc = self.arch.init_uc
208-
QlCoreHooks.__init__(self, self.uc)
205+
if not self.interpreter:
206+
self.uc = self.arch.init_uc
207+
QlCoreHooks.__init__(self, self.uc)
209208

210-
# Setup Outpt
211-
if self.gpos or self.baremetal:
212209
self.arch.utils.setup_output()
213-
214-
if self.gpos:
215210
self._os = os_setup(self.archtype, self.ostype, self)
216211

217212
if stdin is not None:
@@ -225,10 +220,7 @@ def __init__(
225220

226221
# Run the loader
227222
self.loader.run()
228-
229-
if self.gpos:
230-
# Add extra guard options when configured to do so
231-
self._init_stop_guard()
223+
self._init_stop_guard()
232224

233225
#####################
234226
# Qiling Components #
@@ -481,15 +473,6 @@ def baremetal(self) -> bool:
481473
"""
482474
return self.ostype in QL_OS_BAREMETAL
483475

484-
@property
485-
def gpos(self) -> bool:
486-
""" General purpose OS
487-
- Windows, Linux, MacOS and etc
488-
489-
Type: bool
490-
"""
491-
return self.ostype in QL_OS_ALL
492-
493476
@property
494477
def platform_os(self):
495478
""" Specify current platform os where Qiling runs on.

qiling/debugger/gdb/gdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def __init__(self, ql: Qiling, ip: str = '127.0.01', port: int = 9999):
5454
if self.ql.baremetal:
5555
load_address = self.ql.loader.load_address
5656
exit_point = load_address + os.path.getsize(ql.path)
57-
elif self.ql.code and ql.gpos:
57+
elif self.ql.code:
5858
load_address = self.ql.os.entry_point
5959
exit_point = load_address + len(ql.code)
6060
else:

qiling/loader/mcu.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@
1010

1111
from qiling.const import *
1212
from qiling.core import Qiling
13+
from qiling.utils import component_setup
1314

1415
from .loader import QlLoader
1516

16-
1717
class IhexParser:
1818
def __init__(self, path):
1919
self.pc = None
@@ -60,7 +60,7 @@ def parse_line(self, line):
6060
class QlLoaderMCU(QlLoader):
6161
def __init__(self, ql:Qiling):
6262
super(QlLoaderMCU, self).__init__(ql)
63-
63+
self.ql._hw = component_setup("hw", "hw", self.ql)
6464
self.load_address = 0
6565
self.path = self.argv[0]
6666
self.filetype = self.guess_filetype()

qiling/os/mcu/const.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
4+
#
5+

qiling/os/mcu/mcu.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python3
2+
#
3+
# Cross Platform and Multi Architecture Advanced Binary Emulation Framework
4+
#
5+
6+
from unicorn import UcError
7+
8+
from qiling.os.os import QlOs
9+
10+
class QlOsMcu(QlOs):
11+
def __init__(self, ql):
12+
super(QlOsMcu, self).__init__(ql)
13+
14+
def run(self):
15+
pass

qiling/os/os.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def __init__(self, ql: Qiling, resolvers: Mapping[Any, Resolver] = {}):
3535
self.child_processes = False
3636
self.thread_management = None
3737
self.profile = self.ql.profile
38-
self.path = QlPathManager(ql, self.ql.profile.get("MISC", "current_path"))
38+
self.path = None if self.ql.baremetal else QlPathManager(ql, self.ql.profile.get("MISC", "current_path"))
3939
self.exit_code = 0
4040

4141
self.user_defined_api = {

0 commit comments

Comments
 (0)