开发者

"No such file or directory" error when executing a binary

I was installing a binary Linux application on Ubuntu 9.10 x86_64. The app shipped with an old version of gzip (1.2.4), that was compiled for a much older kernel:

$ file gzip 
gzip: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.0.0, stripped

I wasn't able to execute this program. If I tried, this happened:

$ ./gzip
-bash: ./gzip: No such file or directory

ldd was similarly unhappy with this binary:

$ ldd gzip
        not a dynamic executable

I'm curious: What's the most likely source of this problem? A corrupted file? Or a binary incompatibility due to being built for a much older {kernel,libc,...}?

Per nos's suggestsions, here's the output of strace ./gzip:

execve("./gzip", ["./gzip"], [/* 24 vars */]) = -1 ENOENT (No such file or directory)
dup(2)                                  = 3
fcntl(3, F_GETFL)                       = 0x8002 (flags O_RDWR|O_LARGEFILE)
fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 10), ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7fa8c9eee000
lseek(3, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
write(3, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
close(3)                                = 0
munmap(0x7fa8c9eee000, 4096)            = 0
exit_group(1)                           = ?

Here's the output of readelf -a ./gzip:

ELF Header:
  Magic:   7f 45 4c 46 01 01 01 00 00 00 00 00 00 00 00 00 
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - System V
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x8048d20
  Start of program headers:          52 (bytes into file)
  Start of section headers:          46852 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         6
  Size of section headers:           40 (bytes)
  Number of section headers:         26
  Section header string table index: 25

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            00000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        080480f4 0000f4 000013 00   A  0   0  1
  [ 2] .note.ABI-tag     NOTE            08048108 000108 000020 00   A  0   0  4
  [ 3] .hash             HASH            08048128 000128 000178 04   A  4   0  4
  [ 4] .dynsym           DYNSYM          080482a0 0002a0 000370 10   A  5   1  4
  [ 5] .dynstr           STRTAB          08048610 000610 0001ee 00   A  0   0  1
  [ 6] .gnu.version      VERSYM          080487fe 0007fe 00006e 02   A  4   0  2
  [ 7] .gnu.version_r    VERNEED         0804886c 00086c 000030 00   A  5   1  4
  [ 8] .rel.got          REL             0804889c 00089c 000008 08   A  4  20  4
  [ 9] .rel.bss          REL             080488a4 0008a4 000030 08   A  4  22  4
  [10] .rel.plt          REL             080488d4 0008d4 000158 08   A  4  12  4
  [11] .init             PROGBITS        08048a2c 000a2c 00002f 00  AX  0   0  4
  [12] .plt              PROGBITS        08048a5c 000a5c 0002c0 04  AX  0   0  4
  [13] .text             PROGBITS        08048d20 000d20 007f4c 00  AX  0   0 16
  [14] .fini             PROGBITS        08050c6c 008c6c 00001a 00  AX  0   0  4
  [15] .rodata           PROGBITS        08050ca0 008ca0 001751 00   A  0   0 32
  [16] .data             PROGBITS        08053400 00a400 000ab4 00  WA  0   0 32
  [17] .eh_frame         PROGBITS        08053eb4 00aeb4 000004 00  WA  0   0  4
  [18] .ctors            PROGBITS        08053eb8 00aeb8 000008 00  WA  0   0  4
  [19] .dtors            PROGBITS        08053ec0 00aec0 000008 00  WA  0   0  4
  [20] .got              PROGBITS        08053ec8 00aec8 0000bc 04  WA  0   0  4
  [21] .dynamic          DYNAMIC         08053f84 00af84 0000a0 08  WA  5   0  4
  [22] .bss              NOBITS          08054040 00b040 050630 00  WA  0   0 32
  [23] .comment          PROGBITS        00000000 00b040 000487 00      0   0  1
  [24] .note             NOTE            00000487 00b4c7 00017c 00      0   0  1
  [25] .shstrtab         STRTAB          00000000 00b643 0000be 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings)
  I (info), L (link order), G (group), x (unknown)
  O (extra OS processing required) o (OS specific), p (processor specific)

There are no section groups in this file.

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x000c0 0x000c0 R E 0x4
  INTERP         0x0000f4 0x080480f4 0x080480f4 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /lib/ld-linux.so.2]
  LOAD           0x000000 0x08048000 0x08048000 0x0a3f1 0x0a3f1 R E 0x1000
  LOAD           0x00a400 0x08053400 0x08053400 0x00c24 0x51270 RW  0x1000
  DYNAMIC        0x00af84 0x08053f84 0x08053f84 0x000a0 0x000a0 RW  0x4
  NOTE           0x000108 0x08048108 0x08048108 0x00020 0x00020 R   0x4

 Section to Segment mapping:
  Segment Sections...
   00     
   01     .interp 
   02     .interp .note.ABI-tag .hash .dynsym .dynstr .gnu.version .gnu.version_r .rel.got .rel.bss .rel.plt .init .plt .text .fini .rodata 
   03     .data .eh_frame .ctors .dtors .got .dynamic .bss 
   04     .dynamic 
   05     .note.ABI-tag 

