Print this page
4839 3294 generated elfdump struct layouts by hand, shouldn't have
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/cmd/sgs/elfdump/common/gen_struct_layout.c
+++ new/usr/src/cmd/sgs/elfdump/common/gen_struct_layout.c
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
↓ open down ↓ |
15 lines elided |
↑ open up ↑ |
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 -#pragma ident "%Z%%M% %I% %E% SMI"
27 -
28 26
29 27 #include <stdlib.h>
30 28 #include <stddef.h>
31 29 #include <stdio.h>
32 30 #include <string.h>
33 31 #include <fcntl.h>
34 32 #include <sys/types.h>
35 33 #include <sys/stat.h>
36 34 #include <unistd.h>
37 35 #include <sys/sysmacros.h>
38 36 #include <sys/corectl.h>
39 37 #include <procfs.h>
40 38 #include <sys/auxv.h>
41 39 #include <sys/old_procfs.h>
42 40 #include <sys/utsname.h>
43 41
44 42
45 43
46 44 /*
47 45 * This standalone program is used to generate the contents
48 46 * of the struct_layout_XXX.c files that contain per-archtecture
49 47 * structure layout information.
50 48 *
51 49 * Although not part of elfdump, it is built by the makefile
52 50 * along with it.
53 51 * To use it:
54 52 *
55 53 * 1) Run it, capturing the output in a file.
56 54 * 2) If this is a replacement for an existing file,
57 55 * diff the new and old copies to ensure only
58 56 * the changes you expected are present.
59 57 * 3) Put the new file in the common directory under the name
60 58 * struct_layout_XXX.c, where XXX is the name of
61 59 * the architecture (i386, amd64, sparc, sparcv9, etc).
62 60 * 2) Add any necessary header and copyright comments.
63 61 * 3) If this is a new architecture:
64 62 * - Add an extern statement for struct_layout_XXX()
65 63 * to struct_layout.h
66 64 * - Add a case for it to the function sl_struct_layout()
67 65 * in struct_layout.c.
68 66 */
69 67
70 68
71 69 /*
72 70 * Which machine is this build for?
73 71 */
74 72 #if defined(__i386)
75 73
76 74 #define MACH "i386"
77 75
78 76 #elif defined(__amd64)
79 77
80 78 #define MACH "amd64"
81 79
82 80 #elif defined(__sparcv9)
83 81
84 82 #define MACH "sparcv9"
85 83
86 84 #elif defined(__sparc)
87 85
88 86 #define MACH "sparc"
89 87
90 88 #else
91 89
92 90 #error "unrecognized build host type"
93 91
94 92 #endif
95 93
96 94
97 95 /*
98 96 * START and END bracket a struct layout definition. They issue
99 97 * the typedef boilerplate, and the standard first element (sizeof)
100 98 * which captures the overall size of the structure.
101 99 *
102 100 * SCALAR_FIELD is for scalar struct fields
103 101 *
104 102 * ARRAY_FIELD is for array struct fields
105 103 *
106 104 * ARRAY is for plain (non-struct) array types
107 105 */
108 106 #define START(_name, _type) \
109 107 (void) printf("\n\nstatic const sl_" #_name \
110 108 "_layout_t " #_name "_layout = {\n"); \
111 109 (void) printf("\t{ 0,\t%d,\t0,\t0 },\t\t/* sizeof (%s) */\n", \
112 110 sizeof (_type), #_type)
113 111 #define SCALAR_FIELD(_type, _field, _sign) \
114 112 (void) printf("\t{ %d,\t%d,\t0,\t%d },\t\t/* " #_field " */\n", \
115 113 offsetof(_type, _field), sizeof (((_type *)0)->_field), _sign)
116 114 #define ARRAY_FIELD(_type, _field, _sign) \
117 115 (void) printf("\t{ %d,\t%d,\t%d,\t%d },\t\t/* " #_field "[] */\n", \
118 116 offsetof(_type, _field), sizeof (((_type *)0)->_field[0]), \
119 117 sizeof (((_type *)0)->_field) / sizeof (((_type *)0)->_field[0]), \
120 118 _sign)
121 119 #define ARRAY(_type, _sign) \
122 120 (void) printf("\t{ 0,\t%d,\t%d,\t%d },\t\t/* elt0 */\n", \
123 121 sizeof (*((_type *)0)[0]), \
124 122 sizeof (_type) / sizeof (*((_type *)0)[0]), _sign)
125 123 #define END (void) printf("};\n")
126 124
127 125
128 126 /* auxv_t, <sys/auxv.h> */
129 127 static void
130 128 gen_auxv(void)
131 129 {
132 130 START(auxv, auxv_t);
133 131
134 132 SCALAR_FIELD(auxv_t, a_type, 1);
135 133 SCALAR_FIELD(auxv_t, a_un.a_val, 1);
136 134 SCALAR_FIELD(auxv_t, a_un.a_ptr, 0);
137 135 SCALAR_FIELD(auxv_t, a_un.a_fcn, 0);
138 136
139 137 END;
140 138 }
141 139
142 140
143 141 /* prgregset_t, <sys/prgregset.h> */
144 142 static void
145 143 gen_prgregset(void)
146 144 {
147 145 START(prgregset, prgregset_t);
148 146
149 147 ARRAY(prgregset_t, 0);
150 148
151 149 END;
152 150 }
153 151
154 152
155 153 /* lwpstatus_t, <sys/procfs.h> */
156 154 static void
157 155 gen_lwpstatus(void)
158 156 {
159 157 START(lwpstatus, lwpstatus_t);
160 158
161 159 SCALAR_FIELD(lwpstatus_t, pr_flags, 0);
162 160 SCALAR_FIELD(lwpstatus_t, pr_lwpid, 0);
163 161 SCALAR_FIELD(lwpstatus_t, pr_why, 0);
164 162 SCALAR_FIELD(lwpstatus_t, pr_what, 0);
165 163 SCALAR_FIELD(lwpstatus_t, pr_cursig, 0);
166 164 SCALAR_FIELD(lwpstatus_t, pr_info, 0);
167 165 SCALAR_FIELD(lwpstatus_t, pr_lwppend, 0);
168 166 SCALAR_FIELD(lwpstatus_t, pr_lwphold, 0);
169 167 SCALAR_FIELD(lwpstatus_t, pr_action, 0);
170 168 SCALAR_FIELD(lwpstatus_t, pr_altstack, 0);
171 169 SCALAR_FIELD(lwpstatus_t, pr_oldcontext, 0);
172 170 SCALAR_FIELD(lwpstatus_t, pr_syscall, 0);
173 171 SCALAR_FIELD(lwpstatus_t, pr_nsysarg, 0);
174 172 SCALAR_FIELD(lwpstatus_t, pr_errno, 0);
175 173 ARRAY_FIELD(lwpstatus_t, pr_sysarg, 0);
176 174 SCALAR_FIELD(lwpstatus_t, pr_rval1, 0);
177 175 SCALAR_FIELD(lwpstatus_t, pr_rval2, 0);
178 176 ARRAY_FIELD(lwpstatus_t, pr_clname, 0);
179 177 SCALAR_FIELD(lwpstatus_t, pr_tstamp, 0);
180 178 SCALAR_FIELD(lwpstatus_t, pr_utime, 0);
181 179 SCALAR_FIELD(lwpstatus_t, pr_stime, 0);
182 180 SCALAR_FIELD(lwpstatus_t, pr_errpriv, 0);
183 181 SCALAR_FIELD(lwpstatus_t, pr_ustack, 0);
184 182 SCALAR_FIELD(lwpstatus_t, pr_instr, 0);
185 183 SCALAR_FIELD(lwpstatus_t, pr_reg, 0);
186 184 SCALAR_FIELD(lwpstatus_t, pr_fpreg, 0);
187 185
188 186 END;
189 187 }
190 188
191 189
192 190 /* pstatus_t, <sys/procfs.h> */
193 191 static void
194 192 gen_pstatus(void)
195 193 {
196 194 START(pstatus, pstatus_t);
197 195
198 196 SCALAR_FIELD(pstatus_t, pr_flags, 1);
199 197 SCALAR_FIELD(pstatus_t, pr_nlwp, 1);
200 198 SCALAR_FIELD(pstatus_t, pr_pid, 0);
201 199 SCALAR_FIELD(pstatus_t, pr_ppid, 0);
202 200 SCALAR_FIELD(pstatus_t, pr_pgid, 0);
203 201 SCALAR_FIELD(pstatus_t, pr_sid, 0);
204 202 SCALAR_FIELD(pstatus_t, pr_aslwpid, 1);
205 203 SCALAR_FIELD(pstatus_t, pr_agentid, 1);
206 204 SCALAR_FIELD(pstatus_t, pr_sigpend, 0);
207 205 SCALAR_FIELD(pstatus_t, pr_brkbase, 0);
208 206 SCALAR_FIELD(pstatus_t, pr_brksize, 0);
209 207 SCALAR_FIELD(pstatus_t, pr_stkbase, 0);
210 208 SCALAR_FIELD(pstatus_t, pr_stksize, 0);
211 209 SCALAR_FIELD(pstatus_t, pr_utime, 0);
212 210 SCALAR_FIELD(pstatus_t, pr_stime, 0);
213 211 SCALAR_FIELD(pstatus_t, pr_cutime, 0);
214 212 SCALAR_FIELD(pstatus_t, pr_cstime, 0);
215 213 SCALAR_FIELD(pstatus_t, pr_sigtrace, 0);
216 214 SCALAR_FIELD(pstatus_t, pr_flttrace, 0);
217 215 SCALAR_FIELD(pstatus_t, pr_sysentry, 0);
218 216 SCALAR_FIELD(pstatus_t, pr_sysexit, 0);
219 217 SCALAR_FIELD(pstatus_t, pr_dmodel, 0);
220 218 SCALAR_FIELD(pstatus_t, pr_taskid, 1);
221 219 SCALAR_FIELD(pstatus_t, pr_projid, 1);
222 220 SCALAR_FIELD(pstatus_t, pr_nzomb, 1);
223 221 SCALAR_FIELD(pstatus_t, pr_zoneid, 1);
224 222 SCALAR_FIELD(pstatus_t, pr_lwp, 0);
225 223
226 224 END;
227 225 }
228 226
229 227
230 228 /* prstatus_t, <sys/old_procfs.h> */
231 229 static void
232 230 gen_prstatus(void)
233 231 {
234 232 START(prstatus, prstatus_t);
235 233
236 234 SCALAR_FIELD(prstatus_t, pr_flags, 1);
237 235 SCALAR_FIELD(prstatus_t, pr_why, 1);
238 236 SCALAR_FIELD(prstatus_t, pr_what, 1);
239 237 SCALAR_FIELD(prstatus_t, pr_info, 0);
240 238 SCALAR_FIELD(prstatus_t, pr_cursig, 1);
241 239 SCALAR_FIELD(prstatus_t, pr_nlwp, 0);
242 240 SCALAR_FIELD(prstatus_t, pr_sigpend, 0);
243 241 SCALAR_FIELD(prstatus_t, pr_sighold, 0);
244 242 SCALAR_FIELD(prstatus_t, pr_altstack, 0);
245 243 SCALAR_FIELD(prstatus_t, pr_action, 0);
246 244 SCALAR_FIELD(prstatus_t, pr_pid, 0);
247 245 SCALAR_FIELD(prstatus_t, pr_ppid, 0);
248 246 SCALAR_FIELD(prstatus_t, pr_pgrp, 0);
249 247 SCALAR_FIELD(prstatus_t, pr_sid, 0);
250 248 SCALAR_FIELD(prstatus_t, pr_utime, 0);
251 249 SCALAR_FIELD(prstatus_t, pr_stime, 0);
252 250 SCALAR_FIELD(prstatus_t, pr_cutime, 0);
253 251 SCALAR_FIELD(prstatus_t, pr_cstime, 0);
254 252 ARRAY_FIELD(prstatus_t, pr_clname, 0);
255 253 SCALAR_FIELD(prstatus_t, pr_syscall, 1);
256 254 SCALAR_FIELD(prstatus_t, pr_nsysarg, 1);
257 255 ARRAY_FIELD(prstatus_t, pr_sysarg, 1);
258 256 SCALAR_FIELD(prstatus_t, pr_who, 0);
259 257 SCALAR_FIELD(prstatus_t, pr_lwppend, 0);
260 258 SCALAR_FIELD(prstatus_t, pr_oldcontext, 0);
261 259 SCALAR_FIELD(prstatus_t, pr_brkbase, 0);
262 260 SCALAR_FIELD(prstatus_t, pr_brksize, 0);
263 261 SCALAR_FIELD(prstatus_t, pr_stkbase, 0);
264 262 SCALAR_FIELD(prstatus_t, pr_stksize, 0);
265 263 SCALAR_FIELD(prstatus_t, pr_processor, 1);
266 264 SCALAR_FIELD(prstatus_t, pr_bind, 1);
267 265 SCALAR_FIELD(prstatus_t, pr_instr, 1);
268 266 SCALAR_FIELD(prstatus_t, pr_reg, 0);
269 267
270 268 END;
271 269 }
272 270
273 271
274 272 /* psinfo_t, <sys/procfs.h> */
275 273 static void
276 274 gen_psinfo(void)
277 275 {
278 276 START(psinfo, psinfo_t);
279 277
280 278 SCALAR_FIELD(psinfo_t, pr_flag, 1);
281 279 SCALAR_FIELD(psinfo_t, pr_nlwp, 1);
282 280 SCALAR_FIELD(psinfo_t, pr_pid, 0);
283 281 SCALAR_FIELD(psinfo_t, pr_ppid, 0);
284 282 SCALAR_FIELD(psinfo_t, pr_pgid, 0);
285 283 SCALAR_FIELD(psinfo_t, pr_sid, 0);
286 284 SCALAR_FIELD(psinfo_t, pr_uid, 0);
287 285 SCALAR_FIELD(psinfo_t, pr_euid, 0);
288 286 SCALAR_FIELD(psinfo_t, pr_gid, 0);
289 287 SCALAR_FIELD(psinfo_t, pr_egid, 0);
290 288 SCALAR_FIELD(psinfo_t, pr_addr, 0);
291 289 SCALAR_FIELD(psinfo_t, pr_size, 0);
292 290 SCALAR_FIELD(psinfo_t, pr_rssize, 0);
293 291 SCALAR_FIELD(psinfo_t, pr_ttydev, 0);
294 292 SCALAR_FIELD(psinfo_t, pr_pctcpu, 0);
295 293 SCALAR_FIELD(psinfo_t, pr_pctmem, 0);
296 294 SCALAR_FIELD(psinfo_t, pr_start, 0);
297 295 SCALAR_FIELD(psinfo_t, pr_time, 0);
298 296 SCALAR_FIELD(psinfo_t, pr_ctime, 0);
299 297 ARRAY_FIELD(psinfo_t, pr_fname, 0);
300 298 ARRAY_FIELD(psinfo_t, pr_psargs, 0);
301 299 SCALAR_FIELD(psinfo_t, pr_wstat, 1);
302 300 SCALAR_FIELD(psinfo_t, pr_argc, 1);
303 301 SCALAR_FIELD(psinfo_t, pr_argv, 0);
304 302 SCALAR_FIELD(psinfo_t, pr_envp, 0);
305 303 SCALAR_FIELD(psinfo_t, pr_dmodel, 0);
306 304 SCALAR_FIELD(psinfo_t, pr_taskid, 0);
307 305 SCALAR_FIELD(psinfo_t, pr_projid, 0);
308 306 SCALAR_FIELD(psinfo_t, pr_nzomb, 1);
309 307 SCALAR_FIELD(psinfo_t, pr_poolid, 0);
310 308 SCALAR_FIELD(psinfo_t, pr_zoneid, 0);
311 309 SCALAR_FIELD(psinfo_t, pr_contract, 0);
312 310 SCALAR_FIELD(psinfo_t, pr_lwp, 0);
313 311
314 312 END;
315 313 }
316 314
317 315 /* prpsinfo_t, <sys/old_procfs.h> */
318 316 static void
319 317 gen_prpsinfo(void)
320 318 {
321 319 START(prpsinfo, prpsinfo_t);
322 320
323 321 SCALAR_FIELD(prpsinfo_t, pr_state, 0);
324 322 SCALAR_FIELD(prpsinfo_t, pr_sname, 0);
325 323 SCALAR_FIELD(prpsinfo_t, pr_zomb, 0);
326 324 SCALAR_FIELD(prpsinfo_t, pr_nice, 0);
327 325 SCALAR_FIELD(prpsinfo_t, pr_flag, 0);
328 326 SCALAR_FIELD(prpsinfo_t, pr_uid, 0);
329 327 SCALAR_FIELD(prpsinfo_t, pr_gid, 0);
330 328 SCALAR_FIELD(prpsinfo_t, pr_pid, 0);
331 329 SCALAR_FIELD(prpsinfo_t, pr_ppid, 0);
332 330 SCALAR_FIELD(prpsinfo_t, pr_pgrp, 0);
333 331 SCALAR_FIELD(prpsinfo_t, pr_sid, 0);
334 332 SCALAR_FIELD(prpsinfo_t, pr_addr, 0);
335 333 SCALAR_FIELD(prpsinfo_t, pr_size, 0);
336 334 SCALAR_FIELD(prpsinfo_t, pr_rssize, 0);
337 335 SCALAR_FIELD(prpsinfo_t, pr_wchan, 0);
338 336 SCALAR_FIELD(prpsinfo_t, pr_start, 0);
339 337 SCALAR_FIELD(prpsinfo_t, pr_time, 0);
340 338 SCALAR_FIELD(prpsinfo_t, pr_pri, 1);
341 339 SCALAR_FIELD(prpsinfo_t, pr_oldpri, 0);
342 340 SCALAR_FIELD(prpsinfo_t, pr_cpu, 0);
343 341 SCALAR_FIELD(prpsinfo_t, pr_ottydev, 0);
344 342 SCALAR_FIELD(prpsinfo_t, pr_lttydev, 0);
345 343 ARRAY_FIELD(prpsinfo_t, pr_clname, 0);
346 344 ARRAY_FIELD(prpsinfo_t, pr_fname, 0);
347 345 ARRAY_FIELD(prpsinfo_t, pr_psargs, 0);
348 346 SCALAR_FIELD(prpsinfo_t, pr_syscall, 1);
349 347 SCALAR_FIELD(prpsinfo_t, pr_ctime, 0);
350 348 SCALAR_FIELD(prpsinfo_t, pr_bysize, 0);
351 349 SCALAR_FIELD(prpsinfo_t, pr_byrssize, 0);
352 350 SCALAR_FIELD(prpsinfo_t, pr_argc, 1);
353 351 SCALAR_FIELD(prpsinfo_t, pr_argv, 0);
354 352 SCALAR_FIELD(prpsinfo_t, pr_envp, 0);
355 353 SCALAR_FIELD(prpsinfo_t, pr_wstat, 1);
356 354 SCALAR_FIELD(prpsinfo_t, pr_pctcpu, 0);
357 355 SCALAR_FIELD(prpsinfo_t, pr_pctmem, 0);
358 356 SCALAR_FIELD(prpsinfo_t, pr_euid, 0);
359 357 SCALAR_FIELD(prpsinfo_t, pr_egid, 0);
360 358 SCALAR_FIELD(prpsinfo_t, pr_aslwpid, 0);
361 359 SCALAR_FIELD(prpsinfo_t, pr_dmodel, 0);
362 360
363 361 END;
364 362 }
365 363
366 364 /* lwpsinfo_t, <sys/procfs.h> */
367 365 static void
368 366 gen_lwpsinfo(void)
369 367 {
370 368 START(lwpsinfo, lwpsinfo_t);
371 369
372 370 SCALAR_FIELD(lwpsinfo_t, pr_flag, 1);
373 371 SCALAR_FIELD(lwpsinfo_t, pr_lwpid, 0);
374 372 SCALAR_FIELD(lwpsinfo_t, pr_addr, 0);
375 373 SCALAR_FIELD(lwpsinfo_t, pr_wchan, 0);
376 374 SCALAR_FIELD(lwpsinfo_t, pr_stype, 0);
377 375 SCALAR_FIELD(lwpsinfo_t, pr_state, 0);
378 376 SCALAR_FIELD(lwpsinfo_t, pr_sname, 0);
379 377 SCALAR_FIELD(lwpsinfo_t, pr_nice, 0);
380 378 SCALAR_FIELD(lwpsinfo_t, pr_syscall, 0);
381 379 SCALAR_FIELD(lwpsinfo_t, pr_oldpri, 0);
382 380 SCALAR_FIELD(lwpsinfo_t, pr_cpu, 0);
383 381 SCALAR_FIELD(lwpsinfo_t, pr_pri, 1);
384 382 SCALAR_FIELD(lwpsinfo_t, pr_pctcpu, 0);
385 383 SCALAR_FIELD(lwpsinfo_t, pr_start, 0);
386 384 SCALAR_FIELD(lwpsinfo_t, pr_time, 0);
387 385 ARRAY_FIELD(lwpsinfo_t, pr_clname, 0);
388 386 ARRAY_FIELD(lwpsinfo_t, pr_name, 0);
389 387 SCALAR_FIELD(lwpsinfo_t, pr_onpro, 1);
390 388 SCALAR_FIELD(lwpsinfo_t, pr_bindpro, 1);
391 389 SCALAR_FIELD(lwpsinfo_t, pr_bindpset, 1);
392 390 SCALAR_FIELD(lwpsinfo_t, pr_lgrp, 1);
393 391
394 392 END;
395 393 }
396 394
397 395 /* prcred_t, <sys/procfs.h> */
398 396 static void
399 397 gen_prcred(void)
400 398 {
401 399 START(prcred, prcred_t);
402 400
403 401 SCALAR_FIELD(prcred_t, pr_euid, 0);
404 402 SCALAR_FIELD(prcred_t, pr_ruid, 0);
405 403 SCALAR_FIELD(prcred_t, pr_suid, 0);
406 404 SCALAR_FIELD(prcred_t, pr_egid, 0);
407 405 SCALAR_FIELD(prcred_t, pr_rgid, 0);
408 406 SCALAR_FIELD(prcred_t, pr_sgid, 0);
409 407 SCALAR_FIELD(prcred_t, pr_ngroups, 1);
410 408 ARRAY_FIELD(prcred_t, pr_groups, 0);
411 409
412 410 END;
413 411 }
414 412
415 413 /* prpriv_t, <sys/procfs.h> */
416 414 static void
417 415 gen_prpriv(void)
418 416 {
419 417 START(prpriv, prpriv_t);
420 418
421 419 SCALAR_FIELD(prpriv_t, pr_nsets, 0);
422 420 SCALAR_FIELD(prpriv_t, pr_setsize, 0);
423 421 SCALAR_FIELD(prpriv_t, pr_infosize, 0);
424 422 ARRAY_FIELD(prpriv_t, pr_sets, 0);
425 423
426 424 END;
427 425 }
428 426
429 427
430 428 /* priv_impl_info_t, <sys/priv.h> */
431 429 static void
432 430 gen_priv_impl_info(void)
433 431 {
434 432 START(priv_impl_info, priv_impl_info_t);
435 433
436 434 SCALAR_FIELD(priv_impl_info_t, priv_headersize, 0);
437 435 SCALAR_FIELD(priv_impl_info_t, priv_flags, 0);
438 436 SCALAR_FIELD(priv_impl_info_t, priv_nsets, 0);
439 437 SCALAR_FIELD(priv_impl_info_t, priv_setsize, 0);
440 438 SCALAR_FIELD(priv_impl_info_t, priv_max, 0);
441 439 SCALAR_FIELD(priv_impl_info_t, priv_infosize, 0);
442 440 SCALAR_FIELD(priv_impl_info_t, priv_globalinfosize, 0);
443 441
444 442 END;
445 443 }
446 444
447 445
448 446 /* fltset_t, <sys/fault.h> */
449 447 static void
450 448 gen_fltset(void)
451 449 {
452 450 START(fltset, fltset_t);
453 451
454 452 ARRAY_FIELD(fltset_t, word, 0);
455 453
456 454 END;
457 455 }
458 456
459 457 /* Layout description of siginfo_t, <sys/siginfo.h> */
460 458 static void
461 459 gen_siginfo(void)
462 460 {
463 461 START(siginfo, siginfo_t);
464 462
465 463 SCALAR_FIELD(siginfo_t, si_signo, 0);
466 464 SCALAR_FIELD(siginfo_t, si_errno, 0);
467 465 SCALAR_FIELD(siginfo_t, si_code, 1);
468 466 SCALAR_FIELD(siginfo_t, si_value.sival_int, 0);
469 467 SCALAR_FIELD(siginfo_t, si_value.sival_ptr, 0);
470 468 SCALAR_FIELD(siginfo_t, si_pid, 0);
471 469 SCALAR_FIELD(siginfo_t, si_uid, 0);
472 470 SCALAR_FIELD(siginfo_t, si_ctid, 0);
473 471 SCALAR_FIELD(siginfo_t, si_zoneid, 0);
474 472 SCALAR_FIELD(siginfo_t, si_entity, 0);
475 473 SCALAR_FIELD(siginfo_t, si_addr, 0);
476 474 SCALAR_FIELD(siginfo_t, si_status, 0);
477 475 SCALAR_FIELD(siginfo_t, si_band, 0);
478 476
479 477 END;
480 478 }
481 479
482 480 /* sigset_t, <sys/signal.h> */
483 481 static void
484 482 gen_sigset(void)
485 483 {
486 484 START(sigset, sigset_t);
487 485
488 486 ARRAY_FIELD(sigset_t, __sigbits, 0);
489 487
490 488 END;
491 489 }
492 490
493 491
494 492 /* struct sigaction, <sys/signal.h> */
495 493 static void
496 494 gen_sigaction(void)
497 495 {
498 496 START(sigaction, struct sigaction);
499 497
500 498 SCALAR_FIELD(struct sigaction, sa_flags, 0);
501 499 SCALAR_FIELD(struct sigaction, sa_handler, 0);
502 500 SCALAR_FIELD(struct sigaction, sa_sigaction, 0);
503 501 SCALAR_FIELD(struct sigaction, sa_mask, 0);
504 502
505 503 END;
506 504 }
507 505
508 506 /* stack_t, <sys/signal.h> */
509 507 static void
510 508 gen_stack(void)
511 509 {
512 510 START(stack, stack_t);
513 511
514 512 SCALAR_FIELD(stack_t, ss_sp, 0);
515 513 SCALAR_FIELD(stack_t, ss_size, 0);
516 514 SCALAR_FIELD(stack_t, ss_flags, 0);
517 515
518 516 END;
519 517 }
520 518
521 519 /* sysset_t, <sys/syscall.h> */
522 520 static void
523 521 gen_sysset(void)
524 522 {
525 523 START(sysset, sysset_t);
526 524
527 525 ARRAY_FIELD(sysset_t, word, 0);
528 526
529 527 END;
530 528 }
531 529
532 530 /* timestruc_t, <sys/time_impl.h> */
533 531 static void
534 532 gen_timestruc(void)
535 533 {
536 534 START(timestruc, timestruc_t);
537 535
538 536 SCALAR_FIELD(timestruc_t, tv_sec, 0);
539 537 SCALAR_FIELD(timestruc_t, tv_nsec, 0);
540 538
541 539 END;
542 540 }
543 541
544 542 /* struct utsname, <sys/utsname.h> */
545 543 static void
546 544 gen_utsname(void)
547 545 {
548 546 START(utsname, struct utsname);
↓ open down ↓ |
511 lines elided |
↑ open up ↑ |
549 547
550 548 ARRAY_FIELD(struct utsname, sysname, 0);
551 549 ARRAY_FIELD(struct utsname, nodename, 0);
552 550 ARRAY_FIELD(struct utsname, release, 0);
553 551 ARRAY_FIELD(struct utsname, version, 0);
554 552 ARRAY_FIELD(struct utsname, machine, 0);
555 553
556 554 END;
557 555 }
558 556
557 +static void
558 +gen_prfdinfo(void)
559 +{
560 + START(prfdinfo, prfdinfo_t);
561 +
562 + SCALAR_FIELD(prfdinfo_t, pr_fd, 0);
563 + SCALAR_FIELD(prfdinfo_t, pr_mode, 0);
564 + SCALAR_FIELD(prfdinfo_t, pr_uid, 0);
565 + SCALAR_FIELD(prfdinfo_t, pr_gid, 0);
566 + SCALAR_FIELD(prfdinfo_t, pr_major, 0);
567 + SCALAR_FIELD(prfdinfo_t, pr_minor, 0);
568 + SCALAR_FIELD(prfdinfo_t, pr_rmajor, 0);
569 + SCALAR_FIELD(prfdinfo_t, pr_rminor, 0);
570 + SCALAR_FIELD(prfdinfo_t, pr_ino, 0);
571 + SCALAR_FIELD(prfdinfo_t, pr_offset, 0);
572 + SCALAR_FIELD(prfdinfo_t, pr_size, 0);
573 + SCALAR_FIELD(prfdinfo_t, pr_fileflags, 0);
574 + SCALAR_FIELD(prfdinfo_t, pr_fdflags, 0);
575 + ARRAY_FIELD(prfdinfo_t, pr_path, 0);
576 +
577 + END;
578 +}
579 +
559 580
560 581 /*ARGSUSED*/
561 582 int
562 583 main(int argc, char *argv[])
563 584 {
564 585 const char *fmt = "\t&%s_layout,\n";
565 586
566 587 printf("#include <struct_layout.h>\n");
567 588
568 589 gen_auxv();
569 590 gen_prgregset();
570 591 gen_lwpstatus();
571 592 gen_pstatus();
572 593 gen_prstatus();
573 594 gen_psinfo();
574 595 gen_prpsinfo();
575 596 gen_lwpsinfo();
576 597 gen_prcred();
↓ open down ↓ |
8 lines elided |
↑ open up ↑ |
577 598 gen_prpriv();
578 599 gen_priv_impl_info();
579 600 gen_fltset();
580 601 gen_siginfo();
581 602 gen_sigset();
582 603 gen_sigaction();
583 604 gen_stack();
584 605 gen_sysset();
585 606 gen_timestruc();
586 607 gen_utsname();
608 + gen_prfdinfo();
587 609
588 610
589 611 /*
590 612 * Generate the full arch_layout description
591 613 */
592 614 (void) printf(
593 615 "\n\n\n\nstatic const sl_arch_layout_t layout_%s = {\n",
594 616 MACH);
595 617 (void) printf(fmt, "auxv");
596 618 (void) printf(fmt, "fltset");
597 619 (void) printf(fmt, "lwpsinfo");
598 620 (void) printf(fmt, "lwpstatus");
599 621 (void) printf(fmt, "prcred");
600 622 (void) printf(fmt, "priv_impl_info");
601 623 (void) printf(fmt, "prpriv");
602 624 (void) printf(fmt, "psinfo");
603 625 (void) printf(fmt, "pstatus");
↓ open down ↓ |
7 lines elided |
↑ open up ↑ |
604 626 (void) printf(fmt, "prgregset");
605 627 (void) printf(fmt, "prpsinfo");
606 628 (void) printf(fmt, "prstatus");
607 629 (void) printf(fmt, "sigaction");
608 630 (void) printf(fmt, "siginfo");
609 631 (void) printf(fmt, "sigset");
610 632 (void) printf(fmt, "stack");
611 633 (void) printf(fmt, "sysset");
612 634 (void) printf(fmt, "timestruc");
613 635 (void) printf(fmt, "utsname");
636 + (void) printf(fmt, "prfdinfo");
614 637 (void) printf("};\n");
615 638
616 639 /*
617 640 * A public function, to make the information available
618 641 */
619 642 (void) printf("\n\nconst sl_arch_layout_t *\n");
620 643 (void) printf("struct_layout_%s(void)\n", MACH);
621 644 (void) printf("{\n\treturn (&layout_%s);\n}\n", MACH);
622 645
623 646 return (0);
624 647 }
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX