* GAS/GCC Assembler Code Modification @ 2004-05-15 9:28 Martin 2004-05-15 10:15 ` sandeep 2004-05-15 13:32 ` peter willy krause 0 siblings, 2 replies; 6+ messages in thread From: Martin @ 2004-05-15 9:28 UTC (permalink / raw) To: linux-assembly Hi folks, 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 Ok I guess this is ok, because the ESI Register is 'only' 32 Bit. So movw (= mov) would be ok. Next example: If I try to assemble movl $0xb,%eax the gas changes that to mov $0xb,%eax How can I tell gas that I dont want him to optimize the code? Best regards, Martin PS: Sry for my poor english. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: GAS/GCC Assembler Code Modification 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 1 sibling, 0 replies; 6+ messages in thread From: sandeep @ 2004-05-15 10:15 UTC (permalink / raw) To: Martin; +Cc: linux-assembly Martin wrote: > popl %esi > the gas changes that to > pop %esi > Ok I guess this is ok, because the ESI Register is 'only' 32 Bit. So movw (= mov) would be ok. > > Next example: > > If I try to assemble > movl $0xb,%eax > the gas changes that to > mov $0xb,%eax There is no optimisation happening here. it's only that gas is using only mov as mnemonic, irrespective of whether you write movw or movl. I suggest you have a look at the generated instruction bytecodes. while on linux, the default it assumes is 32 bit mode. so, though your movw also it will show as mov, but the generated instruction bytecode will also be prefixed with a mode byte, compared to had same movw been used in 16 bit mode. > How can I tell gas that I dont want him to optimize the code? Do you mean anything other than above as 'optimize the code' ? I don't know if I cleared some things for you or increased the mess. -- sandeep -------------------------------------------------------------------------- I predict that today will be remembered until tomorrow! -------------------------------------------------------------------------- ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: GAS/GCC Assembler Code Modification 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 1 sibling, 1 reply; 6+ messages in thread From: peter willy krause @ 2004-05-15 13:32 UTC (permalink / raw) To: Martin; +Cc: linux-assembly, linux-assembly Am Samstag, 15. Mai 2004 10:28 schrieb Martin: > Hi folks, > > 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'. 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. best, hp -- mail to 'hp': lx at lxhp : in-berlin : de ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: GAS/GCC Assembler Code Modification 2004-05-15 13:32 ` peter willy krause @ 2004-05-15 20:08 ` Martin 2004-05-15 21:45 ` peter willy krause 0 siblings, 1 reply; 6+ messages in thread From: Martin @ 2004-05-15 20:08 UTC (permalink / raw) To: linux-assembly 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 ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: GAS/GCC Assembler Code Modification 2004-05-15 20:08 ` Martin @ 2004-05-15 21:45 ` peter willy krause 2004-05-15 21:01 ` Martin 0 siblings, 1 reply; 6+ messages in thread From: peter willy krause @ 2004-05-15 21:45 UTC (permalink / raw) To: linux-assembly, linux-assembly Am Samstag, 15. Mai 2004 21:08 schrieb Martin: > > But I still have one question. Wouldn't be the code from AlephOne ^^^^^^^^^^ I've no idea of what that is. got a link? best hp -- mail to 'hp': lx at lxhp : in-berlin : de ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: GAS/GCC Assembler Code Modification 2004-05-15 21:45 ` peter willy krause @ 2004-05-15 21:01 ` Martin 0 siblings, 0 replies; 6+ messages in thread From: Martin @ 2004-05-15 21:01 UTC (permalink / raw) To: peter willy krause, linux-assembly peter willy krause <wklux@yahoo.co.uk> wrote: > Am Samstag, 15. Mai 2004 21:08 schrieb Martin: > > > > But I still have one question. Wouldn't be the code from AlephOne > ^^^^^^^^^^ > I've no idea of what that is. got a link? ..my fault. sry. http://www.phrack.org/show.php?p=49&a=14 (etwa in der Mitte des Textes befindet sich der Code) ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2004-05-15 21:45 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 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 2004-05-15 21:45 ` peter willy krause 2004-05-15 21:01 ` Martin
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).