Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a file named b1 that contains assembly language. I am trying to execute the file on OSX using

$ ./b1

I get the following error:

-bash: ./b1: cannot execute binary file

I've looked at other similar questions, but to no avail. I'm definitely using a 64 bit architecture.

Here are output of relevant info:

$ file b1
b1: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses shared libs), for GNU/Linux 2.6.18, not stripped
$ uname -a
Darwin Anthonys-MacBook-Pro.local 13.0.0 Darwin Kernel Version 13.0.0: Thu Sep 19 22:22:27 PDT 2013; root:xnu-2422.1.72~6/RELEASE_X86_64 x86_64

Edit:

Ran as b1 which ended up terminating with: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/as: fatal error in /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../libexec/as/x86_64/as

share|improve this question

2 Answers 2

up vote 1 down vote accepted

Sorry, this file is for GNU/Linux

According to your file output, this program is for GNU/Linux. I know this because:

  1. The file b1 is in the ELF (Extensible and Linkable Format) format, while Mac OS X uses the Mach-O format for binaries;
  2. file recognizes this file is for GNU/Linux 2.6.18, meaning it'll work on most modern Linux distributions.

To solve your problem, you must either run this problem within a Linux distribution, recompile the program, or get the Mac OS X version of this program.

So... Why doesn't b1 work on XYZ OS or CPU?

Just as people speak different languages, different computers understand different instructions. For instance, your Mac uses an Intel processor, while your Android phone uses an ARM processor. Compare these two processors to English and French. They may belong to the same language family, but still, you can't speak both at the same time. This leads to a conclusion:

Dissimilar computers "talk" in different tongues.

As for why different operating systems (such as Windows, Mac OS X, and Linux) can't use the same binaries, consider this:

What makes software objectively different to hardware? Not much.

Both provide a system and a "language" that allows for more complex components of the computer to complete tasks for the end user. Both require an agreed language to get work done. Imagine if there were 10 people in a shouting match, each speaking a different language. This is why different OS software need different binaries, even if both operating systems use the same processor.

share|improve this answer

assembly language? You need to compile it, or rather assemble it.

man as
share|improve this answer
    
The questioner seems to have conflated assembly language and machine code. See the output of file in the question. –  JdeBP Mar 4 at 18:16

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.