ARM 32-bit ELF does not execute using qemu-arm

7,581

Prefix the LD_LIBRARY_PATH with /lib/arm-linux-gnueabihf: (or just set it to /lib/arm-linux-gnueabihf if it's empty on the line invoking the executable:

LD_LIBRARY_PATH=/lib/arm-linux-gnueabihf qemu-arm bin

That should allow the executable to find the file.

Share:
7,581

Related videos on Youtube

Neon Flash
Author by

Neon Flash

Updated on September 18, 2022

Comments

  • Neon Flash
    Neon Flash almost 2 years

    On my Ubuntu 18.04 machine, I am using qemu-arm to execute a 32-bit ELF file for ARM platform as shown below:

    $ file bin
    bin: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 3.2.0, BuildID[sha1]=5018caf41114f911f0a0fd09c4f9a0bb1191c87a, not stripped
    
    $ qemu-arm bin
    bin: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
    

    On another machine which has an ARM processor, I get the following output by running ldd on the binary:

    $ ldd bin
        libc.so.6 => /lib/arm-linux-gnueabihf/libc.so.6 (0xb6e25000)
        /lib/ld-linux-armhf.so.3 (0xb6f11000)
    

    On my Linux machine, I have installed: ld-linux-armhf.so.3 and its located in the path: /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3

    $ ls -l /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3
    lrwxrwxrwx 1 root root 10 Feb 25  2014 /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 -> ld-2.19.so
    

    I created the symlink:

    $ sudo ln -s /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3 /lib/ld-linux-armhf.so.3
    

    However, even then the binary does not execute because it is unable to find and load the file, libc.so.6.

    How do I resolve this?

    • LeanMan
      LeanMan about 4 years
      How did you install ld-linux-armhf.so.3? I am running into this issue right now. I'm on a x86_64 Ubuntu VM 16.04 and I'd like to run a binary with qemu-arm that has a similar file output to yours except mine is stripped: bin: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 3.2.0, stripped
  • Neon Flash
    Neon Flash about 5 years
    Thanks, it works.