From owner-freebsd-mips@FreeBSD.ORG Fri Apr 15 06:47:11 2011 Return-Path: Delivered-To: mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 84291106566C for ; Fri, 15 Apr 2011 06:47:11 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-ww0-f42.google.com (mail-ww0-f42.google.com [74.125.82.42]) by mx1.freebsd.org (Postfix) with ESMTP id D29148FC12 for ; Fri, 15 Apr 2011 06:47:10 +0000 (UTC) Received: by wwk4 with SMTP id 4so6768847wwk.1 for ; Thu, 14 Apr 2011 23:47:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=rVvW/ZjpilnvQSc2B9vpkl0hnUlQ2UF5RfI1m591YgU=; b=g6WtXkO1DFjn06GSkIL8IM9jBhdljw5CD00pdr9OQzkvqQS3Zr6pMOwoazpXBIUas0 L61qZmwSeGEvV87Th7zTBDA93/A3/5VWdCYQMzfZ5ZxhDOAm+4tIUbu5AVSoy4tvFFBB LH5YrTHFN0bapWaUpIy/byyNlwWmR+65+u8xQ= 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:content-transfer-encoding; b=kb/qjTXFYOcvBlp36ko7k+zv+Pikdk1qjYGn7o88hqfYO++u9Pp50vVqpx9MXSqpC9 yUoN6+HjcmcZW1ZS8kOoJ3GArO5vNS95E1aenmPDMM7gfM98jdLzCa5dWqKaDQuFRixq X5/pvV1dg6Tp9hRw0ZM3ttGERCKq1KjB/z3do= MIME-Version: 1.0 Received: by 10.216.239.71 with SMTP id b49mr1518932wer.107.1302848240112; Thu, 14 Apr 2011 23:17:20 -0700 (PDT) Received: by 10.216.166.206 with HTTP; Thu, 14 Apr 2011 23:17:20 -0700 (PDT) In-Reply-To: References: Date: Fri, 15 Apr 2011 11:47:20 +0530 Message-ID: From: "Jayachandran C." To: Andrew Duane Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: "mips@freebsd.org" Subject: Re: Trouble with dynamic executables X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Apr 2011 06:47:11 -0000 On Fri, Apr 15, 2011 at 12:47 AM, Andrew Duane wrote: > I've figured out what the problem is. The elf header of a sample dynamic = executable shows: > > Elf file type is EXEC (Executable file) > Entry point 0x1200028f0 > There are 7 program headers, starting at offset 64 > > Program Headers: > =A0Type =A0 =A0 =A0 =A0 =A0 Offset =A0 =A0 =A0 =A0 =A0 =A0 VirtAddr =A0 = =A0 =A0 =A0 =A0 PhysAddr =A0 =A0 =A0 =A0 =A0 FileSiz =A0 =A0 =A0 =A0 =A0 = =A0MemSiz =A0 =A0 =A0 =A0 =A0 =A0 =A0Flags =A0Align > =A0PHDR =A0 =A0 =A0 =A0 =A0 0x0000000000000040 0x0000000120000040 0x00000= 00120000040 0x0000000000000188 0x0000000000000188 =A0R E =A0 =A08 > =A0INTERP =A0 =A0 =A0 =A0 0x0000000000012788 0x0000000120012788 0x0000000= 120012788 0x0000000000000015 0x0000000000000015 =A0R =A0 =A0 =A01 > =A0 =A0 =A0[Requesting program interpreter: /libexec/ld-elf.so.1] > =A0LOAD =A0 =A0 =A0 =A0 =A0 0x0000000000000000 0x0000000120000000 0x00000= 00120000000 0x00000000000127bc 0x00000000000127bc =A0R E =A0 =A010000 > =A0LOAD =A0 =A0 =A0 =A0 =A0 0x0000000000013000 0x0000000120023000 0x00000= 00120023000 0x00000000000017d8 0x0000000000003c28 =A0RW =A0 =A0 10000 > =A0DYNAMIC =A0 =A0 =A0 =A00x0000000000000808 0x0000000120000808 0x0000000= 120000808 0x00000000000001e0 0x00000000000001e0 =A0RWE =A0 =A08 > =A0NOTE =A0 =A0 =A0 =A0 =A0 0x00000000000127a4 0x00000001200127a4 0x00000= 001200127a4 0x0000000000000018 0x0000000000000018 =A0R =A0 =A0 =A04 > =A0NULL =A0 =A0 =A0 =A0 =A0 0x0000000000000000 0x0000000000000000 0x00000= 00000000000 0x0000000000000000 0x0000000000000000 =A0 =A0 =A0 =A0 8 > > Note section 1 the INTERP header: the offset is 0x12788. There's a check = in the ELF64 image activator to see if the offset is outside the first page= and returns ENOEXEC. The exec path reads in the first page first, and trie= s to figure out what to do with the rest. So if the interpreter name isn't = in the first page, it can't decode it. > > This is a toolchain issue, or some setup issue. This may be a mip64r2 issue. I use the mips64 config and 32 and 64 bit dynamic executables have been working for a long time. For reference, here is my setup: Environment for buildworld: export TARGET=3Dmips export TARGET_ARCH=3Dmips64eb export TARGET_CPUTYPE=3Dmips64 Makeoptions in conf file (from XLP64) makeoptions KERNLOADADDR=3D0xffffffff80100000 makeoptions ARCH_FLAGS=3D"-march=3Dmips64 -mabi=3D64" options ISA_MIPS64 And on the XLR engineering board: xlrboard# uname -a FreeBSD xlrboard.netlogicmicro.com 9.0-CURRENT FreeBSD 9.0-CURRENT #2 r220649M: Fri Apr 15 11:27:57 IST 2011 jc@daemon.razamicroelectronics.com:/var/obj/jc/freebsd-obj-64/mips.mips64eb= /work/jayachandranc/freebsd-devel-clean/sys/XLRJC64 mips xlrboard# ldd /bin/ls /bin/ls: libutil.so.9 =3D> /lib/libutil.so.9 (0x16024d000) libncurses.so.8 =3D> /lib/libncurses.so.8 (0x16035f000) libc.so.7 =3D> /lib/libc.so.7 (0x1604b3000) xlrboard# readelf -a /bin/ls ELF Header: Magic: 7f 45 4c 46 02 02 01 09 00 00 00 00 00 00 00 00 Class: ELF64 Data: 2's complement, big endian Version: 1 (current) OS/ABI: UNIX - FreeBSD ABI Version: 0 Type: EXEC (Executable file) Machine: MIPS R3000 Version: 0x1 Entry point address: 0x120001dd0 Start of program headers: 64 (bytes into file) Start of section headers: 34808 (bytes into file) Flags: 0x60000007, noreorder, pic, cpic, mips= 64 Size of this header: 64 (bytes) Size of program headers: 56 (bytes) Number of program headers: 6 Size of section headers: 64 (bytes) Number of section headers: 29 Section header string table index: 28 Section Headers: [Nr] Name Type Address Offset Size EntSize Flags Link Info Align [ 0] NULL 0000000000000000 00000000 0000000000000000 0000000000000000 0 0 0 [ 1] .interp PROGBITS 0000000120000190 00000190 0000000000000015 0000000000000000 A 0 0 1 [ 2] .note.ABI-tag NOTE 00000001200001a8 000001a8 0000000000000018 0000000000000000 A 0 0 4 [ 3] .MIPS.options MIPS_OPTIONS 00000001200001c0 000001c0 0000000000000168 0000000000000001 Ao 0 0 8 [ 4] .dynamic DYNAMIC 0000000120000328 00000328 0000000000000200 0000000000000010 A 7 0 8 [ 5] .hash HASH 0000000120000528 00000528 0000000000000450 0000000000000004 A 6 0 8 [ 6] .dynsym DYNSYM 0000000120000978 00000978 .... The .interp offset is reasonable here... JC.