Date: Sat, 15 Mar 2014 04:26:48 +0000 (UTC) From: Warren Block <wblock@FreeBSD.org> To: doc-committers@freebsd.org, svn-doc-all@freebsd.org, svn-doc-head@freebsd.org Subject: svn commit: r44239 - head/en_US.ISO8859-1/books/handbook/linuxemu Message-ID: <201403150426.s2F4Qm3P069381@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: wblock Date: Sat Mar 15 04:26:47 2014 New Revision: 44239 URL: http://svnweb.freebsd.org/changeset/doc/44239 Log: Whitespace-only fixes, translators please ignore. Modified: head/en_US.ISO8859-1/books/handbook/linuxemu/chapter.xml Modified: head/en_US.ISO8859-1/books/handbook/linuxemu/chapter.xml ============================================================================== --- head/en_US.ISO8859-1/books/handbook/linuxemu/chapter.xml Sat Mar 15 03:47:56 2014 (r44238) +++ head/en_US.ISO8859-1/books/handbook/linuxemu/chapter.xml Sat Mar 15 04:26:47 2014 (r44239) @@ -4,25 +4,48 @@ $FreeBSD$ --> -<chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="linuxemu"> - <info><title>&linux; Binary Compatibility</title> +<chapter xmlns="http://docbook.org/ns/docbook" + xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" + xml:id="linuxemu"> + + <info> + <title>&linux; Binary Compatibility</title> + <authorgroup> - <author><personname><firstname>Jim</firstname><surname>Mock</surname></personname><contrib>Restructured and parts updated by </contrib></author> + <author> + <personname> + <firstname>Jim</firstname> + <surname>Mock</surname> + </personname> + <contrib>Restructured and parts updated by </contrib> + </author> <!-- 22 Mar 2000 --> </authorgroup> + <authorgroup> - <author><personname><firstname>Brian N.</firstname><surname>Handy</surname></personname><contrib>Originally contributed by </contrib></author> - <author><personname><firstname>Rich</firstname><surname>Murphey</surname></personname></author> + <author> + <personname> + <firstname>Brian N.</firstname> + <surname>Handy</surname> + </personname> + <contrib>Originally contributed by </contrib> + </author> + + <author> + <personname> + <firstname>Rich</firstname> + <surname>Murphey</surname> + </personname> + </author> </authorgroup> </info> - - <sect1 xml:id="linuxemu-synopsis"> <title>Synopsis</title> - <indexterm><primary>Linux binary - compatibility</primary></indexterm> + <indexterm> + <primary>Linux binary compatibility</primary> + </indexterm> <indexterm> <primary>binary compatibility</primary> <secondary>Linux</secondary> @@ -43,6 +66,7 @@ calls, such as enabling virtual 8086 mode.</para> <para>After reading this chapter, you will know:</para> + <itemizedlist> <listitem> <para>How to enable &linux; binary compatibility on a &os; @@ -93,12 +117,12 @@ <screen>&prompt.root; <userinput>cd /usr/ports/emulators/linux_base-f10</userinput> &prompt.root; <userinput>make install distclean</userinput></screen> - <para>Once the port is installed, enable &linux; binary - compatibility by loading the <literal>linux</literal> - module. Type the following as - <systemitem class="username">root</systemitem>:</para> + <para>Once the port is installed, enable &linux; binary + compatibility by loading the <literal>linux</literal> module. + Type the following as + <systemitem class="username">root</systemitem>:</para> - <screen>&prompt.root; <userinput>kldload linux</userinput></screen> + <screen>&prompt.root; <userinput>kldload linux</userinput></screen> <para>In order for &linux; compatibility to always be enabled at boot time, add the following line to @@ -120,26 +144,26 @@ Id Refs Address Size Name </indexterm> <para>Users who prefer to statically link &linux; binary - compatibility into the kernel should add <literal>options - COMPAT_LINUX</literal> to the custom kernel configuration - file. Compile and install the new kernel as described in <xref linkend="kernelconfig"/>.</para> + compatibility into the kernel should add + <literal>options COMPAT_LINUX</literal> to the custom kernel + configuration file. Compile and install the new kernel as + described in <xref linkend="kernelconfig"/>.</para> <sect2 xml:id="linuxemu-libs-manually"> <title>Installing Libraries Manually</title> <para>While using the Ports Collection is recommended, &linux; libraries can be installed manually. The &linux; shared - libraries required by a program and the runtime linker - should be copied to <filename>/compat/linux</filename>. Any shared - libraries opened by &linux; programs run under &os; will - look in this directory first. For example, if a &linux; - program loads <filename>/lib/libc.so</filename>, &os; will - first try to open - <filename>/compat/linux/lib/libc.so</filename>, and if that - does not exist, it will then try - <filename>/lib/libc.so</filename>. Shared libraries should - be installed to <filename>/compat/linux/lib</filename> rather than - to the paths that the &linux; <command>ld.so</command> + libraries required by a program and the runtime linker should + be copied to <filename>/compat/linux</filename>. Any shared + libraries opened by &linux; programs run under &os; will look + in this directory first. For example, if a &linux; program + loads <filename>/lib/libc.so</filename>, &os; will first try + to open <filename>/compat/linux/lib/libc.so</filename>, and if + that does not exist, it will then try + <filename>/lib/libc.so</filename>. Shared libraries should be + installed to <filename>/compat/linux/lib</filename> rather + than to the paths that the &linux; <command>ld.so</command> reports.</para> <para>Generally, one will need to look for the shared @@ -152,13 +176,16 @@ Id Refs Address Size Name <sect3> <title>How to Install Additional Shared Libraries</title> - <indexterm><primary>shared libraries</primary></indexterm> + <indexterm> + <primary>shared libraries</primary> + </indexterm> <para>If the <literal>linux_base</literal> port is installed and an application still complains about missing shared - libraries, there are two methods <systemitem class="username">root</systemitem> - can use to determine which shared libraries the &linux; - binaries need.</para> + libraries, there are two methods + <systemitem class="username">root</systemitem> can use to + determine which shared libraries the &linux; binaries + need.</para> <para>If a &linux; system is available, determine which shared libraries the application needs, and copy them to the &os; @@ -175,7 +202,9 @@ libXt.so.3 (DLL Jump 3.1) => /usr/X11 libX11.so.3 (DLL Jump 3.1) => /usr/X11/lib/libX11.so.3.1.0 libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29</screen> - <indexterm><primary>symbolic links</primary></indexterm> + <indexterm> + <primary>symbolic links</primary> + </indexterm> <para>Copy all the files in the last column into <filename>/compat/linux</filename> on the &os; system, with the names in the first column as @@ -256,7 +285,9 @@ Abort</screen> <screen>&prompt.user; <userinput>brandelf -t Linux my-linux-elf-binary</userinput></screen> - <indexterm><primary>GNU toolchain</primary></indexterm> + <indexterm> + <primary>GNU toolchain</primary> + </indexterm> <para>Since the GNU toolchain places the appropriate branding information into ELF binaries automatically, this step is usually not necessary.</para> @@ -271,7 +302,8 @@ Abort</screen> <para>In order to install a &linux; RPM-based application, first install the <package>archivers/rpm2cpio</package> package or - port. Once installed, <systemitem class="username">root</systemitem> can use this + port. Once installed, + <systemitem class="username">root</systemitem> can use this command to install a <filename>.rpm</filename> as follows:</para> @@ -298,22 +330,24 @@ Abort</screen> <programlisting>order hosts, bind multi on</programlisting> - <para>This order specifies that - <filename>/etc/hosts</filename> is searched first and DNS - is searched second. When + <para>This order specifies that <filename>/etc/hosts</filename> + is searched first and DNS is searched second. When <filename>/compat/linux/etc/host.conf</filename> does not exist, &linux; applications use <filename>/etc/host.conf</filename> and complain about the - incompatible &os; syntax. Remove - <literal>bind</literal> if a name server is not configured - using <filename>/etc/resolv.conf</filename>.</para> + incompatible &os; syntax. Remove <literal>bind</literal> if a + name server is not configured using + <filename>/etc/resolv.conf</filename>.</para> </sect2> </sect1> -<?ignore While the installer works, the binaries do not. As of Oct 2013, Linux - emulation is 32-bit but the trial version of Mathematica is only - available as 64-bit. This section should be revisited if Linux + <?ignore + + While the installer works, the binaries do not. As of Oct 2013, + Linux emulation is 32-bit but the trial version of Mathematica is + only available as 64-bit. This section should be revisited if Linux emulation gets 64-bit binary support. + <sect1 id="linuxemu-mathematica"> <sect1info> <authorgroup> @@ -332,11 +366,11 @@ multi on</programlisting> <secondary><application>Mathematica</application></secondary> </indexterm> - <para>This section describes the process of installing the - &linux; version of <application>&mathematica; 9.X</application> - onto a &os; system. <application>&mathematica;</application> - is a commercial, computational software program used in - scientific, engineering, and mathematical fields. A 30 day trial version is + <para>This section describes the process of installing the &linux; + version of <application>&mathematica; 9.X</application> onto a + &os; system. <application>&mathematica;</application> is a + commercial, computational software program used in scientific, + engineering, and mathematical fields. A 30 day trial version is available for download from <ulink url="http://www.wolfram.com/mathematica/">wolfram.com/mathematica</ulink>.</para> @@ -347,11 +381,11 @@ multi on</programlisting> <filename role="package">textproc/linux-f10-aspell</filename> package or port is installed and that the &man.linprocfs.5; file system is mounted.</para> - + <screen>&prompt.root; <userinput>sysctl kern.fallback_elf_brand=3</userinput></screen> - <para>&os; will now assume that unbranded ELF binaries - use the &linux; <acronym>ABI</acronym> which should allow the + <para>&os; will now assume that unbranded ELF binaries use the + &linux; <acronym>ABI</acronym> which should allow the installer to execute from the CDROM.</para> <para>The downloaded file will be saved to @@ -375,7 +409,6 @@ Enter the installation directory, or pre Now installing... *********************** Installation complete.</programlisting> - </sect2> <sect2> @@ -387,8 +420,7 @@ Installation complete.</programlisting> fonts to be installed locally. This means that these fonts need to be copied from the CDROM or from a host with <application>&mathematica;</application> installed to the - local machine. These fonts are normally stored in - <filename + local machine. These fonts are normally stored in <filename class="directory">/cdrom/Unix/Files/SystemFiles/Fonts</filename> on the CDROM, or <filename class="directory">/usr/local/mathematica/SystemFiles/Fonts</filename> @@ -441,9 +473,9 @@ Installation complete.</programlisting> --> <!-- - As of October 2013, the trial version is only available in the - Professional and Academic editions (not the Student or Personal - editions) and requires a contact with a product specialist before + As of October 2013, the trial version is only available in the + Professional and Academic editions (not the Student or Personal + editions) and requires a contact with a product specialist before the evaluation download link is made available. <sect1 id="linuxemu-maple"> <sect1info> @@ -492,11 +524,10 @@ Installation complete.</programlisting> <step> <para>Install the <application>FLEXlm</application> license - manager by running the - <filename>INSTALL_LIC</filename> install shell script that - comes with <application>&maple;</application>. Specify - the primary hostname for the machine for the license - server.</para> + manager by running the <filename>INSTALL_LIC</filename> + install shell script that comes with + <application>&maple;</application>. Specify the primary + hostname for the machine for the license server.</para> </step> <step> @@ -504,7 +535,7 @@ Installation complete.</programlisting> <filename>/usr/local/maple/bin/maple.system.type</filename> with the following:</para> - + <programlisting> ----- snip ------------------ *** maple.system.type.orig Sun Jul 8 16:35:33 2001 -- - maple.system.type Sun Jul 8 16:35:51 2001 @@ -524,14 +555,16 @@ Installation complete.</programlisting> <literal>"FreeBSD"|\</literal>.</para> <para>This patch instructs <application>&maple;</application> - to recognize &os; as a type of &linux; - system. The <filename>bin/maple</filename> shell script - calls the <filename>bin/maple.system.type</filename> shell - script which in turn calls <command>uname -a</command> to - find out the operating system name. Depending on the OS - name it will find out which binaries to use.</para></step> + to recognize &os; as a type of &linux; system. The + <filename>bin/maple</filename> shell script calls the + <filename>bin/maple.system.type</filename> shell script + which in turn calls <command>uname -a</command> to find out + the operating system name. Depending on the OS name it will + find out which binaries to use.</para> + </step> - <step><para>Start the license server.</para> + <step> + <para>Start the license server.</para> <para>The following script, installed as <filename>/usr/local/rtc/rc.d/lmgrd</filename> is a @@ -562,28 +595,31 @@ stop) esac exit 0 - ----- snip ------------</programlisting></step> - + ----- snip ------------</programlisting> + </step> - <step><para>Test that - <application>&maple;</application> starts:</para> + <step> + <para>Test that <application>&maple;</application> + starts:</para> - <screen>&prompt.user; <userinput>cd /usr/local/maple/bin</userinput> + <screen>&prompt.user; <userinput>cd /usr/local/maple/bin</userinput> &prompt.user; <userinput>./xmaple</userinput></screen> - <para>Once everything is working, consider writing - Maplesoft to let them know you would like a native &os; - version!</para></step> - </procedure> + <para>Once everything is working, consider writing Maplesoft + to let them know you would like a native &os; + version!</para> + </step> + </procedure> - <sect2> - <title>Common Pitfalls</title> + <sect2> + <title>Common Pitfalls</title> - <itemizedlist> - <listitem><para><command>lmgrd</command> is known to be - picky about the license file and to dump core if there - are any problems. A correct license file should look - like this:</para> + <itemizedlist> + <listitem> + <para><command>lmgrd</command> is known to be picky about + the license file and to dump core if there are any + problems. A correct license file should look like + this:</para> <programlisting># ======================================================= @@ -606,23 +642,27 @@ FEATURE Maple maplelmg 2000.0831 permane <para>Editing the license file works as long as the <quote>FEATURE</quote> line is not edited. That line is - protected by the license key.</para></listitem> - </itemizedlist> - </sect2> - </sect1> - --> - <!-- - As of October, 2013, the Linux version of Matlab is only available for 64-bit. - <sect1 id="linuxemu-matlab"> - <sect1info> - <authorgroup> - <author> - <firstname>Dan</firstname> - <surname>Pelleg</surname> - <contrib>Contributed by </contrib> - </author> - </authorgroup> - </sect1info> + protected by the license key.</para> + </listitem> + </itemizedlist> + </sect2> + </sect1> + --> + <!-- + As of October, 2013, the Linux version of Matlab is only available + for 64-bit. + + <sect1 id="linuxemu-matlab"> + <sect1info> + <authorgroup> + <author> + <firstname>Dan</firstname> + <surname>Pelleg</surname> + <contrib>Contributed by </contrib> + </author> + </authorgroup> + </sect1info> + <title>Installing &matlab;</title> <indexterm> @@ -631,9 +671,9 @@ FEATURE Maple maplelmg 2000.0831 permane </indexterm> <para>This document describes the process of installing the - &linux; version of <application>&matlab; version - 6.5</application> onto a &os; system. It works quite well, - with the exception of the + &linux; version of + <application>&matlab; version 6.5</application> onto a &os; + system. It works quite well, with the exception of the <application>&java.virtual.machine;</application> which is described further in <xref linkend="matlab-jre"/>.</para> @@ -790,9 +830,10 @@ exit 0</programlisting> </procedure> <tip> - <para>Depending on the version of <filename - role="package">emulators/linux_base</filename>, running - this script may result in errors. To avoid errors, edit + <para>Depending on the version of + <filename role="package">emulators/linux_base</filename>, + running this script may result in errors. To avoid errors, + edit <filename>/compat/linux/usr/local/matlab/bin/matlab</filename>, and change the line that says:</para> @@ -818,8 +859,9 @@ exit 0</programlisting> <programlisting>! $MATLAB/bin/finish.sh</programlisting> - <note><para>The <literal>$MATLAB</literal> is - literal.</para></note> + <note> + <para>The <literal>$MATLAB</literal> is literal.</para> + </note> <tip> <para>The same directory contains @@ -827,15 +869,15 @@ exit 0</programlisting> <filename>finishdlg.m</filename>, which allow the workspace to be saved before quitting. If either file is used, insert the line above immediately after the - <literal>save</literal> command.</para></tip> - </step> + <literal>save</literal> command.</para> + </tip> + </step> - <step> - <para>Create - <filename>$MATLAB/bin/finish.sh</filename> which - contains the following:</para> + <step> + <para>Create <filename>$MATLAB/bin/finish.sh</filename> + which contains the following:</para> - <programlisting>#!/compat/linux/bin/sh + <programlisting>#!/compat/linux/bin/sh (sleep 5; killall -1 matlab_helper) & exit 0</programlisting> </step> @@ -857,9 +899,10 @@ exit 0</programlisting> </sect1> <sect1 id="linuxemu-oracle"> - While the Oracle website is unclear, the installation script is: You - are attempting to install 64-bit Oracle on a 32-bit operating system. - This is not supported and will not work. + While the Oracle website is unclear, the installation script is: + You are attempting to install 64-bit Oracle on a 32-bit operating + system. This is not supported and will not work. + <sect1info> <authorgroup> <author> @@ -869,6 +912,7 @@ exit 0</programlisting> </author> </authorgroup> </sect1info> + <title>Installing &oracle;</title> <indexterm> @@ -890,8 +934,9 @@ exit 0</programlisting> <para>To run the intelligent agent, install the Red Hat Tcl package: <filename>tcl-8.0.3-20.i386.rpm</filename>. The - general command for installing RPMs with the <filename - role='package'>archivers/rpm</filename> port is:</para> + general command for installing RPMs with the + <filename role='package'>archivers/rpm</filename> port + is:</para> <screen>&prompt.root; <userinput>rpm -i --ignoreos --root /compat/linux --dbpath /var/lib/rpm <replaceable>package</replaceable></userinput></screen> @@ -910,7 +955,9 @@ exit 0</programlisting> <sect3 id="linuxemu-kernel-tuning"> <title>Kernel Tuning</title> - <indexterm><primary>kernel tuning</primary></indexterm> + <indexterm> + <primary>kernel tuning</primary> + </indexterm> <para>As described in the <application>&oracle;</application> installation guide, the maximum size of shared memory needs @@ -965,26 +1012,23 @@ options SYSVMSG #SysV interprocess commu <thead> <row> <entry>Variable</entry> - <entry>Value</entry> </row> </thead> + <tbody> <row> <entry><envar>LD_LIBRARY_PATH</envar></entry> - <entry><literal>$ORACLE_HOME/lib</literal></entry> </row> <row> <entry><envar>CLASSPATH</envar></entry> - <entry><literal>$ORACLE_HOME/jdbc/lib/classes111.zip</literal></entry> </row> <row> <entry><envar>PATH</envar></entry> - <entry><literal>/compat/linux/bin /compat/linux/sbin /compat/linux/usr/bin @@ -1077,22 +1121,22 @@ export PATH</programlisting> # # Define variables to be used in this script</programlisting> - <para>If <application>&oracle;</application> is not installed - from CD, patch the source for <filename>root.sh</filename>. - It is called <filename>rthd.sh</filename> and is located in - <filename class="directory">orainst</filename> in the source - tree.</para> - </sect3> - - <sect3 id="linuxemu-patch-tcl"> - <title>Patching <filename>genclntsh</filename></title> + <para>If <application>&oracle;</application> is not installed + from CD, patch the source for <filename>root.sh</filename>. + It is called <filename>rthd.sh</filename> and is located in + <filename class="directory">orainst</filename> in the source + tree.</para> + </sect3> + + <sect3 id="linuxemu-patch-tcl"> + <title>Patching <filename>genclntsh</filename></title> + + <para>The script <command>genclntsh</command> is used to create + a single shared client library when building the demos. Apply + the following patch to comment out the definition of + <envar>PATH</envar>:</para> - <para>The script <command>genclntsh</command> is used to - create a single shared client library when building the - demos. Apply the following patch to comment out the - definition of <envar>PATH</envar>:</para> - - <programlisting>*** bin/genclntsh.orig Wed Sep 30 07:37:19 1998 + <programlisting>*** bin/genclntsh.orig Wed Sep 30 07:37:19 1998 --- bin/genclntsh Tue Dec 22 15:36:49 1998 *************** *** 32,38 **** @@ -1120,7 +1164,7 @@ export PATH</programlisting> running on &linux;.</para> </sect2> </sect1> -?> + ?> <sect1 xml:id="linuxemu-advanced"> <title>Advanced Topics</title> @@ -1132,9 +1176,9 @@ export PATH</programlisting> <indexterm><primary>execution class loader</primary></indexterm> - <para>&os; has an abstraction called an <quote>execution class - loader</quote>. This is a wedge into the &man.execve.2; - system call.</para> + <para>&os; has an abstraction called an + <quote>execution class loader</quote>. This is a wedge into the + &man.execve.2; system call.</para> <para>Historically, the &unix; loader examined the magic number (generally the first 4 or 8 bytes of the file) to see if it was @@ -1144,8 +1188,8 @@ export PATH</programlisting> <para>If it was not the binary type for the system, the &man.execve.2; call returned a failure, and the shell attempted to start executing it as shell commands. The - assumption was a default of <quote>whatever the current shell - is</quote>.</para> + assumption was a default of + <quote>whatever the current shell is</quote>.</para> <para>Later, a hack was made for &man.sh.1; to examine the first two characters, and if they were <literal>:\n</literal>, it @@ -1155,9 +1199,13 @@ export PATH</programlisting> a fallback to the <literal>#!</literal> loader for running shell interpreters or shell scripts.</para> - <indexterm><primary>ELF</primary></indexterm> + <indexterm> + <primary>ELF</primary> + </indexterm> - <indexterm><primary>Solaris</primary></indexterm> + <indexterm> + <primary>Solaris</primary> + </indexterm> <para>For the &linux; <acronym>ABI</acronym> support, &os; sees the magic number as an ELF binary. The ELF loader looks for a @@ -1171,65 +1219,63 @@ export PATH</programlisting> <screen>&prompt.root; <userinput>brandelf -t Linux file</userinput></screen> - <indexterm> - <primary>ELF</primary> - <secondary>branding</secondary> - </indexterm> + <indexterm> + <primary>ELF</primary> + <secondary>branding</secondary> + </indexterm> - <para>When the ELF loader sees the <literal>Linux</literal> - brand, the loader replaces a pointer in the - <literal>proc</literal> structure. All system calls are - indexed through this pointer. In addition, the process is - flagged for special handling of the trap vector for the signal - trampoline code, and several other (minor) fix-ups that are - handled by the &linux; kernel module.</para> - - <para>The &linux; system call vector contains, among other - things, a list of <literal>sysent[]</literal> entries whose - addresses reside in the kernel module.</para> - - <para>When a system call is called by the &linux; binary, the - trap code dereferences the system call function pointer off - the <literal>proc</literal> structure, and gets the &linux;, - not the &os;, system call entry points.</para> - - <para>&linux; mode dynamically <emphasis>reroots</emphasis> - lookups. This is, in effect, equivalent to the - <option>union</option> option to file system mounts. First, - an attempt is made to lookup the file in <filename - class="directory">/compat/linux/<replaceable>original-path</replaceable></filename>. - If that fails, the lookup is done in - <filename - class="directory">/<replaceable>original-path</replaceable></filename>. - This makes sure that binaries that require other binaries can - run. For example, the &linux; toolchain can all run under - &linux; <acronym>ABI</acronym> support. It also means that - the &linux; binaries can load and execute &os; binaries, if - there are no corresponding &linux; binaries present, and that - a &man.uname.1; command can be placed in the - <filename>/compat/linux</filename> directory - tree to ensure that the &linux; binaries can not tell they are - not running on &linux;.</para> - - <para>In effect, there is a &linux; kernel in the &os; kernel. - The various underlying functions that implement all of the - services provided by the kernel are identical to both the - &os; system call table entries, and the &linux; system call - table entries: file system operations, virtual memory - operations, signal delivery, and System V IPC. The only - difference is that &os; binaries get the &os; - <emphasis>glue</emphasis> functions, and &linux; binaries get - the &linux; <emphasis>glue</emphasis> functions. The &os; - <emphasis>glue</emphasis> functions are statically linked into - the kernel, and the &linux; <emphasis>glue</emphasis> - functions can be statically linked, or they can be accessed - via a kernel module.</para> - - <para>Technically, this is not really emulation, it is an - <acronym>ABI</acronym> implementation. It is sometimes called - <quote>&linux; emulation</quote> because the implementation - was done at a time when there was no other word to describe - what was going on. Saying that &os; ran &linux; binaries was - not true, since the code was not compiled in.</para> - </sect1> - </chapter> + <para>When the ELF loader sees the <literal>Linux</literal> + brand, the loader replaces a pointer in the + <literal>proc</literal> structure. All system calls are indexed + through this pointer. In addition, the process is flagged for + special handling of the trap vector for the signal trampoline + code, and several other (minor) fix-ups that are handled by the + &linux; kernel module.</para> + + <para>The &linux; system call vector contains, among other things, + a list of <literal>sysent[]</literal> entries whose addresses + reside in the kernel module.</para> + + <para>When a system call is called by the &linux; binary, the trap + code dereferences the system call function pointer off the + <literal>proc</literal> structure, and gets the &linux;, not the + &os;, system call entry points.</para> + + <para>&linux; mode dynamically <emphasis>reroots</emphasis> + lookups. This is, in effect, equivalent to the + <option>union</option> option to file system mounts. First, an + attempt is made to lookup the file in <filename + class="directory">/compat/linux/<replaceable>original-path</replaceable></filename>. + If that fails, the lookup is done in <filename + class="directory">/<replaceable>original-path</replaceable></filename>. + This makes sure that binaries that require other binaries can + run. For example, the &linux; toolchain can all run under + &linux; <acronym>ABI</acronym> support. It also means that the + &linux; binaries can load and execute &os; binaries, if there + are no corresponding &linux; binaries present, and that a + &man.uname.1; command can be placed in the + <filename>/compat/linux</filename> directory tree to ensure that + the &linux; binaries can not tell they are not running on + &linux;.</para> + + <para>In effect, there is a &linux; kernel in the &os; kernel. + The various underlying functions that implement all of the + services provided by the kernel are identical to both the &os; + system call table entries, and the &linux; system call table + entries: file system operations, virtual memory operations, + signal delivery, and System V IPC. The only difference is that + &os; binaries get the &os; <emphasis>glue</emphasis> functions, + and &linux; binaries get the &linux; <emphasis>glue</emphasis> + functions. The &os; <emphasis>glue</emphasis> functions are + statically linked into the kernel, and the &linux; + <emphasis>glue</emphasis> functions can be statically linked, or + they can be accessed via a kernel module.</para> + + <para>Technically, this is not really emulation, it is an + <acronym>ABI</acronym> implementation. It is sometimes called + <quote>&linux; emulation</quote> because the implementation was + done at a time when there was no other word to describe what was + going on. Saying that &os; ran &linux; binaries was not true, + since the code was not compiled in.</para> + </sect1> +</chapter>
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201403150426.s2F4Qm3P069381>