From owner-freebsd-embedded@FreeBSD.ORG Mon Oct 13 19:26:41 2008 Return-Path: Delivered-To: freebsd-embedded@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BDF6D1065687 for ; Mon, 13 Oct 2008 19:26:41 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from out4.smtp.messagingengine.com (out4.smtp.messagingengine.com [66.111.4.28]) by mx1.freebsd.org (Postfix) with ESMTP id 7ECD18FC27 for ; Mon, 13 Oct 2008 19:26:41 +0000 (UTC) (envelope-from bms@incunabulum.net) Received: from compute2.internal (compute2.internal [10.202.2.42]) by out1.messagingengine.com (Postfix) with ESMTP id 0818E15E504; Mon, 13 Oct 2008 15:26:41 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute2.internal (MEProxy); Mon, 13 Oct 2008 15:26:41 -0400 X-Sasl-enc: FpY5E5gmVDu0iUDxxaCaN8ytMzaNiQhmUmpzSztyulZ0 1223926000 Received: from empiric.lon.incunabulum.net (82-35-112-254.cable.ubr07.dals.blueyonder.co.uk [82.35.112.254]) by mail.messagingengine.com (Postfix) with ESMTPSA id 3712AC42D; Mon, 13 Oct 2008 15:26:40 -0400 (EDT) Message-ID: <48F3A0EE.7040003@incunabulum.net> Date: Mon, 13 Oct 2008 20:26:38 +0100 From: Bruce M Simpson User-Agent: Thunderbird 2.0.0.14 (X11/20080514) MIME-Version: 1.0 To: "M. Warner Losh" References: <48F39798.3010606@incunabulum.net> <20081013.125648.1239212699.imp@bsdimp.com> In-Reply-To: <20081013.125648.1239212699.imp@bsdimp.com> X-Enigmail-Version: 0.95.6 Content-Type: multipart/mixed; boundary="------------000707010509060807020608" Cc: freebsd-embedded@FreeBSD.org Subject: Re: ELF loader problem with CFE on ASUS WL500g X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2008 19:26:41 -0000 This is a multi-part message in MIME format. --------------000707010509060807020608 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit M. Warner Losh wrote: > I thought you could fix this with linker script tweaks... > Not in an automated way. It'll let you set a *fixed* LMA by adding AT(...) to the PHDR linker script section, but that's not very useful. Trying to use a non-constant expression produces an error; and LOADADDR() wants a *section*, not a *segment*. The first thing I tried was to use the "load -addr" option in CFE; it totally ignores this option as it only applies to raw images. I tried the GNU ld MEMORY { ... } section, but it changes the VMA as well as the LMA. I seem to remember I had headaches like this when trying to build FreeBSD with the MinGW toolchain to boot on an SGI Visual Workstation. > bummer... It sounds a bit like we need to do the normal tricks of > 'early' boot loaders: turn on the mmu and then jump to . to transition > from PA to VA addresses... > > : It looks like objcopy's --change-section-lma option, with a negative > : offset, would do what I want, however it will need to be scripted to > : work on named sections. > > You might try to mock-up a test with a newer version of binutils than > 2.15 we're using? > I tried the attached script, which produces a BFD error: BFD: kernel.rebased: section `.hash' can't be allocated in segment 3 One common problem with these Broadcom based platforms is that they almost always ship with CFE, and it's convenient to use the inbuilt ELF loader for bootstrapping. Unfortunately CFE comes with bugs attached, and there are usually no alternative boot loaders available due to Broadcom's less than, shall we say, "open" attitude towards open source. *ahem* So yeah, it sounds like we probably need something like the ARM ELF trampoline for MIPS ideally. It would probably also be relatively easy to write a small C tool with libelf to do the rebasing CFE expects. I have a train to catch in a few hours, I'd better not get in too deep... later BMS --------------000707010509060807020608 Content-Type: text/plain; name="fnord.sh" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="fnord.sh" #!/bin/sh OBJCOPY=mips-rtems-objcopy KERNEL=kernel REBASE=0x80000000 SECTIONS=$(mips-rtems-objdump -h $KERNEL | grep ' \.' | awk '{ if (substr($4,0,2) == "80") print $2}') OCOPTS="" for i in $SECTIONS ; do OCOPTS="$OCOPTS --change-section-lma ${i}-${REBASE}" done set -x exec $OBJCOPY $OCOPTS $KERNEL ${KERNEL}.rebased --------------000707010509060807020608--