Summary

Summary

Let’s summarize the ways the ILAsm compiler creates a managed PE file. The PE file creation is performed in four phases.

Phase One: Initialization

  • Internal buffers are initialized.

  • The empty template of a PE file is open in memory, including an MS-DOS stub, a PE signature, a COFF header, and a PE header.

  • The Import Address table and the runtime header are allocated in the .text section.

Phase Two: Source Code Parsing

  • The IL code is emitted to the .text section.

  • Data constants are emitted to the .sdata and .tls sections.

  • Metadata is collected in internal buffers.

Phase Three: Image Generation

  • Space for the strong name signature is allocated in the .text section.

  • Metadata is analyzed, rearranged, and emitted to the .text section.

  • Managed resources are emitted to the .text section.

  • Unmanaged export stubs are emitted to the .text section.

  • Unmanaged export tables are emitted to the .sdata section.

  • The TLS directory table is emitted to the .sdata section.

  • The runtime startup stub is emitted to the .text section.

  • Unmanaged resources are read from a .RES file and emitted to the .rsrc section.

  • Necessary base relocations are emitted to the .reloc section.

Phase Four: Completion

  • The image file is written as a disk file.

  • The strong name signing procedure is applied to the file.

The ILAsm compiler allows you to explicitly set certain values in the image file headers, by means of both source code directives and the compiler’s command-line options, as shown in Table 3-7. In all the cases discussed in this chapter, the command-line options take precedence over the respective source code directives.

Table 3-7  Directives and Command-Line Options for Setting Header Fields

Header

Field

Directive

Command-Line Option

PE

ImageBase

.imagebase <integer value>

/BASE=<integer value>

PE

FileAlignment

.file alignment <integer value>

/ALIGNMENT=<integer value>

PE

Subsystem

.subsystem <integer value>

/SUBSYSTEM=<integer value>

CLR

Flags

.corflags <integer value>

/FLAGS=<integer value>



Inside Microsoft. NET IL Assembler
Inside Microsoft .NET IL Assembler
ISBN: 0735615470
EAN: 2147483647
Year: 2005
Pages: 147
Authors: SERGE LIDIN

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net