Metadata Validity Rules

Metadata Validity Rules

The field-related metadata tables include the Field, FieldLayout, FieldRVA, FieldMarshal, Constant, and MemberRef tables. The records of these tables have the following entries:

  • The Field table contains the Flags, Name, and Signature entries.

  • The FieldLayout table contains the OffSet and Field entries.

  • The FieldRVA table contains the RVA and Field entries.

  • The FieldMarshal table contains the Parent and NativeType (native signature) entries.

  • The Constant table contains the Type, Parent, and Value entries.

  • The MemberRef table contains the Class, Name, and Signature entries.

Field Table Validity Rules

  • The Flags entry can have only those bits set that are defined in the enumeration CorFieldAttrEnum in CorHdr.h (validity mask: 0xB7F7).

  • [run time] The accessibility flag (mask 0x0007) must be one of the following: privatescope, private, famandassem, assembly, family, famorassem, or public.

  • The literal and initonly flags are mutually exclusive.

  • If the literal flag is set, the static flag must also be set.

  • If the rtspecialname flag is set, the specialname flag must also be set.

  • [run time] If the flag 0x1000 (fdHasFieldMarshal) is set, the FieldMarshal table must contain a record referencing this Field record, and vice versa.

  • [run time] If the flag 0x8000 (fdHasDefault) is set, the Constant table must contain a record referencing this Field record, and vice versa.

  • [run time] If the flag 0x0100 (fdHasFieldRVA) is set, the FieldRVA table must contain a record referencing this Field record, and vice versa.

  • [run time] Global fields, owned by the TypeDef <Module>, must have the static flag set.

  • [run time] The Name entry must hold a valid reference to the #Strings stream, indexing a nonempty string no more than 1023 bytes long in UTF-8 encoding.

  • [run time] The Signature entry must hold a valid reference to the #Blob stream, indexing a valid field signature. Validity rules for field signatures are discussed in Chapter 7.

  • No duplicate records—attributed to the same TypeDef and having the same Name and Signature values—can exist unless the accessibility flag is privatescope.

  • Fields attributed to enumerators must comply with additional rules, described in Chapter 6.

FieldLayout Table Validity Rules

  • The Field entry must hold a valid reference to the Field table.

  • The field referenced in the Field entry must not have the static flag set.

  • [run time] If the referenced field is an object reference type and belongs to TypeDefs that have an explicit layout, the OffSet entry must hold a value that is a multiple of sizeof(void*).

  • [run time] If the referenced field is an object reference type and belongs to TypeDefs that have an explicit layout, this field must not overlap with any other field.

FieldRVA Table Validity Rules

  • [run time] The RVA entry must hold a valid nonzero relative virtual address.

  • The Field entry must hold a valid index to the Field table.

  • No duplicate records referencing the same field can exist.

FieldMarshal Table Validity Rules

  • The Parent entry must hold a valid reference to the Field or Param table.

  • No duplicate records that contain the same Parent value can exist.

  • The NativeType entry must hold a valid reference to the #Blob stream, indexing a valid marshaling signature. Native types that make up the marshaling signatures are described in Chapter 7.

Constant Table Validity Rules

  • The Type entry must hold a valid ELEMENT_TYPE_* code, one of the following: bool, char, a signed or unsigned integer of 1 to 8 bytes, string, or object.

  • The Value entry must hold a valid offset in the #Blob stream.

  • The Parent entry must hold a valid reference to the Field, Property, or Param table.

  • No duplicate records that contain the same Parent value can exist.

MemberRef Table Validity Rules

  • [run time] The Class entry must hold a valid reference to one of the following tables: TypeRef, TypeSpec, ModuleRef, MemberRef, or Method.

  • [run time] The Class entry of a MemberRef record referencing a field must hold a valid reference to the TypeRef or ModuleRef table.

  • [run time] The Name entry must hold a valid offset in the #Strings stream, indexing a nonempty string no longer than 1023 bytes in UTF-8 encoding.

  • [run time] The name defined by the Name entry must not match the common language runtime reserved names _Deleted* or _VtblGap*.

  • [run time] The Signature entry must hold a valid offset in the #Blob stream, indexing a valid MemberRef signature. Validity rules for MemberRef signatures are discussed in Chapter 7.

  • No duplicate records with all three entries matching can exist.

  • An item (field or method) that a MemberRef record references must not have the accessibility flag privatescope.



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