LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 12-19-2014, 09:32 PM   #1
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,993

Rep: Reputation: 273Reputation: 273Reputation: 273
What does 'Exec format error' mean?


I see that 'Exec format error' is in the kernel, ENOEXEC.

What does it mean? What causes it?
 
Old 12-19-2014, 09:47 PM   #2
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
It's from trying to execute a file that has a magic number that the kernel doesn't know how to handle. Typical examples are a 64-bit binary on a 32-bit kernel, a file intended for a different OS (Windows, Mac OS, etc.). Also, interpreter scripts that lack the "#!/bin/whatever" header will cause that response from the kernel, but a shell that sees that error may try a fallback of trying the file as a script in its own language, sometimes with bizarre results if it is not.
 
Old 12-20-2014, 12:21 AM   #3
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,993

Original Poster
Rep: Reputation: 273Reputation: 273Reputation: 273
How do I know a file's magic number?

Are there any other circumstances?

Beginning with kernel 3.10 the fsck.ext4 in my distribution's package returns that error at boot time when /etc/rc.d/rc.S tries to run it, but it works afterwards, even during the maintenance session linux lets me run on that boot; if I create /etc/fastboot (which prevents file-system-checking) I can boot and run fsck.ext4. I build my own e2fsprogs with the same version and it works at boot. How can I figure out the difference?
 
Old 12-20-2014, 12:21 PM   #4
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
What does the "file" command report for each executable (e.g., "file /sbin/fsck.ext4")? What distribution are you running? What is the output from "uname -rm"?
 
Old 12-21-2014, 12:01 AM   #5
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,993

Original Poster
Rep: Reputation: 273Reputation: 273Reputation: 273
uname -rm returns
Quote:
3.18.1 i686
'file' on the fsck.ext4 I build returns

Quote:
/sbin/fsck.ext4: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), not stripped
fsck.ext4 from the package is script that calls e2fsck, a 'file' of which returns the same thing. I just noticed that the fsck.ext4 I build is identical to e2fsck I build; I suspect that means that the problem is the script.

Code:
#!/bin/sh
exec /sbin/e2fsck -C 0 $*
/bin/sh is a link to /bin/bash
 
Old 12-21-2014, 05:07 PM   #6
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
That script looks fine. I presume this is Slackware.

Does the error message mention the name of the file that caused the error? The only thing that comes to mind is that e2fsck might depend on some kernel modules that are not loaded until later in the /etc/rc.d/rc.S script, but I don't think that would cause an ENOEXEC error. Beyond that, I have no idea.
 
Old 12-22-2014, 12:50 AM   #7
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,993

Original Poster
Rep: Reputation: 273Reputation: 273Reputation: 273
Quote:
Originally Posted by rknichols View Post
That script looks fine.
Looked good to me; works after init.

Quote:
Originally Posted by rknichols View Post
I presume this is Slackware.
My identifying information in the left column reveals this.

Quote:
Originally Posted by rknichols View Post
Does the error message mention the name of the file that caused the error?
fsck.ext4

Quote:
Originally Posted by rknichols View Post
The only thing that comes to mind is that e2fsck might depend on some kernel modules that are not loaded until later in the /etc/rc.d/rc.S script, but I don't think that would cause an ENOEXEC error.
Absent libraries have always returned a different error for me. I suppose a library e2fsck called could be unexecutable. The package version has more dependencies.

Quote:
Originally Posted by rknichols View Post
Beyond that, I have no idea.
I'm puzzled too. Especially since no one else seems to have the same problem. And it's been going on for more than a year.
 
Old 12-22-2014, 10:14 AM   #8
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
Quote:
Originally Posted by RandomTroll View Post
My identifying information in the left column reveals this.
I've learned not to put total trust in that. People change distros without updating their profile info, or try distros other than the one they are currently running.
Quote:
Absent libraries have always returned a different error for me.
Not libraries, kernel modules. If you look at rc.S you'll see that modprobe is run after the file system checks. Is this problem just with the "generic" kernel, or do you see it with "huge" also? (The generic kernel can't even find the root filesystem on my hardware, so I can't test that without building an initrd.)

Last edited by rknichols; 12-22-2014 at 10:19 AM.
 
Old 12-22-2014, 08:00 PM   #9
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,993

Original Poster
Rep: Reputation: 273Reputation: 273Reputation: 273
Quote:
Originally Posted by rknichols View Post
Not libraries, kernel modules.
Whoops! Sorry. Absent modules have never given me ENOEXEC errors either; a module being un-executable could though.

Quote:
Originally Posted by rknichols View Post
Is this problem just with the "generic" kernel, or do you see it with "huge" also?
I build the kernel. I make everything possible a module and attempt not-to-build everything I don't need.
 
Old 12-22-2014, 08:15 PM   #10
rknichols
Senior Member
 
Registered: Aug 2009
Distribution: Rocky Linux
Posts: 4,786

Rep: Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216Reputation: 2216
If you have CONF_BINFMT_SCRIPT as a module and don't load it in an initramfs, then the exec() of that fsck.ext4 script will fail with ENOEXEC. Once the modules have been loaded (near the end of /etc/rc.d/rc.S), it will work fine.
 
1 members found this post helpful.
Old 12-23-2014, 12:14 AM   #11
RandomTroll
Senior Member
 
Registered: Mar 2010
Distribution: Slackware
Posts: 1,993

Original Poster
Rep: Reputation: 273Reputation: 273Reputation: 273
Quote:
Originally Posted by rknichols View Post
If you have CONF_BINFMT_SCRIPT as a module and don't load it in an initramfs, then the exec() of that fsck.ext4 script will fail with ENOEXEC. Once the modules have been loaded (near the end of /etc/rc.d/rc.S), it will work fine.
Hooray! You found it. CONFIG_BINFMT_SCRIPT (note different spelling) appeared for the first time in kernel 3.10, the point at which this problem started to happen. So the 'cure' is to replace trying to run the script with executing e2fsck directly. This parameter is poorly-documented.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] 'hdaps': Exec format error slacksam Slackware 16 02-05-2014 03:42 PM
qemu: run gust images face error > Exec format error Sefid par Linux - Virtualization and Cloud 3 07-30-2013 02:40 PM
Exec Format error on chroot business_kid Fedora 3 10-07-2012 08:51 AM
cgi: exec format error Jane2008 Linux - Newbie 2 08-14-2009 09:10 AM
MDK 9.1 Fatal Error in Stage 1: Exec Format Error Beano Mandriva 5 09-12-2004 03:04 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:40 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration