Deep dive into a Go binary

Whenever you compile a program in Go, it generates a binary that contains your program, but... what is there?
Of course there the compiled version of your code, but what else?
Come with me to explore the inside of the go binary, the elf sections, and how they are used by our executable.

LEVEL: Advanced

Place
GoLab Deep
Length
40 min
When
November 13th, 2024
14:30

Abstract

In this talk I will cover the internals of a Go binary, providing a comprehensive understanding of their structure.

We will begin an introduction of what obviously go in the Go binary, the program itself, and the runtime, and we are going to show that information using the Go tools. Also we are going to discuss other things that we could expect there, based on the things that we see in our programs, like information about the function names shown in stack traces or information about types accessible through reflection.

After that we are going to go a bit farther and explore the ELF format, at this point I'll need to introduce the main sections in that file, and how they are used by Go. Here we are going to cover the most common ELF sections, like `.text`, `.data`, `.bss`, `.rodata` and `.symtab`, and explore a bit what is contained there.

Once we are all in the same page about the ELF format, I'll explain other sections included in the binary, like gopclntab, gosymtab and go.buildinfo. We will explore a bit the Go code in the linker that takes care of the responsibility of building that sections.

From there, I'm going to explore some parts of the go code to expose how this information in the binary is initialized and used in the Go runtime for things like, stack traces, debugging, reflection or profiling.

As a last step, we are going to compile a small Go program and do a quick analysis of the Go binary and explore how some of the information is placed in the sections of the binary.

I'll finalize the talk with a summary of what is contain in the binary expecting the audience to be more aware now about what is there. And after that some references to keep investigating it.

Slides

Video

GoLab is a conference made by Develer.
Develer is a company based in Campi Bisenzio, near Florence. Our motto is : "Technology to give life to your products". We produce hardware and software to create exceptional products and to improve industrial processes and people's well being.
In Develer we have passion for the new technologies and we offer our clients effective solutions that are also efficient, simple and safe for the end users. We also believe in a friendly and welcoming environment where anybody can give their contribution. This passion and this vision are what we've been driven to organize our conference "made by developers for developers".


Subscribe to our newsletter

We hate spam just as much as you do, which is why we promise to only send you relevant communications. We respect your privacy and will never share your information with third parties.
©2024 GoLab | The international conference on Go in Florence-Design & devCantiere Creativo-Made withDatoCMS