From owner-freebsd-questions@FreeBSD.ORG Tue Sep 28 11:25:56 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86FEB10656A4 for ; Tue, 28 Sep 2010 11:25:56 +0000 (UTC) (envelope-from onemda@gmail.com) Received: from mail-gw0-f54.google.com (mail-gw0-f54.google.com [74.125.83.54]) by mx1.freebsd.org (Postfix) with ESMTP id 3DA168FC12 for ; Tue, 28 Sep 2010 11:25:55 +0000 (UTC) Received: by gwb15 with SMTP id 15so2319553gwb.13 for ; Tue, 28 Sep 2010 04:25:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type; bh=jHgQrOKo9YUE0djZykFwsZlrT23AmqUNfTIFMhjrdu4=; b=M7DMaSfGuMX+szgcy5j7rFYuVxQwFuBCtmxsnrdM53qfqGbDTqYzia52NhOuLc+DAp 4BcVwwTVMk+2kwtcV3xJNfjggcEkhcwoNM34lefzxmeCfm9AT8B6Xt1eb3hSMFgm5z7H 6JcPRXTdnkWYXwx+0ASECMcdTeQM36kog3hkw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=ij4rhaepIq2qvoCr3InCSTwERIsjRT6xBrU6nOG866Rzsg4dq721UYLE8FHKbYFQ8A hHSG+YhkucdYYaY0qy3Ca+nbLsUI8lvI67NvWPyHmjjutUO4s5kQP5WsfkuUjWMwCmfd wdhJtN6uF6DO1J7Ly/ju5/p+teYGqEkK2kZrY= MIME-Version: 1.0 Received: by 10.150.135.20 with SMTP id i20mr10554335ybd.62.1285673154548; Tue, 28 Sep 2010 04:25:54 -0700 (PDT) Received: by 10.220.200.1 with HTTP; Tue, 28 Sep 2010 04:25:54 -0700 (PDT) In-Reply-To: <20100928111455.GA58901@mech-cluster241.men.bris.ac.uk> References: <20100928111455.GA58901@mech-cluster241.men.bris.ac.uk> Date: Tue, 28 Sep 2010 11:25:54 +0000 Message-ID: From: Paul B Mahol To: Anton Shterenlikht Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-questions@freebsd.org Subject: Re: ld(1) cannot find entry symbol _start; 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, 28 Sep 2010 11:25:56 -0000 On 9/28/10, Anton Shterenlikht wrote: > I'm trying to learn the very basics of the > compile - assemble - link process on FreeBSD. > Please don't shoot me. > > I've this c code: > > % cat tmp.c > int main() { > int a; > int b; > int c; > > a = 2; > b = 3; > > c=a*b; > } > > which I compile into assembly language: > > % gcc -v > Using built-in specs. > Target: ia64-undermydesk-freebsd > Configured with: FreeBSD/ia64 system compiler > Thread model: posix > gcc version 4.2.1 20070719 [FreeBSD] > > % gcc -S tmp.c > > I then assemble the object file: > > % gcc -o tmp.o -c tmp.s > % file tmp.o > tmp.o: ELF 64-bit LSB relocatable, IA-64, version 1 (FreeBSD), not stripped > > Then I try to link the object file into > an executable: > > % ld tmp.o You are missing something in above command. > ld: warning: cannot find entry symbol _start; defaulting to 20000000000000f0 > > Finally, when I try to run the executable, > I get segfault: > > % ./a.out > Segmentation fault (core dumped) > > > Looking at the asm listing, there is indeed no > _start symbol: > > > .file "tmp.c" > .pred.safe_across_calls p1-p5,p16-p63 > .text > .align 16 > .global main# > .proc main# > main: > .prologue 2, 2 > .vframe r2 > mov r2 = r12 > .body > ;; > adds r15 = 8, r2 > addl r14 = 2, r0 > ;; > st4 [r15] = r14 > adds r15 = 4, r2 > addl r14 = 3, r0 > ;; > st4 [r15] = r14 > adds r14 = 8, r2 > adds r15 = 4, r2 > ;; > ld4 r16 = [r14] > ld4 r14 = [r15] > ;; > setf.sig f6 = r16 > setf.sig f7 = r14 > ;; > xmpy.l f6 = f6, f7 > ;; > getf.sig r14 = f6 > ;; > st4 [r2] = r14 > .restore sp > mov r12 = r2 > br.ret.sptk.many b0 > ;; > .endp main# > .ident "GCC: (GNU) 4.2.1 20070719 [FreeBSD]" > > > What am I missing? > > I'm happy to be referred to FM. > > many thanks > anton > > -- > Anton Shterenlikht > Room 2.6, Queen's Building > Mech Eng Dept > Bristol University > University Walk, Bristol BS8 1TR, UK > Tel: +44 (0)117 331 5944 > Fax: +44 (0)117 929 4423 > _______________________________________________ > freebsd-questions@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-questions > To unsubscribe, send any mail to "freebsd-questions-unsubscribe@freebsd.org" >