Compiling x86 code

Segher Boessenkool segher@kernel.crashing.org
Fri Nov 20 03:43:00 GMT 2015


On Thu, Nov 19, 2015 at 11:15:53PM +0000, 29jr48+4pm9iwb1l08rc@guerrillamail.com wrote:
> I am trying to follow a tutorial in which C code is compiled, for example 
> void buffers_function(int a, int b, int c) {
>    char buffer1[10];
>    char buffer2[11];
> }
> 
> void main() {
>   buffers_function(1,2,3);
> }
> and is compiled using the following command line: 
> gcc -S -o example1.s example1.c
> 
> the problem is, example1.s does not include 3 pushes of the parameters and then the call to buffers_function, but instead it includes: 
> movl    $3, 8(%esp)
> movl    $2, 4(%esp)
> movl    $1, (%esp)
> call    function
> 
> which GCC flags do I need to use in order to see the 3 pushes instead of the movl operation? 

-march=i386 will do (it looks like your compiler defaults to i686).

This tutorial seems to be written with a (much) older compiler in mind,
so you should expect (many) other differences in generated code.


Segher



More information about the Gcc-help mailing list