Date: Wed, 13 Dec 2000 14:25:40 -0800 From: Alfred Perlstein <bright@wintelcom.net> To: Drew Eckhardt <drew@PoohSticks.ORG> Cc: Marc Tardif <intmktg@CAM.ORG>, freebsd-hackers@FreeBSD.ORG, obrien@FreeBSD.ORG Subject: Re: syscall assembly Message-ID: <20001213142539.R16205@fw.wintelcom.net> In-Reply-To: <200012132221.eBDMLdh28943@chopper.Poohsticks.ORG>; from drew@PoohSticks.ORG on Wed, Dec 13, 2000 at 03:21:39PM -0700 References: <20001213141023.O16205@fw.wintelcom.net> <200012132221.eBDMLdh28943@chopper.Poohsticks.ORG>
next in thread | previous in thread | raw e-mail | index | archive | help
David, can you look at this? #include <fcntl.h> int foo() { open("file", O_RDONLY); return 0; } int main() { int x; x = foo(); return 0; } results in: foo: pushl %ebp movl %esp,%ebp subl $8,%esp addl $-8,%esp pushl $0 pushl $.LC0 call open xorl %eax,%eax leave ret why the subl then addl? ~ % gcc -v Using builtin specs. gcc version 2.95.2 19991024 (release) ~ % uname -a 4.2-STABLE FreeBSD 4.2-STABLE #1: Wed Dec 6 02:49:24 PST 2000 * Drew Eckhardt <drew@PoohSticks.ORG> [001213 14:21] wrote: > In message <20001213141023.O16205@fw.wintelcom.net>, bright@wintelcom.net write > s: > >> subl $8,%esp > >> addl $-8,%esp > > >> What is the purpose of the subl and addl > >> instructions? On Linux, they are simply > >> unexistent.. > > > >FreeBSD passes syscall args on the stack, Linux uses registers. > > The 'C' compiler doesn't know open is a syscall, and treats it like > any other code. > > The pushls put the arguments on the stack. > > The subl/addl are there because your version of GCC is broken. -- -Alfred Perlstein - [bright@wintelcom.net|alfred@freebsd.org] "I have the heart of a child; I keep it in a jar on my desk." To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20001213142539.R16205>