第2章_编译和链接

  1. build
    1. 预编译preprosssing .li
    2. 编译compilation (预编译+编译 cc1,cc1plus)
      1. 词法分析lex
      2. 语法分析yacc
      3. 语义分析
      4. 中间代码生成及优化
      5. 目标代码生成及优化
    3. 汇编assembly as .o
    4. 链接linking ld .out
  2. Preprocessing
    1. 删除#define
    2. 处理#if等
    3. 处理#include,将对应文件插入
    4. 删除注释
    5. 添加行号和文件名标识
    6. 保留#pragma
  3. 在语法树上做优化比较困难,所以编译器往往将目标代码转化为中间代码,如三地址码再进行优化。
  4. Linking
    1. Address and Storage Allocation
    2. Symbol Resolution
    3. Relocation
      1. relocation entry