NetBSD Binary Emulation

Binary Emulation


Binary Emulation

What is Binary Emulation? Why does it exist? (top)

A large amount of Unix software is distributed in source-code format. This means the authors actually provide the C (or other language) program code, and the installation process uses a compiler to generate an executable to run on the local machine. Carefully written source-code and installation utilities can allow the same program to be built on dozens of different operating systems.

Commercial software vendors are not inclined to distribute source code since it may contain trade secrets. Commercial vendors normally deliver the executable programs which can be run directly. They perform the compilation stage in-house, and delivery binary files from which their secrets are less easily discernible.

The result of this is that the vendor must make a choice to expend man-power for each different operating system they support, normally maintaining a system to do testing with, and at least one person to do compilation and testing.

This ties together the Operating System and the set of applications a consumer may wish to run. One may choose not to run a particular application because it is not available on their Operating System of choice, or one may be forced to run an Operating System one would rather not, due to the availability of some critical application.

Binary Emulation eliminates this forced linkage.

What other binary compatibility is there? (top)

There is another compatibility feature worth being aware of. NetBSD uses the same binary object file format across NetBSD machines with the same CPU. If you build binaries on your NetBSD sun3, you can run them on your NetBSD amiga, NetBSD mac68k, NetBSD mvme68k, NetBSD next68k... however, you couldn't run them on Intel processor based machines.

How does it work? (top)

Unix and Unix-like systems consist of two primary parts, the Kernel, and everything else. The kernel is the program which controls devices, security, and the programs which wish to use the machine's resources. Typically, the kernel provides these services to other programs through kernel system calls. An example would be a program requesting to OPEN a file, the program calls the kernel OPEN function with a set of parameters indicating what it wishes to do, and the kernel allows or denies the request, and replies with the information the program requires to continue.

Every Unix and Unix-like system supplies a very similar set of these system calls. (They all have an OPEN for example.)

From system to system, the primary differences in syscalls will be in the format of parameters passed to these calls. (NetBSD's OPEN takes a filename, flags, and a mode)  The names of the calls may also differ from system to system. If a NetBSD system wishes to run a Linux executable, each time the program performs a system call, the kernel performs a mapping function to the corresponding NetBSD system call, and re-orders/re-formats the parameters as required.

Another important issue is the format of the executable files. About every second operating system uses a different file format in which it saves its binaries, using different headers, magic cookies, hunks, whatever. The one NetBSD supports natively is a.out or ELF(depending on the architecture, and version of NetBSD. NetBSD is migrating to ELF, with each port moving according to its own schedule). Some other executable formats include b.out, COFF, ECOFF, ieee695, PE, SOM, and XCOFF. NetBSD's emulation knows how to handle the executable format for the emulated system.

Across different systems syscalls are accessed in different ways, and parameters are passed differently. As an example, under AmigaOS, this is done with an index into a table containing pointers to functions pointed to by some address register and the data in some data register. Other operating systems use other methods, traps, tables, registers, stacks, etc. and this is handled by the binary emulation.

The final significant requirement is that the CPU the executable was compiled for must match the system it will run on. Besides system calls, executables consist of raw CPU instructions. Therefore, SCO Unix binaries (Intel 386 series CPU) will run on NetBSD i386, but can not be run on NetBSD Amiga (Motorola 680x0 CPU). Performing that function would require a much more complicated translation system, and would have a significant impact on application performance.

Which systems can I run binaries from? (top)

Generally speaking, you can run binaries from other unix operating systems which run on the same hardware as your NetBSD system. A list of supported Binary formats for each port, as well as user's success stories are available in the platform specific pages selectable at the bottom of this page

How well does it perform? (top)

Since the only additional overhead is the mapping from emulated system calls to native NetBSD system calls, and the reformatting of any parameters, if needed, the performance is really, really good. A rough estimate would be at most a 1-2% performance impact; if you call 2% impact. This varies depending on which system calls a program uses. Most mappings take <1% of the time the actual syscall takes to run.

Any other considerations? (top)

In addition to the CPU being of the same type, and the mapping of system calls, there is one other requirement. Many Unix systems support shared libraries. This means that a compiled program does not come with all of its functions compiled in, (which means it can be smaller) but it requires an external set of libraries which must match the ones the program was compiled to use (not including minor modifications). If you wish to run a program under binary emulation, you can check whether it was statically or dynamically linked, by using the 'file' command...

% file qwsv
qwsv: BSD/OS i386 compact demand paged executable
% file arp
arp: NetBSD/i386 demand paged dynamically linked executable

The presence of 'dynamically linked' indicates exactly that, its absence indicates static linking. Shared object libraries for most freely available Unix systems are available from the NetBSD pkgsrc, under the /compat directory. Note that these shared library sets are _not required_ if you are only going to run statically linked binaries.

For commercial systems, you may need to supply your own set of libraries. See man -k compat for a list, and man compat_os (where os is the target OS) for some installation instructions:

% man -k compat
compat_freebsd(8) - setup procedure for running FreeBSD binaries
compat_hpux(8) - setup procedure for running HP/UX binaries
compat_ibcs2(8) - setup procedure for running binaries that conform to the Intel Binary Compatibility Standard 2, e.g. SCO Unix and others derived from AT&T SVR3.
compat_linux(8) - setup procedure for running Linux binaries
compat_osf1(8) - setup procedure for running OSF/1 (AKA Digital Unix, AKA Tru64) binaries
compat_pecoff(8) - setup procedure for running Win32 binaries
compat_sunos(8) - setup procedure for m68k and sparc architectures
compat_svr4(8) - setup procedure for running SVR4/iBCS2 binaries
compat_ultrix(8) - setup procedure for Ultrix compatibility on mips and vax

Which OSs can I emulate on my machine? (top)

NetBSD runs on many CPUs and hardware platforms, for specific information, please find yours in the list below. If you have additional emulations to report, please let us know.

alpha
  • Linux(Alpha)
  • OSF/1
amiga
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)
arc
arm26
arm32
atari
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)
bebox
cobalt
dreamcast
hp300
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)
hpcmips
hpcsh
i386
  • BSDI (up to BSDI 3.x binaries)
  • FreeBSD(x86) (a.out and ELF binaries)
  • IBCS2 systems
    • Interactive Unix
    • SCO Unix
    • SCO Xenix
  • Linux(x86)
  • Solaris(x86)
