From owner-freebsd-questions@FreeBSD.ORG Tue Sep 28 11:14:58 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 02E59106566B for ; Tue, 28 Sep 2010 11:14:58 +0000 (UTC) (envelope-from mexas@bristol.ac.uk) Received: from dirj.bris.ac.uk (dirj.bris.ac.uk [137.222.10.78]) by mx1.freebsd.org (Postfix) with ESMTP id B41C78FC12 for ; Tue, 28 Sep 2010 11:14:57 +0000 (UTC) Received: from ncsc.bris.ac.uk ([137.222.10.41]) by dirj.bris.ac.uk with esmtp (Exim 4.69) (envelope-from ) id 1P0Y9A-00062s-Ak for freebsd-questions@freebsd.org; Tue, 28 Sep 2010 12:14:56 +0100 Received: from mech-cluster241.men.bris.ac.uk ([137.222.187.241]) by ncsc.bris.ac.uk with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.67) (envelope-from ) id 1P0Y9A-0001TK-7U for freebsd-questions@freebsd.org; Tue, 28 Sep 2010 12:14:56 +0100 Received: from mech-cluster241.men.bris.ac.uk (localhost [127.0.0.1]) by mech-cluster241.men.bris.ac.uk (8.14.4/8.14.4) with ESMTP id o8SBEtjY026057 for ; Tue, 28 Sep 2010 12:14:55 +0100 (BST) (envelope-from mexas@bristol.ac.uk) Received: (from mexas@localhost) by mech-cluster241.men.bris.ac.uk (8.14.4/8.14.4/Submit) id o8SBEtnj026056 for freebsd-questions@freebsd.org; Tue, 28 Sep 2010 12:14:55 +0100 (BST) (envelope-from mexas@bristol.ac.uk) X-Authentication-Warning: mech-cluster241.men.bris.ac.uk: mexas set sender to mexas@bristol.ac.uk using -f Date: Tue, 28 Sep 2010 12:14:55 +0100 From: Anton Shterenlikht To: freebsd-questions@freebsd.org Message-ID: <20100928111455.GA58901@mech-cluster241.men.bris.ac.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Subject: 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:14:58 -0000 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 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