Learning ELF

A few weeks ago I was working with modifying ELF files to muck around with symbols and DWARF data structures.

At first I thought it might be somewhat obscure, but it turns out that it's actually quite straightforward. The only "gotcha" for me was how some sections are both "regular sections" but also, at least from an API perspective from the libelf library, made special/"first-class" - in particular, the string table for section names.

The Gist of it

An ELF file is basically made up of the following, glossing over 32-vs-64 bit concerns.

The section type effectively tells you how to interpret the section data. For example, string tables hold null-terminated strings, referenced by offset, starting with a zero-length string as a first entry.

Resources

Here are some handy resources for learning and playing with ELF files.

Callback

In some ways, these takes me back to my Chasing Symbols post, which appears will always be work-in-progress (if nothing else, because it seems like the more time passes, the more I keep learning.

Happy binary file layouts!

Tags:  debugging

Home