diff --git a/documentation/content/en/books/handbook/linuxemu/_index.adoc b/documentation/content/en/books/handbook/linuxemu/_index.adoc --- a/documentation/content/en/books/handbook/linuxemu/_index.adoc +++ b/documentation/content/en/books/handbook/linuxemu/_index.adoc @@ -11,7 +11,7 @@ --- [[linuxemu]] -= Linux(R) Binary Compatibility += Linux Binary Compatibility :doctype: book :toc: macro :toclevels: 1 @@ -51,35 +51,35 @@ [[linuxemu-synopsis]] == Synopsis -FreeBSD provides binary compatibility with Linux(R), allowing users to install and run most Linux(R) binaries on a FreeBSD system without having to first modify the binary. -It has even been reported that, in some situations, Linux(R) binaries perform better on FreeBSD than they do on Linux(R). +FreeBSD provides binary compatibility with Linux(R), allowing users to install and run most Linux binaries on a FreeBSD system without having to first modify the binary. +It has even been reported that, in some situations, Linux binaries perform better on FreeBSD than they do on Linux. -However, some Linux(R)-specific operating system features are not supported under FreeBSD. -For example, Linux(R) binaries will not work on FreeBSD if they overly use i386(TM) specific calls, such as enabling virtual 8086 mode. +However, some Linux-specific operating system features are not supported under FreeBSD. +For example, Linux binaries will not work on FreeBSD if they overly use i386(TM) specific calls, such as enabling virtual 8086 mode. [NOTE] ==== -Support for 64-bit binary compatibility with Linux(R) was added in FreeBSD 10.3. +Support for 64-bit binary compatibility with Linux was added in FreeBSD 10.3. ==== After reading this chapter, you will know: -* How to enable Linux(R) binary compatibility on a FreeBSD system. -* How to install additional Linux(R) shared libraries. -* How to install Linux(R) applications on a FreeBSD system. -* The implementation details of Linux(R) compatibility in FreeBSD. +* How to enable Linux binary compatibility on a FreeBSD system. +* How to install additional Linux shared libraries. +* How to install Linux applications on a FreeBSD system. +* The implementation details of Linux compatibility in FreeBSD. Before reading this chapter, you should: * Know how to install crossref:ports[ports,additional third-party software]. [[linuxemu-lbc-install]] -== Configuring Linux(R) Binary Compatibility +== Configuring Linux Binary Compatibility -By default, Linux(R) libraries are not installed and Linux(R) binary compatibility is not enabled. -Linux(R) libraries can either be installed manually or from the FreeBSD Ports Collection. +By default, Linux libraries are not installed and Linux binary compatibility is not enabled. +Linux libraries can either be installed manually or from the FreeBSD Ports Collection. -Before attempting to build the port, load the Linux(R) kernel module, otherwise the build will fail: +Before attempting to build the port, load the Linux kernel module, otherwise the build will fail: [source,shell] .... @@ -103,7 +103,7 @@ 7 1 0xc24db000 d000 linux.ko .... -The package:emulators/linux_base-c7[] package or port is the easiest way to install a base set of Linux(R) libraries and binaries on a FreeBSD system. +The package:emulators/linux_base-c7[] package or port is the easiest way to install a base set of Linux libraries and binaries on a FreeBSD system. To install the port: [source,shell] @@ -111,7 +111,7 @@ # pkg install emulators/linux_base-c7 .... -For Linux(R) compatibility to be enabled at boot time, add this line to [.filename]#/etc/rc.conf#: +For Linux compatibility to be enabled at boot time, add this line to [.filename]#/etc/rc.conf#: [.programlisting] .... @@ -120,7 +120,7 @@ On 64-bit machines, [.filename]#/etc/rc.d/abi# will automatically load the module for 64-bit emulation. -Since the Linux(R) binary compatibility layer has gained support for running both 32- and 64-bit Linux(R) binaries (on 64-bit x86 hosts), it is no longer possible to link the emulation functionality statically into a custom kernel. +Since the Linux binary compatibility layer has gained support for running both 32- and 64-bit Linux binaries (on 64-bit x86 hosts), it is no longer possible to link the emulation functionality statically into a custom kernel. For some applications, [.filename]#/compat/linux/proc#, [.filename]#/compat/linux/sys#, and [.filename]#/compat/linux/dev/shm# may need to be mounted. Add this line to [.filename]#/etc/fstab#: @@ -143,10 +143,10 @@ [[linuxemu-libs-manually]] === Installing Additional Libraries Manually -If a Linux(R) application complains about missing shared libraries after configuring Linux(R) binary compatibility, determine which shared libraries the Linux(R) binary needs and install them manually. +If a Linux application complains about missing shared libraries after configuring Linux binary compatibility, determine which shared libraries the Linux binary needs and install them manually. -From a Linux(R) system, `ldd` can be used to determine which shared libraries the application needs. -For example, to check which shared libraries `linuxdoom` needs, run this command from a Linux(R) system that has Doom installed: +From a Linux system, `ldd` can be used to determine which shared libraries the application needs. +For example, to check which shared libraries `linuxdoom` needs, run this command from a Linux system that has Doom installed: [source,shell] .... @@ -156,7 +156,7 @@ libc.so.4 (DLL Jump 4.5pl26) => /lib/libc.so.4.6.29 .... -Then, copy all the files in the last column of the output from the Linux(R) system into [.filename]#/compat/linux# on the FreeBSD system. +Then, copy all the files in the last column of the output from the Linux system into [.filename]#/compat/linux# on the FreeBSD system. Once copied, create symbolic links to the names in the first column. This example will result in the following files on the FreeBSD system: @@ -170,7 +170,7 @@ /compat/linux/lib/libc.so.4 -> libc.so.4.6.29 .... -If a Linux(R) shared library already exists with a matching major revision number to the first column of the `ldd` output, +If a Linux shared library already exists with a matching major revision number to the first column of the `ldd` output, it does not need to be copied to the file named in the last column, as the existing library should work. It is advisable to copy the shared library if it is a newer version, though. The old one can be removed, as long as the symbolic link points to the new one. @@ -199,10 +199,10 @@ /compat/linux/lib/libc.so.4 -> libc.so.4.6.29 .... -Generally, one will need to look for the shared libraries that Linux(R) binaries depend on only the first few times that a Linux(R) program is installed on FreeBSD. -After a while, there will be a sufficient set of Linux(R) shared libraries on the system to be able to run newly installed Linux(R) binaries without any extra work. +Generally, one will need to look for the shared libraries that Linux binaries depend on only the first few times that a Linux program is installed on FreeBSD. +After a while, there will be a sufficient set of Linux shared libraries on the system to be able to run newly installed Linux binaries without any extra work. -=== Installing Linux(R) ELF Binaries +=== Installing Linux ELF Binaries ELF binaries sometimes require an extra step. When an unbranded ELF binary is executed, it will generate an error message: @@ -214,7 +214,7 @@ Abort .... -To help the FreeBSD kernel distinguish between a FreeBSD ELF binary and a Linux(R) binary, use man:brandelf[1]: +To help the FreeBSD kernel distinguish between a FreeBSD ELF binary and a Linux binary, use man:brandelf[1]: [source,shell] .... @@ -223,9 +223,9 @@ Since the GNU toolchain places the appropriate branding information into ELF binaries automatically, this step is usually not necessary. -=== Installing a Linux(R) RPM Based Application +=== Installing a Linux RPM Based Application -To install a Linux(R) RPM-based application, first install the package:archivers/rpm4[] package or port. +To install a Linux RPM-based application, first install the package:archivers/rpm4[] package or port. Once installed, `root` can use this command to install a [.filename]#.rpm#: [source,shell] @@ -256,13 +256,13 @@ .... This specifies that [.filename]#/etc/hosts# is searched first and DNS is searched second. -When [.filename]#/compat/linux/etc/host.conf# does not exist, Linux(R) applications use [.filename]#/etc/host.conf# and complain about the incompatible FreeBSD syntax. +When [.filename]#/compat/linux/etc/host.conf# does not exist, Linux applications use [.filename]#/etc/host.conf# and complain about the incompatible FreeBSD syntax. Remove `bind` if a name server is not configured using [.filename]#/etc/resolv.conf#. [[linuxemu-advanced]] == Advanced Topics -This section describes how Linux(R) binary compatibility works and is based on an email written to {freebsd-chat} by Terry Lambert mailto:tlambert@primenet.com[tlambert@primenet.com] (Message ID: `<199906020108.SAA07001@usr09.primenet.com>`). +This section describes how Linux binary compatibility works and is based on an email written to {freebsd-chat} by Terry Lambert mailto:tlambert@primenet.com[tlambert@primenet.com] (Message ID: `<199906020108.SAA07001@usr09.primenet.com>`). FreeBSD has an abstraction called an "execution class loader". This is a wedge into the man:execve[2] system call. @@ -276,10 +276,10 @@ FreeBSD has a list of loaders, instead of a single loader, with a fallback to the `#!` loader for running shell interpreters or shell scripts. -For the Linux(R) ABI support, FreeBSD sees the magic number as an ELF binary. +For the Linux ABI support, FreeBSD sees the magic number as an ELF binary. The ELF loader looks for a specialized _brand_, which is a comment section in the ELF image, and which is not present on SVR4/Solaris(TM) ELF binaries. -For Linux(R) binaries to function, they must be _branded_ as type `Linux` using man:brandelf[1]: +For Linux binaries to function, they must be _branded_ as type `Linux` using man:brandelf[1]: [source,shell] .... @@ -288,25 +288,25 @@ When the ELF loader sees the `Linux` brand, the loader replaces a pointer in the `proc` 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(R) kernel module. +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. -The Linux(R) system call vector contains, among other things, a list of `sysent[]` entries whose addresses reside in the kernel module. +The Linux system call vector contains, among other things, a list of `sysent[]` entries whose addresses reside in the kernel module. -When a system call is called by the Linux(R) binary, the trap code dereferences the system call function pointer off the `proc` structure, and gets the Linux(R), not the FreeBSD, system call entry points. +When a system call is called by the Linux binary, the trap code dereferences the system call function pointer off the `proc` structure, and gets the Linux, not the FreeBSD, system call entry points. -Linux(R) mode dynamically _reroots_ lookups. +Linux mode dynamically _reroots_ lookups. This is, in effect, equivalent to `union` to file system mounts. First, an attempt is made to lookup the file in [.filename]#/compat/linux/original-path#. If that fails, the lookup is done in [.filename]#/original-path#. This makes sure that binaries that require other binaries can run. -For example, the Linux(R) toolchain can all run under Linux(R) ABI support. -It also means that the Linux(R) binaries can load and execute FreeBSD binaries, if there are no corresponding Linux(R) binaries present, and that a man:uname[1] command can be placed in the [.filename]#/compat/linux# directory tree to ensure that the Linux(R) binaries cannot tell they are not running on Linux(R). +For example, the Linux toolchain can all run under Linux ABI support. +It also means that the Linux binaries can load and execute FreeBSD binaries, if there are no corresponding Linux binaries present, and that a man:uname[1] command can be placed in the [.filename]#/compat/linux# directory tree to ensure that the Linux binaries cannot tell they are not running on Linux. -In effect, there is a Linux(R) kernel in the FreeBSD kernel. -The various underlying functions that implement all of the services provided by the kernel are identical to both the FreeBSD system call table entries, and the Linux(R) system call table entries: file system operations, virtual memory operations, signal delivery, and System V IPC. -The only difference is that FreeBSD binaries get the FreeBSD _glue_ functions, and Linux(R) binaries get the Linux(R) _glue_ functions. -The FreeBSD _glue_ functions are statically linked into the kernel, and the Linux(R) _glue_ functions can be statically linked, or they can be accessed via a kernel module. +In effect, there is a Linux kernel in the FreeBSD kernel. +The various underlying functions that implement all of the services provided by the kernel are identical to both the FreeBSD 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 FreeBSD binaries get the FreeBSD _glue_ functions, and Linux binaries get the Linux _glue_ functions. +The FreeBSD _glue_ functions are statically linked into the kernel, and the Linux _glue_ functions can be statically linked, or they can be accessed via a kernel module. Technically, this is not really emulation, it is an ABI implementation. -It is sometimes called "Linux(R) emulation" because the implementation was done at a time when there was no other word to describe what was going on. -Saying that FreeBSD ran Linux(R) binaries was not true, since the code was not compiled in. +It is sometimes called "Linux emulation" because the implementation was done at a time when there was no other word to describe what was going on. +Saying that FreeBSD ran Linux binaries was not true, since the code was not compiled in.