From owner-freebsd-mips@FreeBSD.ORG Wed Mar 30 05:54:32 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 9576A106566B for ; Wed, 30 Mar 2011 05:54:32 +0000 (UTC) (envelope-from mohun106@gmail.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id 4CCB78FC19 for ; Wed, 30 Mar 2011 05:54:32 +0000 (UTC) Received: by yxl31 with SMTP id 31so458310yxl.13 for ; Tue, 29 Mar 2011 22:54:31 -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=yHxJnp7To1++NkQvhAcgfkf7/tI+Vq8EaoEi4s2nx30=; b=QYlQSix8Z7VU0vYuFJRIg9hNj8Xne5tyOUTKSMiqB1FekfjtgKIB2hj9pC2jc6lU8X GycFjLSXyEZ8tr0rkypjUkFp54uHf3mQvLXUDfn0LTToyFU6zGZQmmsSFPshUPsSCBin VTtj1LGsK6cYR4oIR6E40lL2qelE6stEU+dRU= 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=ZSK1bwP5FGJuRxKXO8fceH9gUEwmnBPG3UrjW02edcxjATAjt+f5OdOX2KVw9X9RPf F9OHkrPoEh13CgfI/Na5o+xpTpe/dWzgpoji4OzIEXklggvIaganTiFDGIB4KxS0B39n y0Ov889XpCfabDDSQaHv+DTsmAXmgtMHfWIyg= MIME-Version: 1.0 Received: by 10.101.95.8 with SMTP id x8mr592380anl.3.1301463077746; Tue, 29 Mar 2011 22:31:17 -0700 (PDT) Received: by 10.100.173.20 with HTTP; Tue, 29 Mar 2011 22:31:17 -0700 (PDT) In-Reply-To: References: Date: Wed, 30 Mar 2011 11:01:17 +0530 Message-ID: From: Radha Mohan To: "Jayachandran C." Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Adrian Chadd , 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: Wed, 30 Mar 2011 05:54:32 -0000 Hi JC, Incidentally I am also trying to load modules under FreeBSD on my MIPS plat= form, but I am getting following error. # /sbin/kldload -v ext2fs linker_load_file: Unsupported file type kldload:can't load ext2fs: Exec format error For me all the modules give me this error. >From what I understood going through the module loading code is the linker_load_file() function is trying for all the registered classes (elf64_obj and elf64 in my case). But the relocatable header type is handled in the link_elf_obj.c only and not link_elf.c . There is still some support lacking for the mips64 relocation in terms of getting "mapbase" (currently its taking only amd64 architecture into consideration)and handling addend (ELF_RELOC_RELA), R_MIPS_64, R_MIPS_HIGHER and R_MIPS_HIGHEST. regards, Radha Mohan On Tue, Mar 29, 2011 at 5:05 PM, Jayachandran C. wrote: > > On Tue, Mar 29, 2011 at 12:45 PM, Adrian Chadd w= rote: > > 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 li= nker > > isn't gluing them together. That (1) is a local patch of mine to figure= out > > where it's broken - here, it's broken in link_elf_obj.c:1038 . Ie, it's= the > > first loop in relocate_file(). > > > > I'm not up to date on how all this ELF and kernel module/linker magic w= orks, > > 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 valu= e we > have for linker_kernel_file->address is not correct for mips, it should b= e > actually the KERNLOADADDR in config file. > > Not really sure if your problem is related, but here is a small hack/patc= h 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) > > =A0 =A0 =A0 =A0if (dp !=3D NULL) > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0parse_dynamic(ef); > +#ifdef __mips__ > + =A0 =A0 =A0 linker_kernel_file->address =3D (caddr_t) 0xffffffff8010000= 0; > +#else > =A0 =A0 =A0 =A0linker_kernel_file->address =3D (caddr_t) KERNBASE; > +#endif > =A0 =A0 =A0 =A0linker_kernel_file->size =3D -(intptr_t)linker_kernel_file= ->address; > > =A0 =A0 =A0 =A0if (modptr !=3D NULL) { > -- > > > JC. >