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