[BACK]Return to compat.html CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / htdocs / docs

File: [cvs.NetBSD.org] / htdocs / docs / compat.html (download) (as text)

Revision 1.64, Mon Apr 19 07:19:25 2021 UTC (5 months, 4 weeks ago) by nia
Branch: MAIN
CVS Tags: HEAD
Changes since 1.63: +1 -1 lines

regen

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<meta name="generator" content="Website XSL Stylesheet V2.6.0">
<link rel="home" href="../." title="Welcome to The NetBSD Project: Of course it runs NetBSD.">
<link rel="up" href="../docs/." title="NetBSD Documentation">
<link rel="previous" href="../docs/bsd/." title="Historic BSD information">
<link rel="next" href="../docs/elf.html" title="NetBSD ELF FAQ">
<link rel="first" href="../docs/Hardware/." title="Hardware Documentation">
<link rel="last" href="../docs/x/." title="NetBSD Documentation: The X Window System">
<link rel="stylesheet" href="../global.css" type="text/css">
<link rel="stylesheet" href="../donations/thermo/fundraiser.css" type="text/css">



<title>NetBSD Binary Emulation</title>
</head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
<body class="website"><div class="webpage">
<a name="docs-compat"></a><div id="top"><a href="#mainContent" id="skiplink" tabindex="1">Skip to main content.</a></div>
<input id="hamburger" type="checkbox"><label class="menuicon" for="hamburger"><span></span><span></span><span></span></label><div id="navBar" role="navigation">
<div id="centralHeader"><div id="logo">
<a href="../"><img id="projectLogo" alt="" height="120" src="../images/NetBSD-smaller-tb.png"></a><a href="/"><div id="fundraiser">
<br><div id="fundraiser-amount"><div id="fundraiser-raised"></div></div>
</div></a>
</div></div>
<span class="doNotDisplay">
	  Navigation:
	</span><ul>
<li>
<a href="../">
	  Home</a><ul>
<li><a href="../changes/">
	    Recent changes</a></li>
<li><a href="//blog.NetBSD.org/">
	    NetBSD blog</a></li>
<li><a href="../gallery/presentations/">
	    Presentations</a></li>
</ul>
</li>
<li>
<a href="../about/">
	  About</a><ul>
<li><a href="../people/developers.html">
	    Developers</a></li>
<li><a href="../gallery/">
	    Gallery</a></li>
<li><a href="//wiki.NetBSD.org/ports/">
	    Ports</a></li>
<li><a href="//www.pkgsrc.org/">
	    Packages</a></li>
</ul>
</li>
<li>
<a href="../docs/">
	  Documentation</a><ul>
<li><a href="../docs/misc/index.html">
	    FAQ &amp; HOWTOs</a></li>
<li><a href="../docs/guide/en/">
	    The Guide</a></li>
<li><a href="//man.NetBSD.org/">
	    Manual pages</a></li>
<li><a href="//wiki.NetBSD.org/">
	    Wiki</a></li>
</ul>
</li>
<li>
<a href="../support/">
	  Support</a><ul>
<li><a href="/community/">
	    Community</a></li>
<li><a href="/mailinglists/">
	    Mailing lists</a></li>
<li><a href="../support/send-pr.html">
	    Bug reports</a></li>
<li><a href="../support/security/">
	    Security</a></li>
</ul>
</li>
<li>
<a href="../developers/">
	  Developers</a><ul>
<li><a href="http://cvsweb.NetBSD.org/">
	    CVSWeb</a></li>
<li><a href="//anonhg.NetBSD.org/">
	    Mercurial</a></li>
<li><a href="//nxr.NetBSD.org/">
	    Cross-reference</a></li>
<li><a href="//releng.NetBSD.org/">
	    Release engineering</a></li>
<li><a href="//wiki.NetBSD.org/projects/">
	    Projects list</a></li>
</ul>
</li>
</ul>
</div>
<div id="content"><div id="mainContent" class="fullWidth"><div class="rowOfBoxes">
<h1>NetBSD Binary Emulation</h1>
<h3 class="title"><a name="binary-emulation">Binary Emulation</a></h3>
<ul>
<li><a href="#what">What is Binary Emulation? Why does it exist?</a></li>
<li><a href="#how">How does it work?</a></li>
<li><a href="#performance">How well does it perform?</a></li>
<li><a href="#considerations">Any other considerations?</a></li>
<li><a href="#ports">Which OSs can I emulate on my machine?</a></li>
</ul>
<hr>
<h3 class="title">Binary Emulation</h3>
<h4 class="title">
<a name="what"></a>What is Binary Emulation? Why does it exist?</h4>
<p>
A large amount of Unix software is distributed in source-code format.
This means the authors actually provide the 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.
</p>
<p>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.
</p>
<p>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.
</p>
<p>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.
</p>
<p>Binary Emulation eliminates this forced linkage.
</p>

