Skip to content

Fix loader, file mapping and spawn bugs hit by the Delphi compilers - #157

Open
cweerm wants to merge 1 commit into
decompals:mainfrom
cweerm:loader-fixes
Open

cweerm wants to merge 1 commit into
decompals:mainfrom
cweerm:loader-fixes

Conversation

@cweerm

@cweerm cweerm commented Oct 28, 2026

Copy link
Copy Markdown

Fixes hit while running the Delphi 11 command-line compilers (dcc32.exe, dcc64.exe, dcclinux64.exe, and the ld-linux.exe that dcclinux64 spawns) under wibo.

  • Loader: copy the PE headers to the image base and patch ImageBase in the mapped copy. Windows maps the headers there, and mingw's pseudo-reloc code walks its own section table from that copy.
  • CreateFileMapping with INVALID_HANDLE_VALUE: back the section with a memfd (shm_open on other hosts) so that two views of one section alias. With MAP_ANONYMOUS, each view got its own pages.
  • Process spawn: qemu-user rejects clone(CLONE_PIDFD) with EINVAL, which broke CreateProcess when running amd64 wibo under emulation (Docker on arm64 hosts). Fall back to fork plus pidfd_open.
  • gen_trampolines.py, x86 fastcall: a 64-bit scalar argument now goes on the stack without pushing the 32-bit arguments after it off their registers. Only an aggregate argument stops register use.
  • gen_trampolines.py, 64-bit host thunks: copy a 64-bit integer result from rax into edx:eax, where the guest reads it.
  • FindResourceA/W debug logging: print MAKEINTRESOURCE ids as #n. Logging them with %s crashed under -D.

New fixture: test_two_views_of_pagefile_mapping_alias in test/test_createfilemapping.c.

Testing:

  • The repo CI workflow, run on this branch in my fork: all pass except test_namedpipe, see below.
  • test_createfilemapping, including the new case, passes under Wine 9.0 and on Windows (GitHub windows-latest).

test_namedpipe fails in the Ubuntu 32-bit CI jobs on current main as well (test_namedpipe.c:64, seen in a fork CI run of d394386), so that failure is not from this PR.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant