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