Dynamic section at offset 0xaf84 contains 20 entries:
  Tag        Type                         Name/Value
 0x00000001 (NEEDED)                     Shared library: [libc.so.6]
 0x0000000c (INIT)                       0x8048a2c
 0x0000000d (FINI)                       0x8050c6c
 0x00000004 (HASH)                       0x8048128
 0x00000005 (STRTAB)                     0x8048610
 0x00000006 (SYMTAB)                     0x80482a0
 0x0000000a (STRSZ)                      474 (bytes)
 0x0000000b (SYMENT)                     16 (bytes)
 0x00000015 (DEBUG)                      0x0
 0x00000003 (PLTGOT)                     0x8053ec8
 0x00000002 (PLTRELSZ)                   344 (bytes)
 0x00000014 (PLTREL)                     REL
 0x00000017 (JMPREL)                     0x80488d4
 0x00000011 (REL)                        0x804889c
 0x00000012 (RELSZ)                      56 (bytes)
 0x00000013 (RELENT)                     8 (bytes)
 0x6ffffffe (VERNEED)                    0x804886c
 0x6fffffff (VERNEEDNUM)                 1
 0x6ffffff0 (VERSYM)                     0x80487fe
 0x00000000 (NULL)                       0x0

Relocation section '.rel.got' at offset 0x89c contains 1 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
08053f80  00000106 R_386_GLOB_DAT    00000000   __gmon_start__

Relocation section '.rel.bss' at offset 0x8a4 contains 6 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
08054040  00000505 R_386_COPY        08054040   stdout
08054044  00002705 R_386_COPY        08054044   stderr
08054048  00000805 R_386_COPY        08054048   __ctype_b
0805404c  00001f05 R_386_COPY        0805404c   stdin
08054050  00001005 R_386_COPY        08054050   optarg
08054054  00001e05 R_386_COPY        08054054   optind

Relocation section '.rel.plt' at offset 0x8d4 contains 43 entries:
 Offset     Info    Type            Sym.Value  Sym. Name
08053ed4  00000307 R_386_JUMP_SLOT   08048a6c   chown
08053ed8  00003407 R_386_JUMP_SLOT   08048a7c   __register_frame_info
08053edc  00001907 R_386_JUMP_SLOT   08048a8c   write
08053ee0  00002e07 R_386_JUMP_SLOT   08048a9c   fileno
08053ee4  00002607 R_386_JUMP_SLOT   08048aac   strcmp
08053ee8  00003507 R_386_JUMP_SLOT   08048abc   close
08053eec  00000d07 R_386_JUMP_SLOT   08048acc   perror
08053ef0  00001a07 R_386_JUMP_SLOT   08048adc   fprintf
08053ef4  00000907 R_386_JUMP_SLOT   08048aec   getenv
08053ef8  00002007 R_386_JUMP_SLOT   08048afc   signal
08053efc  00001207 R_386_JUMP_SLOT   08048b0c   fflush
08053f00  00002407 R_386_JUMP_SLOT   08048b1c   unlink
08053f04  00002a07 R_386_JUMP_SLOT   08048b2c   __errno_location
08053f08  00001407 R_386_JUMP_SLOT   08048b3c   chmod
08053f0c  00000e07 R_386_JUMP_SLOT   08048b4c   malloc
08053f10  00001d07 R_386_JUMP_SLOT   08048b5c   __deregister_frame_inf
08053f14  00002907 R_386_JUMP_SLOT   08048b6c   __xstat
08053f18  00000b07 R_386_JUMP_SLOT   08048b7c   fgets
08053f1c  00002c07 R_386_JUMP_SLOT   08048b8c   __fxstat
08053f20  00001507 R_386_JUMP_SLOT   08048b9c   __lxstat
08053f24  00000a07 R_386_JUMP_SLOT   08048bac   __strtol_internal
08053f28  00002207 R_386_JUMP_SLOT   08048bbc   strncmp
08053f2c  00003007 R_386_JUMP_SLOT   08048bcc   __libc_start_main
08053f30  00001c07 R_386_JUMP_SLOT   08048bdc   strcat
08053f34  00000407 R_386_JUMP_SLOT   08048bec   printf
08053f38  00001307 R_386_JUMP_SLOT   08048bfc   lseek
08053f3c  00000c07 R_386_JUMP_SLOT   08048c0c   memcpy
08053f40  00001607 R_386_JUMP_SLOT   08048c1c   strr开发者_开发问答chr
08053f44  00001b07 R_386_JUMP_SLOT   08048c2c   ctime
08053f48  00000707 R_386_JUMP_SLOT   08048c3c   getopt_long
08053f4c  00003207 R_386_JUMP_SLOT   08048c4c   closedir
08053f50  00002507 R_386_JUMP_SLOT   08048c5c   opendir
08053f54  00003107 R_386_JUMP_SLOT   08048c6c   open
08053f58  00002b07 R_386_JUMP_SLOT   08048c7c   exit
08053f5c  00001807 R_386_JUMP_SLOT   08048c8c   calloc
08053f60  00002d07 R_386_JUMP_SLOT   08048c9c   _IO_putc
08053f64  00003607 R_386_JUMP_SLOT   08048cac   free
08053f68  00000607 R_386_JUMP_SLOT   08048cbc   utime
08053f6c  00000f07 R_386_JUMP_SLOT   08048ccc   isatty
08053f70  00002307 R_386_JUMP_SLOT   08048cdc   strncpy
08053f74  00001107 R_386_JUMP_SLOT   08048cec   readdir
08053f78  00002107 R_386_JUMP_SLOT   08048cfc   read
08053f7c  00000207 R_386_JUMP_SLOT   08048d0c   strcpy

