Re: gcc-4.9.2: Assembly for i386 Target

2015-10-13 Thread Andrew Haley
On 13/10/15 08:55, Abhishek Aggarwal wrote: > The return address of the calling function is still at +4 byte offset > wrt to new frame pointer (%ebp) of 'main' function. However, now the > first argument of 'main' function may not be at +8 byte offset wrt to > the new frame pointer of the 'main' fu

Re: gcc-4.9.2: Assembly for i386 Target

2015-10-13 Thread Abhishek Aggarwal
I am particularly interested about the placement of these 3 assembly instructions in 'main' function and the way it changes the stack memory layout shown in Table 2.2, page 11 of http://www.uclibc.org/docs/psABI-i386.pdf. This layout shows that first argument of the called function is at offset of

Re: gcc-4.9.2: Assembly for i386 Target

2015-10-12 Thread Stefan Ring
On Mon, Oct 12, 2015 at 1:06 PM, Abhishek Aggarwal wrote: > @Jonathan: The reason I started this discussion is due to my suspicion > of a potential bug in gcc-4.9.2. However, I may be wrong. Here is the > explanation: I think everything is alright. The code is only emitted for the main function,

Re: gcc-4.9.2: Assembly for i386 Target

2015-10-12 Thread Abhishek Aggarwal
@Stefan: Thanks a lot for replying. These are the excerpts from http://www.uclibc.org/docs/psABI-i386.pdf (Section 2.2.2. Page 10): "The end of the input argument area shall be aligned on a 16 (32, if __m256 is passed on stack) byte boundary. In other words, the value (%esp + 4) is always a multipl

Re: gcc-4.9.2: Assembly for i386 Target

2015-10-12 Thread Jonathan Wakely
On 12 October 2015 at 10:11, Abhishek Aggarwal wrote: > I was befuddled by the following 3 assembly instructions (generated > right in the beginning of 'main' function): >lea 0x4(%esp), %ecx >and 0xfff0, %esp >pushl -0x4(%ecx) > > I am not able to understand the purpose

Re: gcc-4.9.2: Assembly for i386 Target

2015-10-12 Thread Stefan Ring
On Mon, Oct 12, 2015 at 11:11 AM, Abhishek Aggarwal wrote: > I was befuddled by the following 3 assembly instructions (generated > right in the beginning of 'main' function): >lea 0x4(%esp), %ecx >and 0xfff0, %esp >pushl -0x4(%ecx) > > I am not able to understand the p

gcc-4.9.2: Assembly for i386 Target

2015-10-12 Thread Abhishek Aggarwal
Hi all I was trying to compile the following code with gcc 4.9.2 on Ubuntu 14.04 x86_64 platform: /* File a.cpp */ #include int main (int argc, const char *argv[]) { printf("Hello World!\n"); return 0; } Compilation commands are: g++-4.9.2 -std=c++11 -g -O0 -fno-builtin -m32 a.cpp I was t