forked from goretk/gore
-
Notifications
You must be signed in to change notification settings - Fork 0
/
doc.go
65 lines (51 loc) · 2.3 KB
/
doc.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// This file is part of GoRE.
//
// Copyright (C) 2019-2021 GoRE Authors
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
/*
Package gore is a library for analyzing Go binaries.
Only little endian architectures are supported.
Go compiler
The library has functionality for guessing the compiler version
used. It searches the binary for the identifiable string left
by the compiler. It is not perfect, so functionality for assuming
a specific version is also provided. The version strings used are
identical to the identifiers. For example version "1.10.1" is
represented as "go1.10.1" and version "1.10" is represented as
"go1.10"
Function recovery
Function information is recovered from the pclntab. Information
that is recovered includes: function start and end location in
the text section, source file. The library also tries to estimate
the first and last line number in the source file for the function.
The methods recovered includes the receiver. All functions and
methods belong to a package. The library tries to classify the
type of package. If it is a standard library package, 3rd-party
package, or part of the main application. If it unable to classify
the package, it is classified as unknown.
Type recovery
The types in the binary are parsed from the "typelink" list. Not
all versions of Go are supported equally. Versions 1.7 and later
are fully supported. Versions 1.5 and 1.6 are partially supported.
Version prior to 1.5 are not supported at all at the moment.
Example code
Extract the main package, child packages, and sibling packages:
f, err := gore.Open(fileStr)
pkgs, err := f.GetPackages()
Extract all the types in the binary:
f, err := gore.Open(fileStr)
typs, err := f.GetTypes()
*/
package gore