There are no unwind sections in this file.

Symbol table '.dynsym' contains 55 entries:
   Num:    Value  Size Type    Bind   Vis      Ndx Name
     0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND 
     1: 00000000     0 NOTYPE  WEAK   DEFAULT  UND __gmon_start__
     2: 08048d0c    34 FUNC    GLOBAL DEFAULT  UND strcpy@GLIBC_2.0 (3)
     3: 08048a6c   136 FUNC    GLOBAL DEFAULT  UND chown@GLIBC_2.1 (2)
     4: 08048bec    41 FUNC    GLOBAL DEFAULT  UND printf@GLIBC_2.0 (3)
     5: 08054040     4 OBJECT  GLOBAL DEFAULT   22 stdout@GLIBC_2.0 (3)
     6: 08048cbc    59 FUNC    GLOBAL DEFAULT  UND utime@GLIBC_2.0 (3)
     7: 08048c3c    43 FUNC    GLOBAL DEFAULT  UND getopt_long@GLIBC_2.0 (3)
     8: 08054048     4 OBJECT  GLOBAL DEFAULT   22 __ctype_b@GLIBC_2.0 (3)
     9: 08048aec   224 FUNC    GLOBAL DEFAULT  UND getenv@GLIBC_2.0 (3)
    10: 08048bac  1106 FUNC    GLOBAL DEFAULT  UND __strtol_internal@GLIBC_2.0 (3)
    11: 08048b7c   202 FUNC    WEAK   DEFAULT  UND fgets@GLIBC_2.0 (3)
    12: 08048c0c    62 FUNC    GLOBAL DEFAULT  UND memcpy@GLIBC_2.0 (3)
    13: 08048acc   111 FUNC    GLOBAL DEFAULT  UND perror@GLIBC_2.0 (3)
    14: 08048b4c   338 FUNC    WEAK   DEFAULT  UND malloc@GLIBC_2.0 (3)
    15: 08048ccc    46 FUNC    WEAK   DEFAULT  UND isatty@GLIBC_2.0 (3)
    16: 08054050     4 OBJECT  GLOBAL DEFAULT   22 optarg@GLIBC_2.0 (3)
    17: 08048cec   142 FUNC    WEAK   DEFAULT  UND readdir@GLIBC_2.0 (3)
    18: 08048b0c   152 FUNC    WEAK   DEFAULT  UND fflush@GLIBC_2.0 (3)
    19: 08048bfc    61 FUNC    WEAK   DEFAULT  UND lseek@GLIBC_2.0 (3)
    20: 08048b3c    59 FUNC    WEAK   DEFAULT  UND chmod@GLIBC_2.0 (3)
    21: 08048b9c   314 FUNC    GLOBAL DEFAULT  UND __lxstat@GLIBC_2.0 (3)
    22: 08048c1c   441 FUNC    GLOBAL DEFAULT  UND strrchr@GLIBC_2.0 (3)
    23: 0804f608    29 FUNC    GLOBAL DEFAULT   13 basename
    24: 08048c8c   563 FUNC    WEAK   DEFAULT  UND calloc@GLIBC_2.0 (3)
    25: 08048a8c    61 FUNC    WEAK   DEFAULT  UND write@GLIBC_2.0 (3)
    26: 08048adc    36 FUNC    GLOBAL DEFAULT  UND fprintf@GLIBC_2.0 (3)
    27: 08048c2c    35 FUNC    GLOBAL DEFAULT  UND ctime@GLIBC_2.0 (3)
    28: 08048bdc    49 FUNC    GLOBAL DEFAULT  UND strcat@GLIBC_2.0 (3)
    29: 08048b5c   162 FUNC    WEAK   DEFAULT  UND __deregister_frame_info@GLIBC_2.0 (3)
    30: 08054054     4 OBJECT  GLOBAL DEFAULT   22 optind@GLIBC_2.0 (3)
    31: 0805404c     4 OBJECT  GLOBAL DEFAULT   22 stdin@GLIBC_2.0 (3)
    32: 08048afc   181 FUNC    WEAK   DEFAULT  UND signal@GLIBC_2.0 (3)
    33: 08048cfc    61 FUNC    WEAK   DEFAULT  UND read@GLIBC_2.0 (3)
    34: 08048bbc   148 FUNC    GLOBAL DEFAULT  UND strncmp@GLIBC_2.0 (3)
    35: 08048cdc   147 FUNC    GLOBAL DEFAULT  UND strncpy@GLIBC_2.0 (3)
    36: 08048b1c    55 FUNC    WEAK   DEFAULT  UND unlink@GLIBC_2.0 (3)
    37: 08048c5c   412 FUNC    WEAK   DEFAULT  UND opendir@GLIBC_2.0 (3)
    38: 08048aac    58 FUNC    GLOBAL DEFAULT  UND strcmp@GLIBC_2.0 (3)
    39: 08054044     4 OBJECT  GLOBAL DEFAULT   22 stderr@GLIBC_2.0 (3)
    40: 0804f7fc    40 FUNC    GLOBAL DEFAULT   13 error
    41: 08048b6c   314 FUNC    GLOBAL DEFAULT  UND __xstat@GLIBC_2.0 (3)
    42: 08048b2c    27 FUNC    WEAK   DEFAULT  UND __errno_location@GLIBC_2.0 (3)
    43: 08048c7c   200 FUNC    GLOBAL DEFAULT  UND exit@GLIBC_2.0 (3)
    44: 08048b8c   314 FUNC    GLOBAL DEFAULT  UND __fxstat@GLIBC_2.0 (3)
    45: 08048c9c   150 FUNC    GLOBAL DEFAULT  UND _IO_putc@GLIBC_2.0 (3)
    46: 08048a9c    53 FUNC    GLOBAL DEFAULT  UND fileno@GLIBC_2.0 (3)
    47: 08050ca4     4 OBJECT  GLOBAL DEFAULT   15 _IO_stdin_used
    48: 08048bcc   261 FUNC    GLOBAL DEFAULT  UND __libc_start_main@GLIBC_2.0 (3)
    49: 08048c6c    61 FUNC    WEAK   DEFAULT  UND open@GLIBC_2.0 (3)
    50: 08048c4c   112 FUNC    WEAK   DEFAULT  UND closedir@GLIBC_2.0 (3)
    51: 0804f824    66 FUNC    GLOBAL DEFAULT   13 warn
    52: 08048a7c   116 FUNC    WEAK   DEFAULT  UND __register_frame_info@GLIBC_2.0 (3)
    53: 08048abc    55 FUNC    WEAK   DEFAULT  UND close@GLIBC_2.0 (3)
    54: 08048cac   202 FUNC    WEAK   DEFAULT  UND free@GLIBC_2.0 (3)

