From owner-freebsd-hackers Sat Mar 11 5:32:27 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from kweetal.tue.nl (kweetal.tue.nl [131.155.2.7]) by hub.freebsd.org (Postfix) with ESMTP id 7753037B996 for ; Sat, 11 Mar 2000 05:32:24 -0800 (PST) (envelope-from marcov@toad.stack.nl) Received: from hermes.tue.nl [131.155.2.46] by kweetal.tue.nl (8.9.3) for id OAA18265 (ESMTP); Sat, 11 Mar 2000 14:32:23 +0100 (MET) Received: from deathstar (n176.dial.tue.nl [131.155.209.175]) by hermes.tue.nl (Postfix) with ESMTP id B99A02E804 for ; Sat, 11 Mar 2000 14:32:21 +0100 (CET) From: "Marco van de Voort" To: freebsd-hackers@FreeBSD.ORG Date: Sat, 11 Mar 2000 14:30:19 +0100 Subject: Re: inner workings of the C compiler In-reply-to: <20000310184346.B94441@fisicc-ufm.edu> References: <20000311000014.920E62E802@hermes.tue.nl> X-mailer: Pegasus Mail for Win32 (v3.12b) Message-Id: <20000311133221.B99A02E804@hermes.tue.nl> Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > > > to try things out i create a static binary and coerce it to use my > > > C library instead of the system's one. > > > > > > this is how i compile my program: > > > > > > cc -g -DYP -DFreeBSD -Wall -pedantic -ansi -c -I../../libc/include nss-test.c > > > cc -g -nostdlib -static -L../../libc -o nss-test nss-test.o \ > > > ../../csu/i386-elf/crt1.o ../../csu/i386-elf/crti.o -lc > > > > I'm no expert, but I tried something like this a few weeks back(to totally link without > > libc), and I was wondering, aren't you missing crtbegin and crtend ? > > > > YES! that took care of the double calling of the first function of the > first file... > > I still get the bus error at the end of my program in the atexit() call. > this is because _fini is invalid. > > do you know the exact order in which I should link the objects? prt1 first, and crtbegin ownmodule crtend I believe, I added the others to the end, and that worked. (But I didn't link libc or any other lib) So crt1 crtbegin myobject crtend crti crtn. P.s. Could you sent me a minimal C program linking to libc, and the commandline to compile it with -nostdlib ? I could throw all these experiences with non standard linking in a little tex doc. ( --nostdlib with and without libc, pure assembler instead of c (no gcc), some small chapter about syscall conventions etc) Marco van de Voort (MarcoV@Stack.nl) To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message