-
Notifications
You must be signed in to change notification settings - Fork 0
/
reexec_to_match_kernel.3
50 lines (50 loc) · 1.6 KB
/
reexec_to_match_kernel.3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
.Dd Apr 14, 2008
.Dt REEXEC_TO_MATCH_KERNEL 3
.Os "Mac OS X"
.Sh NAME
.Nm reexec_to_match_kernel
.Nd Re-exec the current binary to match the ABI of the running kernel
.Sh LIBRARY
.Lb libutil
.Sh SYNOPSIS
.In libutil.h
.Ft int
.Fo reexec_to_match_kernel
.Fa "void"
.Fc
.Ft int
.Fo reexec_to_match_lp64ness
.Fa "bool isLP64"
.Fc
.Sh DESCRIPTION
The
.Fn reexec_to_match_kernel
function re-executes the current binary to match the ABI of the running kernel.
That is, if the current kernel is a 64-bit Intel kernel, it will attempt to
execute the 64-bit x86_64 userspace slice of the universal binary. The API
intentionally does not take arguments because its use should be transparent
to the program and to the user.
.Pp
The
.Fn reexec_to_match_lp64ness
is coarser-grained, and only attempts to match the word width that is requested.
For example, if the current system defaults to executing the 64-bit x86_64
userspace slice, but the program should instead run in 32-bit i386 mode,
this routine can be used.
.Pp
Both
.Fn reexec_to_match_kernel
and
.Fn reexec_to_match_lp64ness
can each be used exactly once in a program's lifetime. In certain circumstances,
it may even be desirable to use one, and then the other.
.Sh RETURN VALUES
The
.Fn reexec_to_match_kernel
and
.Fn reexec_to_match_lp64ness
functions return 0 if re-execution was not required. It returns -1 and
sets errno if there was an error performing the re-execution, for example
if the binary is not universal, or does not contain a slice to match the running
kernel's ABI. If the function succeeds, control never returns to the caller
and the program starts from main() again.