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
  • Introducing GICv5: Scalable and secure interrupt management for Arm

    Christoffer Dall
    Christoffer Dall
    Introducing Arm GICv5: a scalable, hypervisor-free interrupt controller for modern multi-core systems with improved virtualization and real-time support.
    • April 28, 2025
  • Getting started with AARCHMRS Features.json using Python

    Joh
    Joh
    A high-level introduction to the Arm Architecture Machine Readable Specification (AARCHMRS) Features.json with some examples to interpret and start to work with the available data using Python.
    • April 8, 2025
  • Advancing server manageability on Arm Neoverse Compute Subsystem (CSS) with OpenBMC

    Samer El-Haj-Mahmoud
    Samer El-Haj-Mahmoud
    Arm and 9elements Cyber Security have brought a prototype of OpenBMC to the Arm Neoverse Compute Subsystem (CSS) to advancing server manageability.
    • January 28, 2025