Histogram for bucket list length (total of 37 buckets):
 Length  Number     % of total  Coverage
      0  10         ( 27.0%)
      1  14         ( 37.8%)     25.9%
      2  4          ( 10.8%)     40.7%
      3  4          ( 10.8%)     63.0%
      4  5          ( 13.5%)    100.0%

Version symbols section '.gnu.version' contains 55 entries:
 Addr: 00000000080487fe  Offset: 0x0007fe  Link: 4 (.dynsym)
  000:   0 (*local*)       0 (*local*)       3 (GLIBC_2.0)     2 (GLIBC_2.1)  
  004:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  008:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  00c:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  010:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  014:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     1 (*global*)   
  018:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  01c:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  020:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  024:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  028:   1 (*global*)      3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  
  02c:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     1 (*global*)   
  030:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)     1 (*global*)   
  034:   3 (GLIBC_2.0)     3 (GLIBC_2.0)     3 (GLIBC_2.0)  

Version needs section '.gnu.version_r' contains 1 entries:
 Addr: 0x000000000804886c  Offset: 0x00086c  Link: 5 (.dynstr)
  000000: Version: 1  File: libc.so.6  Cnt: 2
  0x0010:   Name: GLIBC_2.0  Flags: none  Version: 3
  0x0020:   Name: GLIBC_2.1  Flags: none  Version: 2

