ElfObject – The Yasm Modular Assembler Project

ELF Object Format

The Executable and Linkable Object Format is the primary object format for many operating systems including FreeBSD and GNU/Linux. It appears in three forms:

  • Shared object files (.so)
  • Relocatable files (.o)
  • Executable files (no convention)

YASM only directly supports relocatable object files. Other tools, such as the GNU Linker "ld", help turn object files into the other formats.

YASM ELF Support

YASM provides support of most basic ELF features. Several advanced features are still lacking, such as the ability to provide one's own hashing function.

YASM Integration

ELF supports the x86 architecture in its x86 and AMD64 machine variations.

ELF supports Stabs and DWARF2 debugging.

As other architectures, machines, and debugging formats that can work with ELF are added to YASM, expect to see ELF support for them.

ELF Sections

ELF's section-based output supports attributes on a per-section basis. These attributes include "alloc", "exec", "write", "progbits", and "align". Except for align, they can each be negated by prepending "no", e.g., "noexec". They are later read by the operating system to select the proper behavior for each section, with these meanings:

AttributeIndicates the section
alloc is loaded into memory at runtime. This is true for code and data sections, and false for metadata sections.
exechas permission to be run as executable code.
writeis writable at runtime.
progbitsis stored in the disk image, as opposed to allocated and initialized at load.
align=nrequires a memory alignment of n bytes. The value n is always a power of 2.

The primary sections have attribute defaults according their expected use, and any unknown section gets its own defaults:

Sectionallocexecwriteprogbitsalign
.bssalloc write 4
.dataalloc writeprogbits4
.rodataalloc progbits4
.textallocexec progbits16
unknownalloc progbits1

For Future reference: