Hello fellow Gophers, I am currently looking into what a built Go binary may contain and have found some confusing things around the `.gopclntab` ELF section, also known as the PCLN table.
At first, I assumed that the PCLN table is present in all binaries, no matter how they are built. I've done some tests with stripped, trimmed and CGo binaries and have found it to be present. However, this article <https://utcc.utoronto.ca/~cks/space/blog/programming/GoBinaryStructureNotes> contains an interesting statement: *For ordinary unstripped Go binaries, this debugging information is in the .gopclntab and .gosymtab ELF sections of the binary, and can be read out with debug/elf/File.Section() <https://golang.org/pkg/debug/elf/#File.Section> and Section.Data() <https://golang.org/pkg/debug/elf/#Section.Data>. Unfortunately, Go binaries that use cgo do not have these Go ELF sections. As mentioned in Building a better Go linker <https://docs.google.com/document/d/1D13QhciikbdLtaI67U6Ble5d_1nsI4befEd6_k1z91U/view>:For “cgo” binaries, which may make arbitrary use of C libraries, the Go linker links all of the Go code into a single native object file and then invokes the system linker to produce the final binary.This linkage obliterates .gopclntab and .gosymtab as separate ELF sections. I believe that their data is still there in the final binary, but I don't know how to extract them. * I have also found such binaries in the wild, like the `containerd` binary or some tools from Docker as well. I've tried to decipher how the containerd binary is being built (based on this Makefile <https://github.com/containerd/containerd/blob/main/Makefile>), but I am not really familiar enough with Make to decipher this. This S/O post <https://reverseengineering.stackexchange.com/questions/29077/does-golangs-cgo-now-support-output-with-gopclntab> has asked the same question, but the answer doesn't match what I've seen and also what that article claims. Can someone shed some lights on how one can build CGo binaries without the `.pclntab` section? Also, what happens to stacktraces in such a case? Thanks! -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/f2e9cded-3c04-4591-86ab-5f0d9077424dn%40googlegroups.com.