From owner-freebsd-hackers Fri Mar 10 16:28:11 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from voyager.fisicc-ufm.edu (ip-198-202.guate.net [209.198.197.202]) by hub.freebsd.org (Postfix) with ESMTP id 7B1FF37BB32; Fri, 10 Mar 2000 16:27:50 -0800 (PST) (envelope-from obonilla@voyager.fisicc-ufm.edu) Received: (from obonilla@localhost) by voyager.fisicc-ufm.edu (8.9.3/8.9.3) id SAA94301; Fri, 10 Mar 2000 18:26:06 -0600 (CST) (envelope-from obonilla) Date: Fri, 10 Mar 2000 18:26:02 -0600 From: Oscar Bonilla To: Chuck Robey Cc: Oscar Bonilla , Alfred Perlstein , Kris Kennaway , freebsd-hackers@FreeBSD.ORG Subject: Re: inner workings of the C compiler Message-ID: <20000310182602.A94174@fisicc-ufm.edu> References: <20000310172706.A93660@fisicc-ufm.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0pre1i In-Reply-To: Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Fri, Mar 10, 2000 at 06:51:20PM -0500, Chuck Robey wrote: > I wasn't reading this too closely, but if you're trying to hand feed in > the object files, the C startup object file *MUST* come first in the list > of object files, because it's gotta link at the lowest address ... > > Is that it? Ok, I'm even more puzzled than before... If I link them in this order: nss-test.o crt1.o crti.o I get the following: files called files called retval = 1 NS_SUCCESS Bus error (core dumped) Notice the duplicate line that says "files called"? This had me puzzled before, but now I see that somehow _init point to the first function in the first object file (gdb) p _init $1 = {} 0x8048074 Now if I like it in this order: crt1.o crti.o nss-test.o I get an infinite recursion!!!! (gdb) p _init $1 = {} 0x8048074 <_start> since _start calls _init() *before* calling main() it just loops (and starts swapping like hell) Let me try this order: crti.o crt1.o nss-test.o (gdb) p _init $1 = {} 0x8048074 <_start> nope, same as before. infinite recursion and swapping like hell. maybe this order: crt1.o nss-test.o crti.o (gdb) print _init $1 = {} 0x8048074 <_start> same thing. I created a small C file: #include foo() { printf("foo\n"); } and tried this order: foo.o nss-test.o crt1.o crti.o (gdb) print _init $1 = {} 0x8048074 and if I just run it... foo files called retval = 1 NS_SUCCESS Bus error (core dumped) If I try gdb with a normal program (i.e. one linked with the standard C library in /usr/lib and not my own C library) (gdb) print _init $1 = {} 0x804838c <_init> What could be the problem? regards, -oscar -- pgp public key: finger obonilla@fisicc-ufm.edu pgp fingerprint: 6D 18 8C 90 4C DF F0 4B DF 35 1F 69 A1 33 C7 BC To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message