From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <0ad26600f43ce6f44c61e6f6d78ed116@swtch.com> To: 9fans@cse.psu.edu Subject: Re: [9fans] OS X threads + dynamic linking From: "Russ Cox" Date: Fri, 21 Apr 2006 20:54:04 -0500 In-Reply-To: <3e1162e60604210924h2a12fd99n171afc7893b5e646@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 442d1d88-ead1-11e9-9d60-3106f5b1d025 > Actually, this code violates the ABI. The stack needs to be aligned > on a 16byte address. > > http://developer.apple.com/documentation/DeveloperTools/Conceptual/LowLevelABI/index.html > > So the assembly block should be: > > asm( > "pushal\n" > "movl 8(%ebp), %ebx\n" > "movl 12(%ebp), %eax\n" > "xchgl %esp, %eax\n" > "subl $0xc, %esp\n" //need to align the stack... can't just pushl > "pushl %eax\n" > "call *%ebx\n" > "popl %esp\n" > "popal\n" > ); > > Just don't compile with -Os because gcc freaking inlines runonstack. > Whom to throttle for that one? The real version doesn't use inline assembly, so it's not a problem. I just wanted a single file demonstrating the problem. After aligning the stack pointer properly, the x86 OS X code now in CVS does appear to work. Thanks very much for tracking this down. Russ