Format | Assembly Format | Description |
---|---|---|
7F <T> | ldsflda field |
Push the address of the static field field on the stack. |
…, → …, address
The ldsflda
instruction pushes the address (a managed pointer, type &
, if field refers to a type whose memory is managed; otherwise an unmanaged pointer, type native int
) of a static field on the stack. field
is a metadata token (a fieldref
or fielddef
; see Partition II) referring to a static field member. (Note that field can be a static global with assigned RVA, in which case its memory is unmanaged; where RVA stands for Relative Virtual Address, the offset of the field from the base address at which its containing PE file is loaded into memory)
System.FieldAccessException
is thrown if field is not accessible.
System.MissingFieldException
is thrown if field is not found in the metadata. This is typically checked when CIL is converted to native code, not at runtime.
Correct CIL ensures that field is a valid metadata token referring to a static field member if field refers to a type whose memory is managed.
For verifiable code, field cannot be init-only.
If field refers to a type whose memory is managed, verification (§III.1.8) tracks the type of the value loaded onto the stack as a managed pointer to the verification type (§I.8.7) of field. If field refers to a type whose memory is unmanaged, verification (§III.1.8) tracks the type of the value loaded onto the stack as an unmanaged pointer.
Using ldsflda
to compute the address of a static, init-only field and then using the resulting pointer to modify that value outside the body of the class initializer can lead to unpredictable behavior.