xref: /freebsd/share/man/man4/aout.4 (revision 8ddb146abcdf061be9f2c0db7e391697dafad85c)
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.\" $FreeBSD$
24.\"
25.Dd August 14, 2012
26.Dt AOUT 4
27.Os
28.Sh NAME
29.Nm aout
30.Nd kernel support for executing binary files in legacy a.out format
31.Sh SYNOPSIS
32.Bd -literal -offset indent
33kldload a.out
34.Ed
35.Sh DESCRIPTION
36The
37.Xr a.out 5
38executable format was used before the release of
39.Fx 3.0 .
40Since i386 was the only supported architecture at that time,
41.Xr a.out 5
42executables can only be activated on platforms that support
43execution of i386 code, such as i386 and amd64.
44.Pp
45To add kernel support for old syscalls and old syscall invocation methods,
46place the following options in the kernel configuration file:
47.Bd -ragged -offset indent
48.Cd "options COMPAT_43"
49.br
50.Cd "options COMPAT_FREEBSD32"
51.Ed
52.Pp
53The
54.Va COMPAT_FREEBSD32
55option is only required on 64-bit CPU architectures.
56.Pp
57The
58.Va aout.ko
59module needs to be loaded with the
60.Xr kldload 8
61utility in order to support the
62.Xr a.out 5
63image activator:
64.Bd -ragged -offset indent
65.Ic kldload aout
66.Ed
67.Pp
68Alternatively, to load the module at boot time, place the following line in
69.Xr loader.conf 5 :
70.Bd -literal -offset indent
71aout_load="YES"
72.Ed
73.Pp
74The
75.Xr a.out 5
76format was mainstream quite a long time ago.
77Reasonable default settings and security requirements of
78modern operating systems today contradict the default environment of that time
79and require adjustments of the system to mimic natural environment for
80old binaries.
81.Pp
82The following
83.Xr sysctl 8
84tunables are useful for this:
85.Bl -tag -offset indent -width "XXXXXXXXXXXXXXXXXXXXXXXXX"
86.It Xo Va security.bsd.map_at_zero
87.Xc
88Set to 1 to allow mapping of process pages at address 0.
89Some very old
90.Va ZMAGIC
91executable images require text mapping at address 0.
92.It Xo Va kern.pid_max
93.Xc
94Old versions of
95.Fx
96used signed 16-bit type for
97.Vt pid_t .
98Current kernels use 32-bit type for
99.Vt pid_t ,
100and allow process id's up to 99999.
101Such values cannot be represented by old
102.Vt pid_t ,
103mostly causing issues for processes using
104.Xr wait 2
105syscalls, for example shells.
106Set the sysctl to 30000 to work around the problem.
107.It Xo Va kern.elf32.read_exec
108.Xc
109Set to 1 to force any accessible memory mapping performed by 32-bit
110process to allow execution, see
111.Xr mmap 2 .
112Old i386 CPUs did not have a bit in PTE which disallowed execution
113from the page, so many old programs did not specify
114.Va PROT_EXEC
115even for mapping of executable code.
116The sysctl forces
117.Va PROT_EXEC
118if mapping has any access allowed at all.
119The setting is only needed if the host architecture allows
120non-executable mappings.
121.El
122.Sh SEE ALSO
123.Xr execve 2 ,
124.Xr a.out 5 ,
125.Xr elf 5 ,
126.Xr sysctl 8
127.Sh HISTORY
128The
129.Xr a.out 5
130executable format was used on ancient
131.At
132and served as the main executable format for
133.Fx
134from the beginning up to
135.Fx 2.2.9 .
136In
137.Fx 3.0
138it was superseded by
139.Xr elf 5 .
140.Sh AUTHORS
141The
142.Nm
143manual page was written by
144.An Konstantin Belousov Aq Mt kib@FreeBSD.org .
145.Sh BUGS
146On 64bit architectures, not all wrappers for older syscalls are implemented.
147