I understand that each CPU/architecture has it's own instruction set, therefore a program(binary) written for a specific CPU cannot run on another. But what i don't really understand is why an executable file (binary like .exe for instance) cannot run on Linux but can run on windows even on the very same machine.
This is a basic question, and the answer i'm expecting is that .exe and other binary formats are probably not Raw machine instructions but they contain some data that is operating system dependent. If this is true, then what this OS dependent data is like? and as an example what is the format of an .exe file and the difference between it and Linux executables?
Is there a source i can get brief and detailed information about this?
They include EXE, BAT, COM, CMD, INF, IPA, OSX, PIF, RUN and WSH. With Windows, EXE is the file extension for an executable file. All EXE files are executable files, but not all executable files are EXE files.
An executable is the file that the compiler creates from these source files containing machine instructs that can execute on the CPU. A process is the active execution of the executable on the CPU and in the memory. It includes the memory management information, the current PC, SP, HP, registers, etc.
An executable file is a program that you can run on your computer's operating system. Executable files are typically used to install and run software applications. You trigger the program by selecting the icon of the file, though there may be some verification prompts to start the execution.
Related to Operating system dependent. Operating System means a set of software that manages computer hardware resources and provides common services for computer programs.
In order to do something meaningful, applications will need to interface with the OS. Since system calls and user-space infrastructure look fundamentally different on Windows and Unix/Linux, having different formats for executable programs is the smallest trouble. It's the program logic that would need to be changed.
(You might argue that this is meaningless if you have a program that solely depends on standardized components, for example the C runtime library. This is theoretically true - but irrelevant for most applications since they are forced to use OS-dependent stuff).
The other differences between Windows PE (EXE,DLL,..) files and Linux ELF binaries are related to the different image loaders and some design characteristics of both OSs. For example on Linux a separate program is used to resolve external library imports while this functionality is built-in on Windows. Another example: Linux shared libraries function differently than DLLs on Windows. Not to mention that both formats are optimized to enable the respective OS kernels to load programs as quick as possible.
Emulators like Wine try to fill the gap (and actually prove that the biggest problem is not the binary format but rather the OS interface!).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With