gas' nop(s)
Hi there,
did You noticed that GNU as adds some padding nop(s) like:
lea (%esi),%esi
mov %esi,%esi
nop
at the end of .text section? Is this really necessary? The .text section mustn't be padded to 4 like it seems to be or am i wrong? How can i avoid this? Is there any gas option to switch this off?
Sorry if this topic is doubled by me but i couldn't find something similar in the archive :(
Signature · 1 line
Maciej Hrebien
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 3 lines · Jani Monoses
Hi
look at the .align directive in info gas
.align, oh, of course!! :) Thank You!!
Quoted 1 line
there is no requirement for text to be packed at 4
I thought so. Thanks for Your confirmation!
Quoted 1 line
but it is the default (or maybe even 16)
16? Possibly it depends on system/compilation, don't You think so? On my gas it seems to be 4 as i wrote.
Signature · 1 line
Maciej Hrebien
Quoted 11 lines · On Sun, 04 Aug 2002 22:28:47 +0200 [email protected] wrote:
Hi there,
did You noticed that GNU as adds some padding nop(s) like:
lea (%esi),%esi
mov %esi,%esi
nopat the end of .text section? Is this really necessary? The .text section mustn't be padded to 4 like it seems to be or am i wrong? How can i avoid this? Is there any gas option to switch this off?
some time back, i tried AS as an intermediate program, w. piped i/o, and encountered the same problem, which i didn't manage to solve, too. there is no option + no other idea. those gods of gnu binutils devel might know but, i myself never received an answer to any AS related question...
anyway, AS wsn't meant to do plain, stand alone assembly but is designed to produceing a set of data which can be combined to something, probably executeable, with the "ld" linker. so the implicite alignment might even be very helpful for faster processing.
i'd (highly) recommend the "fasm" assembler for the more 'direct' work:)
http://fasm.metro-nt.pl/
Quoted 10 lines
Sorry if this topic is doubled by me but i couldn't find something similar in the archive :(
Signature · 6 lines
Maciej Hrebien - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 6 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de NO abusive software patents http://petition.eurolinux.org/pr/pr17.html - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 13 lines · h-peter recktenwald
Quoted 5 lines
Hi there,
did You noticed that GNU as adds some padding nop(s) like:
Quoted 7 lines
lea (%esi),%esi
mov %esi,%esi
nopat the end of .text section? Is this really necessary? The .text section mustn't be padded to 4 like it seems to be or am i wrong? How can i avoid this? Is there any gas option to switch this off?
Quoted 8 lines
some time back, i tried AS as an intermediate program, w. piped i/o, and encountered the same problem, which i didn't manage to solve, too. there is no option + no other idea. those gods of gnu binutils devel might know but, i myself never received an answer to any AS related question...
anyway, AS wsn't meant to do plain, stand alone assembly but is designed to produceing a set of data which can be combined to something, probably executeable, with the "ld" linker.
Yes, it's gcc's back-end rather then stand alone assembler.
Quoted 5 lines
so the implicite alignment might even
be very helpful for faster processing.i'd (highly) recommend the "fasm" assembler for the more 'direct' work:)
http://fasm.metro-nt.pl/
:) Thanks, i'll check it...
Quoted 2 lines
Quoted 2 lines
Sorry if this topic is doubled by me but i couldn't find something similar in the archive :(
Guess what? I've tried this .align directive as Jani Monoses suggested like this:
.text
.align 1
.globl _start_start:
mov $1,%eax xor %ebx,%ebx int $0x80
and it's not working as i wish - gas adds lea (%esi),%esi after int $0x80 to the output :( I've tried with 2, 4, 8 & 16 and it seems that .align x works good if x is greater equal than 4 :( But why??
Signature · 1 line
Maciej Hrebien
Quoted 9 lines · On Mon, 05 Aug 2002 19:53:41 +0200 [email protected] wrote:
Guess what? I've tried this .align directive as Jani Monoses suggested like this:
.text
.align 1
.globl
_start_start:
Quoted 7 lines
mov $1,%eax xor %ebx,%ebx int $0x80and it's not working as i wish - gas adds lea (%esi),%esi after int $0x80 to the output :( I've tried with 2, 4, 8 & 16 and it seems that .align x works good if x is greater equal than 4 :( But why??
.text section for ELF format defined to be page aligned, so it's always a multiple of 4, and the end-alignment added for what "bu" gnu-ers seem to think is #the# appropriate thing or, just more convenient to further asm output processing - just guessing, has anyone else a more thorough idea?
a work-around for piped output may be defining a label at code end and taking the actually assmbled code length from the listing file. tested:
echo ".att_syntax noprefix;.global XLAB;jnc XLAB;movl eax,ebx;\
movl ebx,edx;XLAB:;.end"|as -achnlsd m=l --gstabs |tee tthe listing:
----------------------------------------------------
1 0000 0F83FCFF .att_syntax noprefix
1 FFFF89C3
1 89DA89F6
DEFINED SYMBOLS
{standard input}:1 .text:0000000a XLABNO UNDEFINED SYMBOLS
--------------------------------------------------
asm 4 bytes shorter w/o the ".global" statement, <jnc> then w. byte disp.
regards,
hp
Signature · 6 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de NO abusive software patents http://petition.eurolinux.org/pr/pr17.html - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 21 lines · h-peter recktenwald
Quoted 11 lines
.text
.align 1
.globl
_start_start:mov $1,%eax xor %ebx,%ebx int $0x80echo ".att_syntax noprefix;.global XLAB;jnc XLAB;movl eax,ebx;\ movl ebx,edx;XLAB:;.end"|as -achnlsd m=l --gstabs |tee tthe listing:
----------------------------------------------------
1 0000 0F83FCFF .att_syntax noprefix
1 FFFF89C3
1 89DA89F6
DEFINED SYMBOLS
Quoted 5 lines
{standard input}:1 .text:0000000a XLABNO UNDEFINED SYMBOLS
--------------------------------------------------
asm 4 bytes shorter w/o the ".global" statement, <jnc> then w. byte disp.
Yes, right! But it still adds "89F6" padding which stands for "mov %esi,%esi" & my question was how to avoid this.
Signature · 1 line
Maciej Hrebien
Quoted 4 lines · On Tue, 06 Aug 2002 11:30:56 +0200 [email protected] wrote:
Quoted 1 line
asm 4 bytes shorter w/o the ".global" statement, <jnc> then w. byte disp.
Yes, right! But it still adds "89F6" padding which stands for "mov %esi,%esi" & my question was how to avoid this.
ok. you can not.
hp
Quoted 9 lines · On Wed, 7 Aug 2002 07:41:36 +0000 h-peter recktenwald <[email protected]>…
Quoted 4 lines · On Tue, 06 Aug 2002 11:30:56 +0200 [email protected] wrote:
Quoted 1 line
asm 4 bytes shorter w/o the ".global" statement, <jnc> then w. byte disp.
Yes, right! But it still adds "89F6" padding which stands for "mov %esi,%esi" & my question was how to avoid this.
ok. you can not.
just tried: apparently, the ".end" directive inhibits those alignemt bytes, (if not a label at end of code).
hp
Signature · 6 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de NO abusive software patents http://petition.eurolinux.org/pr/pr17.html - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 6 lines · On Thu, 8 Aug 2002 15:50:47 +0000 h-peter recktenwald <*@lxhp.in-berlin.de>…
Quoted 3 lines
Quoted 3 lines
Yes, right! But it still adds "89F6" padding which stands for "mov %esi,%esi" & my question was how to avoid this.
just tried: apparently, the ".end" directive inhibits those alignemt bytes, (if not a label at end of code).
that was an error. though i wonder how some program of mine ends up with an odd address. probably due to its .data end. so i tried asm into a .data section, which works and, does #not# align. so, since you seem not to asm to any fixed 'format', that might be the alternative.
hp
Signature · 6 lines
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml en/de NO abusive software patents http://petition.eurolinux.org/pr/pr17.html - To unsubscribe from this list: send the line "unsubscribe linux-assembly" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 11 lines · h-peter recktenwald
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Yes, right! But it still adds "89F6" padding which stands for "mov %esi,%esi" & my question was how to avoid this.
just tried: apparently, the ".end" directive inhibits those alignemt bytes, (if not a label at end of code).
that was an error. though i wonder how some program of mine ends up with an odd address. probably due to its .data end. so i tried asm into a .data section, which works and, does #not# align. so, since you seem not to asm to any fixed 'format', that might be the alternative.
Good idea!! I've tried to move our example (this with simple exit call) to the .data section but it still adds padding - it's: add %al,(%eax) (coded as "00 00") on my gas even with .align directive set to 1. But! I've followed Your way of thinking and guess what?! :) "why not to move this code to the .rodata section?" and... it works just fine!! No paddings!! :)
Thank You very much for Your suggestion Peter (is that Your name?)!!!
Signature · 1 line
Maciej Hrebien