Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Usage differences between. a.out, .ELF, .EXE, and .COFF

Tags:

People also ask

What is a out is ELF?

out stood for Assembler OUTput and to this day, gcc will compile C code and defaults to naming the output file a. out, unless another output name is specified, although the output file is still ELF. This was a holdover from the days when code was directly translated to assembler output...

Are .out files and ELF files?

ELF file is the format into which executable programs are stored for linux. a. out is simply the default filename output by gcc.

What are ELF files used for?

In computing, the Executable and Linkable Format (ELF, formerly named Extensible Linking Format), is a common standard file format for executable files, object code, shared libraries, and core dumps.

What is the most common executable file extension in macOS?

Among those formats listed, the ones in most common use are PE (on Microsoft Windows), ELF (on Linux and most other versions of Unix), Mach-O (on macOS and iOS) and MZ (on DOS). Extension (Novell/Caldera VERSION etc.)


Don't get me wrong by looking at the question title - I know what they are (format for portable executable files). But my interest scope is slightly different

MY CONFUSION

I am involved in re-hosting/retargeting applications that are originally from third parties. The problem is that sometimes the formats for object codes are also in .elf, .COFF formats and still says, "Executable and linkable".

I am primarily a Windows user and know that when you compile and assemble your C/C++ code, you get something similar to .o or .obj. that are not executable (well, I never tried to execute them). But when you complete linking static and dynamic libraries and finish building, the executable appears. My understanding is that you can then go about and link that executable or "bash" test it with some form of script if necessary.

However, in Linux (or UNIX-like systems) there are .o files after you compile and assemble the C/C++ code. And once the linking is done, the executable is in a.out format (at least in Ubuntu distribution of Linux). It may very well be .elf in some other distrib. In my quick web search none of the sources mentioned anything about .o files as executables.

QUESTIONS

Therefore my question turns into the followings:

  1. What is the true definitions for portable executables and object code?

  2. How is it that Windows and UNIX platform covers both executables annd object code under the same file format (.COFF, .elf).

  3. Am I misinterpreting "Linkable"? My interpretation of "Linkable" is something that is compiled object code and can then be "linked" to other static/dynamic link libraries. Is this a stupid thought?

  4. Based on question 1. (and perhaps 2) do I need to use symbol tables (e.g. .LUM or .MAP files) with object code then? Symbols as in debug symbols and using them when re-hosting the executables/object files on a different machine.

Thanks in advance for the right nudges. Meanwhile, I will keep digging and update the question if necessary.

UPDATE

I have managed to dig this out from somewhere :( Seems like a lot to swallow to me.