AndreRH / hangover

Hangover runs simple Win32 applications on arm64 Linux
GNU Lesser General Public License v2.1
1.33k stars 96 forks source link

undefined reference to NtSetContextThread #46

Closed mpbagot closed 4 years ago

mpbagot commented 4 years ago

I've been attempting to build Hangover, and while most of the build seems to succeed, when building QEMU, I come across the following:

...
...
  GEN     trace/generated-helpers.c
  CC      x86_64-windows-user/trace/generated-helpers.o
  CC      x86_64-windows-user/trace/control-target.o
  CC      x86_64-windows-user/windows-user/main.o
...
...
In file included from /home/ubuntu/build/hangover/qemu/windows-user/main.c:32:
In file included from /home/ubuntu/build/hangover/qemu/windows-user/qemu.h:5:
In file included from /home/ubuntu/build/hangover/wine/include/windows.h:61:
/home/ubuntu/build/hangover/wine/include/winperf.h:165:10: warning: the current #pragma pack alignment value is modified in the included file [-Wpragma-pack]
#include <poppack.h>
         ^
/home/ubuntu/build/hangover/wine/include/poppack.h:253:13: note: previous '#pragma pack' directive that modifies alignment is here
#    pragma pack()
            ^
In file included from /home/ubuntu/build/hangover/qemu/windows-user/main.c:47:
In file included from /home/ubuntu/build/hangover/qemu/windows-user/win_syscall.h:4:
/home/ubuntu/build/hangover/qemu/include/windows-user-services.h:22:15: error: invalid input constraint 'c' in asm
            : "c"(call)
              ^
32 warnings and 1 error generated.
winegcc: clang failed
make[2]: *** [/home/ubuntu/build/hangover/qemu/rules.mak:69: windows-user/main.o] Error 2
make[1]: *** [Makefile:491: x86_64-windows-user/all] Error 2
make[1]: Leaving directory '/home/ubuntu/build/hangover/build/qemu'
make: *** [Makefile:120: build/qemu/x86_64-windows-user/qemu-x86_64.exe.so] Error 2

The error occurs on an assembly call, in the qemu_syscall function of the given header:

static inline void qemu_syscall(struct qemu_syscall *call)
{
    /* TODO: 32 bit version. */
    asm volatile( "syscall\n"
            : /* no output */
            : "c"(call)
            : "memory");
}

I'm running Ubuntu aarch64 19.10 on a Raspberry Pi 4 4GB model, uname -a output is as below:

Linux ubuntu 5.3.0-1014-raspi2 #16-Ubuntu SMP Tue Nov 26 11:18:23 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux

Any advice would be greatly appreciated.

stefand commented 4 years ago

I've never attempted to build this with clang. Try gcc, or see if you can find a way to tell clang to put 'call' into a specific register ('rcx' in this case), preferably without adding an extra mov.

mpbagot commented 4 years ago

When building with GCC, I encounter an entirely different error. The dlls32 all build as expected, but when ntdll.dll in dlls64 tries to build, it fails with an undefined reference to NtSetContextThread, as shown at the end of the log:

