Go to the first, previous, next, last section, table of contents.

## What GAS does when it runs

This is a quick look at what an assembler run looks like.

- The assembler initializes itself by calling various init routines.
- For each source file, the `read_a_source_file` function reads in the file and parses it. The global variable `input_line_pointer` points to the current text; it is guaranteed to be correct up to the end of the line, but not farther.
- For each line, the assembler passes labels to the `colon` function, and isolates the first word. If it looks like a pseudo-op, the word is looked up in the pseudo-op hash table `po_hash` and dispatched to a pseudo-op routine. Otherwise, the target dependent `md_assemble` routine is called to parse the instruction.
- When pseudo-ops or instructions output data, they add it to a frag, calling `frag_more` to get space to store it in.
- Pseudo-ops and instructions can also output fixups created by `fix_new` or `fix_new_exp`.
- For certain targets, instructions can create variant frags which are used to store relaxation information (see section Relaxation).
- When the input file is finished, the `write_object_file` routine is called. It assigns addresses to all the frags (`relax_segment`), resolves all the fixups (`fixup_segment`), resolves all the symbol values (using `resolve_symbol_value`), and finally writes out the file (in the `BFD_ASSEMBLER` case, this is done by simply calling `bfd_close`).

Go to the first, previous, next, last section, table of contents.