linker weirdness for MIPS kernel?

Radha Mohan mohun106 at gmail.com
Wed Mar 30 05:54:32 UTC 2011


Hi JC,

Incidentally I am also trying to load modules under FreeBSD on my MIPS platform,
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.
<c.jayachandran at gmail.com> wrote:
>
> On Tue, Mar 29, 2011 at 12:45 PM, Adrian Chadd <adrian.chadd at gmail.com> wrote:
> > 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  | grep ieee80211_iterate_nodes
> > 00015edc t ieee80211_iterate_nodes
> > # kldstat
> > Id Refs Address    Size     Name
> >  1    7 0x80000000 80000000 kernel
> >  2    1 0xc7b4e000 538e4    wlan.ko
> >  3    1 0xc7ba2000 70b88    ath_hal.ko
> > #
> >
> > So the wlan module is loaded, it has that symbol internally, but the linker
> > 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 works,
> > 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 != NULL)
>                parse_dynamic(ef);
> +#ifdef __mips__
> +       linker_kernel_file->address = (caddr_t) 0xffffffff80100000;
> +#else
>        linker_kernel_file->address = (caddr_t) KERNBASE;
> +#endif
>        linker_kernel_file->size = -(intptr_t)linker_kernel_file->address;
>
>        if (modptr != NULL) {
> --
>
>
> JC.
>


More information about the freebsd-mips mailing list