make -C build/dlls64/ntdll ntdll.dll
make[1]: Entering directory '/home/ubuntu/build/hangover/build/dlls64/ntdll'
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/actctx.c -c -o actctx_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/critsection.c -c -o critsection_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/debugtools.c -c -o debugtools_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/directory.c -c -o directory_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/env.c -c -o env_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/error.c -c -o error_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/exception.c -c -o exception_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/file.c -c -o file_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/heap.c -c -o heap_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/loader.c -c -o loader_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/main.c -c -o main_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/misc.c -c -o misc_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/nt.c -c -o nt_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/om.c -c -o om_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/path.c -c -o path_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/printf.c -c -o printf_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/process.c -c -o process_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/reg.c -c -o reg_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/resource.c -c -o resource_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/rtl.c -c -o rtl_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/rtlbitmap.c -c -o rtlbitmap_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/rtlstr.c -c -o rtlstr_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/sec.c -c -o sec_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/signal.c -c -o signal_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/string.c -c -o string_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/sync.c -c -o sync_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/thread.c -c -o thread_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/threadpool.c -c -o threadpool_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/time.c -c -o time_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/version.c -c -o version_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/virtual.c -c -o virtual_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
x86_64-w64-mingw32-gcc ../../../dlls/ntdll/wcstring.c -c -o wcstring_g.o -I../../../dlls/ntdll/../include -I../../../dlls/ntdll/../../qemu/include -DQEMU_CURRENT_DLL=DLL_NTDLL -O2 -DGUEST_BIT=64 -DHOST_BIT=64 -DNTDDI_VERSION=0x06020000 -D_WIN32_WINNT=0x0603 -DQEMU_DLL_GUEST
../../../build/wine-host/tools/winegcc/winegcc --winebuild ../../../build/wine-host/tools/winebuild/winebuild -I../../../build/wine-host/include -I../../../wine/include --wine-objdir ../../../build/wine-guest -shared -b x86_64-w64-mingw32 ../../../dlls/ntdll/ntdll.spec *_g.o -o ntdll.dll -nodefaultlibs -nostdlib -Wl,--image-base,0x9000000
/usr/bin/x86_64-w64-mingw32-ld: ntdll.dll-3LiQLk.spec.o:fake:(.edata+0x434): undefined reference to `NtSetContextThread'
/usr/bin/x86_64-w64-mingw32-ld: ntdll.dll-3LiQLk.spec.o:fake:(.edata+0xfb8): undefined reference to `NtSetContextThread'
collect2: error: ld returned 1 exit status
winegcc: x86_64-w64-mingw32-gcc failed
make[1]: *** [../../../dlls/ntdll/Makefile:12: ntdll.dll] Error 2
make[1]: Leaving directory '/home/ubuntu/build/hangover/build/dlls64/ntdll'
make: *** [Makefile:203: build/dlls64/ntdll/ntdll.dll] Error 2
ubuntu@ubuntu:~/build/hangover$ 
mpbagot commented 4 years ago

Manually running the winegcc command without the -nodefaultlibs argument allowed the dll to link, and the rest of the build finished without any further problems.

However, when running notepad.exe from wine-guest, the h2g_valid assertion fails in qemu, and notepad never launches. However, notepad.exe in wine-guest32 runs perfectly. I assume this is related, but I'm not sure.

stefand commented 4 years ago

Hmm, I guess both issues are my fault. NtSetContextThread only exists in 32 bit guest ntdll right now, but I enabled the export for both. I am not sure why it managed to build on my box...

Wrt 64 bit notepad.exe, it is quite likely that this has bitrotted. I don't have much time to spend on hangover and can't quite keep up with the recent kernel32->kernelbase code move changes in Wine. I got it to a state where it loads without spewing lots of unimplemented function warnings, but I didn't test much beyond that. And I usually work on the 32 bit client code most of the time because that's the more interesting use case for me.

parkerlreed commented 4 years ago

I seem to be hitting the same NtSetContext error when building https://github.com/AndreRH/hangover/issues/53

I thought my edits may have been wrong (fixing another error) but I guess they worked.

stefand commented 4 years ago

Comment out the NtSetContext line in dlls/ntdll/ntdll.spec. 57428a4e14f219e3729573fbe4a049bab5b2a7a1 was partially wrong there because this function is currently only implemented for x86 and not x86_64.

parkerlreed commented 4 years ago

We have life! (Except 64 bit notepad++.exe may be broken as mentioned)

Any other suggestions as what to try hangover wise that should work?

