Binary files and OS

I am currently studying C ++, and there are some (basic) things that I really don’t know about, and where I did not find anything useful in different search engines.

  • Well, since all operating systems have different “binary formats” for their executable files (Windows / Linux / Mac) - what are the differences? I mean, they are all binary, but is there anything (other than all the OS APIs) that are really different?

  • (Windows) This is a stupid question - but are all the applications there really just binary (and I mean only 0 and 1)? In what format are they stored? (Since you do not see 0 and 1 in all text editors, but mostly non-displayable characters)

Regards, Llamas

+3
source share
4 answers

Executable file formats for Windows (PE), Linux (ELF), OS / X, etc. (MACH-O) are typically designed to solve common problems, so they all have common features. However, each platform defines a different standard, so files are incompatible between platforms, even if the platforms use the same processor type.

Executable file formats are used not only for executable files, but also for libraries that also contain code, but never run directly by the user - they are only loaded into memory to satisfy the needs of directly executable binary files.

General functions of the executable file format:

  • One or more blocks of executable code
  • ,
  • /
  • , ( " " ), () .
  • , , , .

, DOS .com, 64K "" , .

"" , . , 0 1.

+7

Windows/Linux :

  • , , , ;
  • , (, ..)
  • , ; Linux , , Windows.

- , . 0 255 , .. . , . 8 , 8 , 0 1.

+7

, "" , 1 0 ( ). , . , , . , , , , , , , CPU.

, " ": , ELF Windows DLL/EXE. , (.. , , , ..)

+4

Windows PE; Linux - ELF. ( , ..) , .

It should be noted that even if both Windows and Linux use the same file format, they still will not be able to run each other's binary files, because the system APIs and available DLL / SO files are completely different.

+2
source

Source: https://habr.com/ru/post/1727959/


All Articles