Coder Social home page Coder Social logo

gore's Introduction

Build Status GitHub tag (latest SemVer) codecov Go Report Card Go Reference

GoRE - Package gore is a library for analyzing Go binaries

How to use

  1. Use go get to download the library.
  2. Import it into your project.
  3. Write a new cool tool.

For an example use case, please check out redress.

Sample 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()

Update get new Go release information

Instead of downloading new release of the library to get detection for new Go releases, it is possible to do a local pull.

Run go generate and new compiler releases will be generated from the git tags.

Functionality

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.

gore's People

Contributors

boy-hack avatar derekparker avatar github-actions[bot] avatar joakim-intezer avatar monoidic avatar tcm1911 avatar wdvxdr1123 avatar zxilly avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gore's Issues

Confusion about LICENSE

I am using gore to create my own project gsv, but my project is released under the Mozilla Public License 2.0, and I'm not sure if this is compatible with the AGPL that gore uses, so I'd like to get an explicit permit from the author for this use.
Thank you sincerely for your work on gore.

Slice out of range error

Go version I was using: Go 1.13 linux/amd64

I was testing out gore today, and came across a curious bug. I compiled the code below, with no special flags: go build -trimpath -o test.bin main.go
I then ran the file against itself ./test.bin test.bin, and this error occured:

panic: runtime error: slice bounds out of range [:5203186120246329699] with capacity 1001107

goroutine 1 [running]:
github.com/goretk/gore.parseString(0xc0000c6540, 0xfffff8250c8b4864, 0x401000, 0xc000936000, 0xf4693, 0xf4693, 0x0, 0x0)
        github.com/goretk/gore/type.go:785 +0x24e
github.com/goretk/gore.parseUncommonType(0xc0003004b0, 0xc00022f290, 0xc0000c6540, 0xc000936000, 0xf4693, 0xf4693, 0x401000, 0xc00022f140)
        github.com/goretk/gore/type.go:805 +0x40a
github.com/goretk/gore.typeParse(0xc00022f140, 0xc0000c6540, 0xed0, 0xc000936000, 0xf4693, 0xf4693, 0x401000, 0x0)
        github.com/goretk/gore/type.go:387 +0x353f
github.com/goretk/gore.getLegacyTypes(0xc0000c6540, 0x56cec0, 0xc00000e040, 0xa, 0xffffffffffffffff, 0x8)
        github.com/goretk/gore/type.go:107 +0x235
github.com/goretk/gore.getTypes(0xc0000c6540, 0x56cec0, 0xc00000e040, 0x0, 0x4e9c20, 0xc0000b0140)
        github.com/goretk/gore/type.go:47 +0x4cc
github.com/goretk/gore.(*GoFile).GetTypes(0xc0000b0140, 0x0, 0x0, 0x0, 0x0, 0x7762a6bf)
        github.com/goretk/gore/file.go:262 +0x52
main.main()
        command-line-arguments/main.go:21 +0xdc

I also came across this error running this code against various other Go ELF files on my system, so it isn't unique to this file.

Code mentioned above:

package main

import (
	"fmt"
	"os"
	"path"

	"github.com/goretk/gore"
)

func main() {
	file, err := gore.Open(os.Args[1])
	if err != nil {
		panic(err)
	}

	packages, err := file.GetPackages()
	if err != nil {
		panic(err)
	}
	types, err := file.GetTypes()
	if err != nil {
		panic(err)
	}

	symbols := make([]string, (len(packages) + len(types)*2))
	for _, goType := range types {
		symbols = append(symbols, path.Join(goType.PackagePath, goType.Name))
	}
	for _, pkg := range packages {
		for _, method := range pkg.Methods {
			symbols = append(symbols, path.Join(method.PackageName, method.Name))
		}
		for _, function := range pkg.Functions {
			symbols = append(symbols, path.Join(function.PackageName, function.Name))
		}
	}

	for _, symbol := range symbols {
		fmt.Println(symbol)
	}
}

EDIT: ran compiled binary through redress just to make sure I was using gore correctly, and as I thought it panic'd with the same error.

Replacing extracted information

How can I overwrite/replace the extracted information in the compiled binary? e.g BuildID, package names etc. I didn't see any exposed methods that can do this.

