ptitSeb / box86

Box86 - Linux Userspace x86 Emulator with a twist, targeted at ARM Linux devices
https://box86.org
MIT License
3.2k stars 222 forks source link

wrap time64 glibc functions #600

Open Trass3r opened 2 years ago

Trass3r commented 2 years ago

Tested on armv8l Ubuntu 22.04 inside termux-proot.

$ git clone --recursive --depth=1 https://github.com/ptitSeb/box86 .
$ CFLAGS=-flto CXXFLAGS=-flto LDFLAGS=-flto=auto \
$ cmake .. -DARM_DYNAREC=ON -GNinja -DCMAKE_BUILD_TYPE=Release
$ time ninja

$ wget https://dl.winehq.org/wine-builds/ubuntu/dists/impish/main/binary-i386/wine-devel-i386_7.5~impish-1_i386.deb
$ wget https://dl.winehq.org/wine-builds/ubuntu/dists/impish/main/binary-i386/wine-devel_7.5~impish-1_i386.deb
$ dpkg-deb -xv wine-devel_7.5~impish-1_i386.deb wine-installer
$ dpkg-deb -xv wine-devel-i386_7.5~impish-1_i386.deb wine-installer
$ mv wine-installer/opt/wine* ~/wine
$ box86 ~/wine/bin/wine --version
[...]
Error: Symbol __time64 not found, cannot apply R_386_JMP_SLOT 0xe94e22b8 (0x6af6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
wine-7.5

$ file /root/wine/bin/../lib/wine/i386-unix/ntdll.so
ntdll.so: ELF 32-bit LSB shared object, Intel 80386
$ export BOX86_LOG=1 BOX86_DYNAREC_LOG=1
$ WINEARCH=win32 box86 ~/wine/bin/wine wineboot

Dynarec for ARMv8, with extension: HALF FAST_MULT EDSP NEON VFPv4 IDIVA PageSize:4096
Box86 with Dynarec v0.2.5 dc461d4 built on Apr  1 2022 13:56:33
BOX86: Wine detected, WINEPRELOADRESERVE=""
Using default BOX86_LD_LIBRARY_PATH: ./:lib/:lib32/:x86/:i686/
Using default BOX86_PATH: ./:bin/
Counted 35 Env var
Looking for /root/wine/bin/wine
argv[1]="wineboot"
Using native(wrapped) libdl.so.2
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) librt.so.1
Using emulated /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __prctl_time64 not found, cannot apply R_386_JMP_SLOT 0xf785200c (0x6046) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __gmtime64 not found, cannot apply R_386_JMP_SLOT 0xf7852010 (0x6056) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __localtime64 not found, cannot apply R_386_JMP_SLOT 0xf7852020 (0x6096) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __stat64_time64 not found, cannot apply R_386_JMP_SLOT 0xf7852034 (0x60e6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __fstatat64_time64 not found, cannot apply R_386_JMP_SLOT 0xf7852044 (0x6126) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __recvmsg64 not found, cannot apply R_386_JMP_SLOT 0xf785206c (0x61c6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __futimens64 not found, cannot apply R_386_JMP_SLOT 0xf7852088 (0x6236) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __getsockopt64 not found, cannot apply R_386_JMP_SLOT 0xf78520ac (0x62c6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __sendmsg64 not found, cannot apply R_386_JMP_SLOT 0xf78520c8 (0x6336) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __fstat64_time64 not found, cannot apply R_386_JMP_SLOT 0xf78520e4 (0x63a6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __clock_getres64 not found, cannot apply R_386_JMP_SLOT 0xf78520e8 (0x63b6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __setsockopt64 not found, cannot apply R_386_JMP_SLOT 0xf7852134 (0x64e6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __select64 not found, cannot apply R_386_JMP_SLOT 0xf785213c (0x6506) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __fcntl_time64 not found, cannot apply R_386_JMP_SLOT 0xf7852144 (0x6526) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __lstat64_time64 not found, cannot apply R_386_JMP_SLOT 0xf78521f4 (0x67e6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __ctime64 not found, cannot apply R_386_JMP_SLOT 0xf7852204 (0x6826) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __gettimeofday64 not found, cannot apply R_386_JMP_SLOT 0xf7852238 (0x68f6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __clock_gettime64 not found, cannot apply R_386_JMP_SLOT 0xf785225c (0x6986) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __ioctl_time64 not found, cannot apply R_386_JMP_SLOT 0xf7852268 (0x69b6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __mktime64 not found, cannot apply R_386_JMP_SLOT 0xf7852288 (0x6a36) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __time64 not found, cannot apply R_386_JMP_SLOT 0xf78522b8 (0x6af6) in /root/wine/bin/../lib/wine/i386-unix/ntdll.so
Address 0x63a6 not found in Elf memory and is not a native call wrapper
Address 0x63a6 not found in Elf memory and is not a native call wrapper
8082|SIGSEGV @0x6290368c (???(/root/Desktop/box86/build/box86/0x6290368c)) (x86pc=0x63a6/???:"???", esp=0xf713fa8c, stack=0xf6941000:0xf7141000 own=(nil) fp=0xf713fb38), for accessing 0x63a6 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0)
8082|Double SIGSEGV (code=1, pc=0x6290368c, addr=0x63a6)!
ptitSeb commented 2 years ago

I would suggest you use another wine build. this is built with the new "64" time stuff that are not yet wrapped on box86 but also not present on all system yet.

Trass3r commented 2 years ago

Yeah the functions exist:

 ...  =>PltResolver: Addr=0x63328688, Slot=24 Return=0x7d00158e: elf is /root/wine/bin/wine (VerSym=0x7d000614)
            Apply Global R_386_JMP_SLOT 0x7d003fa4 with sym=free(ver 3: free@GLIBC_2.0) (0x7d001076 -> 0x6332f0a0 / (noelf))
 return 0x00000001
13215|0x7d00158e: Calling free (/lib/arm-linux-gnueabihf/libc.so.6) (633316E0, 00000002, 0000001F...) => return 0x00000001
13215|0x7d001273: Calling free (/lib/arm-linux-gnueabihf/libc.so.6) (633378A0, 0000000E, E9B80CE8...) => return 0x00000001
 ...  =>PltResolver: Addr=0x63328688, Slot=144 Return=0x7d00128d: elf is /root/wine/bin/wine (VerSym=0x7d000614)
            Apply Global R_386_JMP_SLOT 0x7d003fe0 with sym=dlsym(ver 2: dlsym@GLIBC_2.34) (0x7d001166 -> 0x6332c020 / (noelf))
13215|0xea240af0: Calling puts (/lib/arm-linux-gnueabihf/libc.so.6)("wine-7.5"...) =>wine-7.5
$ nm -D ~/wine/lib/wine/i386-unix/ntdll.so | grep -w U
U __time64@GLIBC_2.34
U puts@GLIBC_2.0
$ nm -D /lib/arm-linux-gnueabihf/libc.so.6 | fgrep -wi T
0007b0fc T __time64@@GLIBC_2.34
00069058 T free@@GLIBC_2.4
ptitSeb commented 2 years ago

Ok. Anyway, it's a large bunch of functions. Not sure when I'll add them.

Trass3r commented 2 years ago

Thanks I'll test an older version in the meantime. Using the focal build works.

wget https://dl.winehq.org/wine-builds/ubuntu/dists/focal/main/binary-i386/wine-devel-i386_7.5~focal-1_i386.deb
wget https://dl.winehq.org/wine-builds/ubuntu/dists/focal/main/binary-i386/wine-devel_7.5~focal-1_i386.deb
danmons commented 1 year ago

I hit this running Debian Bookworm on RPi this week.

Rolling back through the WINE-HQ provided i386 releases in their bookworm repo, 7.15 is the last working version.

7.16 introduces __time64 and no longer works on my RPi's 5.15.56-v7l+ armv7l kernel coupled with Debian Bookworm armhf distro.

aselafernando commented 9 months ago

Trying with latest Raspbian (Bookworm) aarch64 with x86 wine 8.0.2 On Bullseye with wine 8.0.2 this error is not present.

Confirmed Bookworm and wine 7.0.2 does not have this error

BOX86_LOG=1 BOX86_DYNAREC_LOG=1 WINEARCH=win32 /opt/wine/bin/wineboot
Debug level is 1
Dynarec log level is 1
Dynarec for ARMv8, with extension: HALF FAST_MULT EDSP NEON VFPv4 IDIVA PageSize:4096 Running on Cortex-A72 with 4 Cores
Params database has 29 entries
Box86 with Dynarec v0.3.3 f7162129 built on Oct 16 2023 18:37:22
BOX86: Wine detected, WINEPRELOADRESERVE=""
New Bridge brick at 0x40000000 (size 0x1000)
New Bridge brick at 0x40010000 (size 0x1000)
New Bridge brick at 0x40020000 (size 0x1000)
Using default BOX86_LD_LIBRARY_PATH: ./:lib/:lib32/:x86/:i686/
Using default BOX86_PATH: ./:bin/
Counted 27 Env var
Looking for ./wine
argv[1]="wineboot.exe"
Rename process to "wine"
New Bridge brick at 0x40030000 (size 0x1000)
Using native(wrapped) libdl.so.2
New Bridge brick at 0x40040000 (size 0x1000)
Using native(wrapped) libc.so.6
New Bridge brick at 0x40050000 (size 0x1000)
Using native(wrapped) ld-linux.so.2
New Bridge brick at 0x40060000 (size 0x1000)
Using native(wrapped) libpthread.so.0
New Bridge brick at 0x40070000 (size 0x1000)
Using native(wrapped) librt.so.1
New Bridge brick at 0x40080000 (size 0x1000)
Using native(wrapped) libm.so.6
Using emulated /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
New Bridge brick at 0x40090000 (size 0x1000)
Error: Symbol __gmtime64 not found, cannot apply R_386_JMP_SLOT 0xf7b03004 (0x6046) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __localtime64 not found, cannot apply R_386_JMP_SLOT 0xf7b03010 (0x6076) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __stat64_time64 not found, cannot apply R_386_JMP_SLOT 0xf7b03024 (0x60c6) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __fstatat64_time64 not found, cannot apply R_386_JMP_SLOT 0xf7b03034 (0x6106) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __recvmsg64 not found, cannot apply R_386_JMP_SLOT 0xf7b0305c (0x61a6) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __futimens64 not found, cannot apply R_386_JMP_SLOT 0xf7b03080 (0x6236) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __getsockopt64 not found, cannot apply R_386_JMP_SLOT 0xf7b030a8 (0x62d6) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __sendmsg64 not found, cannot apply R_386_JMP_SLOT 0xf7b030c4 (0x6346) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __fstat64_time64 not found, cannot apply R_386_JMP_SLOT 0xf7b030e0 (0x63b6) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __clock_getres64 not found, cannot apply R_386_JMP_SLOT 0xf7b030e4 (0x63c6) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __setsockopt64 not found, cannot apply R_386_JMP_SLOT 0xf7b03130 (0x64f6) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __select64 not found, cannot apply R_386_JMP_SLOT 0xf7b03138 (0x6516) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __fcntl_time64 not found, cannot apply R_386_JMP_SLOT 0xf7b03140 (0x6536) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __lstat64_time64 not found, cannot apply R_386_JMP_SLOT 0xf7b031f4 (0x6806) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __ctime64 not found, cannot apply R_386_JMP_SLOT 0xf7b03204 (0x6846) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __gettimeofday64 not found, cannot apply R_386_JMP_SLOT 0xf7b03238 (0x6916) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __ioctl_time64 not found, cannot apply R_386_JMP_SLOT 0xf7b0326c (0x69e6) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __mktime64 not found, cannot apply R_386_JMP_SLOT 0xf7b0328c (0x6a66) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: Symbol __time64 not found, cannot apply R_386_JMP_SLOT 0xf7b032c0 (0x6b36) in /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Error: relocating Plt symbols in elf ntdll.so
Error initializing needed lib /opt/wine/bin/../lib/wine/i386-unix/ntdll.so
Free DynaBlocks for /opt/wine/lib/wine/i386-unix/ntdll.so
wine: could not load ntdll.so: Cannot dlopen("/opt/wine/bin/../lib/wine/i386-unix/ntdll.so"/0x65031e38, 2)

Free DynaBlocks for /opt/wine/bin/wine