summaryrefslogtreecommitdiff
path: root/share/man/man8/compat_freebsd.8
blob: 7b19d32cf93e5e7dc0f6be3f9d2803e122393823 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
.\"	$OpenBSD: compat_freebsd.8,v 1.17 2003/10/25 07:50:51 jmc Exp $
.\"	$NetBSD: compat_linux.8,v 1.1 1995/03/05 23:30:36 fvdl Exp $
.\"
.\" Copyright (c) 1995 Frank van der Linden
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"      This product includes software developed for the NetBSD Project
.\"      by Frank van der Linden
.\" 4. The name of the author may not be used to endorse or promote products
.\"    derived from this software without specific prior written permission
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd June 4, 1995
.Dt COMPAT_FREEBSD 8
.Os
.Sh NAME
.Nm compat_freebsd
.Nd setup for running
.Fx
binaries under emulation
.Sh DESCRIPTION
.Ox
supports running
.Fx
binaries.
Most binaries should work, except for programs that use
FreeBSD-specific features.
These include i386-specific calls, such as syscons utilities and audio
devices.
.Pp
The
.Fx
compatibility feature is active for kernels compiled
with the
.Nm COMPAT_FREEBSD
option and the kern.emul.freebsd
.Xr sysctl 8
enabled.
.Pp
A lot of programs are dynamically linked.
This means that the
.Fx
shared libraries that the programs depend on and the runtime linker
are also needed.
Additionally, a "shadow root" directory for
.Fx
binaries on the
.Ox
system will have to be created.
This directory is named
.Pa /emul/freebsd .
Any file operations done by
.Fx
programs run under
.Ox
will look in this directory first.
So, if a
.Fx
program opens, for example,
.Pa /etc/passwd ,
.Ox
will first try to open
.Pa /emul/freebsd/etc/passwd ,
and if that does not exist
open the `real'
.Pa /etc/passwd file .
It is recommended that
.Fx
packages that include configuration files, etc., be installed under
.Pa /emul/freebsd ,
to avoid naming conflicts with possible
.Ox
counterparts.
Shared libraries should also be installed in the shadow tree.
.Pp
Generally, it will only be necessary to look for the shared libraries that
.Fx
binaries depend on the first few times that
.Fx
programs are installed on the
.Ox
system.
After a while, there will be a sufficient set of
.Fx
shared libraries on the system to be able to run newly imported
.Fx
binaries without any extra work.
.Ss Setting up shared libraries
How to get to know which shared libraries
.Fx
binaries need, and where to get them?
Basically, there are 3 possibilities.
(When following these instructions, root privileges are required on the
.Ox
system to perform the necessary installation steps).
.Bl -enum
.It
Access to the
.Ox
.Xr ports 7
system:
Install the port named
.Nm freebsd_lib
in the
.Nm emulators
category.
The
.Nm freebsd_lib
port contains the shared libraries, binaries, and other related files
necessary to run
.Fx
applications.
.It
Access to a
.Fx
system:
In this case temporarily install the binary there, see what shared
libraries it needs, and copy them to the
.Ox
system.
Example: ftp the
.Fx
binary of SimCity.
Put it on the
.Fx
system, and check which shared libraries it needs by running
`ldd sim':
.Pp
.Dl me@freebsd% ldd /usr/local/lib/SimCity/res/sim
.Bd -unfilled -offset indent
/usr/local/lib/SimCity/res/sim:
	-lXext.6 => /usr/X11R6/lib/libXext.so.6.0 (0x100c1000)
	-lX11.6 => /usr/X11R6/lib/libX11.so.6.0 (0x100c9000)
	-lc.2 => /usr/lib/libc.so.2.1 (0x10144000)
	-lm.2 => /usr/lib/libm.so.2.0 (0x101a7000)
	-lgcc.261 => /usr/lib/libgcc.so.261.0 (0x101bf000)
