summaryrefslogtreecommitdiff
path: root/man/mcpu-run.1
blob: 65c8f4295b5f1d4349e42946b9f6b1dc6498d2ca (plain)
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
.TH MCPU-RUN 1 "October 2026" "LibMCPU" "User Commands"

.SH NAME
mcpu-run \- load and execute an MCPU MELF executable
.SH SYNOPSIS
.B mcpu-run
.RI [ runtime-options ] " -- executable " [ program-args ...]
.br
.B mcpu-run
.RI [ runtime-options ] " executable " [ program-args ...]
.SH DESCRIPTION
.B mcpu-run
is the LibMCPU loader, startup linker, execution supervisor and host-side test
bench for MELF ET_EXEC images.  The form with an explicit
.B --
separator is preferred.  STACK and HEAP sizes are part of the executable MELF
ABI and cannot be overridden by the runner.
.PP
The loader accepts static ABI-v1 executables, historical ABI-v2 explicit
preload files, and frozen ABI-v3 startup-dynamic executables and dependencies.
All startup dependency discovery, symbol selection and runtime relocation is
completed before the first guest instruction.
.SH HLL STARTUP AND LIFECYCLE
An HLL PROGRAM or MODEL executable still enters through the ordinary MELF
_start/_life/_fini lifecycle supplied by the linked CRT.  mcpu-run does not
call main, init, life or fini directly.
.PP
Before _start, the loader constructs one persistent McpuStartup v1 area in
STACK containing version, size, argc, PTR64 argv and a reserved zero field.
The argv array and argument strings remain valid for the executable lifetime.
The HLL CRT validates this state and bridges it to the ordinary CALL ABI.
.PP
PROGRAM executes its HLL main once and exits with the returned int32 status.
MODEL performs INIT through init(), then invokes life() once per lifecycle
iteration.  INT32_MIN means continue through one LIFE END boundary; zero means
normal completion; a positive value is an error exit status.  Other negative
life results are reserved by HLL Runtime ABI v1.
.PP
Graceful HLL exit runs user fini(), __mcpu_fini_array() and
__mcpu_libc_fini() before the final FINI END.  Startup failure before the CRT
reaches RUNNING skips those finalizers.  A diagnostic --steps stop remains a
supervisor stop and does not synthesize graceful HLL finalization.
.SH SYSTEM OPTIONS
.TP
.B --no-config
Do not read mcpu-ld.conf files while keeping the executable-derived default
system library tree.
.TP
.BI --sys-root= PATH
Use PATH as the MCPU root, suppress configuration files and use PATH/lib as the
system library directory.
.TP
.B --dump-config
Print effective MCPU configuration and exit.
.TP
.B --print-search-dirs
Print effective library search directories and exit.
.SH LIBRARY OPTIONS
These options must precede the executable or explicit -- separator.
.TP
.BI --library-path= DIR[:DIR...]
Add explicit library search directories.  The option may be repeated.  These
directories precede the effective system library path.
.TP
.BI --ldpreload= a.so:b.so
Preload ABI-v2 or ABI-v3 shared objects.  A name without slash is searched;
a spelling containing slash is used as an explicit pathname.
.SH ENVIRONMENT
.TP
.B MCPU_LD_PRELOAD
Colon-separated preload list applied before command-line --ldpreload entries.
For equal-strength definitions the established rightmost priority applies, so
command-line preloads can override environment preloads.
.SH POST-STOP INSPECTION OPTIONS
.TP
.BI --int-reg= r<bits>@<addr>
Print a signed integer register after execution stops.
.TP
.BI --real-reg= r<bits>@<addr>
Print a real register after execution stops.
.TP
.BI --int-data= <bits>@<addr>
.TQ
.BI --real-data= <bits>@<addr>
.TQ
.BI --raw-data= <bytes>@<addr>
Inspect DATA.
.TP
.BI --int-control= <bits>@<addr>
.TQ
.BI --real-control= <bits>@<addr>
.TQ
.BI --raw-control= <bytes>@<addr>
Inspect CONTROL.
.TP
.BI --int-heap= <bits>@<addr>
.TQ
.BI --real-heap= <bits>@<addr>
.TQ
.BI --raw-heap= <bytes>@<addr>
Inspect HEAP.
.TP
.BI --int-input= <bits>@<addr>
.TQ
.BI --real-input= <bits>@<addr>
.TQ
.BI --raw-input= <bytes>@<addr>
Inspect INPUT.
.TP
.BI --int-output= <bits>@<addr>
.TQ
.BI --real-output= <bits>@<addr>
.TQ
.BI --raw-output= <bytes>@<addr>
Inspect OUTPUT.
.TP
.BI --int-trace= <bits>@<addr>
.TQ
.BI --real-trace= <bits>@<addr>
.TQ
.BI --raw-trace= <bytes>@<addr>
Inspect TRACE.
.SH LIFECYCLE CONTROL
.TP
.BI --digits= n
Set mantissa digits for real output.  Default: 80.
.TP
.B --init-only
Execute INIT through its END boundary, then stop.
.TP
.BI --steps= n
Stop after n LIFE END boundaries.  Without this option normal diagnostic
stepping stops at the first LIFE END boundary.
.TP
.BR -h ", " --help
Display command-line help and exit.
.TP
.B --version
Display the program name, MCPU toolchain identity and version, then exit.
.TP
.B --dump-version
Display only the MCPU package version number and exit.
.SH STAGE ACTIONS
The following repeatable options run host actions at lifecycle boundaries:
.TP
.BI --before-run= action
After loading, startup linking, relocations and startup-area preparation, but
before the first guest instruction.
.TP
.BI --after-init= action
After INIT END, or once at the logical empty INIT boundary when .init is absent.
.TP
.BI --on-step= action
After every LIFE END boundary.
.TP
.BI --after-run= action
After final normal execution stop; graceful FINI has already completed.
.PP
Actions execute in command-line order.  Supported action forms are:
.nf
print-int-regs:r<bits>@<addr>[,...]
print-real-regs:r<bits>@<addr>[,...]
set-int-regs:r<bits>@<addr>=<value>[,...]
set-real-regs:r<bits>@<addr>=<value>[,...]
print-int-<memory>:<bits>@<addr>[,...]
print-real-<memory>:<bits>@<addr>[,...]
set-int-<memory>:<bits>@<addr>=<value>[,...]
set-real-<memory>:<bits>@<addr>=<value>[,...]
print-raw-<memory>:<bytes>@<addr>
.fi
.PP
.I memory
is data, control, heap, input, output or trace.  Scalar print actions print the
comma-separated objects on one line.  Raw actions contain exactly one dump;
repeat the stage option for multiple dumps.  There are no set-raw-* actions.
Set values are parsed by LibMPUIO mpu_sscanf().  Step-number action filters are
not implemented.
.PP
Raw byte counts accept K/KiB, M/MiB and G/GiB binary suffixes.
.SH LIFECYCLE AND EXIT
END returns control to the supervisor at managed INIT/LIFE/FINI boundaries.
A graceful guest EXIT may enter optional FINI before the final stop.  A
diagnostic --steps stop does not synthesize a graceful EXIT and therefore does
not by itself invoke FINI.
.SH FILES
.TP
.I <runtime-root>/etc/mcpu-ld.conf
Installed relocatable-tree library-search configuration.
.TP
.I /etc/mcpu/mcpu-ld.conf
Optional machine-wide override.
.TP
.I $HOME/.mcpu/etc/mcpu-ld.conf
Optional per-user override.
.SH EXIT STATUS
For a normally completed guest program the runner returns the guest exit
status.  Loader, startup-linker, option or runtime errors terminate with a
nonzero host-side status.
.SH EXAMPLES
.nf
mcpu-run -- program arg1 arg2
mcpu-run --library-path=./lib -- program
MCPU_LD_PRELOAD=libhook.so mcpu-run -- program
mcpu-run --steps=20 --on-step=print-real-trace:128@0,128@16 -- pendulum
.fi
.SH SEE ALSO
.BR mcpu-ld (1),
.BR mcpu-readelf (1),
.BR mcpu-objdump (1),
.BR libmcpu (7)