Commit Graph

75 Commits

Author SHA1 Message Date
Claude 210987745c
Merge upstream main into fix/audit-2026-09
Resolve conflicts with boykopovar/AnyPS5#10 (sce module loading) and
later upstream changes.

- Pthread Cond/Mutex: take upstream. It already releases mutex
  ownership across condition waits, returns ETIMEDOUT 0x8002003C, and
  rejects unlocks from non-owners for every mutex type.
- Pthread Thread: keep upstream's lifecycle, Windows adoption and job
  affinity; re-apply the POSIX fixes on top: reference-counted
  release on join/detach/exit, self-join rejection on both platforms,
  and scePthreadSelf adoption for threads not created by
  scePthreadCreate.
- Semaphore: keep upstream's TimedWait::Condition and wait tracing;
  re-apply sceKernelDeleteSema waking waiters with EACCES.
- Relinker: keep --windows-gui alongside upstream's --skip-sce-module,
  trampoline-aware Patch signature and new Python tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018emyZ4Rk8yoSJvxTFBe4DL
2026-09-28 07:34:25 +00:00
boykopovar a6bb98d4d5
Merge pull request #54 from oneandonlydean/feat/extrq-register-form
feat(relinker): lower register-form EXTRQ and relocate following instructions for short sites
- **Lowering:** register-form EXTRQ is emitted out of line with SSE2 only. Two scratch XMM registers (distinct from both operands) are spilled; one gets the index (`src >> 8 & 63`), the other `(64 - length) & 63` (`length` masked to 6 bits, so 0 means 64). The destination is shifted right by the index, then left and right by the complement, which keeps the low `length` bits. INSERTQ register form is still reported as unsupported.
- **Short sites:** when a site is shorter than a `jmp rel32`, the converter extends it over the instructions that follow it until it's 5 bytes long:
  - following EXTRQ/INSERTQ instructions (before any other instruction) are lowered into the same stub, via a new `MatchSequence`;
  - other instructions are copied after the lowered body (`LowerOutOfLine`'s new `trailing` bytes), but only if they're sequential, have no RIP-relative operand and no branch target;
  - anything else (a return, a branch, RIP-relative code, the segment ending) still fails the relink, as does a branch target inside the extended site.
- `docs/TechnicalDebt.md` now lists only the INSERTQ register form, MONITORX/MWAITX/CLZERO/RDPRU/MCOMMIT and SHA-NI.
2026-09-28 09:35:28 +03:00
boykopovar f354dbd17e
Merge pull request #47 from oneandonlydean/fix/linux-load-alignment
fix(relinker): align the linux header load segment to the largest segment alignment
2026-09-28 08:44:02 +03:00
boykopovar 20e5c359d9
Merge pull request #45 from oneandonlydean/fix/linux-guest-dynlibdata
fix(relinker): skip the flagless dynlib data segment in linux guest modules
2026-09-28 08:31:05 +03:00
Dean Galvin ff1fa9eb69 feat(relinker): lower register-form EXTRQ and relocate following instructions for short sites
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 16:37:15 +13:00
Dean Galvin 06b3413961 fix(relinker): align the linux header load segment to the largest segment alignment
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 14:22:48 +13:00
Dean Galvin 346b7280e2 fix(relinker): skip the flagless dynlib data segment in linux guest modules
GuestModuleWriter::WriteLinux adds read permission to every PT_LOAD, including
the SCE dynlib data segment, which has no flags and is never mapped on the PS5.
When that segment starts inside the last page of the preceding RW segment, the
read-only mapping covers the tail of its bss and the module's initializer faults
on its first write there. The symbol and relocation tables it holds are already
copied into the appended segment, so it no longer needs to be mapped.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ButHENCbXXt8h4EZuWUabJ
2026-09-28 13:32:36 +13:00
Darko Gjorgjijoski 42594eecd4 fix(relinker): report buffered output write failures 2026-09-28 00:25:42 +02:00
devilismyfriend a503d0b617 Merge remote-tracking branch 'origin/main' into feat/demons-souls-boot
Brings in main up to 9958d26 (homebrew runtime, POSIX wrappers in
libkernel, sce_module guest modules and --skip-sce-module, the --to-intel
general pipeline, libSceRandom, libSceRtc, libScePosixForWebKit,
libRenoirCore, test wiring).

Resolutions where both sides implemented the same thing:
- libkernel pthread: main's structure (lazy static initialisation,
  destroyed markers, MutexOperations/CondOperations, mutex protocol and
  condattr clock) with this branch's TimedWait deadlines and condition
  (precise timed lock/wait on Windows), wait tracing, the adaptive mutex
  type 4, POSIX default ERRORCHECK mutexes, EDEADLK/EPERM results instead
  of throws, and condition clocks honoured for absolute timeouts.
