Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Linux binary, compiled on Fedora 10, unrecognized ELF binary type

106 views
Skip to first unread message

Andrew Falanga

unread,
Mar 1, 2013, 10:28:12 AM3/1/13
to
HI everyone,

In my quest to get a Linux program working in FreeBSD, I decided to try running Fedora 10 in a VM and compile the code there (since FreeBSDs linux emulator is FC10). I've compiled the program in FC10, the program sources are on a USB thumb drive. I then make that same thumb drive available to my FreeBSD VM, on which I've installed the linux compatibility port, and try to run the program. I get the error:

ELF binary type "0" not known
./program: Exec format error. Binary file not executable.

The process used to build the code:
1) Place sources on a thumb drive (preserving directory structure)
2) Mount this thumb drive in my FC10 VM
3) cd /mnt/ProgramHome
4) make program
5) cd; umount /mnt
6) Remove thumb drive from VM and put the thumb drive into the FBSD VM
7) Mount the thumb drive in FreeBSD
8) kldload linux
9) cd /mnt/ProgramHome/output
10) ./program

At this point, the error occurs.

Does anyone have any ideas? I thought that FreeBSDs linux emulation is FC 10. Am I wrong in this? I'm running FreeBSD 9.1-RELEASE and installed linux emulation from the ports tree that was distributed with the release.

Thanks,
Andy

Lowell Gilbert

unread,
Mar 1, 2013, 3:00:05 PM3/1/13
to
Sounds like you did everything fine, you just need brandelf(1) to
indicate the correct ABI.

--
Lowell Gilbert, embedded/networking software engineer
http://be-well.ilk.org/~lowell/

Andrew Falanga

unread,
Mar 1, 2013, 4:30:00 PM3/1/13
to
>> ELF binary type "0" not known
>> ./program: Exec format error. Binary file not executable.
>
>
>
> Sounds like you did everything fine, you just need brandelf(1) to
>
> indicate the correct ABI.
>
>

I did try this and for each of the supported brands, only the FreeBSD brand didn't produce the error mentioned earlier. However, all did not work. In fact, they dumped their cores. This program works just fine on linux. It's been in production now for some time. After rebranding, and the subsequent core dump, I looked at it with gdb. The core shows an recursive loop in the stack, but no function is being called recursively.

The thing I don't understand is, about 6 years ago, I was doing this very same thing with a different linux binary built in SuSE linux. I'd installed linux compatibility on my FreeBSD machine and that was it, there was no branding required. I guess stated a different way, why would I need to brand these? I built them in Fedora Core 10. I installed emulators/linux_base-f10. Why should these need to be rebranded?

Thanks for the pointer. I didn't know of the branding utility.

Andy

Andrew Falanga

unread,
Mar 1, 2013, 4:50:16 PM3/1/13
to
Ok, now I'm truly confused. I've gone poking around in my /compat/linux directory hierarchy. I decided to see what brand of ELF these binaries are. Interestingly, every binary I've thus far tested is of type "3" "Linux". So, I make my binary of type 3, "Linux." Guess what, it *still* refuses to execute saying that the ELF binary type is "not known". The binary type it's complaining about is type 3.

I thought that it may have something to do with the location I was executing the linux program. So I copied it to /compat/linux and tried executing from there: no dice. Am I missing something on the install? I do have linux.ko loaded. Interestingly, the binaries in the /compat/linux directories execute just fine.

I'm stumped.

Andy

Lowell Gilbert

unread,
Mar 2, 2013, 11:57:10 AM3/2/13
to
I don't have a Linux system to test against, but did you try statically
linking your own program?

Lowell Gilbert

unread,
Mar 3, 2013, 2:48:21 PM3/3/13
to
I just built a binary on a virtual-machine Ubuntu system, moved it over
to FreeBSD (-STABLE, within the last few days), and it worked fine
branded as *either* type 0 or 3. With the Linux kernel module loaded, of
course; I didn't check what the failure mode is if it wasn't loaded.
0 new messages