From: Niklas_Pson AT nosmam DOT hotmail DOT com (Niklas Pettersson) Newsgroups: comp.os.msdos.djgpp Subject: Another align question Date: 31 Jul 2001 18:54:52 GMT Organization: Lund Institute of Technology, Sweden Lines: 138 Message-ID: <90EFDC811NiklasPsonnospamhotm@130.235.20.4> NNTP-Posting-Host: npedt97.univ.vxu.se User-Agent: Xnews/03.04.11 To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Reply-To: djgpp AT delorie DOT com Hi! I'm wrote a little program that tries to align all functions on 16 byte boundaries. I wan't to have "nop"'s between the functions (doesn't realy matter in this example but I want this for other purposes). The alignment is always correct but the "padding byte (0x90)" seems only to work with .balignl and .balignw (not with .balign). The code and disassembly is attached to the message. Can someone please tell me how to get the effect I'm looking for (without using .balign(w|l)) / Niklas .text /* * Make functions visible to linker */ .globl _func1 .globl _func2 .globl _func3 .globl _func4 /* * Function aligned to a 16 byte boundary. */ .balign 16 _func1: pushl %ebp movl %esp, %ebp popl %ebp /* Padd so alignment below will work */ nop nop nop ret /* * Function aligned to a 16 byte boundary. Fill with nop (4 bytes at once) */ .balignl 16, 0x90909090 _func2: pushl %ebp movl %esp, %ebp popl %ebp /* Padd so alignment below will work */ nop ret /* * Function aligned to a 16 byte boundary. Fill with nop (2 bytes at once) */ .balignw 16, 0x9090 _func3: pushl %ebp movl %esp, %ebp popl %ebp ret /* * Function aligned to a 16 byte boundary. Fill with nop (1 byte at once) */ .balign 16, 0x90 _func4: pushl %ebp movl %esp, %ebp popl %ebp ret This is the output (pasted in from GDB) 0x1570 : push %ebp 0x1571 : mov %esp,%ebp 0x1573 : pop %ebp 0x1574 : nop 0x1575 : nop 0x1576 : nop 0x1577 : ret /* This padding is correct! (used balignl) */ 0x1578 : nop 0x1579 : nop 0x157a : nop 0x157b : nop 0x157c : nop 0x157d : nop 0x157e : nop 0x157f : nop 0x1580 : push %ebp 0x1581 : mov %esp,%ebp 0x1583 : pop %ebp 0x1584 : nop 0x1585 : ret /* This padding is correct! (used balignw) */ 0x1586 : nop 0x1587 : nop 0x1588 : nop 0x1589 : nop 0x158a : nop 0x158b : nop 0x158c : nop 0x158d : nop 0x158e : nop 0x158f : nop 0x1590 : push %ebp 0x1591 : mov %esp,%ebp 0x1593 : pop %ebp 0x1594 : ret /* This padding is NOT correct! (used balign) (well padding is correct but not fill byte) */ 0x1595 : lea 0x0(%esi,1),%esi 0x1599 : lea 0x0(%edi,1),%edi 0x15a0 : push %ebp 0x15a1 : mov %esp,%ebp 0x15a3 : pop %ebp 0x15a4 : ret 0x15a5 : lea 0x0(%esi,1),%esi 0x15a9 : lea 0x0(%edi,1),%edi Main goes here...