Closed fumeboy closed 1 year ago
and share an discovery of type system here
i found the relocation R_MethodOff
is used to put value as typeOff
of method.mtyp
, and the runtime (reflect indeed) always use the function resolveTypeOff
the get *_type
from moduledata.typemap
by using the typeOff
value as key
type method struct {
name nameOff
mtyp typeOff
ifn textOff
tfn textOff
}
so we could build custom moduledata.typemap
with custom typeOff
value for plugins, such as using math.MaxUint32 - 123
to visit json.Marshaler.Marshal
, and the json.Marshaler.Marshal
is provided by loader.
if a type is too far to visit by plugin (farther than 32bit), we can use this operation.
My implementation is different and produces fully qualified symbol names (no collisions), and I'd already implemented a similar idea to your second suggestion in this commit a few weeks ago. I need to fix a final few CGo bugs in that branch before I merge though
typelinksRegister
write elem tosymPtr
with key, the key is made by_type.String()
, and which is lost the pkgpath and just cotains package name, so if two packages have same name,typelinksRegister
may writesymPtr
twice at same key.let user do registerType manually may be more safe, like this: