views:

15

answers:

2

I'm creating an ELF executable file and I need to know what sections are required by the operating system in order to load and execute it.

Details:

OS:               Ubuntu 10.04 (64-bit)
Kernel version:   2.6.32-24
Architecture:     i386

I realize that the following would probably be necessary:

  • .text
  • .symtab
  • .rel.text

Are there others?

+2  A: 

"A Whirlwind Tutorial on Creating Really Teensy ELF Executables for Linux " has information on how to (ab)use the various ELF sections to make an executable as small as possible. It also contains a link to the ELF specification if you need more information. (It's also a fairly entertaining read.) Maybe it will tell you what you need to know?

Josh Kelley
Yup. It helped tremendously! Thanks!
George Edison
Strictly speaking, you don't need **any** sections. The dynamic loader uses program headers to load the file, not section headers. The article does come to that but I just wanted to mention it explicitly. If you need to import symbols, you can do it by adding a PT_DYNAMIC segment.
Igor Skochinsky
A: 

I decided to try systematically stripping sections from an ELF file generated by GCC.

I was able to remove many of the sections, but these could not be removed and have the executable still execute without a segmentation fault:

.dynsym
.dynstr
.gnu.version_r
.rel.plt
.init
.plt
.text
.fini
.ctors
.dtors
.dynamic
.got.plt
.data
.strtab
George Edison