<h4 class="title">
<a name="how"></a>How does it work?</h4>
<p>
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.
</p>
<p>Every Unix and Unix-like system supplies a very similar set of these
system calls. They all have an OPEN for example.</p>
<p>
From system to system, the primary differences in syscalls will be in
the format of parameters passed to these calls. 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.
</p>
<p>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 ones NetBSD supports natively are ELF and a.out. NetBSD's
emulation knows how to handle the executable format for the emulated system. 
</p>
<p>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.
</p>

<h4 class="title">
<a name="performance"></a>How well does it perform?</h4>
<p>
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.  This
varies depending on which system calls a program uses. Most mappings take
&lt;1% of the time the actual syscall takes to run.
</p>

<h4 class="title">
<a name="considerations"></a>Any other considerations?</h4>
<p>
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, 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...
</p>

<pre class="programlisting">% file qwsv
qwsv: BSD/OS i386 compact demand paged executable
% file arp
arp: NetBSD/i386 demand paged dynamically linked executable</pre>

<p>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.
</p>
<p>For commercial systems, you may need to supply your own set of libraries.
See <code class="code">man -k compat</code> for a list, and <code class="code">man compat_<span class="emphasis"><em>os</em></span></code>
(where <span class="emphasis"><em>os</em></span> is the target OS) for some installation instructions:

</p>
<pre class="programlisting">% man -k compat
compat_linux(8) - setup procedure for running Linux binaries
compat_sunos(8) - setup procedure for m68k and sparc architectures
compat_ultrix(8) - setup procedure for Ultrix compatibility on mips and vax</pre>
<p>
</p>

<h4 class="title">
<a name="ports"></a>Which OSs can I emulate on my machine?</h4>
<p>
NetBSD supports emulation of several systems. Generally speaking, you can
run binaries from other unix operating systems which run on the same
hardware as your NetBSD system.
</p>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-aarch64"></a>aarch64</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">NetBSD 32bit</li></ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-alpha"></a>alpha</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Linux (Alpha)</li></ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-amd64"></a>amd64</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux 64bit</li>
<li class="listitem">Linux 32bit</li>
<li class="listitem">NetBSD 32bit</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-amiga"></a>amiga</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-atari"></a>atari</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-hp300"></a>hp300</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-i386"></a>i386</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Linux 32bit</li></ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-mac68k"></a>mac68k</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-mvme68k"></a>mvme68k</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-news68k"></a>news68k</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-next68k"></a>next68k</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-sgimips"></a>sgimips</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (mips)</li>
<li class="listitem">Ultrix (mips)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-sparc"></a>sparc</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">SunOS (sparc)</li></ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-sparc64"></a>sparc64</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">32-bit NetBSD/sparc (both ELF and a.out)</li>
<li class="listitem">SunOS (sparc)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-sun3"></a>sun3</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-vax"></a>vax</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">Ultrix</li></ul></div>
</div>

<div class="sect4">
<div class="titlepage"><div><div><h5 class="title">
<a name="emulation-x68k"></a>x68k</h5></div></div></div>

	<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Linux (m68k)</li>
<li class="listitem">SunOS (68k)</li>
</ul></div>
</div>
<hr>Back to em><a href=".">NetBSD Documentation</a></em>
</div></div></div>
<div class="navfoot"></div>
<div id="footer"><div id="footerContent"><center>
<span class="footfeed"><a href="//www.NetBSD.org/cgi-bin/feedback.cgi">
	  Contact</a> |
      </span><span class="footcopy"><a href="../about/disclaimer.html">
      Disclaimer</a> |

      <span class="copyright">Copyright 1994-2021 The NetBSD Foundation, Inc. </span>ALL RIGHTS RESERVED.<br>NetBSD<sup>/sup> is a registered trademark of The NetBSD
	Foundation, Inc.</span>
</center></div></div>
</div></body>
</html>