From owner-freebsd-questions@FreeBSD.ORG Tue Aug 30 10:44:03 2005 Return-Path: X-Original-To: freebsd-questions@freebsd.org Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 13EC816A41F for ; Tue, 30 Aug 2005 10:44:03 +0000 (GMT) (envelope-from jcm@FreeBSD-uk.eu.org) Received: from yearning.mcc.ac.uk (yearning.mcc.ac.uk [130.88.203.23]) by mx1.FreeBSD.org (Postfix) with ESMTP id 9DE7A43D49 for ; Tue, 30 Aug 2005 10:44:02 +0000 (GMT) (envelope-from jcm@FreeBSD-uk.eu.org) Received: from dogma.freebsd-uk.eu.org ([130.88.200.97]) by yearning.mcc.ac.uk with esmtp (Exim 4.51 (FreeBSD)) id 1EA3az-000HTX-AV; Tue, 30 Aug 2005 11:44:01 +0100 Received: from dogma.freebsd-uk.eu.org (localhost [127.0.0.1]) by dogma.freebsd-uk.eu.org (8.13.1/8.13.1) with ESMTP id j7UAi01G043947; Tue, 30 Aug 2005 11:44:00 +0100 (BST) (envelope-from jcm@dogma.freebsd-uk.eu.org) Received: (from jcm@localhost) by dogma.freebsd-uk.eu.org (8.13.1/8.12.6/Submit) id j7UAi0eo043946; Tue, 30 Aug 2005 11:44:00 +0100 (BST) Date: Tue, 30 Aug 2005 11:43:59 +0100 From: Jonathon McKitrick To: Giorgos Keramidas Message-ID: <20050830104359.GA43823@dogma.freebsd-uk.eu.org> References: <20050830032917.GA39730@dogma.freebsd-uk.eu.org> <20050830103702.GA80388@orion.daedalusnetworks.priv> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20050830103702.GA80388@orion.daedalusnetworks.priv> User-Agent: Mutt/1.4i Cc: freebsd-questions@freebsd.org Subject: Re: Linking standalone NASM binary with libc X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Aug 2005 10:44:03 -0000 On Tue, Aug 30, 2005 at 01:37:02PM +0300, Giorgos Keramidas wrote: : On 2005-08-30 04:29, Jonathon McKitrick 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.