[parker@alarm hangover]$ DISPLAY=:0 /home/parker/build/hangover/build/wine-host/loader/wine64 /home/parker/build/hangover/build/qemu/x86_64-windows-user/qemu-x86_64.exe.so notepad++.exe                      
0020:err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
000d:err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
002d:err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
0009:err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
0009:err:winediag:SECUR32_initNTLMSP ntlm_auth was not found or is outdated. Make sure that ntlm_auth >= 3.0.25 is in your path. Usually, you can find it in the winbind package of your distribution.
0009:fixme:qemu_module:import_dll No implementation for ntdll.dll.NtSetContextThread imported from L"C:\\windows\\system32\\kernelbase.dll", setting to 0x7fb50e1190
0009:fixme:qemu_ntdll:qemu_LdrDisableThreadCalloutsForDll Unverified!
0009:fixme:qemu_ntdll:qemu_RtlUnicodeStringToAnsiString Unverified!
0009:fixme:qemu_ntdll:qemu_LdrGetProcedureAddress Unverified!
0009:fixme:qemu_ntdll:qemu_LdrGetProcedureAddress Unverified!
0009:fixme:qemu_ntdll:qemu_LdrDisableThreadCalloutsForDll Unverified!
0009:fixme:qemu_ntdll:qemu_strncmp Unverified!
0009:fixme:qemu_ntdll:qemu_strncmp Unverified!
0009:fixme:qemu_ntdll:qemu_strncmp Unverified!
0009:fixme:qemu_ntdll:qemu_strncmp Unverified!
0009:fixme:qemu_ntdll:qemu_strncmp Unverified!
0009:fixme:qemu_ntdll:qemu_strncmp Unverified!
0009:fixme:qemu_module:qemu_LoadLibrary unsupported flag(s) used (flags: 0x00000800)
0009:fixme:qemu_module:qemu_LoadLibrary unsupported flag(s) used (flags: 0x00000800)
0009:fixme:qemu_module:qemu_LoadLibrary unsupported flag(s) used (flags: 0x00000800)
0009:fixme:qemu_module:qemu_LoadLibrary unsupported flag(s) used (flags: 0x00000800)
0009:fixme:qemu_module:qemu_LoadLibrary unsupported flag(s) used (flags: 0x00000800)
0009:fixme:qemu_module:qemu_LoadLibrary unsupported flag(s) used (flags: 0x00000800)
0009:fixme:qemu_module:qemu_LoadLibrary unsupported flag(s) used (flags: 0x00000800)
0009:fixme:qemu_ntdll:qemu_NtQueryInformationProcess Unverified!
0009:fixme:qemu_ntdll:qemu_NtSetInformationProcess Unverified!
0009:fixme:qemu_ntdll:qemu_RtlIsDosDeviceName_U Unverified!
0009:fixme:qemu_ntdll:qemu_NtQueryInformationProcess Unverified!
0009:fixme:qemu_ntdll:qemu_NtSetInformationProcess Unverified!
Exception triggered in host code at 0x7fb7429758, guest PC 2000ce2c
wine: Unhandled alignment at address 0000007FB7429758 (thread 0009), starting debugger...
0032:err:winediag:xrandr12_init_modes Broken NVIDIA RandR detected, falling back to RandR 1.0. Please consider using the Nouveau driver instead.
0009:err:seh:call_function_handlers invalid frame 22fff8 (0x132000-0x230000)
Unhandled exception: Alignment, invalid program stack in 64-bit code (0x0000007fb7429758).
Register dump:
ARM64 EL0t Mode
 Pc:0000007fb7429758 Sp:000000000022e778 Lr:6000000000400003 Cpsr:60000000(-ZC-)
 x0: 0000000000000000 x1: 000000007ffda000 x2: 0000000000000001 x3: 0000007fb7cdf048 x4: 0000000000000001
 x5: 0000000000000000 x6: 0000007fb7eee6b8 x7: 0000000000000000 x8: 000000007be9bd20 x9: 000000007bcb7128
 x10:00000000000e8860 x11:000000000022e9d8 x12:0000000000002290 x13:0000007fb5167000 x14:0000000000000008
 x15:000000000000785c ip0:000000007be90260 ip1:0000007fb7cc4718 x18:0000000000000000 x19:000000000022d970
 x20:000000007bcede48 x21:000000000022dd58 x22:000000000022e778 x23:000000000022dd48 x24:000000007be9b000
 x25:0000007c00000078 x26:0000000000000000 x27:000000007bcede48 x28:0000000000000000 Fp:000000000022d8b0
Stack dump:
0x000000000022e778:  000000000022ff08 0000007fb74297e8
0x000000000022e788:  0000007fb73e6438 0000000000000082
0x000000000022e798:  000000000022e778 0000000000000000
0x000000000022e7a8:  00000000000e8860 000000000022e9d8
0x000000000022e7b8:  000000000022e9e8 00000002000002b8
0x000000000022e7c8:  0000007fb50dfe38 0000007fb5167000
0x000000000022e7d8:  000000007ffda000 0000007fb5167000
0x000000000022e7e8:  0000007fb7b31710 0000007faf66eba0
0x000000000022e7f8:  000000000022e710 0000007fb73e7e0c
0x000000000022e808:  000000000022e710 0000001000000000
0x000000000022e818:  0000000000000000 0000000000000000
0x000000000022e828:  0000000000000000 0000000000000000
Backtrace:
=>0 0x0000007fb7429758 (0x000000000022d8b0)
  1 0x6000000000400003 (0x000000000022d8b0)
