1.\" $NetBSD: compat_bsdos.8,v 1.7 2020/09/02 23:38:11 uwe Exp $ 2.\" 3.\" Copyright (c) 2020 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Dan Plassche. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd August 27, 2020 31.Dt COMPAT_BSDOS 8 32.Os 33.Sh NAME 34.Nm compat_bsdos 35.Nd binary compatibility for BSDi releases 36.Sh DESCRIPTION 37The 38.Dv COMPAT_NOMID 39kernel option includes compatibility with 40.Tn BSDi Ns No \ 1. Ns Em \^x Ns \|\(en\|3. Ns Em \^x 41.Xr a.out 5 42binaries on 43.Nx Ns Tn /i386 44and 45.Nx Ns Tn /amd64 . 46The option is enabled by default in the 47.Li GENERIC 48kernel on i386, 49but needs to be set along with 50.Dv EXEC_AOUT 51on amd64. 52.Pp 53Null memory protection must be disabled with the 54.Xr sysctl 7 55option 56.Va vm.user_va0_disable 57set to 58.Li 0 59for the binaries to run successfully. 60.Pp 61.Bsx 62binaries may be placed under 63.Pa /emul 64directory to match the location of other 65non-native executables 66on 67.Nx , 68but the compatibility environment 69does not automatically lookup libraries 70under 71.Pa /emul/bsdos 72as happens with the shared 73libraries 74for 75.Nx 1.0\|\(en\|1.5 76.Xr a.out 5 77binaries under 78.Pa /emul/aout . 79.Pp 80.Tn BSD/386 Ns No \ 1.0\|\(en\|1.1 81uses static binaries that do not 82dynamically load libraries at runtime. 83.Pp 84.Bsx 2.0 85introduced 86.Dq "static shared libraries" 87as the default for standard binaries. 88The shared libraries are compiled from 89.Pa /lib 90and 91.Pa /usr/lib 92to a custom format bound to memory 93loading addresses for each library 94under 95.Pa /shlib . 96BSDi libraries 97under 98.Pa /shlib 99are not in the standard 100.Xr ar 5 101or position-independent shared object 102formats and cannot be loaded by 103.Xr ldconfig 8 104on 105.Nx . 106In order for BSDi executables to 107access the objects at the 108hardcoded 109.Pa /shlib 110path, 111the user may setup a 112symbolic link from 113.Pa /shlib 114to 115.Pa /emul/bsdos/shlib . 116.\" or run a shell under a 117.\" .Ic chroot 118.\" with the command 119.\" .Ic chroot "/emul/bsdos /bin/sh" . 120.\" One could rebuild the BSDi userland 121.\" from source using 122.\" .Pa /emul/bsdos/lib 123.\" and 124.\" .Pa /emul/bsdos/usr/lib . 125.\" Then adding 126.\" .Pa /emul/bsdos/lib 127.\" and 128.\" .Pa /emul/bsdos/usr/lib 129.\" to 130.\" .Pa /etc/ld.so.conf 131.\" and running 132.\" .Ic ldconfig 133.\" to regenerate 134.\" .Pa /var/run/ld.so.hints 135.\" for a new hybrid setup. 136.Pp 137.Bsx 4.0 138switched to an ELF binary executable format 139that does not run under the 140compatibility layers currently available on 141.Nx . 142.Sh SEE ALSO 143.Xr ld.aout_so 1 , 144.Xr options 4 , 145.Xr a.out 5 , 146.Xr elf 5 , 147.Xr sysctl 7 , 148.Xr compat_netbsd32 8 , 149.Xr ldconfig 8 150.Sh HISTORY 151.Tn BSD/386 Ns No \ 1.0\|\(en\|1.1 152was derived from 153.Bx 4.3 Tn Reno 154code in the 155.Tn Net/2 156release. 157.Pp 158.Bsx 2.0 159was based on 160.Bx 4.4 Tn Lite , 161but added the new static shared library 162format as the runtime default for executables. 163The build system included the 164.Li shlicc 165command with the 166.Fl Bstatic 167flag that allowed reverting to the standard 168library archive format that remained available 169under 170.Pa /lib 171and 172.Pa /usr/lib . 173.Pp 174.Nx 1.0 175added shared libraries using a standard 176position-independent shared object 177format. 178The previous default relocatable libraries 179in the traditional 180.Xr ar 5 181format remained available. 182.Pp 183.Ox 2.2\|\(en\|4.7 184included a different compatibility implementation 185under the 186.Dv COMPAT_BSDOS 187kernel option. 188.Sh BUGS 189.Bsx 190compatibility was broken on 191.Nx 5\|\(en\|6 . 192.Pp 193.Bsx 3.0 194added 195.Tn SPARC 196support, but the binaries are incorrectly recognized as 197.Tn SunOS 198executables and fail on 199.Nx Ns Tn /sparc 200and 201.Nx Ns Tn /sparc64 . 202