Re: Compiling x86 code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 19, 2015 at 11:15:53PM +0000, 29jr48+4pm9iwb1l08rc@xxxxxxxxxxxxxxxxx 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



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux