run qemu with QEMU_LD_PREFIX argument will not load correct library order in the PATH.
How to reproduce this bug:
These command will download the library of other architectures
wget https://raw.githubusercontent.com/BinaryAnalysisPlatform/qira/master/fetchlibs.sh
bash fetchlibs.sh
This is 32bit binary file,
wget http://train.cs.nctu.edu.tw/files/magic
chmod +x ./magic
qemu-i386 -L /home/apple/libs/i386 /home/apple/magic
This is work fine.
But after you install gcc-multilib, it failed.
sudo apt-get install gcc-multilib
qemu-i386 -L /home/apple/libs/i386 /home/apple/magic
The following is the error message
/home/apple/magic: 0���: ̀Í�: D$(�$: Error 18446744073549536926
Because the order of dynamic linker search the shared library is wrong.
When your system has /lib32 directory, its priority is higher than the QEMU_LD_PREFIX.
If the system not loaded correspond with the dynamic linker, it will crash.
Code flow:
linux-user/main.c:
call loader_exec
linuxload.c:
call load_elf_binary
elfload.c:
in load_elf_binary function
dynamic loader will be elf_interpreter
I think the problem should be here.
The QEMU project is currently considering to move its bug tracking to another system. For this we need to know which bugs are still valid and which could be closed already. Thus we are setting older bugs to "Incomplete" now.
If you still think this bug report here is valid, then please switch the state back to "New" within the next 60 days, otherwise this report will be marked as "Expired". Or mark it as "Fix Released" if the problem has been solved with a newer version of QEMU already. Thank you and sorry for the inconvenience.