Update
This commit is contained in:
parent
75162aa119
commit
4ae8d8e892
6 changed files with 92 additions and 19 deletions
12
go.mod
Normal file
12
go.mod
Normal file
|
@ -0,0 +1,12 @@
|
|||
module tools
|
||||
|
||||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/AlecAivazis/survey/v2 v2.3.2 // indirect
|
||||
github.com/akamensky/argparse v1.3.1 // indirect
|
||||
github.com/awalterschulze/gographviz v2.0.3+incompatible // indirect
|
||||
github.com/fatih/color v1.13.0 // indirect
|
||||
github.com/knightsc/gapstone v4.0.1+incompatible // indirect
|
||||
github.com/sergi/go-diff v1.2.0 // indirect
|
||||
)
|
56
go.sum
Normal file
56
go.sum
Normal file
|
@ -0,0 +1,56 @@
|
|||
github.com/AlecAivazis/survey/v2 v2.3.2 h1:TqTB+aDDCLYhf9/bD2TwSO8u8jDSmMUd2SUVO4gCnU8=
|
||||
github.com/AlecAivazis/survey/v2 v2.3.2/go.mod h1:TH2kPCDU3Kqq7pLbnCWwZXDBjnhZtmsCle5EiYDJ2fg=
|
||||
github.com/Netflix/go-expect v0.0.0-20180615182759-c93bf25de8e8/go.mod h1:oX5x61PbNXchhh0oikYAH+4Pcfw5LKv21+Jnpr6r6Pc=
|
||||
github.com/akamensky/argparse v1.3.1 h1:kP6+OyvR0fuBH6UhbE6yh/nskrDEIQgEA1SUXDPjx4g=
|
||||
github.com/akamensky/argparse v1.3.1/go.mod h1:S5kwC7IuDcEr5VeXtGPRVZ5o/FdhcMlQz4IZQuw64xA=
|
||||
github.com/awalterschulze/gographviz v2.0.3+incompatible h1:9sVEXJBJLwGX7EQVhLm2elIKCm7P2YHFC8v6096G09E=
|
||||
github.com/awalterschulze/gographviz v2.0.3+incompatible/go.mod h1:GEV5wmg4YquNw7v1kkyoX9etIk8yVmXj+AkDHuuETHs=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/fatih/color v1.13.0 h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=
|
||||
github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk=
|
||||
github.com/hinshun/vt10x v0.0.0-20180616224451-1954e6464174/go.mod h1:DqJ97dSdRW1W22yXSB90986pcOyQ7r45iio1KN2ez1A=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=
|
||||
github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51/go.mod h1:CzGEWj7cYgsdH8dAjBGEr58BoE7ScuLd+fwFZ44+/x8=
|
||||
github.com/knightsc/gapstone v4.0.1+incompatible h1:yROPRgpqBWgD/7fyH3+AJ2hQR4gYfKNFGnKcNY8HPIA=
|
||||
github.com/knightsc/gapstone v4.0.1+incompatible/go.mod h1:N9Q82fxOi8Fp9pHE2eflNZf5/FSg1815WZFhV8Gc2PE=
|
||||
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
|
||||
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/pty v1.1.4/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
|
||||
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
|
||||
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
|
||||
github.com/mattn/go-colorable v0.1.9 h1:sqDoxXbdeALODt0DAeJCVp38ps9ZogZEAXjus69YV3U=
|
||||
github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
|
||||
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
|
||||
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
|
||||
github.com/mattn/go-isatty v0.0.14 h1:yVuAays6BHfxijgZPzw+3Zlu5yQgKGP2/hcQbHb7S9Y=
|
||||
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b h1:j7+1HpAFS1zy5+Q4qx1fWh90gTKwiN4QCGoY9TWyyO4=
|
||||
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
|
||||
github.com/sergi/go-diff v1.2.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
|
||||
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
|
||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||
golang.org/x/crypto v0.0.0-20190530122614-20be4c3c3ed5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
|
||||
golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg=
|
||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c h1:F1jZWGFhYfh0Ci55sIpILtKKK8p3i2/krTr0H1rg74I=
|
||||
golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
|
||||
golang.org/x/term v0.0.0-20210503060354-a79de5458b56/go.mod h1:tfny5GFUkzUvx4ps4ajbZsCe5lw1metzhBm9T3x7oIY=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||
gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
|
@ -15,7 +15,7 @@ import (
|
|||
const (
|
||||
filesArg = "file"
|
||||
mappingArg = "mapping"
|
||||
listArg = "list"
|
||||
rootArg = "root"
|
||||
)
|
||||
|
||||
// ParseArguments parses arguments of the application.
|
||||
|
@ -26,10 +26,8 @@ func parseLocalArguments(p *argparse.Parser, args *u.Arguments) error {
|
|||
args.InitArgParse(p, args, u.BOOL, "m", mappingArg,
|
||||
&argparse.Options{Required: false, Default: false,
|
||||
Help: "Display libraries mapping (required -l argument)"})
|
||||
|
||||
args.InitArgParse(p, args, u.STRING, "l", listArg,
|
||||
&argparse.Options{Required: false, Help: "A list of build directories " +
|
||||
"to analyse (sep: ,)"})
|
||||
args.InitArgParse(p, args, u.STRING, "r", rootArg,
|
||||
&argparse.Options{Required: false, Help: "The root folder which contains build directories "})
|
||||
args.InitArgParse(p, args, u.STRING, "f", filesArg,
|
||||
&argparse.Options{Required: false, Help: "Json file that contains " +
|
||||
"the information for the binary analyser"})
|
||||
|
|
|
@ -120,6 +120,7 @@ func compareFunctions(elf *elf64core.ELF64File, obj *elf64core.ELF64File) (uint6
|
|||
elfFuncsAll := make([]elf64core.ELF64Function, 0)
|
||||
mapArrayFuncs := make(map[string]uint64, 0)
|
||||
for _, elfFunc := range elfFuncs {
|
||||
|
||||
if _, ok := mapObjFuncs[elfFunc.Name]; ok {
|
||||
// Check if the function is already in mapArrayFuncs
|
||||
val, ok := mapArrayFuncs[elfFunc.Name]
|
||||
|
|
|
@ -10,7 +10,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"path/filepath"
|
||||
"tools/srcs/binarytool/elf64analyser"
|
||||
"tools/srcs/binarytool/ukManager"
|
||||
u "tools/srcs/common"
|
||||
|
@ -36,17 +36,23 @@ func RunBinaryAnalyser(homeDir string) {
|
|||
// Check if a json file is used or if it is via command line
|
||||
manager := new(ukManager.Manager)
|
||||
manager.MicroLibs = make(map[string]*ukManager.MicroLib)
|
||||
if len(*args.StringArg[listArg]) > 0 {
|
||||
manager.Unikernels = make([]*ukManager.Unikernel, len(*args.StringArg[listArg]))
|
||||
if len(*args.StringArg[rootArg]) > 0 {
|
||||
manager.Unikernels = make([]*ukManager.Unikernel, 0)
|
||||
mapping := false
|
||||
if *args.BoolArg[mappingArg] {
|
||||
mapping = true
|
||||
}
|
||||
list := strings.Split(*args.StringArg[listArg], ",")
|
||||
for i, arg := range list {
|
||||
manager.Unikernels[i] = &ukManager.Unikernel{
|
||||
BuildPath: arg,
|
||||
files, err := os.ReadDir(*args.StringArg[rootArg])
|
||||
if err != nil {
|
||||
u.PrintErr(err)
|
||||
}
|
||||
for _, file := range files {
|
||||
if file.IsDir() {
|
||||
println(file.Name())
|
||||
manager.Unikernels = append(manager.Unikernels, &ukManager.Unikernel{
|
||||
BuildPath: filepath.Join(*args.StringArg[rootArg], file.Name()),
|
||||
DisplayMapping: mapping,
|
||||
})
|
||||
}
|
||||
}
|
||||
} else if len(*args.StringArg[filesArg]) > 0 {
|
||||
|
|
|
@ -251,15 +251,15 @@ func (uk *Unikernel) sectionsObjs(linkerInfo LinkerInfo) string {
|
|||
// Ignore ukbootMain
|
||||
continue
|
||||
}
|
||||
strBuilder[0].WriteString(fmt.Sprintf("%s (.rodata);\n", obj.name))
|
||||
strBuilder[1].WriteString(fmt.Sprintf("%s (.data);\n", obj.name))
|
||||
strBuilder[2].WriteString(fmt.Sprintf("%s (.bss);\n", obj.name))
|
||||
strBuilder[0].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);%s (.rodata);\n", obj.sectionSize.rodataAddr, obj.name))
|
||||
strBuilder[1].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);%s (.data);\n", obj.sectionSize.dataAddr, obj.name))
|
||||
strBuilder[2].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);%s (.bss);\n", obj.sectionSize.bssAddr, obj.name))
|
||||
}
|
||||
|
||||
for _, obj := range uk.alignedLibs.OnlyFewMicroLibs {
|
||||
strBuilder[0].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);\n%s (.rodata);\n", obj.sectionSize.rodataAddr, obj.name))
|
||||
strBuilder[1].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);\n%s (.data);\n", obj.sectionSize.dataAddr, obj.name))
|
||||
strBuilder[2].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);\n%s (.bss);\n", obj.sectionSize.bssAddr, obj.name))
|
||||
strBuilder[0].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);%s (.rodata);\n", obj.sectionSize.rodataAddr, obj.name))
|
||||
strBuilder[1].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);%s (.data);\n", obj.sectionSize.dataAddr, obj.name))
|
||||
strBuilder[2].WriteString(fmt.Sprintf(". = ABSOLUTE(0x%x);%s (.bss);\n", obj.sectionSize.bssAddr, obj.name))
|
||||
}
|
||||
|
||||
// Add ukbootMain before single microlibs
|
||||
|
|
Loading…
Add table
Reference in a new issue