Notes at offset 0x00000108 with length 0x00000020:
  Owner         Data size       Description
  GNU           0x00000010      NT_GNU_ABI_TAG (ABI version tag)

Notes at offset 0x0000b4c7 with length 0x0000017c:
  Owner         Data size       Description
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)
  01.01         0x00000000      NT_VERSION (version)


The answer is in this line of the output of readelf -a in the original question

  [Requesting program interpreter: /lib/ld-linux.so.2]

I was missing the /lib/ld-linux.so.2 file, which is needed to run 32-bit apps. The Ubuntu package that has this file is libc6-i386.


Old question, but hopefully this'll help someone else.

In my case I was using a toolchain on Ubuntu 12.04 that was built on Ubuntu 10.04 (requires GCC 4.1 to build). As most of the libraries have moved to multiarch dirs, it couldn't find ld.so. So, make a symlink for it.

Check required path:

$ readelf -a arm-linux-gnueabi-gcc | grep interpreter:
      [Requesting program interpreter: /lib/ld-linux-x86-64.so.2]

Create symlink:

$ sudo ln -s /lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /lib/ld-linux-x86-64.so.2

If you're on 32bit, it'll be i386-linux-gnu and not x86_64-linux-gnu.


You get this error when you try to run a 32-bit build on your 64-bit Linux.

Also contrast what file had to say on the binary you tried (ie: 32-bit) with what you get for your /bin/gzip:

$ file /bin/gzip
/bin/gzip: ELF 64-bit LSB executable, x64-64, version 1 (SYSV), \
dynamically linked (uses shared libs), for GNU/Linux 2.6.15, stripped

which is what I get on Ubuntu 9.10 for amd64 aka x86_64.

Edit: Your expanded post shows that as the readelf output also reflects a 32-bit build.


I think you're x86-64 install does not have the i386 runtime linker. The ENOENT is probably due to the OS looking for something like /lib/ld.so.1 or similar. This is typically part of the 32-bit glibc runtime, and while I'm not directly familiar with Ubuntu, I would assume they have some sort of 32-bit compatibility package to install. Fortunately gzip only depends on the C library, so that's probably all you'll need to install.


readelf -a xxx

 INTERP         
  0x0000000000000238 0x0000000000400238 0x0000000000400238           
  0x000000000000001c 0x000000000000001c  R      1
  [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]


I also had problems because my program interpreter was /lib/ld-linux.so.2 however it was on an embedded device, so I solved the problem by asking gcc to use ls-uClibc instead as follows:

-Wl,--dynamic-linker=/lib/ld-uClibc.so.0


It is possible that the executable is statically linked and that is why ldd gzip does not see any links - because it isn't. I don't know much about things that far back so I don't know if there would be incompatibilities if libraries are linked in statically. I might expect there to be.

I know it's the most obvious thing going and I'm sure you've done it, but chmod +x ./gzip, yes? No such file or directory is a classic symptom of that not being done, that's why I mention it.


Well another possible cause of this can be simple line break at end of each line and shebang line If you have been coding in windows IDE its possible that windows has added its own line break at the end of each line and when you try to run it on linux the line break cause problems


You can see execve return ENOENT . Then search ENOENT in execve man.

The file pathname or a script or ELF interpreter does not exist.

The gzip file exist, and is a ELF file. So check whether ELF interpreter exist or not. According the man again:

If the executable is a dynamically linked ELF executable, the interpreter named in the PT_INTERP segment is used to load the needed shared objects. This interpreter is typically /lib/ld-linux.so.2 for binaries linked with glibc .

We can find the ELF interpreter path with readelf as @Lorin Hochstein said:

$ readelf -l <filename> |grep -i interp
...
[Requesting program interpreter: /lib/ld-linux.so.2]

The ELF interpreter should not exist here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