.Ed
.Pp
All the files from the last column should be placed under
.Pa /emul/freebsd .
The following files would therefore be required on the
.Ox
system:
.Bd -unfilled -offset indent
/emul/freebsd/usr/X11R6/lib/libXext.so.6.0
/emul/freebsd/usr/X11R6/lib/libX11.so.6.0
/emul/freebsd/usr/lib/libc.so.2.1
/emul/freebsd/usr/lib/libm.so.2.0
/emul/freebsd/usr/lib/libgcc.so.261.0
.Ed
.Pp
Note that if a
.Fx
shared library with a matching major revision number to the first
column of the 'ldd' output is already present, it isn't necessary to copy
the file named in the last column to the
.Ox
system; the one already there should work.
It is advisable to copy the shared library anyway, if it is a newer version.
The old one can be removed.
So, if this library exists on the system:
.Pp
.D1 /emul/freebsd/usr/lib/libc.so.2.0
.Pp
and the ldd output for a new binary is:
.Pp
.D1 -lc.2 => /usr/lib/libc.so.2.1 (0x10144000)
.Pp
it isn't necessary to copy
.Pa /usr/lib/libc.so.2.1
too,
because the program should work fine with the slightly older version.
.Pa libc.so
can be replaced anyway, and that should leave:
.Pp
.D1 /emul/freebsd/usr/lib/libc.so.2.1
.Pp
Finally, the
.Fx
runtime linker and its config files must be present on the system.
These files should be copied from the
.Fx
system to their appropriate place on the
.Ox
system (in the
.Pa /emul/freebsd
tree):
.Bd -unfilled -offset indent
usr/libexec/ld-elf.so.1
usr/libexec/ld.so
var/run/ld-elf.so.hints
var/run/ld.so.hints
.Ed
.It
No access to a
.Fx
system:
In that case, get the extra files from various ftp sites.
Information on where to look for the various files is appended
below.
.Pp
Retrieve the following files (from _one_ ftp site to avoid
any version mismatches), and install them under
.Pa /emul/freebsd
(i.e.
.Pa foo/bar
is installed as
.Pa /emul/freebsd/foo/bar ) :
.Bd -unfilled -offset indent
sbin/ldconfig
usr/bin/ldd
usr/lib/libc.so.x.y.z
usr/libexec/ld-elf.so.1
usr/libexec/ld.so
.Ed
.Pp
ldconfig and ldd don't necessarily need to be under
.Pa /emul/freebsd ,
they can be installed elsewhere in the system too.
Just make sure they don't conflict with their
.Ox
counterparts.
A good idea would be to install them in
.Pa /usr/local/bin
as ldconfig-freebsd and ldd-freebsd.
.Pp
Run the
.Fx
ldconfig program with directory arguments in which the
.Fx
runtime linker should look for shared libs.
.Pa /usr/lib
is standard.
For example:
.Bd -literal -offset indent
me@openbsd% mkdir -p /emul/freebsd/var/run
me@openbsd% touch /emul/freebsd/var/run/ld-elf.so.hints
me@openbsd% touch /emul/freebsd/var/run/ld.so.hints
me@openbsd% ldconfig-freebsd /usr/X11R6/lib /usr/local/lib
.Ed
.Pp
Note that argument directories of ldconfig are
mapped to
.Pa /emul/freebsd/XXXX
by OpenBSD's compat code, and should exist as such on the
.Ox
system.
Make sure
.Pa /emul/freebsd/var/run/ld.so.hints
exists when running FreeBSD's ldconfig; if not, OpenBSD's
.Pa /var/run/ld.so.hints
could be lost.
.Pp
.Fx
ldconfig should be statically
linked, so it doesn't need any shared libraries by itself.
It will create the file
.Pa /emul/freebsd/var/run/ld.so.hints .
The
.Fx
version of the ldconfig program should be rerun each time a new shared
library is added.
.Pp
The
.Ox
system should now be set up for
.Fx
binaries which only need a shared libc.
Test this by running the
.Fx
ldd on itself.
Suppose that it is installed as ldd-freebsd, it should produce
something like:
.Pp
.Dl me@openbsd% ldd-freebsd `which ldd-freebsd`
.Bd -unfilled -offset indent
/usr/local/bin/ldd-freebsd:
	-lc.2 => /usr/lib/libc.so.2.1 (0x1001a000)
.Ed
.Pp
This being done, new
.Fx
binaries can now be installed.
Whenever a new
.Fx
program is installed, it should be determined if it needs shared libraries,
and if so, whether they are installed in the
.Pa /emul/freebsd
tree.
To do this, run the
.Fx
version ldd on the new program, and watch its output.
ldd (see also the manual page for ldd(1)) will print a list
of shared libraries that the program depends on, in the
form -l<majorname> => <fullname>.
.Pp
If it prints "not found" instead of <fullname> it means that
an extra library is needed.
Which library this is, is shown
in <majorname>, which will be of the form XXXX.<N>.
Find a libXXXX.so.<N>.<mm> on a
.Fx
ftp site, and install it on the
.Ox
system.
The XXXX (name) and <N> (major revision number) should match;
the minor number(s) <mm> are less important,
though it is advised to take the most recent version.
.El
.Ss Finding the necessary files
.Sy Note :
the information below is valid as of Feb 2003, but certain details
such as names of ftp sites, directories and distribution names
may have changed since then.
.Pp
.Fx
distribution is available on a lot of ftp sites.
Sometimes the files are unpacked,
and individual files can be retrieved, but mostly they
are stored in distribution sets, usually consisting of subdirectories
with gzipped tar files in them.
The primary ftp site for the distribution is:
.Pp
.D1 Pa ftp.freebsd.org:/pub/FreeBSD
.Pp
Mirror sites are described at:
.Pp
.D1 Pa www.freebsdmirrors.org
.Pp
This distribution consists of a number of tar-ed and gzipped files.
Normally, they're controlled by an install program, but the files can
be retrieved "by hand" too.
The way to look something up is to retrieve all
the files in the distribution, and ``tar ztvf'' through them for the files
needed.
Here is an example of a list of files that might be needed:
.Bd -unfilled -offset indent
Needed          Files

ld.so           5.0-RELEASE/base/base.??
ldconfig        5.0-RELEASE/base/base.??
ldd             5.0-RELEASE/base/base.??
libc.so.6       5.0-RELEASE/base/base.??
libX11.so.6     5.0-RELEASE/packages/x11/XFree86-libraries-??
libXt.so.6      5.0-RELEASE/packages/x11/XFree86-libraries-??
.Ed
.Pp
The files called ``base.??'' are tar-ed, gzipped and split,
so they can be extracted with ``cat base.?? | tar zpxf -''.
.Pp
The XFree86 libraries are compressed with bzip2 and can be
extracted with ``bzcat <file> | tar pxf -''.
Note: The bzip2 utilities are not part of a base
.Ox
system.
bzip2 can be added via
.Xr packages 7
or
.Xr ports 7 .
.Pp
Simply extract the files from these compressed tarfiles in the
.Pa /emul/freebsd
directory (possibly omitting or afterwards removing unnecessary files).
.Sh BUGS
The information about
.Fx
distributions may become outdated.