Single-Pass Assembly & Binary Layout
The final stage of the AzLang compiler pipeline turns the emitted assembly into a finished, standalone bare-metal executable — in one invocation, with no linker.
1. Pipeline Execution Flow
AzLang produces machine code through a deterministic two-step lowering pipeline:
- Assembly Emission: the validated AST is lowered into one
.asmfile — header,includedirectives for every invoked@linksource, the program’s code, and its string data. - Single-Pass Assembly:
fasmassembles that file directly into the final ELF executable. Assembly and linking happen in the same pass, so no intermediate object files ever exist.
fasm main.asm main
Because @link targets are fasm assembly sources (not pre-built .o files), there is nothing to pre-compile: the symbols write, exit, etc. are defined in the same translation unit and resolved statically at assembly time.
2. Resulting Binary
AzLang emits format ELF64 executable with entry _start and a single readable executable segment (a 120-byte program header). Because the program targets the system entry point _start and inlines its syscall stubs, no C runtime or dynamic linker is involved:
- No dynamic interpreter (
/lib64/ld-linux-x86-64.so.2is not required) - No section headers, no relocations — a minimal static image
- Tiny footprint: the Hello World program measures 180 bytes; a comprehensive 60-line multi-module program stays around 2 KB
- Instantaneous startup: execution begins at
_startwith direct syscalls
$ file main
main: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, no section header
$ ./main
Hello World from AzLang!