For my first post, I'll just cover some findings on the usage of elf sections in AMD64 assembly stored in well, elfs. While you can call a section almost anything you want, there are some standard sections a compiler/linker uses. These are obviously all documented somewhere, I don't seem to very very good at finding it with a search engine though, so fragmented findings will have to do.
Where did this desire to know more come from? Well, someone on irc was wondering if an elf was statically or dynamically linked, despite being built as static since some tools reported it as static, and some reported as it containing dynamic sections. As it turns out, it seems that the compiler/linker decided to use the .dynamic section, despite that section name seemingly being reserved for machine code that sets up usage of a dynamic library.
Running the program and checking strace did show that the elf was indeed static, so that section name was misleading. This left me with a desire to know what the standard section names and usage was. My findings are below.
- Not really sure what this one is for.
- Seems to be a marker of some ABI version.
- Contains some version string with gnu in the name.
- Seeminly contains an offset into .dynstr, where the name of the external symbol can be found. Not used in fully static elfs.
- Seeminly contains the strings of external symbols. Not used in fully static elfs.
- Seeminly contains refrences to .dynstr via .dynsym, which the dynamic loader interprets to find which librarys to load. May be used by static elfs for some other unknown purpose.
- Another version string with GNU in the name.
- Yet another version string with GNU in the name.
- Seems to contain execption unwinding and source language information.
- Seems to contain something to do with comments.
- Contains uninitalised data that may be written to. Gcc's linker doesn't seem to use this.
- Contains initalised data that is read only.
- Contains initalized data that read and write. May be jmp'd to for execution, but no compiler will ever decide to do that.
- Where the main program is located, containing _start, main and any other function.