0x0000007fb7429758: be_arm64_disasm_one_insn: not done

Modules:
Module  Address                                 Debug info      Name (43 modules)
PE              7b420000-        7b610000       Deferred        kernel32
PE              7bc20000-        7bc60000       Deferred        ntdll
PE            7fac260000-      7fac2a0000       Deferred        xinput1_3
PE            7fac2b0000-      7fac2f0000       Deferred        wsock32
PE            7fac710000-      7fac750000       Deferred        winspool
PE            7fac8b0000-      7fac8f0000       Deferred        msacm32
PE            7fac8f0000-      7fac9a0000       Deferred        winmm
PE            7faca00000-      7faca30000       Deferred        shcore
PE            7faca40000-      7faca80000       Deferred        shlwapi
PE            7facab0000-      7facaf0000       Deferred        propsys
PE            7facb00000-      7facb40000       Deferred        windowscodecs
PE            7facfb0000-      7facfe0000       Deferred        kerberos
PE            7facfb0000-      7facfe0000       Deferred        ws2_32
PE            7fad020000-      7fad050000       Deferred        netapi32
PE            7fad070000-      7fad0a0000       Deferred        secur32
PE            7fad370000-      7fad3a0000       Deferred        usp10
PE            7fad3d0000-      7fad410000       Deferred        riched20
PE            7fad6f0000-      7fad730000       Deferred        oleaut32
PE            7fad820000-      7fad860000       Deferred        mmdevapi
PE            7fad960000-      7fad9a0000       Deferred        iphlpapi
PE            7fada40000-      7fada80000       Deferred        dxgi
PE            7fadbe0000-      7fadc20000       Deferred        ucrtbase
PE            7fadce0000-      7fadd20000       Deferred        dsound
PE            7fadda0000-      7fadde0000       Deferred        ddraw
PE            7fae140000-      7fae180000       Deferred        winex11
PE            7fae250000-      7fae290000       Deferred        opengl32
PE            7fae390000-      7fae3d0000       Deferred        wined3d
PE            7fae510000-      7fae550000       Deferred        d3d9
PE            7fae600000-      7fae680000       Deferred        crypt32
PE            7fae730000-      7fae770000       Deferred        cabinet
PE            7faeef0000-      7faef30000       Deferred        bcrypt
PE            7faef50000-      7faef90000       Deferred        setupapi
PE            7faefe0000-      7faf020000       Deferred        rpcrt4
PE            7faf0a0000-      7faf100000       Deferred        ole32
PE            7faf1f0000-      7faf220000       Deferred        advpack
PE            7faf380000-      7faf3c0000       Deferred        imm32
PE            7faf9b0000-      7faf9f0000       Deferred        msvcrt
PE            7fafa80000-      7fafac0000       Deferred        advapi32
PE            7fafb20000-      7fafb60000       Deferred        gdi32
PE            7fafcc0000-      7fafde0000       Deferred        user32
PE            7fb4fa0000-      7fb5307000       Deferred        notepad++
PE            7fb73c0000-      7fb73f0000       Deferred        kernelbase
PE            7fb7cf0000-      7fb7d30000       Deferred        version
Threads:
process  tid      prio (all id:s are in hex)
00000008 (D) F:\home\parker\build\hangover\notepad++.exe
        00000009    0 <==
0000000e services.exe
        00000027    0
        00000024    0
        0000001d    0
        0000001a    0
        00000014    0
        00000013    0
        00000010    0
        0000000f    0
00000011 plugplay.exe
        00000017    0
        00000016    0
        00000012    0
00000018 winedevice.exe
        00000021    0
        0000001e    0
        0000001c    0
        0000001b    0
        00000019    0
00000022 winedevice.exe
        00000028    0
        00000026    0
        00000025    0
        00000023    0
0000002c explorer.exe
        00000030    0
        0000002f    0
        0000002e    0
        0000002d    0
System information:
    Wine build: wine-1.5.11-44390-g151e57f0d5
    Platform: arm64
    Version: Windows 7
    Host system: Linux
    Host version: 4.9.140+