luna68k
mac68k
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)
macppc
mipsco
mvme68k
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)
news68k
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)
newsmips
next68k
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)
ofppc
pc532
pmax
prep
sandpoint
sgimips
  • IRIX(mips)
  • Linux(mips)
  • Ultrix(mips)
sh3
sparc
  • SunOS(sparc)
  • Solaris(sparc)
sparc64
  • 32-bit NetBSD/sparc (both ELF and a.out)
  • SunOS(sparc)
  • Solaris(sparc) (both 32-bit and 64-bit)
sun3
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)
vax
x68k
  • Amiga Unix (SVR4)
  • HPUX(68k)
  • Linux(m68k)
  • SunOS(68k)

Which applications have been reported to work on my machine? (top)

NetBSD runs on many CPUs and hardware platforms, for specific information, please find yours in the list below. If you have additional applications to report, please let us know.

alpha
  • Acroread - Digital Unix
amiga
arc
arm26
arm32
atari
bebox
cobalt
dreamcast
hp300
  • Gnat (Gnu Ada Translator) - SunOS
hpcmips
hpcsh
i386
  • Acroread - Linux(x86)
  • Honyaku-no-Ousama POWER+ - Linux(x86)
  • Mathematica 5.2 - Linux(x86)

    When installing Mathematica, you may need to apply this patch:

    --- Unix/Installer/MathInstaller.orig	2005-07-18 14:23:57.000000000 -0400
    +++ Unix/Installer/MathInstaller	2005-07-18 14:26:36.000000000 -0400
    @@ -1,4 +1,4 @@
    -#!/bin/sh
    +-o #!/bin/sh
     # ----------------------------------------------------------------------------
     #
     #   Installer for Mathematica Applications
    @@ -11,6 +11,8 @@
     LANG=C
     export LANG
     
    +UNAME=`uname -s`
    +
     # ----------------------------------------------------------------------------
     # Function: CleanUp_()
     
    @@ -806,7 +808,7 @@
              DefaultSystemID="HPUX-PA64";;
           IRIX64)
              DefaultSystemID="IRIX-MIPS64";;
    -      Linux)
    +      Linux|NetBSD)
              case `uname -m` in
                 alpha)
                    DefaultSystemID="Linux-AXP";;
    @@ -1229,7 +1231,8 @@
              -o "${DefaultSystemID}" = "DEC-AXP" \
              -o "${DefaultSystemID}" = "HPUX-PA64" \
              -o "${DefaultSystemID}" = "IRIX-MIPS64" \
    -         -o "${DefaultSystemID}" = "MacOSX" ]; then
    +         -o "${DefaultSystemID}" = "MacOSX" \
    +	 -o "${UNAME}" = "NetBSD" ]; then
              Spacing_=`expr ${TermWidth} - 3`
              WhiteSpace_=`printf "%-${Spacing_}s"`
              DotText_="[${WhiteSpace_}]"
    @@ -1993,14 +1996,14 @@
     
        case "${CopyTextType_}" in
        "Error")
    -      if [ "${DefaultSystemID}" = "MacOSX" ]; then
    +      if [ "${DefaultSystemID}" = "MacOSX" -o "${UNAME}" = "NetBSD" ]; then
              echo "${CopyText_}" | fmt ${TWmin} ${TermWidth}
           else
              echo "${CopyText_}" | fmt -${TermWidth}
           fi
           echo "";;
        "Prompt")
    -      if [ "${DefaultSystemID}" = "MacOSX" ]; then
    +      if [ "${DefaultSystemID}" = "MacOSX" -o "${UNAME}" = "NetBSD" ]; then
              echo "${CopyText_}" | fmt ${TWmin} ${TermWidth}
           else
              echo "${CopyText_}" | fmt -${TermWidth}
    @@ -2008,7 +2011,7 @@
           echo ${n} "> ${c}";;
        "Text")
           if [ "${CopyText_}" != "" ]; then
    -         if [ "${DefaultSystemID}" = "MacOSX" ]; then
    +        if [ "${DefaultSystemID}" = "MacOSX" -o "${UNAME}" = "NetBSD" ]; then
                 echo "${CopyText_}" | fmt ${TWmin} ${TermWidth}
              else
                 echo "${CopyText_}" | fmt -${TermWidth}
    @@ -2022,7 +2025,7 @@
           WhiteSpace_=`printf "%-${Spacing_}s"`
           echo "${WhiteSpace_}${CopyText_}";;
        "Verbose")
    -      if [ "${DefaultSystemID}" = "MacOSX" ]; then
    +      if [ "${DefaultSystemID}" = "MacOSX" -o "${UNAME}" = "NetBSD" ]; then
              echo "<< ${CopyText_} >>" | fmt ${TWmin} ${TermWidth}
           else
              echo "<< ${CopyText_} >>" | fmt -${TermWidth}

    The shell scripts that start the application after the installation need the following patch:

    --- MathKernel.orig	2005-07-18 14:36:44.000000000 -0400
    +++ MathKernel	2005-07-18 14:35:37.000000000 -0400
    @@ -16,7 +16,7 @@
     			SystemIDList="HPUX-PA64";;
     		IRIX64)
     			SystemIDList="IRIX-MIPS64";;
    -		Linux)
    +		Linux|NetBSD)
     			case `uname -m` in
     				ia64)
     					SystemIDList="Linux-IA64";;
    --- Mathematica.orig	2005-07-18 14:36:47.000000000 -0400
    +++ Mathematica	2005-07-18 14:35:47.000000000 -0400
    @@ -19,7 +19,7 @@
     			SystemIDList="HPUX-PA64 HP-RISC";;
     		IRIX64)
     			SystemIDList="IRIX-MIPS64";;
    -		Linux)
    +		Linux|NetBSD)
     			case `uname -m` in
     				alpha)
     					SystemIDList="Linux-AXP";;
    --- math.orig	2005-07-18 14:35:18.000000000 -0400
    +++ math	2005-07-18 14:36:03.000000000 -0400
    @@ -16,7 +16,7 @@
     			SystemIDList="HPUX-PA64";;
     		IRIX64)
     			SystemIDList="IRIX-MIPS64";;
    -		Linux)
    +		Linux|NetBSD)
     			case `uname -m` in
     				ia64)
     					SystemIDList="Linux-IA64";;
    --- mathematica.orig	2005-07-18 14:36:52.000000000 -0400
    +++ mathematica	2005-07-18 14:36:13.000000000 -0400
    @@ -19,7 +19,7 @@
     			SystemIDList="HPUX-PA64 HP-RISC";;
     		IRIX64)
     			SystemIDList="IRIX-MIPS64";;
    -		Linux)
    +		Linux|NetBSD)
     			case `uname -m` in
     				alpha)
     					SystemIDList="Linux-AXP";;
    --- mcc.orig	2005-07-18 14:36:36.000000000 -0400
    +++ mcc	2005-07-18 14:36:31.000000000 -0400
    @@ -15,7 +15,7 @@
     		SystemIDList="HPUX-PA64";;
     	IRIX64)
     		SystemIDList="IRIX-MIPS64";;
    -	Linux)
    +	Linux|NetBSD)
     		case `uname -m` in
     			ia64)
     				SystemIDList="Linux-IA64";;

  • Matlab - Linux(x86)

    More information is available at http://www.spg.tu-darmstadt.de/~hf/notes/matlab-on-netbsd.html and http://mail-index.NetBSD.org/port-i386/2005/10/07/0002.html.

  • Maple 6.1, 7, 8, 9.5, 10 - RedHat Linux(x86)

    Maple ships with binaries for SuSE and RedHat Linux, but even with our SuSE compat pkgs, (only) the RedHat version works. No big problem, if you have both. A small patch is needed to get the system to know about NetBSD:

    --- maple.system.type.orig      Mon Apr 30 17:26:11 2001
    +++ maple.system.type   Mon Apr 30 17:40:49 2001
    @@ -84,6 +84,11 @@
                    MAPLE_BIN="bin.IBM_INTEL_LINUX"
            fi
             ;;
    +    "NetBSD")
    +       # NetBSD uses SuSE compat per default, but maple works
    +       # (only) with the RedHat compat. 
    +       MAPLE_BIN="bin.IBM_INTEL_LINUX"
    +       ;;
         *)
             # currently do not support any other platforms
             MAPLE_BIN="FAIL"

    Apply this to the mapledir/bin/maple.system.type script and you can use maple, xmaple, etc.

    Remember that if you tell the installer to create a new directory, it will create that directory under the emulation root (for example if you tell it to install under /usr/local/maple, it will actually create /usr/pkg/emul/linux/usr/local/maple).

  • Mozilla - FreeBSD(x86)
  • Mozilla - Linux(x86)
  • Netscape - BSDI(x86)
  • Netscape - Linux(x86)
  • Netscape - Solaris(x86)
  • Neverwinternights dedicated server - Linux(x86)
  • Perforce - FreeBSD(x86)
  • Planmaker - Linux(x86)
  • Realplayer 5, 7 - Linux(x86)
  • sqlplus Oracle client - Solaris(x86)
  • StarOffice 5.1a - Linux(x86) (requires NetBSD 1.5 or later)
  • Textmaker - Linux(x86)
  • Quake 1, 2, 3 - Linux(x86)
  • VMWare ESX/GSX Server - Linux(x86)
  • WordPerfect 8, 8.1 - Linux(x86)
  • Oracle Oracle 9.2.0.4 - Linux(x86) - see http://www.telefonica.net/web2/joseyluis/
