Skip to content

Commit 6f2670e

Browse files
committed
Merge branch 'dev' of https://github.com/cla7aye15I4nd/qiling into dev
2 parents efbb1c0 + 07a08e0 commit 6f2670e

File tree

9 files changed

+20
-45
lines changed

9 files changed

+20
-45
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ test.file
3636
core
3737
*.perf
3838
tests/output.txt
39+
tests/testtest_*
3940

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ FROM python:3.8-slim AS builder
33
LABEL maintainer="Kevin Foo <[email protected]>"
44

55
ENV DEBIAN_FRONTEND=noninteractive
6+
ENV AM_I_IN_A_DOCKER_CONTAINER Yes
67

78
RUN apt-get update \
89
&& apt-get -y upgrade \

qiling/const.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,14 @@ class QL_INTERCEPT(IntEnum):
5151

5252
QL_DEBUGGER_ALL = (QL_DEBUGGER.IDAPRO, QL_DEBUGGER.GDB, QL_DEBUGGER.QDB)
5353

54-
QL_ARCH_MCU32 = (QL_ARCH.CORTEX_M,)
55-
QL_ARCH_MCU = QL_ARCH_MCU32
56-
5754
QL_ARCH_ENDIAN = (QL_ARCH.MIPS, QL_ARCH.ARM)
5855
QL_ARCH_1BIT = (QL_ARCH.EVM,)
5956
QL_ARCH_16BIT = (QL_ARCH.A8086,)
60-
QL_ARCH_32BIT = (QL_ARCH.ARM, QL_ARCH.ARM_THUMB, QL_ARCH.MIPS, QL_ARCH.X86) + QL_ARCH_MCU32
57+
QL_ARCH_32BIT = (QL_ARCH.ARM, QL_ARCH.ARM_THUMB, QL_ARCH.MIPS, QL_ARCH.X86, QL_ARCH.CORTEX_M)
6158
QL_ARCH_64BIT = (QL_ARCH.ARM64, QL_ARCH.X8664)
6259

6360
QL_OS_NONPID = (QL_OS.DOS, QL_OS.UEFI)
64-
QL_ARCH_HARDWARE = QL_ARCH_MCU
61+
QL_ARCH_HARDWARE = (QL_ARCH.CORTEX_M,)
6562
QL_ARCH_NONEOS = (QL_ARCH.EVM,)
6663
QL_OS_POSIX = (QL_OS.LINUX, QL_OS.FREEBSD, QL_OS.MACOS, QL_OS.QNX)
6764
QL_OS_ALL = QL_OS_POSIX + QL_OS_NONPID + (QL_OS.WINDOWS,)

qiling/core.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -609,7 +609,7 @@ def filter(self, ft):
609609
def uc(self) -> Uc:
610610
""" Raw uc instance.
611611
612-
Type: Uc
612+
Type: Ucgit
613613
"""
614614
return self._uc
615615

@@ -864,7 +864,7 @@ def stop(self):
864864
self.arch.stop()
865865

866866
else:
867-
self.uc.emu_stop()
867+
self.uc.emu_stop()
868868

869869
# start emulation
870870
def emu_start(self, begin, end, timeout=0, count=0):

