separate debug info from go binary after the file has been built

51 Views Asked by At

I know that go build ldflags="-s -w" would work. However, I cannot optain a .debug file or debug info archive. Is there any method to strip binary generated from go build command only?

I've tried eu-strip but the sizes of files are not the same.

  • with "-s -w" tag : 62780680 Bytes
  • without "-s -w" tag: 94617747 Bytes
  • not stripped yet .bin after eu-strip: 77073712 Bytes

There are some other combination I've tried.

  • with "-s" tag: 86700186 Bytes

  • after eu-strip: 62780752 Bytes

  • with "-w" tag: 69849906 Bytes

  • after eu-strip: 62780784 Bytes

I noticed that the size of files that are built with "-s" or "-w" tags and stripped are very close to the one that is built with "-s -w" tags. Their sizes are still different though. Maybe eu-strip is not a suitable tool.

How can I separate debug information from non-stripped binary? I want to use such file to debug with dlv.

(ref of debug-info-directory: https://github.com/go-delve/delve/blob/master/pkg/config/config.go)

0

There are 0 best solutions below