luna68k
mac68k
macppc
mipsco
mvme68k
news68k
newsmips
next68k
ofppc
pc532
pmax
prep
sandpoint
sgimips
sh3
sparc
  • Acroread3 - SunOS(sparc)
  • Netscape - Solaris(sparc)
  • Networker - SunOS(sparc)
  • "Most" of the SunOS(sparc) userland. Kernel grovellers will not usually work.
sparc64
  • "Most" of the SunOS(sparc) userland. Kernel grovellers will not usually work.
sun3
vax
  • The userland that comes with DEC SVR3 via (yes!) iBCS2.
x68k

Which applications have been reported to not work on my machine? (top)

NetBSD runs on many CPUs and hardware platforms, for specific information, please find yours in the list below. If you have additional applications to report, please let us know.

In some cases, foreign applications require features not available in the emulation layer provided by earlier NetBSD releases. This usually happens when a foreign OS implements new syscalls and application authors change their applications to require their availability. Where an application is listed below with the phrase 'last unsupported version', all later NetBSD releases are able to run the application.

alpha
amiga
arc
arm26
arm32
atari
bebox
cobalt
dreamcast
hp300
hpcmips
hpcsh
i386
  • eWnn(Japanese/English translator) - Linux(x86) (requires Mule 2.3, SEGVs)
  • Honyaku-Damasi (Japanese/English translator) - Linux(x86)
  • Ichitaro ARK for Java (Japanese word processor) - Linux(x86) (needs JSDK1.2.2)
  • Objectivity - Linux(x86) (coredumps creating database)
  • Oracle - Linux(x86) (SEGV in install)
  • Shade Preview - Linux(x86) (may need RedHat shared libs)
  • StarOffice 5.1a - Linux(x86) (last unsupported version, NetBSD 1.4.x)
  • Wnn6 Ver3 - Linux(x86) (can't open a needed symlink)
luna68k
mac68k
macppc
mipsco
mvme68k
news68k
newsmips
next68k
ofppc
pc532
pmax
prep
sandpoint
sgimips
sh3
sparc
  • Acroread4 - Solaris(sparc)
sparc64
sun3
vax
x68k

Back to  NetBSD Documentation

(contact us)   Generated from %NetBSD: compat.xml,v 1.14 2006/03/05 16:40:07 jschauma Exp %
Copyright © 1994-2006 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.
NetBSD® is a registered trademark of The NetBSD Foundation, Inc.