How is code stored in exe format?

My questions are as follows:

  • How does the Portable Executable format (on windows / unix) relate to the x86 / x64 instruction set as a whole?
  • Does the PE format retain the exact set of opcodes supported by the processor, or is it a more general format that the OS converts to the CPU?
  • How does the EXE file indicate the required command set extensions (e.g. 3DNOW! Or SSE / MMX?)
  • Are opcodes common on all platforms like windows, mac and unix?
  • Intel i386 integrated processors, such as Intel and AMD processors, use a common set of instructions. But I'm sure ARM processors use different opcodes. Are they very different or similar to concepts? registers, int / float / double, SIMD, etc.

On newer platforms, such as .NET, Java, or Flash, instruction sets are stack-based opcodes that JIT converts to native format at run time. Being used to this format, I would like to know how the "old" native EXE format is made and formatted. For example, “registers” are usually not available in new platform operation codes, since JIT converts stack instructions into available 16/32 processor registers, which it considers necessary. But in native formats, you need to refer to the registers by index and work out which registers can be reused and how often.

+5
source share
2 answers

ARM opcodes are very different from x86 opcodes?

, . , . , :

  • ;
  • ;
  • ;
  • ;
  • .

, , , .

: ARM , /, x86 , , /.

: . (, add), - .

, , .

, int/float/double SIMD ?

, . , IEEE 754 . , x86 80- , , 32- 64- , . SIMD , , , .

, Windows, Mac Unix?

Intel x86, Windows, Mac OS X Unix/Linux, , , . . , , , , . , , Windows Linux.

PE , , , ?

, PE . , , . PE .

: .NET PE , , . PE "" , . , mono Linux .NET.

EXE (, 3DNOW! SSE/MMX?)

, (. ), , , . . , x86 CPUID, , . , .

.NET

, - .NET , CIL (Common Intermediate Language). CIL . CIL . ( Windows mscoree.dll, Linux mono) , Just-In-Time (JIT) CIL . , . - . , , , .

ARM?

ARM, , , . ARM 32-. (, ), ARM :

31             28  27  26  25              21  20              16
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--
|   Condition   | 0 | 0 |R/I|    Opcode     | S |   Operand 1   | ...
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+--

                   12                                               0
  --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
... |  Destination  |               Operand 2                       |
  --+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+

:

  • . , , true, . Zero, Carry, Negative Overflow. 1110, .
  • R/I: 0 2 . 1, 2 .
  • Opcode: .
  • S. 1, Zero, Carry, Negative Overflow .
  • Operand1: , .
  • : , -.
  • 2: . R/I - 0, . R/I 1, 8- . 2 , / .

ARM, . ARM7TDMI-S, 4 .

, ARM, , , 4 . - ARM- 16- Thumb. , 32- , .

, x86-64 . ARM , x86 x86-64, x86-64 Encoding Encoding, OSDev.org.


. , , .

+7

PE ( ELF/COFF , Windows) , , "". PE "Machine" 2 , :

0x1d3   Matsushita AM33
0x8664  AMD x64
0x1c0   ARM little endian   
0x1c4   ARMv7 (or higher) Thumb mode only
0xebc   EFI byte code   
0x14c   Intel 386 or later processors and compatible processors 
0x200   Intel Itanium processor family  
0x9041  Mitsubishi M32R little endian   
0x266   MIPS16  
0x366   MIPS with FPU
0x466   MIPS16 with FPU 
0x1f0   Power PC little endian  
0x1f1   Power PC with floating point support    
0x166   MIPS little endian  
0x1a2   Hitachi SH3 
0x1a3   Hitachi SH3 DSP 
0x1a6   Hitachi SH4 
0x1a8   Hitachi SH5     
0x1c2   ARM or Thumb ("interworking")   
0x169   MIPS little endian WCE v2   

PE ( ELF) "", () . CPU. / ( ) , , "" , , , . , , .

+3

All Articles