# linux.ko - exec format error



## eyebone (Jun 9, 2010)

hello folks,

i have built a new kernel today. the system crashed at bootime(couldnt track so far what the message was, as the crashes where ongoing). i disabled nvidia.ko in loader.conf and the system was coming up cleanly. i tried to load nvidia.ko by hand and got:

```
Jun  9 10:30:08 kern kernel: link_elf_obj: symbol elf32_insert_brand_entry undefined
Jun  9 10:30:08 kern kernel: linker_load_file: Unsupported file type
Jun  9 10:30:08 kern kernel: KLD nvidia.ko: depends on linux - not available or version mismatch
Jun  9 10:30:08 kern kernel: linker_load_file: Unsupported file type
```

so i recompiled nvidia driver tried to load it and got the same error.
next i had a look at linux.ko going to /boot/kernel trying to load linux.ko by hand resulted in:


```
Jun  9 10:32:58 kern kernel: link_elf_obj: symbol elf32_insert_brand_entry undefined
Jun  9 10:32:58 kern kernel: linker_load_file: Unsupported file type
```

now, having a look onto both modules with file:

```
linux.ko: ELF 64-bit LSB relocatable, x86-64, version 1 (FreeBSD), not stripped
nvidia.ko: ELF 64-bit LSB relocatable, x86-64, version 1 (FreeBSD), not stripped
```
which sounds perfectly fine to me. what else can i do to track this problem down?
i have several other modules loaded which work fine. 

one last note, some time ago i was playing with /compat/i386 and trying to build an nvidia i386 driver for wine support onto amd64 systems. in the end i am not sure how this should affect new kernelbuilds in /usr/src however - maybe there is some magic constraints.

regards,


----------



## SirDice (Jun 9, 2010)

Make sure your kernel is up to date. Also make sure the nvidia driver you built matches the kernel you built it on. 

Remove any CFLAGS or similar from /etc/make.conf if you have any.


----------



## eyebone (Jun 9, 2010)

SirDice said:
			
		

> Make sure your kernel is up to date. Also make sure the nvidia driver you built matches the kernel you built it on.
> 
> Remove any CFLAGS or similar from /etc/make.conf if you have any.



hi, the kernel is:

```
FreeBSD kern 8.1-PRERELEASE FreeBSD 8.1-PRERELEASE #6: Wed Jun  9 09:57:32 CEST 2010     root@kern:/usr/obj/usr/src/sys/kern  amd64
```

(fresh cvsup'ed), the nvidia driver was built for this kernel and there are no cflags in make.conf(i am using there the defaults):

```
cat /etc/make.conf 
# added by use.perl 2010-04-09 23:57:50
PERL_VERSION=5.8.9
```
but i remember to have the same problems with newly create 8.0-STABLE's as well, but never dived into the problem.

and i still wonder why this linux.ko says it has the wrong ELF brand entry, even it was part of the recent building process. this makes no sense to me 


```
Jun  9 13:11:39 kern kernel: link_elf_obj: symbol elf32_insert_brand_entry undefined
Jun  9 13:11:39 kern kernel: linker_load_file: Unsupported file type
```

maybe another direction i could dig through?

UPDATE:

just tried to recompile the module by itself, was working without any problem, but still i get an exec format error:


```
cd /usr/src/sys/modules/linux
make clean;
make
kldload ./linux.ko 
kldload: can't load ./linux.ko: Exec format error
```


----------



## eyebone (Jun 9, 2010)

think i have found the problem. for some strange reasons(maybe during an former wine i386 build for amd64 system in chroot) i uncommented FREEBSD_COMPAT32:

```
options       COMPAT_FREEBSD32        # Compatible with i386 binaries
```

i guess this is mandatory for linux.ko


----------



## SirDice (Jun 9, 2010)

I never would have guessed that :e

But now that I see the solution I do remember that the linuxilator is only able to do 32bit linux. So it does make sense.


----------

