LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   *BSD (https://www.linuxquestions.org/questions/%2Absd-17/)
-   -   Linux chroot under OpenBSD /bin/bash: Exec format error (https://www.linuxquestions.org/questions/%2Absd-17/linux-chroot-under-openbsd-bin-bash-exec-format-error-4175507593/)

nolretou 06-10-2014 07:58 AM

Linux chroot under OpenBSD /bin/bash: Exec format error
 
Hi !

I'm under OpenBSD 5.5, and i would like to run some Linux programs inside a chroot.

# chroot ./ /bin/bash
chroot: /bin/bash: Exec format error

First, is it possible (to some extent) ?
And if yes, how ?

linosaurusroot 06-10-2014 10:59 AM

You should get bash for OpenBSD ... just copying a linux binary won't work (although there may be some compatibility cheat).

nolretou 06-10-2014 11:03 AM

I installed bash under BSD with pkg_add . Maybe you mean that i have to copy the BSD version inside the chroot ?

nolretou 06-13-2014 04:04 AM

Bump !

rocket357 06-13-2014 08:48 PM

This isn't going to work the way you want it to.

First off, the operating system syscall numbers (which any non-trivial program is more than likely going to call) are different, as well as the method for calling syscalls.

Second, Linux-compiled libraries will need to be present (i.e. a Linux binary wouldn't be able to call an OpenBSD library of the same name as the Linux library it needs).

Third (and perhaps most critically), even if you got everything else to line up properly, the calling conventions are different between Linux and OpenBSD (Linux passes parameters in registers and uses the stack for overflow parameters, OpenBSD passes all parameters on the stack).

Fourth, Linux emulation was removed from OpenBSD many, many moons ago (which required syscall emulation and linux libraries to be installed).

Fifth, what are you trying to accomplish?

moisespedro 06-14-2014 12:31 AM

Linux emulation was not removed, was it? If i am not mistaken they even talk about it on the FAQ

ReaperX7 06-14-2014 03:29 AM

FreeBSD has Linux emulation. I'm not sure about OpenBSD. However, do take heed that the Linux emulation binaries are not as modern as a true Linux system.

rocket357 06-14-2014 01:15 PM

Quote:

Originally Posted by moisespedro (Post 5187933)
Linux emulation was not removed, was it?

Ahh, you're right. There was a discussion around removing it, but it wasn't actually removed (I don't use Linux compat, so I never bothered following the conversation to completion). Looking at CURRENT sources, I see /usr/src/sys/compat/linux...so the code is still there, it seems.

It's no longer in the default kernel build, however, so running Linux binaries would require a custom kernel.

cynwulf 06-22-2014 01:49 AM

What Linux programs are you trying to run? Have you checked to see if there are ports?

nolretou 06-23-2014 05:40 AM

I try different things. Some of them are pre-compiled libraries which relies on a Linux rootfs.


All times are GMT -5. The time now is 03:24 AM.