aboutsummaryrefslogtreecommitdiff
path: root/man/man3/mach-file.html
blob: 7fd1a578edf3f0ea2943c17e244d8b99f5d7ff68 (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
<head>
<title>mach-file(3) - Plan 9 from User Space</title>
<meta content="text/html; charset=utf-8" http-equiv=Content-Type>
</head>
<body bgcolor=#ffffff>
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=10><td>
<tr><td width=20><td>
<tr><td width=20><td><b>MACH-FILE(3)</b><td align=right><b>MACH-FILE(3)</b>
<tr><td width=20><td colspan=2>
    <br>
<p><font size=+1><b>NAME     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    crackhdr, uncrackhdr, mapfile, unmapfile, mapproc, unmapproc,
    detachproc, ctlproc, procnotes &ndash; machine-independent access to
    exectuable files and running processes<br>
    
</table>
<p><font size=+1><b>SYNOPSIS     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>#include &lt;u.h&gt;<br>
    #include &lt;libc.h&gt;<br>
    #include &lt;mach.h&gt; 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    </font></tt>
    int &nbsp;&nbsp;&nbsp;&nbsp;crackhdr(int fd, Fhdr *hdr)<br>
    void &nbsp;&nbsp;&nbsp;uncrackhdr(Fhdr *hdr) 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    int &nbsp;&nbsp;&nbsp;&nbsp;mapfile(Fhdr *hdr, ulong base, Map *map, Regs **regs)<br>
    void &nbsp;&nbsp;&nbsp;unmapfile(Fhdr *hdr, Map *map)<br>
    int &nbsp;&nbsp;&nbsp;&nbsp;mapproc(int pid, Map *map, Regs **regs)<br>
    void &nbsp;&nbsp;&nbsp;unmapproc(Map *map)<br>
    int &nbsp;&nbsp;&nbsp;&nbsp;detachproc(int pid)<br>
    int &nbsp;&nbsp;&nbsp;&nbsp;ctlproc(int pid, char *msg)<br>
    int &nbsp;&nbsp;&nbsp;&nbsp;procnotes(int pid, char ***notes)<br>
    
</table>
<p><font size=+1><b>DESCRIPTION     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    These functions parse executable files and provide access to those
    files and to running processes. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Crackhdr</i> opens and parses the named executable file. The returned
    data structure <i>hdr</i> is initialized with a machine-independent description
    of the header information. The following fields are the most commonly
    used:<br>
    <tt><font size=+1>mach</font></tt>a pointer to the <tt><font size=+1>Mach</font></tt> structure for the target architecture<br>
    <tt><font size=+1>mname<br>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        the name of the target architecture<br>
        
    </table>
    <tt><font size=+1>fname<br>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        a description of the kind of file (e.g., executable, core dump)<br>
        
    </table>
    <tt><font size=+1>aname<br>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        a description of the application binary interface this file uses;
        typically it is the name of an operating system If the global
        variable <i>mach</i> is nil, <i>crackhdr</i> points it to the same <tt><font size=+1>Mach</font></tt> structure.
        
        <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
        
        
    </table>
    <i>Mapfile</i> adds the segments found in <i>hdr</i> to <i>map</i>. If <i>hdr</i> is an executable
    file, there are typically three segments: <i>text</i>, <i>data</i>, and a zero-backed
    <i>bss</i>. If <i>hdr</i> is a dynamic shared library, its segments are relocated
    by <i>base</i> before being mapping. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    If <i>hdr</i> is a core file, there is one segment named <i>core</i> for each
    contiguous section of memory recorded in the core file. There
    are often quite a few of these, as most operating systems omit
    clean memory pages when writing core files (Mac OS X is the only
    exception among the supported systems). Because core files
    have such holes, it is typically necessary to construct the core
    map by calling <i>mapfile</i> on the executable and then calling it again
    on the core file. Newly-added segments are mapped on top of existing
    segments, so this arrangement will use the core file for the segments
    it contains but fall back to the executable for the
    rest. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Unmapfile</i> removes the mappings in <i>map</i> corresponding to <i>hdr</i>. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Mapproc</i> attaches to a running program and adds its segments to
    the given map. It adds one segment for each contiguous section
    of mapped memory. On systems where this information cannot be
    determined, it adds a single segment covering the entire address
    space. Accessing areas of this segment that are
    actually not mapped in the process address space will cause the
    get/put routines to return errors. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Unmapproc</i> removes the mappings in <i>map</i> corresponding to <i>pid</i>. <i>Detachproc</i>
    detaches from all previously attached processes. 
    <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
    
    <i>Ctlproc</i> manipulates the process with id <i>pid</i> according to the message
    <i>msg</i>. Valid messages include:<br>
    <tt><font size=+1>kill</font></tt>terminate the process<br>
    <tt><font size=+1>startstop<br>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        start the process and wait for it to stop<br>
        
    </table>
    <tt><font size=+1>sysstop<br>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        arrange for the process to stop at its next system call, start
        the process, and then wait for it to stop<br>
        
    </table>
    <tt><font size=+1>waitstop<br>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        wait for the process to stop<br>
        
    </table>
    <tt><font size=+1>start<br>
    </font></tt>
    <table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

        start the process 
        <table border=0 cellpadding=0 cellspacing=0><tr height=5><td></table>
        
        
    </table>
    <i>Procnotes</i> fills <tt><font size=+1>*</font></tt><i>notes</i> with a pointer to an array of strings representing
    pending notes waiting for the process. (On Unix, these notes are
    textual descriptions of any pending signals.) <i>Procnotes</i> returns
    the number of pending notes. The memory at <tt><font size=+1>*</font></tt><i>notes</i> should be freed
    via <i>free</i> (see <a href="../man3/malloc.html"><i>malloc</i>(3)</a>) when no longer needed.
    
</table>
<p><font size=+1><b>SOURCE     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <tt><font size=+1>/usr/local/plan9/src/libmach<br>
    </font></tt>
</table>
<p><font size=+1><b>SEE ALSO     </b></font><br>

<table border=0 cellpadding=0 cellspacing=0><tr height=2><td><tr><td width=20><td>

    <a href="../man3/mach.html"><i>mach</i>(3)</a>, <a href="../man3/mach-map.html"><i>mach-map</i>(3)</a><br>
    
</table>

<td width=20>
<tr height=20><td>
</table>
<!-- TRAILER -->
<table border=0 cellpadding=0 cellspacing=0 width=100%>
<tr height=15><td width=10><td><td width=10>
<tr><td><td>
<center>
<a href="../../"><img src="../../dist/spaceglenda100.png" alt="Space Glenda" border=1></a>
</center>
</table>
<!-- TRAILER -->
</body></html>