Recent

Author Topic: [SOLVED] cannot execute binary file: Exec format error  (Read 4704 times)

nomorelogic

  • Full Member
  • ***
  • Posts: 148
[SOLVED] cannot execute binary file: Exec format error
« on: May 17, 2021, 07:59:09 pm »
Hi all
I need some help about binary format executable.

I've developed a console application using Lazarus 2.1.0 and fpc 3.2.1.
My OS is linux and this is uname output:
Code: Pascal  [Select][+][-]
  1. $ uname -a
  2. Linux myhostname 5.10.23_1 #1 SMP 1615503150 x86_64 GNU/Linux
  3.  

This is the "file" command output:
Code: Pascal  [Select][+][-]
  1. $ file ./myprogram
  2. ./myprogram: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, for GNU/Linux 2.4.0, stripped
  3.  

well...
Deploy (production system) is on a VM running ubuntu, follow uname output:
Code: Pascal  [Select][+][-]
  1. $ uname -a
  2. Linux myvmhost 5.4.0-72-generic #80-Ubuntu SMP Mon Apr 12 17:35:00 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
  3.  

and this is the "file" command output on ubuntu:
Code: Pascal  [Select][+][-]
  1. $ file ./myprogram
  2. ./myprogram: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), too many program (2573)


When I run myprogram I get this error:
Code: Pascal  [Select][+][-]
  1. $ ./myprogram
  2. -bash: ./myprogram: cannot execute binary file: Exec format error
  3.  

Searching in web I found this error can occur when I run a 64bit application on a 32bit system.
But I think I've both systems using 64bit.
The strange to me is "too many program (2573)" on ubuntu: why a different uname output for the same bin?

Thanks in advance for any help.
nomorelogic






« Last Edit: May 18, 2021, 09:29:30 am by nomorelogic »

MarkMLl

  • Hero Member
  • *****
  • Posts: 2875
Re: cannot execute binary file: Exec format error
« Reply #1 on: May 17, 2021, 08:20:20 pm »
Odd. I'd suggest stepping back and compiling a "cogito ergo sum" program i.e.

Code: Pascal  [Select][+][-]
  1. program test;
  2.  
  3. begin
  4. end.
  5.  

Don't use any fancy options on the command line, see if you get the same problem with that, and if you do then take a careful look at your /etc/fpc.cfg file.

I know this isn't the problem, but the "32-bit program on a 64-bit system" issue can be fixed by installing the multi-arch libraries, so unqualified warnings that "it can't be done" should be treated with caution. That's not to say that there might not be other library or architecture (i.e. /precise/ CPU type) issues.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lucamar

  • Hero Member
  • *****
  • Posts: 4163
Re: cannot execute binary file: Exec format error
« Reply #2 on: May 17, 2021, 08:28:07 pm »
The  "too many program (2573)" is a file error. You should check it, because my memory isn't so good this days, but IIRC it means there is something wrong with either the executable (usually caused by the linker, I think) or the magic configuration.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

MarkMLl

  • Hero Member
  • *****
  • Posts: 2875
Re: cannot execute binary file: Exec format error
« Reply #3 on: May 17, 2021, 09:44:13 pm »
The  "too many program (2573)" is a file error. You should check it, because my memory isn't so good this days, but IIRC it means there is something wrong with either the executable (usually caused by the linker, I think) or the magic configuration.

I'm concerned that it's both an apparent magic problem, and an error at attempted execution.

I can't remember how to look at this, but I wonder if it's something like the kernel's been told about lots of different versions of Java etc. and the overexertion of making it forgetful?

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

lucamar

  • Hero Member
  • *****
  • Posts: 4163
Re: cannot execute binary file: Exec format error
« Reply #4 on: May 17, 2021, 11:20:24 pm »
No; what happens is that the executable has too many "sections" for file to look well into it and it complains about it. As said, it can be either or both: a problem with how the linker worked to build the exec or how file (or the magic it depends on) were built/configured.

Though it's a little strange: it usually happens with core dumps, not with "normal" biinaries.

What I would do, in your place, is to rebuild the program in the target system and try to see what differences there in the binary, the tool-chain and the system after installing the tool-chain (ld config, added libs, etc.), but that can take you quite some time ...
« Last Edit: May 17, 2021, 11:26:03 pm by lucamar »
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

nomorelogic

  • Full Member
  • ***
  • Posts: 148
[SOLVED] Re: cannot execute binary file: Exec format error
« Reply #5 on: May 18, 2021, 09:29:10 am »
Hi all

It’s actually a file error.
Looking around I found a programmer with the same problem that had transferred a binary file using Filezilla (like me) and had not checked that the transfer was binary and not ascii (like me).

Usually I transfer using the ftp command line and "BIN" is the first command I run after connection... Not this time...

I fell in the oldest mistake in the IT-world.  :-[
Thank you all for the support.

nomorelogic
« Last Edit: May 18, 2021, 09:31:34 am by nomorelogic »

MarkMLl

  • Hero Member
  • *****
  • Posts: 2875
Re: [SOLVED] cannot execute binary file: Exec format error
« Reply #6 on: May 18, 2021, 09:46:09 am »
Happens to all of us. Don't forget the cksum command, I think that the algorithm is stable across all UNIX variants and I'd certainly expect it to behave on fairly recent Linux systems.

MarkMLl
Turbo Pascal v1 on CCP/M-86, multitasking with LAN and graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

 

TinyPortal © 2005-2018