linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Martin <asmfreshmeat@gmx.de>
To: linux-assembly@vger.kernel.org
Subject: Re: GAS/GCC Assembler Code Modification
Date: Sat, 15 May 2004 22:08:19 +0200	[thread overview]
Message-ID: <20040515220819.3ffa6298@deepblack> (raw)
In-Reply-To: <200405151432.01409.wklux@yahoo.co.uk>

peter willy krause <wklux@yahoo.co.uk> wrote:

> Am Samstag, 15. Mai 2004 10:28 schrieb Martin:
> > I have a question regarding GAS and GCC.
> > Does the GAS modify the Assembler Code? If I try to assemble (for
> > example) the following line:
> >
> > popl %esi
> >
> > the gas changes that to
> >
> > pop %esi
> 
> though gas 'optimizes', which cannot be configured(!), in your example gas 
> doesn't, re listing by gas, itself! (my version ex binutils 2.14.90) - 
> apparently, your disassembler translates differently. compare the code...
> 
> the only 'optimization' by gas, which I'm aware of, is branches distance 
> coding and selection of alignment fill code. branches coding can be 
> forced to always 'long' (4 bytes) by declaring the destn label '.global'.
Alright.
 
> while assembling gas tries to deduce the oprands' formats by mnemonics and 
> register nameing and, tries some correction if the proper size specs were 
> missing, plus emanating a concerning warning (not an error!) message.
Ok. I guess here is my error in reasoning. I just wondered because in AlephOnes
Paper about Stacksmashing he printed the following code:

[...]
        popl   %esi         
        movl   %esi,0x8(%esi)
        movb   $0x0,0x7(%esi)
        movl   $0x0,0xc(%esi)
        movl   $0xb,%eax
        movl   %esi,%ebx              
        leal   0x8(%esi),%ecx         
        leal   0xc(%esi),%edx         
        int    $0x80                
        movl   $0x1, %eax		
        movl   $0x0, %ebx
[...]

After assembling with gas and disassembling with gdb I got the following code:
[...]
        pop   %esi         
        mov   %esi,0x8(%esi)
        movb   $0x0,0x7(%esi)
        movl   $0x0,0xc(%esi)
        mov   $0xb,%eax      
        mov   %esi,%ebx      
        lea   0x8(%esi),%ecx 
        lea   0xc(%esi),%edx 
        int    $0x80         
        mov   $0x1, %eax	
        mov   $0x0, %ebx	
[...]

But if you are right, the code above should be the same. 

But I still have one question. Wouldn't be the code from AlephOne bigger (bytesize)
than the code I got?

Best regards,
thanks for your help.
Martin

  reply	other threads:[~2004-05-15 20:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-05-15  9:28 GAS/GCC Assembler Code Modification Martin
2004-05-15 10:15 ` sandeep
2004-05-15 13:32 ` peter willy krause
2004-05-15 20:08   ` Martin [this message]
2004-05-15 21:45     ` peter willy krause
2004-05-15 21:01       ` Martin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040515220819.3ffa6298@deepblack \
    --to=asmfreshmeat@gmx.de \
    --cc=linux-assembly@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).