1

I would like to analyse Go object files.

When I use the following command:

go tool compile -o test.o test.go

the generated file test.o is in the form of an archive (known as Go object archive). I can extract it using

go tool pack x test.o

which extracts two files: _go_.o and __.PKGDEF The file command outputs that those two are data files.

My problem is that the extracted object file is not in ELF format, so it can't be used by tools like readelf or objdump. However go tools understand those files. For example I can disassemble it using:

go tool objdump _go_.o

Is there an other way to extract object files from go archives? Or another way to compile go code to object files directly and not in archive format?

0 Answers0