xref: /freebsd/share/man/man4/aout.4 (revision fa9896e082a1046ff4fbc75fcba4d18d1f2efc19)
1b80225cdSKonstantin Belousov.\" Copyright (c) 2012 Konstantin Belousov <kib@FreeBSD.org>
2b80225cdSKonstantin Belousov.\"
3b80225cdSKonstantin Belousov.\" Redistribution and use in source and binary forms, with or without
4b80225cdSKonstantin Belousov.\" modification, are permitted provided that the following conditions
5b80225cdSKonstantin Belousov.\" are met:
6b80225cdSKonstantin Belousov.\" 1. Redistributions of source code must retain the above copyright
7b80225cdSKonstantin Belousov.\"    notice, this list of conditions and the following disclaimer.
8b80225cdSKonstantin Belousov.\" 2. Redistributions in binary form must reproduce the above copyright
9b80225cdSKonstantin Belousov.\"    notice, this list of conditions and the following disclaimer in the
10b80225cdSKonstantin Belousov.\"    documentation and/or other materials provided with the distribution.
11b80225cdSKonstantin Belousov.\"
12b80225cdSKonstantin Belousov.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
13b80225cdSKonstantin Belousov.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
14b80225cdSKonstantin Belousov.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
15b80225cdSKonstantin Belousov.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
16b80225cdSKonstantin Belousov.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
17b80225cdSKonstantin Belousov.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
18b80225cdSKonstantin Belousov.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
19b80225cdSKonstantin Belousov.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
20b80225cdSKonstantin Belousov.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
21b80225cdSKonstantin Belousov.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22b80225cdSKonstantin Belousov.\"
23b80225cdSKonstantin Belousov.Dd August 14, 2012
24b80225cdSKonstantin Belousov.Dt AOUT 4
25b80225cdSKonstantin Belousov.Os
26b80225cdSKonstantin Belousov.Sh NAME
27b80225cdSKonstantin Belousov.Nm aout
28b80225cdSKonstantin Belousov.Nd kernel support for executing binary files in legacy a.out format
29b80225cdSKonstantin Belousov.Sh SYNOPSIS
30b80225cdSKonstantin Belousov.Bd -literal -offset indent
31b80225cdSKonstantin Belousovkldload a.out
32b80225cdSKonstantin Belousov.Ed
33b80225cdSKonstantin Belousov.Sh DESCRIPTION
34b80225cdSKonstantin BelousovThe
35b80225cdSKonstantin Belousov.Xr a.out 5
36ecb84463SJoel Dahlexecutable format was used before the release of
37ecb84463SJoel Dahl.Fx 3.0 .
38ecb84463SJoel DahlSince i386 was the only supported architecture at that time,
39b80225cdSKonstantin Belousov.Xr a.out 5
40ecb84463SJoel Dahlexecutables can only be activated on platforms that support
41e7d939bdSMarcel Moolenaarexecution of i386 code, such as i386 and amd64.
42b80225cdSKonstantin Belousov.Pp
43b80225cdSKonstantin BelousovTo add kernel support for old syscalls and old syscall invocation methods,
44ecb84463SJoel Dahlplace the following options in the kernel configuration file:
45b80225cdSKonstantin Belousov.Bd -ragged -offset indent
46b80225cdSKonstantin Belousov.Cd "options COMPAT_43"
47b80225cdSKonstantin Belousov.br
48b80225cdSKonstantin Belousov.Cd "options COMPAT_FREEBSD32"
49b80225cdSKonstantin Belousov.Ed
50b80225cdSKonstantin Belousov.Pp
51b80225cdSKonstantin BelousovThe
52b80225cdSKonstantin Belousov.Va COMPAT_FREEBSD32
53b80225cdSKonstantin Belousovoption is only required on 64-bit CPU architectures.
54b80225cdSKonstantin Belousov.Pp
55b80225cdSKonstantin BelousovThe
56b80225cdSKonstantin Belousov.Va aout.ko
57ecb84463SJoel Dahlmodule needs to be loaded with the
58ecb84463SJoel Dahl.Xr kldload 8
59ecb84463SJoel Dahlutility in order to support the
60b80225cdSKonstantin Belousov.Xr a.out 5
61ecb84463SJoel Dahlimage activator:
62b80225cdSKonstantin Belousov.Bd -ragged -offset indent
63b80225cdSKonstantin Belousov.Ic kldload aout
64b80225cdSKonstantin Belousov.Ed
65ecb84463SJoel Dahl.Pp
66ecb84463SJoel DahlAlternatively, to load the module at boot time, place the following line in
67b80225cdSKonstantin Belousov.Xr loader.conf 5 :
68b80225cdSKonstantin Belousov.Bd -literal -offset indent
69b80225cdSKonstantin Belousovaout_load="YES"
70b80225cdSKonstantin Belousov.Ed
71b80225cdSKonstantin Belousov.Pp
72b80225cdSKonstantin BelousovThe
73b80225cdSKonstantin Belousov.Xr a.out 5
74ecb84463SJoel Dahlformat was mainstream quite a long time ago.
75ecb84463SJoel DahlReasonable default settings and security requirements of
76ddb2537bSKonstantin Belousovmodern operating systems today contradict the default environment of that time
77ddb2537bSKonstantin Belousovand require adjustments of the system to mimic natural environment for
78b80225cdSKonstantin Belousovold binaries.
79b80225cdSKonstantin Belousov.Pp
80b80225cdSKonstantin BelousovThe following
81b80225cdSKonstantin Belousov.Xr sysctl 8
82b80225cdSKonstantin Belousovtunables are useful for this:
83b80225cdSKonstantin Belousov.Bl -tag -offset indent -width "XXXXXXXXXXXXXXXXXXXXXXXXX"
84b80225cdSKonstantin Belousov.It Xo Va security.bsd.map_at_zero
85b80225cdSKonstantin Belousov.Xc
86ecb84463SJoel DahlSet to 1 to allow mapping of process pages at address 0.
87b80225cdSKonstantin BelousovSome very old
88b80225cdSKonstantin Belousov.Va ZMAGIC
89ecb84463SJoel Dahlexecutable images require text mapping at address 0.
90b80225cdSKonstantin Belousov.It Xo Va kern.pid_max
91b80225cdSKonstantin Belousov.Xc
92b80225cdSKonstantin BelousovOld versions of
93b80225cdSKonstantin Belousov.Fx
94ddb2537bSKonstantin Belousovused signed 16-bit type for
95b80225cdSKonstantin Belousov.Vt pid_t .
96b80225cdSKonstantin BelousovCurrent kernels use 32-bit type for
97b80225cdSKonstantin Belousov.Vt pid_t ,
98ecb84463SJoel Dahland allow process id's up to 99999.
99b80225cdSKonstantin BelousovSuch values cannot be represented by old
100b80225cdSKonstantin Belousov.Vt pid_t ,
101ecb84463SJoel Dahlmostly causing issues for processes using
102b80225cdSKonstantin Belousov.Xr wait 2
103ecb84463SJoel Dahlsyscalls, for example shells.
104b80225cdSKonstantin BelousovSet the sysctl to 30000 to work around the problem.
105b80225cdSKonstantin Belousov.It Xo Va kern.elf32.read_exec
106b80225cdSKonstantin Belousov.Xc
107b80225cdSKonstantin BelousovSet to 1 to force any accessible memory mapping performed by 32-bit
108b80225cdSKonstantin Belousovprocess to allow execution, see
109b80225cdSKonstantin Belousov.Xr mmap 2 .
110b80225cdSKonstantin BelousovOld i386 CPUs did not have a bit in PTE which disallowed execution
111ecb84463SJoel Dahlfrom the page, so many old programs did not specify
112b80225cdSKonstantin Belousov.Va PROT_EXEC
113b80225cdSKonstantin Belousoveven for mapping of executable code.
114b80225cdSKonstantin BelousovThe sysctl forces
115b80225cdSKonstantin Belousov.Va PROT_EXEC
116b80225cdSKonstantin Belousovif mapping has any access allowed at all.
117b80225cdSKonstantin BelousovThe setting is only needed if the host architecture allows
118b80225cdSKonstantin Belousovnon-executable mappings.
119b80225cdSKonstantin Belousov.El
120b80225cdSKonstantin Belousov.Sh SEE ALSO
121b80225cdSKonstantin Belousov.Xr execve 2 ,
122b80225cdSKonstantin Belousov.Xr a.out 5 ,
123b80225cdSKonstantin Belousov.Xr elf 5 ,
124*0b3504fdSChristian Brueffer.Xr sysctl 8
125b80225cdSKonstantin Belousov.Sh HISTORY
126b80225cdSKonstantin BelousovThe
127b80225cdSKonstantin Belousov.Xr a.out 5
128b80225cdSKonstantin Belousovexecutable format was used on ancient
129b80225cdSKonstantin Belousov.At
130b80225cdSKonstantin Belousovand served as the main executable format for
131b80225cdSKonstantin Belousov.Fx
132ecb84463SJoel Dahlfrom the beginning up to
133b80225cdSKonstantin Belousov.Fx 2.2.9 .
134b80225cdSKonstantin BelousovIn
135b80225cdSKonstantin Belousov.Fx 3.0
136b80225cdSKonstantin Belousovit was superseded by
137b80225cdSKonstantin Belousov.Xr elf 5 .
138b80225cdSKonstantin Belousov.Sh AUTHORS
139b80225cdSKonstantin BelousovThe
140b80225cdSKonstantin Belousov.Nm
141b80225cdSKonstantin Belousovmanual page was written by
1426c899950SBaptiste Daroussin.An Konstantin Belousov Aq Mt kib@FreeBSD.org .
143ecb84463SJoel Dahl.Sh BUGS
144ecb84463SJoel DahlOn 64bit architectures, not all wrappers for older syscalls are implemented.
145