Arm Community
Arm Community
  • Site
  • User
  • Site
  • Search
  • User
Arm Community blogs
Arm Community blogs
Architectures and Processors blog File not found when executing assembled program
  • Blogs
  • Mentions
  • Sub-Groups
  • Tags
  • Jump...
  • Cancel
More blogs in Arm Community blogs
  • AI blog

  • Announcements

  • Architectures and Processors blog

  • Automotive blog

  • Embedded and Microcontrollers blog

  • Internet of Things (IoT) blog

  • Laptops and Desktops blog

  • Mobile, Graphics, and Gaming blog

  • Operating Systems blog

  • Servers and Cloud Computing blog

  • SoC Design and Simulation blog

  • Tools, Software and IDEs blog

Tell us what you think
Tags
  • not_found
  • Assembly
  • Android
  • linker
  • elf
  • execve
  • problem
  • linking
  • Linux
Actions
  • RSS
  • More
  • Cancel
Related blog posts
Related forum threads

File not found when executing assembled program

Myy
Myy
November 29, 2016
1 minute read time.

The main problem

When assembling your first programs with AS, and linking it to external libraries like this :

armv7a-hardfloat-linux-gnueabi-as -o test.o test.S

armv7a-hardfloat-linux-gnueabi-ld.gold --hash-style=sysv -o test test.o -lc

You might be confronted to this error when executing your program :

$ ./test

-bash: ./test: No such file or directory

Using strace to pinpoint the problem will result to something like this :

execve("./test", ["./test"], [/* 28 vars */]) = -1 ENOENT (No such file or directory)

write(2, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory

) = 40

exit_group(1)                           = ?

+++ exited with 1 +++

Looking at execve manual page, ENOENT is described like this :

ENOENT The file filename or a script or ELF interpreter does not exist, or a shared library needed for the file or interpreter cannot be found.

The executable is not a script. The file clearly exists. However, the ELF interpreter ?

When running readelf -l elf_executable you can see which interpreter the executable tries to use. In this case, the output is :

Elf file type is EXEC (Executable file)

Entry point 0x81b8

There are 5 program headers, starting at offset 52

Program Headers:

  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align

  PHDR           0x000034 0x00008034 0x00008034 0x000a0 0x000a0 R   0x4

  INTERP         0x0000d4 0x000080d4 0x000080d4 0x00013 0x00013 R   0x1

      [Requesting program interpreter: /usr/lib/libc.so.1]

  LOAD           0x000000 0x00008000 0x00008000 0x00208 0x00208 R E 0x1000

  LOAD           0x000208 0x00009208 0x00009208 0x000cc 0x000cc RW  0x1000

  DYNAMIC        0x000208 0x00009208 0x00009208 0x000a0 0x000a0 RW  0x4

Section to Segment mapping:

  Segment Sections...

   00    

   01     .interp

   02     .interp .dynsym .dynstr .hash .gnu.version .gnu.version_r .rel.plt .plt .text

   03     .dynamic .data .got

   04     .dynamic

The line Requesting program interpreter shows which ELF interpreter the system tries to use. On this system /usr/lib/libc.so.1 does not exist, which is why executing the program returns "File not found".

However, on a Linux system for example, the standard ELF interpreter is not libc but ld.

The solution

Define the system dynamic linker as the ELF interpreter using the --dynamic-linker directive when linking the program.

When linking programs for Linux ARM systems :

armv7a-hardfloat-linux-gnueabi-ld.gold --hash-style=sysv --dynamic-linker=/lib/ld-linux-armhf.so.3 -o test test.o -lc

When linking programs for Android ARM systems :

armv7a-hardfloat-linux-gnueabi-ld.gold --hash-style=sysv --dynamic-linker=/system/bin/linker -o test test.o -lc

Anonymous
  • Myy
    Myy over 7 years ago

    I just encountered the same issue while trying to cross-compile a C program from a system using GlibC and execute it on a system using Musl.

    Musl dynamic  linker is located at : /lib/ld-musl-armhf.so.1 on ARMv7 with Hardware FPU.

    So you'll have to pass -Wl,--dynamic-linker=/lib/ld-musl-armhf.so.1 to GCC, when linking an executable, to be able to execute the program correctly on the Musl system.

    Example :

    arm-linux-gnueabihf-gcc -o test test.c -Wl,--dynamic-linker=/lib/ld-musl-armhf.so.1

    • Cancel
    • Up 0 Down
    • Reply
    • More
    • Cancel
Architectures and Processors blog
  • Scalable Matrix Extension: Expanding the Arm Intrinsics Search Engine

    Chris Walsh
    Chris Walsh
    Arm is pleased to announce that the Arm Intrinsics Search Engine has been updated to include the Scalable Matrix Extension (SME) intrinsics, including both SME and SME2 intrinsics.
    • October 3, 2025
  • Arm A-Profile Architecture developments 2025

    Martin Weidmann
    Martin Weidmann
    Each year, Arm publishes updates to the A-Profile architecture alongside full Instruction Set and System Register documentation. In 2025, the update is Armv9.7-A.
    • October 2, 2025
  • When a barrier does not block: The pitfalls of partial order

    Wathsala Vithanage
    Wathsala Vithanage
    Acquire fences aren’t always enough. See how LDAPR exposed unsafe interleavings and what we did to patch the problem.
    • September 15, 2025