[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-discuss] How to run cross-compiled binaries using Qemuuser spa
From: |
Libo Zhou |
Subject: |
Re: [Qemu-discuss] How to run cross-compiled binaries using Qemuuser space emulation? |
Date: |
Tue, 3 Sep 2019 16:46:41 +0800 |
Hi Peter,
Thanks for your reply. Creating a dummy ld.so.cache in ${sysroot}/etc/ did the
trick for me. It was missing.
Cheers,
Libo
------------------ Original message ------------------
From: "Peter Maydell";
Sendtime: Tuesday, Sep 3, 2019 4:17 PM
To: "Libo Zhou";
Cc: "qemu-discuss";
Subject: Re: [Qemu-discuss] How to run cross-compiled binaries using Qemuuser
space emulation?
On Mon, 2 Sep 2019 at 11:34, Libo Zhou <address@hidden> wrote:
>
> I am trying to run C programs compiled for MIPS32 big-endian architecture on
> an x86_64 host. And I am using Ubuntu 18.04 LTS.
> Then I got a segmentation fault, and here is the strace log:
>
>
> 10255 brk(NULL) = 0x00412000
> 10255 mmap2(NULL,8192,PROT_READ|PROT_WRITE,MAP_PRIVATE|MAP_ANONYMOUS,-1,0) =
> 0x7f7c8000
> 10255 uname(0x7fffe8c8) = 0
> 10255 access("/etc/ld.so.nohwcap",F_OK) = -1 errno=2 (No such file or
> directory)
> 10255 access("/etc/ld.so.preload",R_OK) = -1 errno=2 (No such file or
> directory)
> 10255 openat(AT_FDCWD,"/etc/ld.so.cache",O_RDONLY|O_CLOEXEC) = 3
> 10255 fstat64(3,0x7fffe518) = 0
> 10255 mmap2(NULL,106802,PROT_READ,MAP_PRIVATE,3,0) = 0x7f7ad000
> 10255 close(3) = 0
> --- SIGSEGV {si_signo=SIGSEGV, si_code=1, si_addr=0x2392d008} ---
> qemu: uncaught target signal 11 (Segmentation fault) - core dumped
> [1] 10255 segmentation fault (core dumped) ./qemu-mips -strace test
You're running into a bug in the guest ld.so (dynamic linker).
Here it is reading the host's /etc/ld.so.cache, but the problem
is that the guest ld.so can't cope with finding a ld.so.cache
for the "wrong" endianness, and it segfaults.
You can work around this by:
* using QEMU inside a chroot which provides a complete
guest-binary filesystem
* ensuring that there is at least a dummy /etc/ld.so.cache in
the 'sysroot' where QEMU looks first for files for the guest
(I think an empty file will do.) Usually the sysroot
directory is specified via the -L option to QEMU (you seem
to be specifying it via configure, but the configure
--interp-prefix option is just setting the default value
for the runtime -L option, so you don't have to do that.)
thanks
-- PMM