volatilityfoundation / dwarf2json

convert ELF/DWARF symbol and type information into vol3's intermediate JSON
Other
106 stars 28 forks source link

Issue running "go build" #54

Closed kathyl21 closed 10 months ago

kathyl21 commented 1 year ago

I am trying to build dwarf2json. When I run go build I get the following error message:

# /usr/lib/go/src/pflag
./dwarf.go:108:15: d.AddSection undefined (type *dwarf.Data has no field or method AddSection)

My go version is go 1.13.8.

Context Volatility Version: 2 Operating System: Ubuntu 20 Python Version: 2.7.18 Command: go build

eve-mem commented 1 year ago

Hello @kathyl21

This seems like a problem with dwarf2json rather than volatility3. You might get more help raising an issue there instead: https://github.com/volatilityfoundation/dwarf2json

I don't know go very much at all, so I can't help with your issue. I know I've had issues in the past because Ubuntu defaulted to a strange version of go when i installed it, although i would imagine you're having a different problem.

ikelos commented 1 year ago

The readme points out that go-1.14 or later is required, please update your version of go and let us know if the problem still exists?

kathyl21 commented 1 year ago

I installed go version 1.16.15. When I issue a "go build" the error reads:

go: invalid module path "/usr/lib/go/sc/pflag": is an absolute path

npetroni commented 1 year ago

I installed go version 1.16.15. When I issue a "go build" the error reads:

go: invalid module path "/usr/lib/go/sc/pflag": is an absolute path

Can you please provide more details about your OS and development environment? I tried on both macOS and Ubuntu with a standard Go installation for 1.16.15 and couldn't reproduce.

kathyl21 commented 1 year ago

I'm trying to build this on an Ubuntu 20.04.6 LTS box with kernel version 5.4.0-132-generic kernel. All packages are up to date. go is version 1.16.15. gcc is 9.4.0. I also tried go version 1.18 on an Ubuntu 22 box, with kernel 5.15.0-83-generic with the same results.

eve-mem commented 1 year ago

I know I've had issues on Ubuntu installing the snap version of go, if you try installing the golang-go package from apt instead does that work?

kathyl21 commented 1 year ago

I tried that also and had the same issues.

eve-mem commented 1 year ago

Ah! Sorry for wasting your time with that suggestion, it just reminded me of that issue I'd had before. I'll leave it to the people that actually know what they're talking about now... Good luck.

npetroni commented 1 year ago

I'm trying to build this on an Ubuntu 20.04.6 LTS box with kernel version 5.4.0-132-generic kernel. All packages are up to date. go is version 1.16.15. gcc is 9.4.0. I also tried go version 1.18 on an Ubuntu 22 box, with kernel 5.15.0-83-generic with the same results.

Thanks. Can you please describe the exact steps you are using in your environment? How are you installing Go and what steps are you using to clone the repository and build (specific commands)?

Here is a process that works for me reliably. Tested using Docker and EC2, docker shown below:

$ docker pull ubuntu:latest

$ docker run --rm -it ubuntu:latest

root@3aec988f8149:~# apt-get update

root@3aec988f8149:~# apt-get install -y golang git

root@3aec988f8149:~# git clone https://github.com/volatilityfoundation/dwarf2json.git

root@3aec988f8149:~# cd dwarf2json/

root@3aec988f8149:~/dwarf2json# go build

root@3aec988f8149:~/dwarf2json# ./dwarf2json 
Usage: ./dwarf2json COMMAND

A tool for generating intermediate symbol file (ISF)

Commands:
  linux  generate ISF for Linux analysis
  mac    generate ISF for macOS analysis

The above works on 22.04 but not 20.04, because of the Go version incompatibility.

kathyl21 commented 1 year ago

Interesting. I have a similar setup, but am setting up on a machine that is not connected to the Internet.

- I start with an Ubuntu 22.04.3 LTS VM running Linux 5.15.0-88-generic kernel.
- apt-get install golang - this installs go version 1.18.1
- I download the latest version of dwarf2json and transfer to my VM 
- In dwarf2json-master I issue "go build".  And I get the same result - 
    go: malformed module path "/usr/lib/go/src/pflag": empty path element

When i get home I will try your instructions above with a docker image.

npetroni commented 1 year ago

Thanks for the explanation. Go's module system depends on Internet access to pull down dependencies prior to a build. This isn't unique to our project. dwarf2json currently uses one dependency: https://github.com/volatilityfoundation/dwarf2json/blob/master/go.mod#L5

If you need to build offline, try running go mod vendor after cloning the source on your Internet-connected machine. Then, copy the entire source tree, including the vendor directory created by that step. This should enable you to build without Internet access. I tested on a machine without Internet access and this procedure worked for me with dwarf2json.

Note that it might make more sense to just build the tool on the Internet-connected machine and bring over the resulting binary.

kathyl21 commented 1 year ago

Thanks - that worked. I built on an Internet-connected system using npetroni's suggestion and everything worked. I'll take this binary and copy it over. Thanks for the help everyone.