From 3e21179814b4c7901f9767c72382a09c18aca5c9 Mon Sep 17 00:00:00 2001 From: Stephen Eckels Date: Wed, 16 Nov 2022 11:51:05 -0500 Subject: [PATCH] Add ProtoBuf, fix 1.19 type parsing --- GoReSym.proto | 75 ++++++++++++++++++++++++++++++++++++++++++++++ objfile/objfile.go | 6 ++++ 2 files changed, 81 insertions(+) create mode 100644 GoReSym.proto diff --git a/GoReSym.proto b/GoReSym.proto new file mode 100644 index 0000000..5f82d33 --- /dev/null +++ b/GoReSym.proto @@ -0,0 +1,75 @@ +syntax = "proto3"; +package GoReSym; +option go_package = "protobuf/GoReSym/"; + +message PcLnTabMetadata { + uint64 va = 1; + string version = 2; + string endianess = 3; + uint32 cpuQuantum = 4; + string cpuQuantumStr = 5; + uint32 pointerSize = 6; +} + +message FuncMetadata { + uint64 start = 1; + uint64 end = 2; + string packageName = 3; + string fullName = 4; +} + +message GoSlice { + uint64 data = 1; + uint64 len = 2; + uint64 capacity = 3; +} + +message ModuleData { + uint64 va = 1; + uint64 types = 2; + uint64 etypes = 3; + GoSlice typeLinks = 4; + GoSlice itabLinks = 5; + GoSlice legacyTypes = 6; +} + +message Type { + uint64 va = 1; + string str = 2; + string kind = 3; + string reconstructed = 4; +} + +message Module { + string path = 1; + string version = 2; + string sum = 3; +} + +message BuildSetting { + string key = 1; + string value = 2; +} + +message BuildInfo { + string goVersion = 1; + string path = 2; + Module main = 3; + repeated Module deps = 4; + repeated BuildSetting settings = 5; +} + +message ExtractMetadata { + string version = 1; + string buildId = 2; + string arch = 3; + string os = 4; + PcLnTabMetadata tabMeta = 5; + ModuleData moduleMeta = 6; + repeated Type types = 7; + repeated Type interfaces = 8; + BuildInfo buildInfo = 9; + repeated string files = 10; + repeated FuncMetadata userFunctions = 11; + repeated FuncMetadata stdFunctions = 12; +} \ No newline at end of file diff --git a/objfile/objfile.go b/objfile/objfile.go index 723606e..edd8578 100644 --- a/objfile/objfile.go +++ b/objfile/objfile.go @@ -754,6 +754,8 @@ func (e *Entry) readRTypeName(runtimeVersion string, typeFlags tflag, namePtr ui case "1.17": fallthrough case "1.18": + fallthrough + case "1.19": varint_len, namelen, err := e.readVarint(namePtr + 1) if err != nil { return "", fmt.Errorf("Failed to read name") @@ -943,6 +945,8 @@ func (e *Entry) ParseType_impl(runtimeVersion string, moduleData *ModuleData, ty case "1.17": fallthrough case "1.18": + fallthrough + case "1.19": if is64bit { var rtype Rtype114_115_116_117_118_64 rtype_raw, err := e.raw.read_memory(typeAddress, uint64(unsafe.Sizeof(rtype))) @@ -1321,6 +1325,8 @@ func (e *Entry) ParseType_impl(runtimeVersion string, moduleData *ModuleData, ty case "1.17": fallthrough case "1.18": + fallthrough + case "1.19": // type structType struct { // rtype // pkgPath name // pointer