aout.4 (b80225cd7b7012df7fff1cd4809ecec6d256a667) aout.4 (ecb84463033bcaadd90c1860e7aa90a0613a3cf7)
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

--- 21 unchanged lines hidden (view full) ---

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
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

--- 21 unchanged lines hidden (view full) ---

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
38executable format was used before the release of
39.Fx 3.0.
40Since i386 was the only supported architecture at that time,
42.Xr a.out 5
41.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.
42executables can only be activated on platforms that support
43execution of i386 code, such as i386, amd64 and (partially) ia64.
45.Pp
46To add kernel support for old syscalls and old syscall invocation methods,
44.Pp
45To add kernel support for old syscalls and old syscall invocation methods,
47you need to place the following options in the kernel configuration file:
46place 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
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
60module must be loaded to get support for
59module needs to be loaded with the
60.Xr kldload 8
61utility in order to support the
61.Xr a.out 5
62.Xr a.out 5
62image activator.
63Use the command
63image activator:
64.Bd -ragged -offset indent
65.Ic kldload aout
66.Ed
64.Bd -ragged -offset indent
65.Ic kldload aout
66.Ed
67or put the following line in
67.Pp
68Alternatively, to load the module at boot time, place 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
69.Xr loader.conf 5 :
70.Bd -literal -offset indent
71aout_load="YES"
72.Ed
73.Pp
74The
75.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
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 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
79require 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
87Set to 1 to allow the mapping of process pages at the address 0.
88Set to 1 to allow mapping of process pages at address 0.
88Some very old
89.Va ZMAGIC
89Some very old
90.Va ZMAGIC
90executable images require the text mapping at the address 0.
91executable images require text mapping at 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 ,
92.It Xo Va kern.pid_max
93.Xc
94Old versions of
95.Fx
96used 16-bit types for
97.Vt pid_t .
98Current kernels use 32-bit type for
99.Vt pid_t ,
99and allow the process id's up to 99999.
100and allow process id's up to 99999.
100Such values cannot be represented by old
101.Vt pid_t ,
101Such values cannot be represented by old
102.Vt pid_t ,
102mostly causing issues for the processes using
103mostly causing issues for processes using
103.Xr wait 2
104.Xr wait 2
104syscalls, for instance, shells.
105syscalls, for example 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
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
112from the page, so many old programs did not specified
113from the page, so many old programs did not specify
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 .
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 .
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
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
135from inception up to
134from the beginning 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 .
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 kib@FreeBSD.org .
145.Sh BUGS
146On 64bit architectures, not all wrappers for older syscalls are implemented.