Date: Fri, 10 Mar 2000 18:26:02 -0600 From: Oscar Bonilla <obonilla@fisicc-ufm.edu> To: Chuck Robey <chuckr@picnic.mat.net> Cc: Oscar Bonilla <obonilla@fisicc-ufm.edu>, Alfred Perlstein <bright@wintelcom.net>, Kris Kennaway <kris@hub.freebsd.org>, freebsd-hackers@FreeBSD.ORG Subject: Re: inner workings of the C compiler Message-ID: <20000310182602.A94174@fisicc-ufm.edu> In-Reply-To: <Pine.BSF.4.21.0003101849420.32633-100000@picnic.mat.net> References: <20000310172706.A93660@fisicc-ufm.edu> <Pine.BSF.4.21.0003101849420.32633-100000@picnic.mat.net>
next in thread | previous in thread | raw e-mail | index | archive | help
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 = {<text variable, no debug info>} 0x8048074 <files>
Now if I like it in this order: crt1.o crti.o nss-test.o
I get an infinite recursion!!!!
(gdb) p _init
$1 = {<text variable, no debug info>} 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 = {<text variable, no debug info>} 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 = {<text variable, no debug info>} 0x8048074 <_start>
same thing.
I created a small C file:
#include <stdio.h>
foo() {
printf("foo\n");
}
and tried this order: foo.o nss-test.o crt1.o crti.o
(gdb) print _init
$1 = {<text variable, no debug info>} 0x8048074 <foo>
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 = {<text variable, no debug info>} 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20000310182602.A94174>