qiling/core_struct.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def __init__(self, endian: QL_ENDIAN, bit: int):
3030
self._fmt32s = f'{modifier}i'
3131
self._fmt64 = f'{modifier}Q'
3232
self._fmt64s = f'{modifier}q'
33-
33+
3434
handlers = {
3535
64 : (self.pack64, self.pack64s, self.unpack64, self.unpack64s),
3636
32 : (self.pack32, self.pack32s, self.unpack32, self.unpack32s),

qiling/hw/timer/stm32f4xx_rtc.py

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@
55

66
import time
77
import ctypes
8-
from datetime import datetime
98

109
from qiling.hw.peripheral import QlPeripheral
1110
from qiling.hw.const.stm32f4xx_rtc import RTC_TR, RTC_ISR
12-
from qiling.hw.utils.bcd import bcd2byte, byte2bcd
1311

1412

1513
class STM32F4xxRtc(QlPeripheral):
@@ -123,26 +121,6 @@ def write(self, offset: int, size: int, value: int):
123121
data = (value).to_bytes(size, 'little')
124122
ctypes.memmove(ctypes.addressof(self.rtc) + offset, data, size)
125123

126-
def set_time(self, hour=0, minute=0, second=0, time_format=0):
127-
hour = (byte2bcd(hour) << 16) & (RTC_TR.HT | RTC_TR.HU)
128-
minute = (byte2bcd(minute) << 8) & (RTC_TR.MNT | RTC_TR.MNU)
129-
second = byte2bcd(second) & (RTC_TR.ST | RTC_TR.SU)
130-
time_format = (time_format << 16) & RTC_TR.PM
131-
132-
self.rtc.TR = hour | minute | second | time_format
133-
134-
def get_time(self, value):
135-
hour = (value & (RTC_TR.HT | RTC_TR.HU)) >> 16
136-
minute = (value & (RTC_TR.MNT | RTC_TR.MNU)) >> 8
137-
second = value & (RTC_TR.ST | RTC_TR.SU)
138-
time_format = (value & RTC_TR.PM) >> 16
139-
140-
return hour, minute, second, time_format
141-
142-
def increase(self):
143-
self.calendar += 1
144-
self.set_time(self.calendar.tm_hour, self.calendar.tm_min, self.calendar.tm_sec)
145-
146124
def step(self):
147125
if self.rtc.ISR & RTC_ISR.INIT:
148126
self.rtc.ISR |= RTC_ISR.INITF

qiling/os/posix/syscall/unistd.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,13 @@ def _type_mapping(ent):
687687
d_type = _type_mapping(result)
688688
d_reclen = n + n + 2 + len(d_name) + 1
689689

690+
# TODO: Dirty fix for X8664 MACOS 11.6 APFS
691+
# For some reason MACOS return int value is 64bit
692+
try:
693+
packed_d_ino = (ql.pack(d_ino), n)
694+
except:
695+
packed_d_ino = (ql.pack64(d_ino), n)
696+
690697
if is_64:
691698
fields = (
692699
(ql.pack(d_ino), n),
@@ -697,7 +704,7 @@ def _type_mapping(ent):
697704
)
698705
else:
699706
fields = (
700-
(ql.pack(d_ino), n),
707+
packed_d_ino,
701708
(ql.pack(d_off), n),
702709
(ql.pack16(d_reclen), 2),
703710
(d_name, len(d_name)),

tests/test_elf_multithread.py

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def test_elf_linux_execve_x8664(self):
3434
del QL_TEST
3535
del ql
3636

37+
3738
def test_elf_linux_cloexec_x8664(self):
3839
with open('../examples/rootfs/x8664_linux/testfile', 'wb') as f:
3940
f.write(b'0123456789')
@@ -149,9 +150,6 @@ def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
149150

150151

151152
def test_tcp_elf_linux_x86(self):
152-
if platform.system() == "Darwin" and platform.machine() == "arm64":
153-
return
154-
155153
def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
156154
try:
157155
buf = ql.mem.read(write_buf, write_count)
@@ -170,9 +168,6 @@ def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
170168

171169

172170
def test_tcp_elf_linux_x8664(self):
173-
if platform.system() == "Darwin" and platform.machine() == "arm64":
174-
return
175-
176171
def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
177172
try:
178173
buf = ql.mem.read(write_buf, write_count)
@@ -242,9 +237,6 @@ def test_tcp_elf_linux_mips32el(self):
242237

243238

244239
def test_udp_elf_linux_x86(self):
245-
if platform.system() == "Darwin" and platform.machine() == "arm64":
246-
return
247-
248240
def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
249241
try:
250242
buf = ql.mem.read(write_buf, write_count)
@@ -264,9 +256,6 @@ def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
264256

265257

266258
def test_udp_elf_linux_x8664(self):
267-
if platform.system() == "Darwin" and platform.machine() == "arm64":
268-
return
269-
270259
def check_write(ql, write_fd, write_buf, write_count, *args, **kw):
271260
try:
272261
buf = ql.mem.read(write_buf, write_count)

tests/test_evm.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env python3
22

3-
import platform, sys, unittest
3+
import os, platform, sys, unittest
44

55
sys.path.append("..")
66
from qiling import Qiling
77

8-
if sys.version_info.major == 3 and sys.version_info.minor == 9:
8+
SECRET_KEY = os.environ.get('AM_I_IN_A_DOCKER_CONTAINER', False)
9+
10+
if SECRET_KEY:
911
sys.exit(0)
1012

1113
if platform.system() == "Darwin" and platform.machine() == "arm64":

0 commit comments

Comments
 (0)