- libc locale: the guest Dinkumware ABI (_Locimp, facet vtables, short
  ctype/case tables, locale ids, stream storage) is kept because guest code
  inlines those layouts; main's C character functions are kept on top.
- libc stdio/strings/math: main's stream functions (guest FILE status
  sync), strerror/perror, remove, formatting, string and math exports win
  over this branch's duplicates.
- libc paths: main's working directory with this branch's path aliases
  resolved on the normalised guest path.
- libkernel file: this branch's sceKernel* results as SCE errors, main's
  POSIX wrappers and both fstat helpers.
- relinker: this branch's stub lowering keeps its trampolines through the
  main executable path; guest modules refuse lowerings that need stubs.
- AGC driver: main's rendering wait is executed by this branch's workers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-27 10:52:21 -07:00
boykopovar 179841caff feat(relinker): report full module path when windows loading fails 2026-09-27 13:10:06 +03:00
boykopovar 43d2e8b4dc fix(codegen): decode xadd byte and popcnt instruction lengths fix 2026-09-27 12:49:46 +03:00
boykopovar e3dc9a6acc fix(relinker): accept zero alignment for empty tls segments 2026-09-27 12:41:52 +03:00
boykopovar 52b683d208 fix(relinker): skip generated guest prx files during sce module scan 2026-09-27 11:43:42 +03:00
boykopovar bfa1ac0751 fix(relinker): scan complete function ranges for windows tls accesses 2026-09-27 11:43:41 +03:00
boykopovar 2e654e4f89 feat(relinker): scan sce modules for syscalls 2026-09-27 11:43:33 +03:00
boykopovar 630cb018c0 feat(relinker): add --skip-sce-module flag 2026-09-27 11:43:32 +03:00
boykopovar 337e763597 fix(relinker): support operand-size prefixes on fs:[0] access 2026-09-27 11:43:30 +03:00
boykopovar 2cc34985c0 fix(codegen): decode int imm8 instruction length correctly 2026-09-27 11:43:30 +03:00
boykopovar fa10c6d7eb fix(relinker): scan reachable code for windows guest tls accesses 2026-09-27 11:43:30 +03:00
boykopovar 6b2db1d8a8 fix(relinker): support windows guest tls relocations and accesses 2026-09-27 11:43:29 +03:00
boykopovar 0c6765e6a6 fix(relinker): ignore non-loadable SCE segments outside file bounds 2026-09-27 11:43:29 +03:00
boykopovar 1379ec001b feat(relinker): add native guest module loading with export priority 2026-09-27 11:43:28 +03:00
QDarkRex 908befe81d feat(relinker): add --windows-gui to emit a GUI subsystem executable
Generated executables always used the console subsystem and opened a
console window on launch. The opt-in flag writes IMAGE_SUBSYSTEM_WINDOWS_GUI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:24:15 +07:00
QDarkRex f8485ce6a6 fix(relinker): return unpacked exit status and wait for a single Enter in autorun
std::system returns a wait status on POSIX, so returning it from main
truncated a guest exit code of 1 (status 256) to 0. The prompt also
required pressing Enter twice because cin.get followed cin.ignore.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-27 12:24:14 +07:00
devilismyfriend 01c4e3edf7 feat(relinker): --to-intel lowers SSE4a sites to same-length jumps into an appended stub section
EXTRQ, INSERTQ, MOVNTSS and MOVNTSD are rewritten at relink time: same-length in-place forms
where they exist, otherwise a jmp rel32 into an appended executable section holding a
scratch-free SSE body and a jump back, so no code shifts and no RIP-relative or jump-table
operand needs adjusting. Decoder fixes for POPCNT and 0F BB (BTC), codegen and elfpatcher
tests, README and technical-debt notes. The runtime illegal-instruction trap stays as a
fallback.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0177gthrWEBBfBu5xJDXgBfo
2026-09-26 19:00:39 -07:00
boykopovar 2f30b62a69 fix(relinker): use general pipeline after converting for --to-intel flag 2026-09-26 12:47:31 +03:00
SamG-Coder cf3c8081fd fix(build): make Python relinker tests optional 2026-09-26 14:55:02 +10:00
SamG-Coder f146a3d069 fix(windows): expose shared libc for internal runtime imports 2026-09-25 06:00:07 +10:00
SamG-Coder eca52b4725 fix(relinker): accept unused empty ELF TLS segments 2026-09-25 05:53:32 +10:00
SamG-Coder 221086beb6 fix(relinker): support ELF images without PLT relocations 2026-09-25 05:32:49 +10:00
SamG-Coder 0968c32b72 fix(build): register relinker tests with CTest 2026-09-25 05:27:19 +10:00
boykopovar 2778c1e86e perf(agc): keep render targets on gpu across draws 2026-09-24 21:30:00 +03:00
boykopovar 594656581e feat(libs): add new std symbols + unused filter off by default 2026-09-24 10:28:33 +03:00
boykopovar fa27b50832 chore(relinker): unused filter level = 1 by default 2026-09-24 08:14:05 +03:00
boykopovar ad68f86df1 chore(docs): update readme status for unused filter1 bug 2026-09-24 08:13:03 +03:00
boykopovar f5bc2d7649 feat(libs): add new sceAgc functions def 2026-09-24 07:54:15 +03:00
boykopovar 9f2b41b9a1 fix(libc): route guest allocations through application heap 2026-09-24 06:53:12 +03:00
boykopovar 8fd65f2a25 add EVENT_WRITE support for CS/GS/PS_PARTIAL_FLUSH + relinker return exit code from autorun 2026-09-22 20:27:49 +03:00
boykopovar 3da76b9b33 refactor(graphics): add new graphics pipeline log + remove redunant ones 2026-09-18 21:03:11 +03:00
boykopovar 7e5f41aba3 feat(cli): add --windows-diagnostics arg - off by default 2026-09-13 17:21:13 +03:00
boykopovar 04e1bc0a2d refactor(codegen): separated x86 assembler 2026-09-13 17:04:02 +03:00
boykopovar 9d7c255316 feat(windows): add import error chain diagnostic 2026-09-12 15:55:46 +03:00
boykopovar 4b643c6655 refactor(core): seprated folders for relinker and libs 2026-09-11 14:53:01 +03:00
boykopovar 2a14912b65 feat(cli): relinker --lazy-binding flag 2026-09-10 14:57:27 +03:00
boykopovar 5bf78ab8b4 feat(relinker): strict unused nids filtering mode 2026-09-09 19:29:25 +03:00
boykopovar 77cfe65b9c feat(relinker): unused nid filter fix + cli update 2026-09-09 18:17:10 +03:00
boykopovar febac8978e chore(relinker): protect .rela.plt + static jump_slot 2026-09-09 11:36:47 +03:00
boykopovar 3b5ae707cd fix(relinker): exact opcode instead of any rip-relative disp in unused nid filter 2026-09-09 10:14:45 +03:00
boykopovar a81a1bf1b5 feat(relinker): upgrade unused import finder via graph 2026-09-09 09:56:52 +03:00
boykopovar 6af387172a fix(relinker): update elf to windows pe relinking 2026-09-08 18:24:03 +03:00