Open ValdikSS opened 7 months ago
When running in fully emulated mode, it crashes with SIGSEGV 0x2a reloc type is R_386_IRELATIVE.
# BOX86_DLSYM_ERROR=1 BOX86_LOG=1 BOX86_PREFER_EMULATED=1 BOX86_EMULATED_LIBS=libc.so.6 BOX86_DYNAREC=0 BOX86_SHOWSEGV=1 BOX86_SHOWBT=1 box86 /tmp/a.out
Debug level is 1
Dynarec is off
Shows details of dlopen / dlsym /dlclose : Yes
Show Segfault signal even if a signal handler is present
Show Backtrace for signals
Running on Cortex-A7 with 2 Cores
Params database has 32 entries
Box86 with Dynarec v0.3.4 nogit built on Jan 18 2024 07:41:17
Using default BOX86_LD_LIBRARY_PATH: ./:lib/:lib32/:x86/:i686/
BOX86 will force the used of emulated libs for libc.so.6
Using default BOX86_PATH: ./:bin/
BOX86: Prefer Emulated libs
Counted 16 Env var
Looking for /tmp/a.out
Rename process to "a.out"
Using emulated /lib/i386-linux-gnu/libc.so.6
Redirecting overridden malloc function for /lib/i386-linux-gnu/libc.so.6
Using emulated /lib/i386-linux-gnu/ld-linux.so.2
Warning, don't know how to handle rel #2 type: 0x2a (unknown) (0x60432ba0) for
Warning, don't know how to handle rel #92 type: 0x2a (unknown) (0x6021c844) for
Warning, don't know how to handle rel #15 type: 0x2a (unknown) (0x6021d03c) for
Warning, don't know how to handle rel #16 type: 0x2a (unknown) (0x6021d01c) for
Warning, don't know how to handle rel #17 type: 0x2a (unknown) (0x6021d014) for
Warning, don't know how to handle rel #18 type: 0x2a (unknown) (0x6021d004) for
Warning: Global Symbol _ITM_deregisterTMCloneTable not found, cannot apply R_386_GLOB_DAT @0x30003fe0 ((nil)) in /tmp/a.out
Warning: Global Symbol _ITM_registerTMCloneTable not found, cannot apply R_386_GLOB_DAT @0x30003ff0 ((nil)) in /tmp/a.out
10673|SIGSEGV @0x62ae72dc (???(/tmp/a.out/0x62ae72dc)) (x86pc=0x230d0/???:"???", esp=0xb6cefd88, stack=0xb64f0000:0xb6cf0000 own=(nil) fp=(nil)), for accessing 0x230d0 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0)
ESP-0x10:0x00000000 ESP-0x0c:0x00000000 ESP-0x08:0x00000000 ESP-0x04:0x00000000
ESP+0x00:0x40020010 ESP+0x04:0x00000001 ESP+0x08:0xb6cefd9c ESP+0x0c:0xb6cefda4
Native bactrace:
/tmp/a.out() [0x629609c0]
/lib/arm-linux-gnueabihf/libc.so.6(+0x2e1b0) [0xb6e791b0]
/tmp/a.out() [0x62ae72dc]
/tmp/a.out() [0x62969650]
/tmp/a.out() [0x629697f8]
/tmp/a.out() [0x6289b244]
/tmp/a.out() [0x62936674]
/tmp/a.out() [0x62936848]
/tmp/a.out() [0x628899e8]
/lib/arm-linux-gnueabihf/libc.so.6(+0x1e2da) [0xb6e692da]
/lib/arm-linux-gnueabihf/libc.so.6(__libc_start_main+0x5d) [0xb6e6938a]
10673|Double SIGSEGV (code=1, pc=0x62ae72dc, addr=0x230d0)!
And the similar issue with symbol loading when running in prefer-emulated mode:
# BOX86_DLSYM_ERROR=1 BOX86_LOG=1 BOX86_PREFER_EMULATED=1 box86 /tmp/a.out
Debug level is 1
Shows details of dlopen / dlsym /dlclose : Yes
Dynarec for ARMv7, with extension: HALF FAST_MULT EDSP NEON VFPv4 SWP IDIVA PageSize:4096 Running on Cortex-A7 with 2 Cores
Params database has 32 entries
Box86 with Dynarec v0.3.4 nogit built on Jan 18 2024 07:41:17
Using default BOX86_LD_LIBRARY_PATH: ./:lib/:lib32/:x86/:i686/
Using default BOX86_PATH: ./:bin/
BOX86: Prefer Emulated libs
Counted 16 Env var
Looking for /tmp/a.out
Rename process to "a.out"
Using native(wrapped) libc.so.6
Using emulated /lib/i386-linux-gnu/ld-linux.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) librt.so.1
Using native(wrapped) libdl.so.2
Using native(wrapped) libm.so.6
Using emulated /lib/i386-linux-gnu/libbsd.so.0
Warning, don't know how to handle rel #2 type: 0x2a (unknown) (0x60032ba0) for
Using emulated /lib/i386-linux-gnu/libmd.so.0
Using native(wrapped) libc.so.6
Error: Global Symbol __progname not found, cannot apply R_386_GLOB_DAT @0x60215fd8 ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Warning: Global Symbol _ITM_deregisterTMCloneTable not found, cannot apply R_386_GLOB_DAT @0x60215fdc ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Error: Global Symbol printf not found, cannot apply R_386_GLOB_DAT @0x60215fe0 ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Error: Global Symbol stderr not found, cannot apply R_386_GLOB_DAT @0x60215fe4 ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Error: Global Symbol optind not found, cannot apply R_386_GLOB_DAT @0x60215fe8 ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Warning: Global Symbol __cxa_finalize not found, cannot apply R_386_GLOB_DAT @0x60215fec ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Error: Global Symbol program_invocation_short_name not found, cannot apply R_386_GLOB_DAT @0x60215ff4 ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Warning: Global Symbol _ITM_registerTMCloneTable not found, cannot apply R_386_GLOB_DAT @0x60215ff8 ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Error: Global Symbol environ not found, cannot apply R_386_GLOB_DAT @0x60215ffc ((nil)) in /lib/i386-linux-gnu/libbsd.so.0
Error: PltResolver: Symbol fstat(ver 4: fstat@GLIBC_2.33) not found, cannot apply R_386_JMP_SLOT 0x30004004 (0x30001046) in /tmp/a.out
Note that I don't use bundled x86lib
's from the repository, namely libstdc++6
breaks my working version of it which I use in qemu.
I figured out how to add wrapping symbols to libc.
@ptitSeb, do I understand correctly that right now the linker does not respect symvers for wrapped libraries, that's why there are checks for glibc version? I see the version checks in the loader itself (for emulated libraries), but not in the wrappers.
I figured out how to add wrapping symbols to libc.
@ptitSeb, do I understand correctly that right now the linker does not respect symvers for wrapped libraries, that's why there are checks for glibc version? I see the version checks in the loader itself (for emulated libraries), but not in the wrappers.
There is some limited support for symver
, but most wrapped function ignore that. You can create a GO2(blah@VER2, iFp, my_blah_old)
for example to hande some symver.
So, right now I've just uncommented these stat, lstat, fstat
and made them GO
Not sure how to fix this properly as this apparently would break Steam userspace you're targeting. These symbols were wrapped via __xstat
in previous glibc versions.
So, right now I've just uncommented these
stat, lstat, fstat
and made themGO
Not sure how to fix this properly as this apparently would break Steam userspace you're targeting. These symbols were wrapped via
__xstat
in previous glibc versions.
A GOM
should be created and check if stat
symbol exist. If yes, use it, else use __xstat
...
getting this error trying to run bash with box86
in nixOS as well
> export LD_LIBRARY_PATH="$(for lib in ncurses glibc; do nix-build '<nixpkgs>' -A pkgsCross.armv7l-hf-multiplatform.${lib} --no-out-link; done | xargs -I {} echo -n {}/lib: | sed 's/:$//')"
> box86 /nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash 16:21:41
Box86 with Dynarec v0.3.6 nogit built on Jan 1 1980 00:00:00
Error: PltResolver: Symbol __isoc23_strtoimax(ver 10: __isoc23_strtoimax@GLIBC_2.38) not found, cannot apply R_386_JMP_SLOT 0x813ec88 (0x805d2e6) in /nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash
> BOX86_DLSYM_ERROR=1 BOX86_LOG=1 BOX86_PREFER_EMULATED=1 BOX86_EMULATED_LIBS=libc.so.6 BOX86_DYNAREC=0 BOX86_SHOWSEGV=1 BOX86_SHOWBT=1 box86 /nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash
Debug level is 1
Dynarec is off
Shows details of dlopen / dlsym /dlclose : Yes
Show Segfault signal even if a signal handler is present
Show Backtrace for signals
Running on Neoverse-N1 with 4 Cores
Box86 with Dynarec v0.3.6 nogit built on Jan 1 1980 00:00:00
Using default BOX86_LD_LIBRARY_PATH: ./:lib/:lib32/:x86/:i686/
BOX86 will force the used of emulated libs for libc.so.6
Using default BOX86_PATH: ./:bin/
BOX86: Prefer Emulated libs
Counted 107 Env var
Looking for /nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash
bash detected, disabling banner
Rename process to "bash"
Using native(wrapped) libdl.so.2
Using emulated /nix/store/756q2acnjgi6ym709gw1f3jp0ciqwib1-glibc-2.39-52/lib/libc.so.6
Redirecting overridden malloc function for /nix/store/756q2acnjgi6ym709gw1f3jp0ciqwib1-glibc-2.39-52/lib/libc.so.6
Using emulated /nix/store/756q2acnjgi6ym709gw1f3jp0ciqwib1-glibc-2.39-52/lib/ld-linux.so.2
Warning, don't know of to handle rel #2 type: 0x2a (unknown) (0x60432b00) for
Warning, don't know of to handle rel #91 type: 0x2a (unknown) (0x60227c74) for
Warning, don't know of to handle rel #19 type: 0x2a (unknown) (0x60227e74) for
Warning, don't know of to handle rel #20 type: 0x2a (unknown) (0x60227e6c) for
Warning, don't know of to handle rel #21 type: 0x2a (unknown) (0x60227e64) for
Warning, don't know of to handle rel #22 type: 0x2a (unknown) (0x60227e58) for
Warning, don't know of to handle rel #23 type: 0x2a (unknown) (0x60227e34) for
Warning, don't know of to handle rel #24 type: 0x2a (unknown) (0x60227e30) for
Warning, don't know of to handle rel #25 type: 0x2a (unknown) (0x60227e24) for
1531240|SIGSEGV @0x62aace58 (???(/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash/0x62aace58)) (x86pc=0x24ab0/???:"???", esp=0x41a601fc, stack=0x41269000:0x41a69000 own=(nil) fp=(nil)), for accessing 0x24ab0 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0)
ESP-0x10:0x00000000 ESP-0x0c:0x00000000 ESP-0x08:0x00000000 ESP-0x04:0x00000000
ESP+0x00:0x40a70010 ESP+0x04:0x00000001 ESP+0x08:0x41a60210 ESP+0x0c:0x41a60218
Native bactrace:
/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash() [0x628fb2a4]
/nix/store/176g0h9j5vmkil0k8zb5h4a8iac06qcb-glibc-armv7l-unknown-linux-gnueabihf-2.39-52/lib/libc.so.6(__default_rt_sa_restorer+0) [0x40866cb0]
/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash() [0x62aace58]
/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash() [0x629057f8]
/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash() [0x629059c8]
/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash() [0x6282eed0]
/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash() [0x628d1ce8]
/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash() [0x628d1eb0]
/nix/store/3c54hwp1zji0h8yl66860cp8zp2vsrzv-bash-5.2p26/bin/bash() [0x6281c5dc]
/nix/store/176g0h9j5vmkil0k8zb5h4a8iac06qcb-glibc-armv7l-unknown-linux-gnueabihf-2.39-52/lib/libc.so.6(+0x238cc) [0x4084f8cc]
/nix/store/176g0h9j5vmkil0k8zb5h4a8iac06qcb-glibc-armv7l-unknown-linux-gnueabihf-2.39-52/lib/libc.so.6(__libc_start_main+0x98) [0x4084f9c0]
1531240|Double SIGSEGV (code=1, pc=0x62aace58, addr=0x24ab0)!
Using a glibc version older than 2.39-5
gives me segmentation fault, and older than 2.38
tells me `GLIBC_2.38' is missing
0x2a
This is a completly different issue: it's the relocation type "0x2a" that is not handled by box86. This need to be in a new ticket, not here.
0x2a
This is a completly different issue: it's the relocation type "0x2a" that is not handled by box86. This need to be in a new ticket, not here.
Ok, thanks, I'll make a new ticket then, but you said it is not handled by box86, I'm trying to test the package for nixOS, is it possible that it's a problem on the packaging then?
0x2a
This is a completly different issue: it's the relocation type "0x2a" that is not handled by box86. This need to be in a new ticket, not here.
Ok, thanks, I'll make a new ticket then, but you said it is not handled by box86, I'm trying to test the package for nixOS, is it possible that it's a problem on the packaging then?
Nope. It's a box86 iisue. Well, I guess the bash you have is built on NixOS itself and is fairly recent, compared to the one in the box86 repo....
0x2a
This is a completly different issue: it's the relocation type "0x2a" that is not handled by box86. This need to be in a new ticket, not here.
Ok, thanks, I'll make a new ticket then, but you said it is not handled by box86, I'm trying to test the package for nixOS, is it possible that it's a problem on the packaging then?
Nope. It's a box86 iisue. Well, I guess the bash you have is built on NixOS itself and is fairly recent, compared to the one in the box86 repo....
yeah, using the one in the repo would require a bunch of patching to work in a system like nixOS where libraries are never where programs usually expect them to be :v, I'll open another issue and maybe try to play around with the bash versioning a bit, if I figure anything out I'll put it there, thanks a lot :pray:
EDIT: made a new issue, also tried running with bash version 5.1.16(1)-release (i686-pc-linux-gnu)
, but got a similar error:
> export LD_LIBRARY_PATH="$(for lib in ncurses glibc; do nix-build '<nixpkgs>' -A pkgsCross.armv7l-hf-multiplatform.${lib} --no-out-link; done | xargs -I {} echo -n {}/lib: | sed 's/:$//')"
> echo $LD_LIBRARY_PATH 18:26:24
/nix/store/74gp2wabmv0cqwhpsjmglpzlwvyvd2r5-ncurses-armv7l-unknown-linux-gnueabihf-6.4/lib:/nix/store/176g0h9j5vmkil0k8zb5h4a8iac06qcb-glibc-armv7l-unknown-linux-gnueabihf-2.39-52/lib
> box86 /nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash 18:33:59
Box86 with Dynarec v0.3.6 nogit built on Jan 1 1980 00:00:00
# (exits with bash error code 255)
> BOX86_DLSYM_ERROR=1 BOX86_LOG=1 BOX86_PREFER_EMULATED=1 BOX86_EMULATED_LIBS=libc.so.6 BOX86_DYNAREC=0 BOX86_SHOWSEGV=1 BOX86_SHOWBT=1 box86 /nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash
Debug level is 1
Dynarec is off
Shows details of dlopen / dlsym /dlclose : Yes
Show Segfault signal even if a signal handler is present
Show Backtrace for signals
Running on Neoverse-N1 with 4 Cores
Box86 with Dynarec v0.3.6 nogit built on Jan 1 1980 00:00:00
Using default BOX86_LD_LIBRARY_PATH: ./:lib/:lib32/:x86/:i686/
BOX86 will force the used of emulated libs for libc.so.6
Using default BOX86_PATH: ./:bin/
BOX86: Prefer Emulated libs
Counted 107 Env var
Looking for /nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash
bash detected, disabling banner
Rename process to "bash"
Redirecting overridden malloc function for /nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash
Using native(wrapped) libdl.so.2
Using emulated /nix/store/0wr8hawrkjxp9bygcdisdg4kj2irqqyb-glibc-2.35-163/lib/libc.so.6
Redirecting overridden malloc function for /nix/store/0wr8hawrkjxp9bygcdisdg4kj2irqqyb-glibc-2.35-163/lib/libc.so.6
Using emulated /nix/store/0wr8hawrkjxp9bygcdisdg4kj2irqqyb-glibc-2.35-163/lib/ld-linux.so.2
Warning, don't know of to handle rel #145 type: 0x2a (unknown) (0x60436b18) for
Warning, don't know of to handle rel #1356 type: 0x2a (unknown) (0x60221cb4) for
Warning, don't know of to handle rel #17 type: 0x2a (unknown) (0x60221e8c) for
Warning, don't know of to handle rel #18 type: 0x2a (unknown) (0x60221e64) for
Warning, don't know of to handle rel #19 type: 0x2a (unknown) (0x60221e5c) for
Warning, don't know of to handle rel #20 type: 0x2a (unknown) (0x60221e4c) for
1708800|SIGSEGV @0x62aae070 (???(/nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash/0x62aae070)) (x86pc=0x600213dc//nix/store/0wr8hawrkjxp9bygcdisdg4kj2irqqyb-glibc-2.35-163/lib/libc.so.6:"???", esp=0x41a601c0, stack=0x41269000:0x41a69000 own=(nil) fp=(nil)), for accessing 0x50 (code=1/prot=0), db=(nil)((nil):(nil)/(nil):(nil)/???:clean, hash:0/0)
ESP-0x10:0x40a70010 ESP-0x0c:0x00000000 ESP-0x08:0x00000000 ESP-0x04:0x00000000
ESP+0x00:0x00000000 ESP+0x04:0x00000000 ESP+0x08:0x00000000 ESP+0x0c:0x00000000
Native bactrace:
/nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash() [0x628fb2a4]
/nix/store/176g0h9j5vmkil0k8zb5h4a8iac06qcb-glibc-armv7l-unknown-linux-gnueabihf-2.39-52/lib/libc.so.6(__default_rt_sa_restorer+0) [0x40866cb0]
/nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash() [0x62aae070]
/nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash() [0x629057f8]
/nix/store/9cf3kcqal0v4sj78kmfkdkplpifs1piv-bash-5.1-p16/bin/bash() [0x6281c68c]
/nix/store/176g0h9j5vmkil0k8zb5h4a8iac06qcb-glibc-armv7l-unknown-linux-gnueabihf-2.39-52/lib/libc.so.6(+0x238cc) [0x4084f8cc]
/nix/store/176g0h9j5vmkil0k8zb5h4a8iac06qcb-glibc-armv7l-unknown-linux-gnueabihf-2.39-52/lib/libc.so.6(__libc_start_main+0x98) [0x4084f9c0]
1708800|Double SIGSEGV (code=1, pc=0x62aae070, addr=0x50)!
Trying to study the code to understand why
fstat
symbol could not be found in the wrapped libc. It seems to be wrapped, and wrapper generator complains if I explicitly add the definition as under#ifdef ANDROID
insrc/wrapped/wrappedlibc_private.h
, but it still complains.Do I understand correctly that the wrappers were written to a specific base userspace libraries (Steam's Ubuntu I guess?) and won't work if the library such as libc gets updated? I'm running Debian 12 armhf with i386 libraries (also Debian 12, glibc 2.36-9+deb12u3).