791 Commits
Author SHA1 Message Date
retrocpugeekandClaude Opus 5 5d2835a528 Add regression tests for the illegal-instruction CPU exception
The existing shellcode tests end emulation from their execve hook, so they
never reach the trailing '/bin/sh' string and never execute it as code. These
two deliberately let execve return and fall through into it, which raises an
undefined/reserved instruction exception on ARM64 and MIPS.

Without the preceding commits both fail with
QlErrorCoreHook: _hook_intr_cb : not handled.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-09-06 20:50:55 +10:00
retrocpugeekandClaude Opus 4.8 0e52738d53 Add regression test for statx byte order on big-endian guests
Drives ql_syscall_statx on a big-endian MIPS context and checks that
stx_mode, read back in the guest's byte order, still reports a directory
(S_IFDIR). Before the fix the statx struct was emitted little-endian
regardless of guest endianness, so the type bits were byte-swapped and a
directory looked like a regular file. Self-contained (no rootfs binary,
runs on stock unicorn).

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-09-06 13:38:50 +10:00
xwings 748e254bd8 Merge pull request #1641 from retrocpugeek/fix/mips-socket-options
Fix MIPS socket option (SO_*) values
2026-09-05 21:29:49 +08:00
xwings 4ee2ab144e Merge pull request #1636 from retrocpugeek/fix/getdents64-alignment
Align getdents and getdents64 records to fix unaligned access on MIPS
2026-09-05 20:51:08 +08:00
xwings f444f8171a Merge pull request #1639 from retrocpugeek/fix/clone3-syscall
Implement the clone3 syscall
2026-09-05 20:49:30 +08:00
xwings deca26e4ba Merge pull request #1651 from Jvlegod/feature/qdb-riscv
feat: add qdb riscv support
2026-09-05 17:02:46 +08:00
xwings 206b90fd89 minor refactor and pypi fix 2026-09-05 16:57:28 +08:00
retrocpugeekandClaude Opus 5 a13a8c8c1f gdb: accept vCont C/S actions carrying any signal
A client that resumes while a signal is pending sends a vCont action of the
form 'C<sig>' (continue and deliver) or 'S<sig>' (step and deliver), e.g.
'vCont;S0f:pa410.1996;c:pa410.-1' -- the exact packet reported in issue
#1377. handle_v matched only 'c'/'C05' and 's'/'S05', so any other signal
fell through to an empty reply and clients aborted the session with
'Invalid remote reply:'.

We do not deliver host signals to the guest, so the signal value carries no
meaning for us: accept any of them and carry the action out as a plain
resume or step, which is what the client asked for. This matters more now
that the stub can stop with SIGINT on an async interrupt, since a client
may well resume from such a stop with 'C02'.

