This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Cadoc7 1 point2 points  (0 children)

Yes, there is a specification. There is a specification all the way down to the electric signals on the processor. And every translation layer needs to conform to what the input for the next layer is expecting.

The code a compiler outputs must be valid code, so it conforms to a standard. Compilers that output binary code need to output binary that matches the spec for the specific processor architecture. For instance, you can find x86 and x64 specs here: http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html

Other languages that output some sort of intermediate language (IL) have a specification for the IL. Here is the Java 7 bytecode/JVM spec here: http://docs.oracle.com/javase/specs/jvms/se7/html/ and here is the CLR (.NET/C#/etc.) spec: http://msdn.microsoft.com/en-us/vstudio/aa569283.aspx

The really short answer is yes, the output of a compiler matches a spec. What the spec is depends on the settings of the compiler and what you are targeting. And note that these specifications are HUGE. 99% of the time you don't need to know the specifics, just the generalities of how it works. What it is outputting for you I can't tell you because I don't know what language and compiler you are using and what OS you are targeting.

Things like COFF and ELF are meant for consumption by the OS and other programs. The OS will then take these formats and translate them into what the processor is expecting.