代码之家  ›  专栏  ›  技术社区  ›  Mask

你能解释一下为什么gcc-S输出像assemble这样的东西吗?

  •  0
  • Mask  · 技术社区  · 16 年前
    $ gcc -S buffer-overflow.c && cat buffer-overflow.s 
    _foo: 
            pushl   %ebp           ;2 
            movl    %esp, %ebp     ;3 
            subl    $16, %esp      ;4 
            movl    LC1, %eax      ;5 
            movl    %eax, -4(%ebp) ;6 
            leal    -4(%ebp), %eax ;7 
            leal    8(%eax), %edx  ;8 
            movl    $_bad, %eax    ;9 
            movl    %eax, (%edx)   ;10 
            leave 
            ret 
    
    _main: 
        ... 
            call    _foo            ;1 
        ... 
    

    帮助信息说它不应该编译或汇编:

     -S                       Compile only; do not assemble or link
    

    为什么它们是矛盾的?

    3 回复  |  直到 16 年前
        1
  •  2
  •   Community Mohan Dere    9 年前

    很好地解释了 compiling 和 linking 概念是 here .

    还有,看这个 SO thread

        2
  •  1
  •   DVK    16 年前

    这是由于类似的根“汇编”语言(也称为汇编程序)和代码的“汇编”(即-S“帮助所指的过程)的不同。

        3
  •  0
  •   Johannes Schaub - litb    16 年前

    assemble 意思是翻译 compile 阶段,和 link

    这个 编译