ClassMetadata layout #23
-
@Azoy How did you come to this class metadata layout structure? struct _ClassMetadata {
let _kind: Int
let _superclass: Any.Type?
let _reserved: (Int, Int)
let _rodata: UnsafeRawPointer
let _flags: ClassMetadata.Flags
let _instanceAddressPoint: UInt32
let _instanceSize: UInt32
...
} After looking through |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
So class metadata is a little weird for ObjC. The first 4 fields represent struct _ClassMetadata {
let _kind: Int // Class isa
let _superclass: Any.Type? // Class superclass
let _reserved: (Int, Int) // cache_t cache
let _rodata: UnsafeRawPointer // class_data_bits_t bits
// EVERYTHING else is Swift specific and not defined for ObjC classes.
// So like getting the descriptor in an ObjC class will result in a runtime crash.
} I'm unsure exactly where I got the name |
Beta Was this translation helpful? Give feedback.
So class metadata is a little weird for ObjC. The first 4 fields represent
struct objc_class: objc_obejct { ... }
where:I'm unsure exactly where I got the name
rodata
from for this field, but in reality this is the rwdata pointer after class realization. This is actually the type of data being stored here h…