parkerlreed commented 4 years ago

32 and 64 bit notepad++ are showing that same error. I guess I'll keep going and see if I can find anything else I may want to run.

EDIT: Hah, SkiFree 32bit worked. Sweet.

stefand commented 4 years ago

Hah, something's working :-) Wine's own programs (notepad, winemine, wordpad) are good test cases too. Not everything works though, e.g. winecfg inside hangover is somewhat pointless.

Not sure what's wrong in notepad++. Some "older" DLLs have fixed load addresses (look into the makefile), making them easy to identify. "guest PC 2000ce2c" is kernel32.dll, sl WINEDEBUG=qemu_kernel32 might give some clues.

parkerlreed commented 4 years ago

Here's the log from that winedebug http://ix.io/27jC (notepad++.exe 64bit)

stefand commented 4 years ago

0009:trace:qemu_kernel32:qemu_OutputDebugStringW Exception triggered in host code at 0x7fa127e758, guest PC 2000ce2c

I have seen this issue before - OutputDebugStringW internally triggers an exception, but it also handles it if no debugger is attached. The point is to pass some information to a debugger, if one is there.

What a crash like this usually means is that host-side (aarch64) exception handling is broken. For notepad++ you can hack around this by editing wine/dlls/kernel32/debugger.c to make OutputDebugStringA() just return after writing the WARN line before the __TRY block. Do expect troubles later on though :-)

parkerlreed commented 4 years ago

Doesn't seem to be in that file

[parker@alarm hangover]$ grep -r OutputDebugStringA wine/
wine/include/winbase.h:WINBASEAPI VOID        WINAPI OutputDebugStringA(LPCSTR);
wine/dlls/mmsystem.dll16/mmsystem.c:    OutputDebugStringA( str );
wine/dlls/kernelbase/kernelbase.spec:@ stdcall OutputDebugStringA(str)
wine/dlls/kernelbase/debug.c: *           OutputDebugStringA   (kernelbase.@)
wine/dlls/kernelbase/debug.c:void WINAPI DECLSPEC_HOTPATCH OutputDebugStringA( LPCSTR str )
wine/dlls/kernelbase/debug.c:        OutputDebugStringA( strA.Buffer );
wine/dlls/dxerr8/dxerr8.c:        OutputDebugStringA(msg);
wine/dlls/kernel32/kernel32.spec:@ stdcall -import OutputDebugStringA(str)
wine/dlls/api-ms-win-core-debug-l1-1-0/api-ms-win-core-debug-l1-1-0.spec:@ stdcall OutputDebugStringA(str) kernel32.OutputDebugStringA
wine/dlls/krnl386.exe16/kernel.c:    OutputDebugStringA( str );
wine/dlls/ntdll/tests/exception.c:    OutputDebugStringA("Hello World");
wine/dlls/ntdll/tests/exception.c:    ok(outputdebugstring_exceptions == numexc, "OutputDebugStringA generated %d exceptions, expected %d\n",
wine/dlls/api-ms-win-core-debug-l1-1-1/api-ms-win-core-debug-l1-1-1.spec:@ stdcall OutputDebugStringA(str) kernel32.OutputDebugStringA
wine/dlls/dxerr9/dxerr9.c:        OutputDebugStringA(msg);

wine/dlls/kernelbase/debug.c maybe?

stefand commented 4 years ago

Yeah, kernelbase. It got moved recently (and those moves cause me a lot of pain), but in the long run it will make something like hangover way simpler by reducing the interface surface between Win32 and host.

parkerlreed commented 4 years ago

I made the edit and reran make but I don't think it got picked up. Appears to crash in the exact same way. Is there something I have to clean first before rerunning make?

stefand commented 4 years ago

try to build in build/wine-host/dlls/kernelbase. I think the top level makefile is buggy and doesn't recurse into wine-hosts when the build output is there.

Trass3r commented 4 years ago

I've never attempted to build this with clang. Try gcc, or see if you can find a way to tell clang to put 'call' into a specific register ('rcx' in this case), preferably without adding an extra mov.

Clang does support input constraint 'c' but only on x86 of course. I guess the wrong compiler gets used, for aarch64?: https://github.com/Trass3r/hangover/runs/395587246

AndreRH commented 4 years ago

fixed by 38217cad87e3cbfddc9eaa719038c825897b22ca