Date: Tue, 30 Aug 2005 11:43:59 +0100 From: Jonathon McKitrick <jcm@FreeBSD-uk.eu.org> To: Giorgos Keramidas <keramida@ceid.upatras.gr> Cc: freebsd-questions@freebsd.org Subject: Re: Linking standalone NASM binary with libc Message-ID: <20050830104359.GA43823@dogma.freebsd-uk.eu.org> In-Reply-To: <20050830103702.GA80388@orion.daedalusnetworks.priv> References: <20050830032917.GA39730@dogma.freebsd-uk.eu.org> <20050830103702.GA80388@orion.daedalusnetworks.priv>
next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 30, 2005 at 01:37:02PM +0300, Giorgos Keramidas wrote: : On 2005-08-30 04:29, Jonathon McKitrick <jcm@FreeBSD-uk.eu.org> wrote: : > : > I'm doing some experimentation with assembly code based on the int80h.org : > tutorials. But since I am going to use malloc and some other functions, : > I need to make my code link with libc rather than stand totally on its own. : > : > ld -s -o foo foo.o -lc : > : > leaves 'environ' and '__progname' undefined. What is the correct way to link : > standalone asm code with needed libraries? : : That depends on what the ``standalone'' code contains. If your foo.o : object file defines a 'main' function, then you can just use cc(1): This is the method I've been using until now. And maybe it's the best one. I was just wondering, though, if I want to write an app that is linked to libc, but doesn't have 'main', and has '_start' instead, and where I want to use ld directly rather than indirectly through cc to link. Jonathon McKitrick -- Hoppiness is a good beer.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050830104359.GA43823>