Also stop assuming os.exit_code exists when reporting termination: bare-metal
os layers (QlOsMcu) do not define it, which turns the exit path into an
AttributeError (seen in issue #1276). The underlying MCU interrupt handling
of #1276 is out of scope here.

Add a regression test asserting the '#1377' packet is answered with a
SIGTRAP stop-reply and that a signalled continue runs the guest to
termination; both replies are empty without the fix.

Fixes #1377

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
2026-08-23 22:15:04 +10:00
retrocpugeekandClaude Opus 4.8 c5a8a9b73e gdb: support async interrupt (ctrl-c) to break into a running guest
The stub drove continue by calling emu_start synchronously and only read
the socket again once the target stopped on its own, so the bare \x03 break
byte a client sends to pause a running target was never seen. A guest that
free-runs (e.g. an idle/event loop) could not be interrupted at all --
gdb/Ghidra reported 'Cannot execute this command while the target is running'.

Poll the client socket for the break byte from the per-instruction run hook
(dbg_hook), which does run on the emulation thread during emu_start:

- GdbSerialConn.poll_interrupt(): non-blocking select+recv, True on \x03.
- QlGdbUtils.dbg_hook: throttled (every INTR_POLL_INTERVAL insns) check of an
  installed check_interrupt callback; on a break, stop emulation and record it.
- handle_c: reply SIGINT when the stop was an interrupt rather than a
  breakpoint or normal exit.

Add a regression test that lets an infinite-loop guest free-run, sends the
bare break byte and asserts the stop-reply is 'S02' (SIGINT). Without the
fix no reply ever arrives, so the test stops the guest itself and fails
rather than hanging the run.

Also verified against a free-running MIPS64 BE guest: \x03 -> S02 in <1ms.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-08-23 22:14:50 +10:00
retrocpugeekandClaude Opus 4.8 de34db212d gdb: report SIGTRAP (not SIGTERM) on single-step
handle_s answered every single-step ('s') with a SIGTERM stop-reply
whenever ql.emu_state was QL_STATE.STOPPED. But emu_start always leaves
the state STOPPED after running the requested step count, so the guard
was true on every step and gdb clients saw a spurious termination signal,
disconnecting mid-debug (issues #1377, #1538).

Give handle_s the same exit-vs-trap discrimination handle_c already uses:
a step reports SIGTRAP unless it carried pc to the emulation exit point,
in which case the guest has actually terminated and we reply W{exit_code}.
Also wrap the step in the same UcError/KeyboardInterrupt handling as
handle_c so a fault while stepping maps to a signal instead of crashing
the stub, and hoist the shared uc-error->signal map to a module constant.

Add a regression test that single-steps over the gdb stub and asserts the
stop-reply is 'S05' (SIGTRAP), which fails as 'S0f' (SIGTERM) without the fix.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
2026-08-07 22:28:08 +10:00
Jvle b69128fee9 feat: add riscv qdb support
Signed-off-by: Jvle <[email protected]>
2026-08-04 16:40:00 +08:00
retrocpugeekandClaude Opus 4.8 9e21eb9d66 Fix MIPS socket option (SO_*) values
linux_mips_socket_options used generic/incorrect values. MIPS has its own
SO_* numbering (arch/mips/include/uapi/asm/socket.h) with the buffer/timeout/
type options in the 0x1000 range. The table listed SO_SNDBUF=0x01,
SO_RCVBUF=0x02 (should be 0x1001/0x1002), SO_SND/RCVLOWAT and SO_SND/RCVTIMEO_OLD
all wrong, SO_RCVLOWAT=0x04 silently collided with SO_REUSEADDR (Enum alias),
and SO_OOBINLINE/SO_REUSEPORT were 0x00.

A guest setsockopt(SOL_SOCKET, SO_RCVBUF, ...) (e.g. busybox ping) therefore
raised 'Could not convert emulated socket option 4098'. Correct all values to
the MIPS uapi and add the missing SO_TYPE/SO_ERROR/SO_ACCEPTCONN/SO_PROTOCOL/
SO_DOMAIN.

Add test_elf.ELFTest.test_setsockopt_mips_so_rcvbuf: opens a socket on a MIPS
guest and asserts setsockopt(SOL_SOCKET, SO_RCVBUF) succeeds. Self-contained,
runs on stock unicorn; fails on dev, passes with the fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-25 22:38:50 +10:00
retrocpugeekandClaude Opus 4.8 a4ca725e4e Align legacy getdents records too
Extend the record alignment to the legacy getdents path. The kernel rounds
both getdents and getdents64 records up to the alignment of their leading
d_ino (ALIGN(reclen, sizeof(long))); without it a strict-alignment guest
(MIPS) faults walking the buffer, e.g. older glibc busybox 'ls' (which uses
the legacy getdents syscall) crashes on directory listings.

Legacy linux_dirent stores d_type in the record's last byte (offset
d_reclen-1), so the alignment padding goes between d_name and d_type to keep
d_type there -- padding without relocating d_type is what got the earlier
blanket attempt (PR #1419) reverted. getdents64 (d_type before d_name) is
unchanged.

Add test_linux_getdents_alignment: walks legacy getdents records on a
big-endian MIPS guest and asserts each is aligned, tiles the buffer, and
keeps d_type (DT_DIR for '.'/'..'). Runs on stock unicorn.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-25 21:55:21 +10:00
retrocpugeekandClaude Opus 4.8 f5c0afab58 Implement the clone3 syscall
Modern glibc (recent toolchains) issues clone3 from pthread_create rather
than clone, so thread creation fails on any guest built against it: Qiling
does not return -ENOSYS for unimplemented syscalls (it logs a warning and
leaves the return register untouched), so glibc's clone3->clone fallback
never fires.

Add ql_syscall_clone3, which unpacks struct clone_args and delegates to the
existing clone() handler. Translations: child_stack = stack + stack_size
(clone3 passes the stack base plus a size; legacy clone wants the highest
address), exit_signal folded into the flags' CSIGNAL byte, and an x8664
pre-swap that cancels ql_syscall_clone's arch-specific newtls<->child_tidptr
swap.

Add a self-contained regression test (test_clone3_translates_to_clone) that
drives ql_syscall_clone3 directly and asserts the translation for both the
generic path and the x8664 swap. Runs on stock unicorn; no clone3 binary
needed.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-25 20:22:02 +10:00
retrocpugeekandClaude Opus 4.8 0e48da4be8 Add regression test for getdents64 record alignment
Calls ql_syscall_getdents64 on a directory and walks the returned
linux_dirent64 records, asserting every record (and thus its leading u64
d_ino) starts on an 8-byte boundary. Before the fix d_reclen was not
rounded up, so records were misaligned and a strict-alignment guest (e.g.
MIPS) faulted with an unaligned load. Self-contained; runs on stock unicorn.

Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
2026-06-25 00:31:16 +10:00
xwings 486369d375 better New SYSCALL_EX IPC message, FD arg type and Forwarder closure 2026-04-27 21:52:49 +08:00
xwings cb875f8488 more qiling style. update logging and exception 2026-04-12 16:48:53 +08:00
xwings 5ed49e7dcb Merge branch 'qilingframework:dev' into dev 2026-04-11 23:04:43 +08:00
xwings 30eba376fc Add TODO.md, ARCHITECTURE.md. Update README.md. and add kernel proxy 2026-04-11 22:48:18 +08:00
libumem 3675f557e9 Address @elicn feedback 2025-11-16 18:19:20 +00:00
libumem 4448d4c129 Remove stray PDB invocation 2025-11-15 01:57:40 +00:00
libumem a76b858332 Tentative fix for epoll server test case 2025-11-14 04:39:15 +00:00
libumem 2ecd1d924a Merge branch 'qilingframework:dev' into dev 2025-11-12 20:23:27 -05:00
elicn 147ec7c18c Make Windows compatible to latest image 2025-10-29 14:43:10 +02:00
technikelly 04236d77b1 enabling test and updating rootfs submodule 2025-08-27 11:26:39 -04:00
technikelly 5ec4a3b57a addressing review comments, removing copyright notices 2025-08-25 13:34:45 -04:00
technikelly 6d697b5d7f updating copyright statements with license info 2025-08-20 15:12:54 -04:00
technikelly 81c2a39f1f minimizing blob changes 2025-08-20 14:55:37 -04:00
technikelly d3cc47dc7f adding support for raw binary blobs 2025-08-12 10:55:50 -04:00
elicn 7088d22a73 Allow tests to import relatively 2025-07-06 18:44:59 +03:00
elicn d2b4867f21 Adjust test and example 2025-07-06 18:23:36 +03:00
elicn 327f475ba3 Decouple BLOB entry point and load address 2025-07-06 18:23:07 +03:00
libumem aefef5ffaf Disable test case, for now 2025-06-23 23:40:35 +00:00
libumem d5b51dd724 Remove dup'd comment, locally tested fix for error during ELFTest suite 2025-06-22 23:57:28 +00:00
libumem fdfec5b6d1 Attempt #1 to fix test case root 2025-06-17 22:39:45 +00:00
libumem 92e43a3552 Fix glibc issue with new test root 2025-06-04 00:40:36 +00:00
libumem 5ad49c0fdc Revert "Revert "Fix root for test case""
This reverts commit 4d0b939da5.
2025-06-02 23:37:38 +00:00
libumem 4d0b939da5 Revert "Fix root for test case"
This reverts commit 47c3df1eb5.
2025-06-02 23:27:36 +00:00
libumem 47c3df1eb5 Fix root for test case 2025-05-16 02:23:58 +00:00
libumem 265406eb08 Merge branch 'dev' into libumem-epoll-fixes 2025-05-07 19:51:43 -04:00
libumem 90df05f7a6 Merge branch 'qilingframework:dev' into dev 2025-05-06 21:06:50 -04:00
xwings d614855e78 Merge pull request #1552 from sakura57/dev
Various fixes and improvements for Windows emulation
2025-05-06 10:27:20 +08:00
elicn 5a87323df3 Tidy up tests 2025-04-30 13:52:40 +03:00
libumem 74380b26d5 Address a few elicn comments, fix root for server test 2025-04-30 00:18:41 +00:00
libumem f2861b7f38 Nominally working epoll server test 2025-04-26 16:36:05 +00:00
libumem fd32154ca1 Begin working on test issues 2025-04-26 03:38:56 +00:00
libumem 033fb4b4bc Address PR comments 2025-04-26 01:50:44 +00:00
libumem c6eee99422 Add socket import back, was not supposed to be removed 2025-04-25 02:07:36 +00:00
libumem 290f11671a Begin fixing this PR 2025-04-25 02:03:53 +00:00
libumem f79d17937d Merge branch 'qilingframework:dev' into dev 2025-04-21 20:33:00 -04:00