0
$ 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 
    ... 

The help information says it should not compile nor assemble:

 -S                       Compile only; do not assemble or link

Why are they contradictory?

Mask
  • 33,129
  • 48
  • 101
  • 125
  • Assembling is practically just the conversion of machine code from text form to binary form. – Paggas Mar 28 '10 at 16:49
  • People take verbal short cuts all the time, and different people use terms in different ways. In particular the gcc docs have *their* own meanings for "compile", "assemble", and "link"; and each of those terms can hide several separate passes over and transformations of the input. Trying to impose definition(s) that you got from some other source is foolish and unproductive. Now would be a good time to learn to deal with the ambiguity of natural language. – dmckee --- ex-moderator kitten Mar 28 '10 at 17:36

3 Answers3

2

A good explanation of the compiling and linking concepts is here.

Also, see this SO thread (difference between compiling and linking).

Community
  • 1
  • 1
Lazer
  • 90,700
  • 113
  • 281
  • 364
  • It says "Compiling is the act of turning source code into object code.",but in fact it's not the case here.Or when we say compile,we actually mean compile & assemble? – Mask Mar 28 '10 at 16:51
  • @Mask: from Wikipedia(http://en.wikipedia.org/wiki/Compiler): "A compiler is something that transforms source code written in a computer language (the source language) into another computer language." So compiling + assembling = compiling :) – Lazer Mar 30 '10 at 07:59
1

This is due to the difference of similarly-rooted "assembly" language (aka assembler) and "assembling" of the code (the process that "-S" help refers to).

DVK
  • 126,886
  • 32
  • 213
  • 327
0

assemble means to translate the result of the compile phase, and link means to combine the results of the assemble phases of different executions of gcc together into an executable or library.

The compile phase takes the result of the preprocessing phase and results in assembler code, roughly.

Johannes Schaub - litb
  • 496,577
  • 130
  • 894
  • 1,212