From owner-freebsd-mips@FreeBSD.ORG Tue Mar 29 11:35:16 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 51DB51065678 for ; Tue, 29 Mar 2011 11:35:16 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id DB76E8FC12 for ; Tue, 29 Mar 2011 11:35:15 +0000 (UTC) Received: by wyf23 with SMTP id 23so60072wyf.13 for ; Tue, 29 Mar 2011 04:35:14 -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=5VsSb/RrNbHOoZEWIAQPFyyzgBg7Al1HdKWu7uKQ1yM=; b=uk0KvXMjaXZvPkwKvQfZJoMMk0hiryWG9FeF4cYjRfPQCUkcVqJ3jMesx4RRxxdVOV 2fUc/Kmyh9hMKeuSe62ZXjBaG7XbKHZdDwxew69og2lBo3MYT9eDi36pBg8Xtm0JvYpo An+8qr958tn7/rCo8UdPDxpWDl8+/qS1WhTWY= 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=R0UxH5ImBp5wz5mFvRZuQAiIEa6LsYF9bRXOq1ab8u/088RQ9cBJXcAuMOWQQYojTN i7ZchKbRuo5EAljHXFOqCdllhmAHpVL3Gyd0eEsA0wca5lvodEc8smDJVxhX/uJJC8XQ 5i7tzBB2bpS+mjOMqWkUOqLbAy4UPXljq06UQ= MIME-Version: 1.0 Received: by 10.227.203.76 with SMTP id fh12mr5145820wbb.110.1301398514815; Tue, 29 Mar 2011 04:35:14 -0700 (PDT) Received: by 10.227.9.23 with HTTP; Tue, 29 Mar 2011 04:35:14 -0700 (PDT) In-Reply-To: References: Date: Tue, 29 Mar 2011 17:05:14 +0530 Message-ID: From: "Jayachandran C." To: Adrian Chadd Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-mips@freebsd.org Subject: Re: linker weirdness for MIPS kernel? 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: Tue, 29 Mar 2011 11:35:16 -0000 On Tue, Mar 29, 2011 at 12:45 PM, Adrian Chadd wro= te: > Hi guys, > > I'm trying to use modules on my MIPS boards and I'm hitting a snag. > > # kldload ./wlan.ko > # kldload ./ath_hal.ko > # kldload ./ath_rate_sample.ko > link_elf_obj: symbol ieee80211_iterate_nodes undefined (1) > linker_load_file: Unsupported file type > kldload: can't load ./ath_rate_sample.ko: Exec format error > # nm ./wlan.ko =A0| grep ieee80211_iterate_nodes > 00015edc t ieee80211_iterate_nodes > # kldstat > Id Refs Address =A0 =A0Size =A0 =A0 Name > =A01 =A0 =A07 0x80000000 80000000 kernel > =A02 =A0 =A01 0xc7b4e000 538e4 =A0 =A0wlan.ko > =A03 =A0 =A01 0xc7ba2000 70b88 =A0 =A0ath_hal.ko > # > > So the wlan module is loaded, it has that symbol internally, but the link= er > isn't gluing them together. That (1) is a local patch of mine to figure o= ut > where it's broken - here, it's broken in link_elf_obj.c:1038 . Ie, it's t= he > first loop in relocate_file(). > > I'm not up to date on how all this ELF and kernel module/linker magic wor= ks, > could someone please give me a hand diagnosing why this is happening? There was an issue we had seen in link_elf.c in another context, the value = we have for linker_kernel_file->address is not correct for mips, it should be actually the KERNLOADADDR in config file. Not really sure if your problem is related, but here is a small hack/patch = to try: diff --git a/sys/kern/link_elf.c b/sys/kern/link_elf.c index 1e0bac1..14dfe9e 100644 --- a/sys/kern/link_elf.c +++ b/sys/kern/link_elf.c @@ -323,7 +323,11 @@ link_elf_init(void* arg) if (dp !=3D NULL) parse_dynamic(ef); +#ifdef __mips__ + linker_kernel_file->address =3D (caddr_t) 0xffffffff80100000; +#else linker_kernel_file->address =3D (caddr_t) KERNBASE; +#endif linker_kernel_file->size =3D -(intptr_t)linker_kernel_file->address= ; if (modptr !=3D NULL) { -- JC.