Hi everyone! Today, I am going to show you the minimal file structure of two popular binary executable format. Windows (PE) and Linux (ELF).
Windows
Let's take a look at Windows PE file format:
PE:

Please note that Code Section and Data Section is minimum 512 bytes each, or power of two to the multiple of 512 as required by File Alignment setting in File Header.
As its name implies, Code Section contains all machine code (normally Intel x86 or AMD64 CPU architecture opcodes) while Data Section contains all data values. A functional PE should have Import Table referencing to either kernel32.dll or user32.dll or both.
For ordinary EXE, you can always ignore the checksum and timestamp in File Header.
Linux
Now, it's time to look at ELF32/64 binary file format.
ELF:

ELF file format is smaller compared to that of PE. A functional "Hello World!" ELF64 binary file could be well below 200 bytes, compared to a similar "Hello World!" (CUI) PE binary file which is about 2048 bytes (or 1024 bytes if you combine three section altogether).
The similarity between these two binary file formats is each Code Segment or Code Section and Data Segment or Data Section has respective headers.
These binary file formats have existed for more than 20 years and have not changed much since then.
Tiny executable file like a 2048-byte portable executable (PE) is often falsely detected by antivirus software as trojan or malware.
macOS
Well, I could not afford an Apple machine so I give up researching on anything related to macOS including its binary file format. To date, I never have used macOS in my life time.
Conclusion
I hope you already get the preliminary idea about the file structure of two popular binary executable format.
As for me, PE file format even in its minimal form is way more complex than ELF file format.
This post has been edited by FlierMate: Aug 7 2021, 06:40 PM
Dec 19 2020, 02:22 AM, updated 4y ago
Quote

0.0143sec
0.37
6 queries
GZIP Disabled