1

I read this page in which the author, Chris Siebenmann, states that binaries created using cgo will not have the gopclntab or the gosymtab sections. However, I see that on go version go1.13.15 linux/amd64, I have built a Go program which links basic c code, using cgo, and I've confirmed with radare2 that there is in fact a .gopclntab section in the resulting binary.

Has there been a change since this article (and the referenced Building a Better Go Linker article) was written? Or is there some other situation in which cgo may strip these sections? I ask because I have indeed seen other cgo output binaries that have these sections missing, but I have been unable to reproduce this using my version of the cgo toolchain.

Aside from just knowing this fact, this information is relevant to reverse engineering go binaries because the .gopclntab can be used to extract symbol information. In the past, the absence of this table due to cgo compilation has made it more difficult to do so.

3
  • It seems to be a question for go developers, not sure why you are asking here…
    – Igor Skochinsky
    Aug 1 at 15:02
  • @IgorSkochinsky I agree that the Go developers may be able to answer this question. However, it is relevant to reversing Go binaries. Not having this section has made it difficult to do so, and I have not found a clear answer in the docs. The question is being asked from a reversing perspective. Although, I do agree that it borderline could be a general Go question; but I've found that Go developer forums usually focus on the language itself, rather than the binary outputs of the compiler at such a low level.
    – the_endian
    Aug 2 at 3:31
  • I’m not sure what you expect since by your description the answer seems to be “yes”. As for when it’s present or not, golang developers surely know better than us.
    – Igor Skochinsky
    Aug 7 at 20:25
1

I think the gopclntab section should always be present in any Go binary. Without it panic() couldn't print a stack trace. I suspect the author you are citing was mistaken about this.

That being said, AFAIK gopclntab will not include symbols or unwind information for linked C libraries. This information is exclusively found in DWARF.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.