Go module support

Enable Go module support.

Currently some tests are failing when in "go mod" mode.

Linux type kind parsing fails

When running the following script on a installation of pygore on a debian system i sometimes see erroneous values for kind. These are parsed correctly on a windows installation, using the same binary. I've verified the binaries are not corrupted by checking their hashes.

import pygore
import sys

testfile = sys.argv[1]

f = pygore.GoFile(testfile)
c = f.get_compiler_version()

types = f.get_types()
f.close()
for t in types:
    val,  = t.kind
    if val > 30 :
        print(val)

Output:

140033113718791
140033113718785
140033113718803
140033113718803
140033113718786
140033113718809
140033113718807

Analysis fails if no build id exist in ELF binaries

[gore]$ GOOS=linux go build -o test -ldflags='-s -w -buildid=' testdata/simple.go 
[gore]$ file test
test: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, stripped
[gore]$ redress -compiler test
2019/10/26 14:41:06 Error when opening the file: error when getting note section section does not exist

Works for Windows and macOS binaries:

[gore]$ GOOS=windows go build -o test -ldflags='-s -w -buildid=' testdata/simple.go 
[gore]$ redress -compiler test
Compiler version: go1.13.1 (2019-09-25T18:48:17Z)
[gore]$ GOOS=darwin go build -o test -ldflags='-s -w -buildid=' testdata/simple.go 
[gore]$ redress -compiler test
Compiler version: go1.13.1 (2019-09-25T18:48:17Z

panic: runtime error: index out of range [757869355] with length 33282560

I used redress to analyze a program of about 70mb. When using -struct or -interface, the program reported an error.

github.com/goretk/gore.resolveName(...)
github.com/goretk/[email protected]/type.go:980
github.com/goretk/gore.typeParse(0xc000ea1170, 0xc000192e40, 0xed923c, 0xc007bba000, 0x1fbda00, 0x1fbda00, 0x20a5000, 0x0)
github.com/goretk/[email protected]/type.go:371 +0x39fb
github.com/goretk/gore.typeParse(0xc000ea1170, 0xc000192e40, 0x284d20, 0xc007bba000, 0x1fbda00, 0x1fbda00, 0x20a5000, 0x0)
github.com/goretk/[email protected]/type.go:654 +0x148e
github.com/goretk/gore.typeParse(0xc000ea1170, 0xc000192e40, 0x1dcac0, 0xc007bba000, 0x1fbda00, 0x1fbda00, 0x20a5000, 0x0)
github.com/goretk/[email protected]/type.go:418 +0x2529
github.com/goretk/gore.getTypes(0xc000192e40, 0xa05368, 0xc0001120f0, 0x0, 0x9784e0, 0xc00011e280)
github.com/goretk/[email protected]/type.go:76 +0x2a5
github.com/goretk/gore.(*GoFile).GetTypes(0xc00011e280, 0x0, 0x0, 0x0, 0x0, 0x0)
github.com/goretk/[email protected]/file.go:262 +0x59
main.standalone()
github.com/goretk/redress/standalone.go:59 +0x308
main.main()
github.com/goretk/redress/main.go:73 +0x54

Fix function line logic

The estimate of function source code lines uses a deprecated function. Update to use the new functions provided by the standard library and improve its accuracy.

gosym can provide the wrong address for funcs in cgo go binary

As described in golang/go#65232, gosym.NewLineTable should be used with the value of symbol runtime.text but not just use the start of .text segment, which was used by gore right now.

I have no idea how to implement a search for runtime.text in the stripped binary, but at least we can show a warning like the offset in func can be incorrect in cgo binary right now.

image

GetGoRoot return ErrNoGoRootFound when running on windows

in goroot.go:357, subpath := fmt.Sprintf("/src/%s", v.Name), subpath will be /src/:packageName.
in goroot.go:358, *github.com/goretk/gore.Package.Filepath will return\usr\local\go\src\:packageName.
so in goroot.go:358, if strings.HasSuffix(v.Filepath, subpath) will alway be false.
image

if i use this statement subpath := filepath.Join("/src", v.Name), it will get expect result.
image

but, in goroot.go:359, it will return \usr\local\go, not equal expectGoRoot in goroot_test.go
in my project, i use filepath.ToSlash to deal with the result return from GetGoRoot. i have no idea, if use filepath.ToSlash in goroot.go:360, will it adversely affect the project?
image

i run go test, it seems good.

Running tool: go.exe test -timeout 30s -run ^TestExtractGoRoot$ github.com/goretk/gore

=== RUN   TestExtractGoRoot
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.10.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.11.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.12.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.13.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.14.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.5.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.6.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.7.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.7beta1
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.8.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.9.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.10.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.11.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.12.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.13.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.14.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.15.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.16.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.17.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.18.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.5.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.6.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.7.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.7beta1
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.8.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.9.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.10.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.11.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.12.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.13.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.14.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.15.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.16.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.17.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.18.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.5.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.6.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.7.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.7beta1
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.8.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-386-1.9.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.10.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.11.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.12.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.13.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.14.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.15.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.16.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.17.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.18.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.5.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.6.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.7.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.7beta1
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.8.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.9.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.10.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.11.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.12.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.13.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.14.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.15.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.16.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.17.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.18.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.5.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.6.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.7.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.7beta1
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.8.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-386-1.9.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.10.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.11.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.12.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.13.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.14.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.15.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.16.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.17.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.18.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.5.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.6.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.7.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.7beta1
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.8.0
=== RUN   TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.9.0
--- PASS: TestExtractGoRoot (0.74s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.10.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.11.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.12.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.13.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.14.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.5.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.6.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.7.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.7beta1 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.8.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-386-1.9.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.10.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.11.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.12.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.13.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.14.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.15.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.16.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.17.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.18.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.5.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.6.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.7.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.7beta1 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.8.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-darwin-amd64-1.9.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.10.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.11.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.12.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.13.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.14.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.15.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.16.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.17.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.18.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.5.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.6.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.7.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.7beta1 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.8.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-386-1.9.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.10.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.11.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.12.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.13.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.14.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.15.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.16.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.17.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.18.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.5.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.6.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.7.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.7beta1 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.8.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-linux-amd64-1.9.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.10.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.11.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.12.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.13.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.14.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.15.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.16.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.17.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.18.0 (0.00s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.5.0 (0.02s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.6.0 (0.02s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.7.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.7beta1 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.8.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-386-1.9.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.10.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.11.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.12.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.13.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.14.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.15.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.16.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.17.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.18.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.5.0 (0.02s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.6.0 (0.02s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.7.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.7beta1 (0.02s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.8.0 (0.01s)
    --- PASS: TestExtractGoRoot/get_goroot_form_gold-windows-amd64-1.9.0 (0.02s)
PASS
ok      github.com/goretk/gore  0.805s

`GoVersionCompare` can provide wrong result

For exmaple, it believes go1.8.5rc5 less than go1

image

Golang just introduces a new builtin lib https://github.com/golang/go/blob/master/src/go/version/version.go to solve the comparison of golang versions. But it's available since go1.22rc1. Maybe we can make a copy of the lib?

Generate of moduledata timeout

The daily cron job is currently timing out after 6 hours. It appears to be due to the moduledata code generation. It has currently been disabled.

https://github.com/goretk/gore/actions/runs/7862718547

Run go generate ./...
go: downloading github.com/google/go-github/v58 v58.0.0
go: downloading golang.org/x/mod v0.14.0
go: downloading golang.org/x/arch v0.6.0
go: downloading github.com/google/go-querystring v1.1.0
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
Error when parsing time: parsing time "date" as "2006-01-02T15:04:05Z07:00": cannot parse "date" as "2006"
/home/runner/work/gore/gore/goversion_gen.go changes detected.
Fetching moduledata for go1.5...
Fetching moduledata for go1.6...
Fetching moduledata for go1.7...
Fetching moduledata for go1.8...
Fetching moduledata for go1.9...
Fetching moduledata for go1.10...
Fetching moduledata for go1.11...
Fetching moduledata for go1.12...
Fetching moduledata for go1.13...
Fetching moduledata for go1.14...
Fetching moduledata for go1.15...
Fetching moduledata for go1.16...
Fetching moduledata for go1.17...
Fetching moduledata for go1.18...
Fetching moduledata for go1.19...
Fetching moduledata for go1.20...
Fetching moduledata for go1.21...
Fetching moduledata for go1.22...
Error: The operation was canceled.

Fix map struct parsing for Go 1.7 to 1.13

The internal structure for the map type has changed between some Go versions. The current parsing logic can't handle Go 1.7 to 1.13. Due to this, if the the map has methods, the parser reads bad data. This bug only affects the develop branch and not the stable branch.

GetTypes panic: runtime error: invalid memory address or nil pointer dereference.

here is the scan file md5sum: 02bf1d9f09eb370101bf971c0a0214bc
you can download this file from url below

https://www.virustotal.com/gui/file/56b110a95c2b16784ba053c69f3ffcdbffcef1fdf42214f71d61b9e0d59b9a42

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x58ad15]

goroutine 1 [running]:
github.com/goretk/gore.typeParse(0xd76fe0, 0xc0000c7b00, 0x295800, {0xc001bb6000, 0x435600, 0x435600}, 0x401000)
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/type.go:497 +0x11d5
github.com/goretk/gore.typeParse(0xc00000e540, 0xc0000c7b00, 0x21d6e0, {0xc001bb6000, 0x435600, 0x435600}, 0x401000)
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/type.go:578 +0xaed
github.com/goretk/gore.getLegacyTypes(0xc0000c7b00, {0xd7da98, 0xc00000e540})
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/type.go:129 +0x271
github.com/goretk/gore.getTypes(0xc0000c7b00, {0xd7da98, 0xc00000e540})
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/type.go:60 +0x3b1
github.com/goretk/gore.(*GoFile).GetTypes(0xc0009f4000)
/home/nobody/go/pkg/mod/github.com/goretk/[email protected]/file.go:319 +0x71

external linked pie elf binary can work without .gopclntab section

I'm playing with some golang compiler arguments, and I found a linkmode=external buildmode=pie bianry can work without .gopclntab section.

The example file placed at https://github.com/Zxilly/go-testdata/releases/download/latest/bin-linux-1.21-amd64-ext-pie, and the readelf -S -W reported as below.

There are 48 section headers, starting at offset 0x6ec970:

Section Headers:
  [Nr] Name              Type            Address          Off    Size   ES Flg Lk Inf Al
  [ 0]                   NULL            0000000000000000 000000 000000 00      0   0  0
  [ 1] .interp           PROGBITS        0000000000000350 000350 00001c 00   A  0   0  1
  [ 2] .note.gnu.property NOTE            0000000000000370 000370 000020 00   A  0   0  8
  [ 3] .note.gnu.build-id NOTE            0000000000000390 000390 000024 00   A  0   0  4
  [ 4] .note.ABI-tag     NOTE            00000000000003b4 0003b4 000020 00   A  0   0  4
  [ 5] .note.go.buildid  NOTE            00000000000003d4 0003d4 000064 00   A  0   0  4
  [ 6] .gnu.hash         GNU_HASH        0000000000000438 000438 000034 00   A  7   0  8
  [ 7] .dynsym           DYNSYM          0000000000000470 000470 000570 18   A  8   1  8
  [ 8] .dynstr           STRTAB          00000000000009e0 0009e0 000323 00   A  0   0  1
  [ 9] .gnu.version      VERSYM          0000000000000d04 000d04 000074 02   A  7   0  2
  [10] .gnu.version_r    VERNEED         0000000000000d78 000d78 000060 00   A  8   1  8
  [11] .rela.dyn         RELA            0000000000000dd8 000dd8 06cc78 18   A  7   0  8
  [12] .rela.plt         RELA            000000000006da50 06da50 000480 18  AI  7  26  8
  [13] .init             PROGBITS        000000000006e000 06e000 00001b 00  AX  0   0  4
  [14] .plt              PROGBITS        000000000006e020 06e020 000310 10  AX  0   0 16
  [15] .plt.got          PROGBITS        000000000006e330 06e330 000008 08  AX  0   0  8
  [16] .text             PROGBITS        000000000006e340 06e340 21efe7 00  AX  0   0 32
  [17] .fini             PROGBITS        000000000028d328 28d328 00000d 00  AX  0   0  4
  [18] .rodata           PROGBITS        000000000028e000 28e000 077370 00   A  0   0 32
  [19] .eh_frame_hdr     PROGBITS        0000000000305370 305370 00016c 00   A  0   0  4
  [20] .eh_frame         PROGBITS        00000000003054e0 3054e0 000690 00   A  0   0  8
  [21] .tbss             NOBITS          00000000003074d0 3064d0 000008 00 WAT  0   0  8
  [22] .init_array       INIT_ARRAY      00000000003074d0 3064d0 000008 08  WA  0   0  8
  [23] .fini_array       FINI_ARRAY      00000000003074d8 3064d8 000008 08  WA  0   0  8
  [24] .data.rel.ro      PROGBITS        00000000003074e0 3064e0 1c2750 00  WA  0   0 32
  [25] .dynamic          DYNAMIC         00000000004c9c30 4c8c30 0001f0 10  WA  8   0  8
  [26] .got              PROGBITS        00000000004c9e20 4c8e20 0001c8 08  WA  0   0  8
  [27] .data             PROGBITS        00000000004ca000 4c9000 008a50 00  WA  0   0 32
  [28] .go.buildinfo     PROGBITS        00000000004d2a50 4d1a50 000280 00  WA  0   0 16
  [29] .noptrdata        PROGBITS        00000000004d2ce0 4d1ce0 026722 00  WA  0   0 32
  [30] .bss              NOBITS          00000000004f9420 4f8402 02fea0 00  WA  0   0 32
  [31] .noptrbss         NOBITS          00000000005292c0 4f8402 006af0 00  WA  0   0 32
  [32] .comment          PROGBITS        0000000000000000 4f8402 00002b 01  MS  0   0  1
  [33] .debug_aranges    PROGBITS        0000000000000000 556680 000106 00   C  0   0  8
  [34] .debug_info       PROGBITS        0000000000000000 556788 09e24a 00   C  0   0  8
  [35] .debug_abbrev     PROGBITS        0000000000000000 5f49d8 000724 00   C  0   0  8
  [36] .debug_line       PROGBITS        0000000000000000 5f5100 05b2e1 00   C  0   0  8
  [37] .debug_frame      PROGBITS        0000000000000000 6503e8 011194 00   C  0   0  8
  [38] .debug_str        PROGBITS        0000000000000000 661580 0006a3 01 MSC  0   0  8
  [39] .debug_loc        PROGBITS        0000000000000000 661c28 06a159 00   C  0   0  8
  [40] .debug_ranges     PROGBITS        0000000000000000 6cbd88 0200ba 00   C  0   0  8
  [41] .debug_line_str   PROGBITS        0000000000000000 6ebe48 0001ec 01 MSC  0   0  8
  [42] .debug_loclists   PROGBITS        0000000000000000 6ec038 00066f 00   C  0   0  8
  [43] .debug_rnglists   PROGBITS        0000000000000000 6ec6a8 000084 00   C  0   0  8
  [44] .debug_gdb_scripts PROGBITS        0000000000000000 6ec72c 00003f 00      0   0  1
  [45] .symtab           SYMTAB          0000000000000000 4f8430 02a660 18     46 7124  8
  [46] .strtab           STRTAB          0000000000000000 522a90 033bed 00      0   0  1
  [47] .shstrtab         STRTAB          0000000000000000 6ec76b 000201 00      0   0  1
Key to Flags:
  W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
  L (link order), O (extra OS processing required), G (group), T (TLS),
  C (compressed), x (unknown), o (OS specific), E (exclude),
  D (mbind), l (large), p (processor specific)

codecov/codecov-action v1 will not work after 2024 Feb 1

As https://github.com/codecov/codecov-action said:

Deprecation of v1
As of February 1, 2022, v1 has been fully sunset and no longer functions

Due to the deprecation of the underlying bash uploader, the Codecov GitHub Action has released v2/v3 which will use the new uploader. You can learn more about our deprecation plan and the new uploader on our blog.

We will be restricting any updates to the v1 Action to security updates and hotfixes.

But update to v2/v3 required a token from codecov, which can only be set by maintainer. It's hard to create to pr to fix this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.