Print this page
8158 Want named threads API
9857 proc manpages should have LIBRARY section
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/exec/elf/elf_notes.c
+++ new/usr/src/uts/common/exec/elf/elf_notes.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, Version 1.0 only
6 6 * (the "License"). You may not use this file except in compliance
7 7 * with the License.
8 8 *
9 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 10 * or http://www.opensolaris.org/os/licensing.
11 11 * See the License for the specific language governing permissions
12 12 * and limitations under the License.
13 13 *
14 14 * When distributing Covered Code, include this CDDL HEADER in each
15 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 16 * If applicable, add the following below this CDDL HEADER, with the
17 17 * fields enclosed by brackets "[]" replaced with your own identifying
18 18 * information: Portions Copyright [yyyy] [name of copyright owner]
↓ open down ↓ |
18 lines elided |
↑ open up ↑ |
19 19 *
20 20 * CDDL HEADER END
21 21 */
22 22 /*
23 23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 24 * Use is subject to license terms.
25 25 */
26 26
27 27 /*
28 28 * Copyright 2012 DEY Storage Systems, Inc. All rights reserved.
29 - * Copyright (c) 2014, Joyent, Inc. All rights reserved.
29 + * Copyright 2018 Joyent, Inc.
30 30 */
31 31
32 32 #include <sys/types.h>
33 33 #include <sys/param.h>
34 34 #include <sys/thread.h>
35 35 #include <sys/sysmacros.h>
36 36 #include <sys/signal.h>
37 37 #include <sys/cred.h>
38 38 #include <sys/priv.h>
39 39 #include <sys/user.h>
40 40 #include <sys/file.h>
41 41 #include <sys/errno.h>
42 42 #include <sys/vnode.h>
43 43 #include <sys/mode.h>
44 44 #include <sys/vfs.h>
45 45 #include <sys/mman.h>
46 46 #include <sys/kmem.h>
47 47 #include <sys/proc.h>
48 48 #include <sys/pathname.h>
49 49 #include <sys/cmn_err.h>
50 50 #include <sys/systm.h>
51 51 #include <sys/elf.h>
52 52 #include <sys/vmsystm.h>
53 53 #include <sys/debug.h>
54 54 #include <sys/procfs.h>
55 55 #include <sys/regset.h>
56 56 #include <sys/auxv.h>
57 57 #include <sys/exec.h>
58 58 #include <sys/prsystm.h>
59 59 #include <sys/utsname.h>
60 60 #include <sys/zone.h>
61 61 #include <vm/as.h>
62 62 #include <vm/rm.h>
63 63 #include <sys/modctl.h>
64 64 #include <sys/systeminfo.h>
65 65 #include <sys/machelf.h>
66 66 #include <sys/sunddi.h>
67 67 #include "elf_impl.h"
68 68 #if defined(__i386) || defined(__i386_COMPAT)
69 69 #include <sys/sysi86.h>
70 70 #endif
71 71
72 72 void
73 73 setup_note_header(Phdr *v, proc_t *p)
74 74 {
75 75 int nlwp = p->p_lwpcnt;
76 76 int nzomb = p->p_zombcnt;
77 77 int nfd;
78 78 size_t size;
79 79 prcred_t *pcrp;
80 80 uf_info_t *fip;
81 81 uf_entry_t *ufp;
82 82 int fd;
83 83
84 84 fip = P_FINFO(p);
85 85 nfd = 0;
86 86 mutex_enter(&fip->fi_lock);
↓ open down ↓ |
47 lines elided |
↑ open up ↑ |
87 87 for (fd = 0; fd < fip->fi_nfiles; fd++) {
88 88 UF_ENTER(ufp, fip, fd);
89 89 if ((ufp->uf_file != NULL) && (ufp->uf_file->f_count > 0))
90 90 nfd++;
91 91 UF_EXIT(ufp);
92 92 }
93 93 mutex_exit(&fip->fi_lock);
94 94
95 95 v[0].p_type = PT_NOTE;
96 96 v[0].p_flags = PF_R;
97 - v[0].p_filesz = (sizeof (Note) * (10 + 2 * nlwp + nzomb + nfd))
97 + v[0].p_filesz = (sizeof (Note) * (10 + 3 * nlwp + nzomb + nfd))
98 98 + roundup(sizeof (psinfo_t), sizeof (Word))
99 99 + roundup(sizeof (pstatus_t), sizeof (Word))
100 100 + roundup(prgetprivsize(), sizeof (Word))
101 101 + roundup(priv_get_implinfo_size(), sizeof (Word))
102 102 + roundup(strlen(platform) + 1, sizeof (Word))
103 103 + roundup(strlen(p->p_zone->zone_name) + 1, sizeof (Word))
104 104 + roundup(__KERN_NAUXV_IMPL * sizeof (aux_entry_t), sizeof (Word))
105 105 + roundup(sizeof (utsname), sizeof (Word))
106 106 + roundup(sizeof (core_content_t), sizeof (Word))
107 107 + roundup(sizeof (prsecflags_t), sizeof (Word))
108 108 + (nlwp + nzomb) * roundup(sizeof (lwpsinfo_t), sizeof (Word))
109 109 + nlwp * roundup(sizeof (lwpstatus_t), sizeof (Word))
110 + + nlwp * roundup(sizeof (prlwpname_t), sizeof (Word))
110 111 + nfd * roundup(sizeof (prfdinfo_t), sizeof (Word));
111 112
112 113 if (curproc->p_agenttp != NULL) {
113 114 v[0].p_filesz += sizeof (Note) +
114 115 roundup(sizeof (psinfo_t), sizeof (Word));
115 116 }
116 117
117 118 size = sizeof (prcred_t) + sizeof (gid_t) * (ngroups_max - 1);
118 119 pcrp = kmem_alloc(size, KM_SLEEP);
119 120 prgetcred(p, pcrp);
120 121 if (pcrp->pr_ngroups != 0) {
121 122 v[0].p_filesz += sizeof (Note) + roundup(sizeof (prcred_t) +
122 123 sizeof (gid_t) * (pcrp->pr_ngroups - 1), sizeof (Word));
123 124 } else {
124 125 v[0].p_filesz += sizeof (Note) +
125 126 roundup(sizeof (prcred_t), sizeof (Word));
126 127 }
127 128 kmem_free(pcrp, size);
128 129
129 130
130 131 #if defined(__i386) || defined(__i386_COMPAT)
131 132 mutex_enter(&p->p_ldtlock);
132 133 size = prnldt(p) * sizeof (struct ssd);
133 134 mutex_exit(&p->p_ldtlock);
134 135 if (size != 0)
135 136 v[0].p_filesz += sizeof (Note) + roundup(size, sizeof (Word));
136 137 #endif /* __i386 || __i386_COMPAT */
137 138
138 139 if ((size = prhasx(p)? prgetprxregsize(p) : 0) != 0)
139 140 v[0].p_filesz += nlwp * sizeof (Note)
140 141 + nlwp * roundup(size, sizeof (Word));
141 142
142 143 #if defined(__sparc)
143 144 /*
144 145 * Figure out the number and sizes of register windows.
145 146 */
146 147 {
147 148 kthread_t *t = p->p_tlist;
148 149 do {
149 150 if ((size = prnwindows(ttolwp(t))) != 0) {
150 151 size = sizeof (gwindows_t) -
151 152 (SPARC_MAXREGWINDOW - size) *
152 153 sizeof (struct rwindow);
153 154 v[0].p_filesz += sizeof (Note) +
154 155 roundup(size, sizeof (Word));
155 156 }
156 157 } while ((t = t->t_forw) != p->p_tlist);
157 158 }
158 159 /*
159 160 * Space for the Ancillary State Registers.
160 161 */
161 162 if (p->p_model == DATAMODEL_LP64)
162 163 v[0].p_filesz += nlwp * sizeof (Note)
163 164 + nlwp * roundup(sizeof (asrset_t), sizeof (Word));
164 165 #endif /* __sparc */
165 166 }
166 167
167 168 int
168 169 write_elfnotes(proc_t *p, int sig, vnode_t *vp, offset_t offset,
169 170 rlim64_t rlimit, cred_t *credp, core_content_t content)
170 171 {
171 172 union {
172 173 psinfo_t psinfo;
173 174 pstatus_t pstatus;
174 175 lwpsinfo_t lwpsinfo;
175 176 lwpstatus_t lwpstatus;
176 177 #if defined(__sparc)
177 178 gwindows_t gwindows;
178 179 asrset_t asrset;
179 180 #endif /* __sparc */
180 181 char xregs[1];
181 182 aux_entry_t auxv[__KERN_NAUXV_IMPL];
182 183 prcred_t pcred;
183 184 prpriv_t ppriv;
184 185 priv_impl_info_t prinfo;
185 186 struct utsname uts;
186 187 prsecflags_t psecflags;
187 188 } *bigwad;
188 189
189 190 size_t xregsize = prhasx(p)? prgetprxregsize(p) : 0;
190 191 size_t crsize = sizeof (prcred_t) + sizeof (gid_t) * (ngroups_max - 1);
191 192 size_t psize = prgetprivsize();
192 193 size_t bigsize = MAX(psize, MAX(sizeof (*bigwad),
193 194 MAX(xregsize, crsize)));
194 195
195 196 priv_impl_info_t *prii;
196 197
197 198 lwpdir_t *ldp;
198 199 lwpent_t *lep;
199 200 kthread_t *t;
200 201 klwp_t *lwp;
201 202 user_t *up;
202 203 int i;
203 204 int nlwp;
204 205 int nzomb;
205 206 int error;
206 207 uchar_t oldsig;
207 208 uf_info_t *fip;
208 209 int fd;
209 210 vnode_t *vroot;
210 211
211 212 #if defined(__i386) || defined(__i386_COMPAT)
212 213 struct ssd *ssd;
213 214 size_t ssdsize;
214 215 #endif /* __i386 || __i386_COMPAT */
215 216
216 217 bigsize = MAX(bigsize, priv_get_implinfo_size());
217 218
218 219 bigwad = kmem_alloc(bigsize, KM_SLEEP);
219 220
220 221 /*
221 222 * The order of the elfnote entries should be same here
222 223 * and in the gcore(1) command. Synchronization is
223 224 * needed between the kernel and gcore(1).
224 225 */
225 226
226 227 /*
227 228 * Get the psinfo, and set the wait status to indicate that a core was
228 229 * dumped. We have to forge this since p->p_wcode is not set yet.
229 230 */
230 231 mutex_enter(&p->p_lock);
231 232 prgetpsinfo(p, &bigwad->psinfo);
232 233 mutex_exit(&p->p_lock);
233 234 bigwad->psinfo.pr_wstat = wstat(CLD_DUMPED, sig);
234 235
235 236 error = elfnote(vp, &offset, NT_PSINFO, sizeof (bigwad->psinfo),
236 237 (caddr_t)&bigwad->psinfo, rlimit, credp);
237 238 if (error)
238 239 goto done;
239 240
240 241 /*
241 242 * Modify t_whystop and lwp_cursig so it appears that the current LWP
242 243 * is stopped after faulting on the signal that caused the core dump.
243 244 * As a result, prgetstatus() will record that signal, the saved
244 245 * lwp_siginfo, and its signal handler in the core file status. We
245 246 * restore lwp_cursig in case a subsequent signal was received while
246 247 * dumping core.
247 248 */
248 249 mutex_enter(&p->p_lock);
249 250 lwp = ttolwp(curthread);
250 251
251 252 oldsig = lwp->lwp_cursig;
252 253 lwp->lwp_cursig = (uchar_t)sig;
253 254 curthread->t_whystop = PR_FAULTED;
254 255
255 256 prgetstatus(p, &bigwad->pstatus, p->p_zone);
256 257 bigwad->pstatus.pr_lwp.pr_why = 0;
257 258
258 259 curthread->t_whystop = 0;
259 260 lwp->lwp_cursig = oldsig;
260 261 mutex_exit(&p->p_lock);
261 262
262 263 error = elfnote(vp, &offset, NT_PSTATUS, sizeof (bigwad->pstatus),
263 264 (caddr_t)&bigwad->pstatus, rlimit, credp);
264 265 if (error)
265 266 goto done;
266 267
267 268 error = elfnote(vp, &offset, NT_PLATFORM, strlen(platform) + 1,
268 269 platform, rlimit, credp);
269 270 if (error)
270 271 goto done;
271 272
272 273 up = PTOU(p);
273 274 for (i = 0; i < __KERN_NAUXV_IMPL; i++) {
274 275 bigwad->auxv[i].a_type = up->u_auxv[i].a_type;
275 276 bigwad->auxv[i].a_un.a_val = up->u_auxv[i].a_un.a_val;
276 277 }
277 278 error = elfnote(vp, &offset, NT_AUXV, sizeof (bigwad->auxv),
278 279 (caddr_t)bigwad->auxv, rlimit, credp);
279 280 if (error)
280 281 goto done;
281 282
282 283 bcopy(&utsname, &bigwad->uts, sizeof (struct utsname));
283 284 if (!INGLOBALZONE(p)) {
284 285 bcopy(p->p_zone->zone_nodename, &bigwad->uts.nodename,
285 286 _SYS_NMLN);
286 287 }
287 288 error = elfnote(vp, &offset, NT_UTSNAME, sizeof (struct utsname),
288 289 (caddr_t)&bigwad->uts, rlimit, credp);
289 290 if (error)
290 291 goto done;
291 292
292 293 prgetsecflags(p, &bigwad->psecflags);
293 294 error = elfnote(vp, &offset, NT_SECFLAGS, sizeof (prsecflags_t),
294 295 (caddr_t)&bigwad->psecflags, rlimit, credp);
295 296 if (error)
296 297 goto done;
297 298
298 299 prgetcred(p, &bigwad->pcred);
299 300
300 301 if (bigwad->pcred.pr_ngroups != 0) {
301 302 crsize = sizeof (prcred_t) +
302 303 sizeof (gid_t) * (bigwad->pcred.pr_ngroups - 1);
303 304 } else
304 305 crsize = sizeof (prcred_t);
305 306
306 307 error = elfnote(vp, &offset, NT_PRCRED, crsize,
307 308 (caddr_t)&bigwad->pcred, rlimit, credp);
308 309 if (error)
309 310 goto done;
310 311
311 312 error = elfnote(vp, &offset, NT_CONTENT, sizeof (core_content_t),
312 313 (caddr_t)&content, rlimit, credp);
313 314 if (error)
314 315 goto done;
315 316
316 317 prgetpriv(p, &bigwad->ppriv);
317 318
318 319 error = elfnote(vp, &offset, NT_PRPRIV, psize,
319 320 (caddr_t)&bigwad->ppriv, rlimit, credp);
320 321 if (error)
321 322 goto done;
322 323
323 324 prii = priv_hold_implinfo();
324 325 error = elfnote(vp, &offset, NT_PRPRIVINFO, priv_get_implinfo_size(),
325 326 (caddr_t)prii, rlimit, credp);
326 327 priv_release_implinfo();
327 328 if (error)
328 329 goto done;
329 330
330 331 /* zone can't go away as long as process exists */
331 332 error = elfnote(vp, &offset, NT_ZONENAME,
332 333 strlen(p->p_zone->zone_name) + 1, p->p_zone->zone_name,
333 334 rlimit, credp);
334 335 if (error)
335 336 goto done;
336 337
337 338
338 339 /* open file table */
339 340 vroot = PTOU(p)->u_rdir;
340 341 if (vroot == NULL)
341 342 vroot = rootdir;
342 343
343 344 VN_HOLD(vroot);
344 345
345 346 fip = P_FINFO(p);
346 347
347 348 for (fd = 0; fd < fip->fi_nfiles; fd++) {
348 349 uf_entry_t *ufp;
349 350 vnode_t *fvp;
350 351 struct file *fp;
351 352 vattr_t vattr;
352 353 prfdinfo_t fdinfo;
353 354
354 355 bzero(&fdinfo, sizeof (fdinfo));
355 356
356 357 mutex_enter(&fip->fi_lock);
357 358 UF_ENTER(ufp, fip, fd);
358 359 if (((fp = ufp->uf_file) == NULL) || (fp->f_count < 1)) {
359 360 UF_EXIT(ufp);
360 361 mutex_exit(&fip->fi_lock);
361 362 continue;
362 363 }
363 364
364 365 fdinfo.pr_fd = fd;
365 366 fdinfo.pr_fdflags = ufp->uf_flag;
366 367 fdinfo.pr_fileflags = fp->f_flag2;
367 368 fdinfo.pr_fileflags <<= 16;
368 369 fdinfo.pr_fileflags |= fp->f_flag;
369 370 if ((fdinfo.pr_fileflags & (FSEARCH | FEXEC)) == 0)
370 371 fdinfo.pr_fileflags += FOPEN;
371 372 fdinfo.pr_offset = fp->f_offset;
372 373
373 374
374 375 fvp = fp->f_vnode;
375 376 VN_HOLD(fvp);
376 377 UF_EXIT(ufp);
377 378 mutex_exit(&fip->fi_lock);
378 379
379 380 /*
380 381 * There are some vnodes that have no corresponding
381 382 * path. Its reasonable for this to fail, in which
382 383 * case the path will remain an empty string.
383 384 */
384 385 (void) vnodetopath(vroot, fvp, fdinfo.pr_path,
385 386 sizeof (fdinfo.pr_path), credp);
386 387
387 388 if (VOP_GETATTR(fvp, &vattr, 0, credp, NULL) != 0) {
388 389 /*
389 390 * Try to write at least a subset of information
390 391 */
391 392 fdinfo.pr_major = 0;
392 393 fdinfo.pr_minor = 0;
393 394 fdinfo.pr_ino = 0;
394 395 fdinfo.pr_mode = 0;
395 396 fdinfo.pr_uid = (uid_t)-1;
396 397 fdinfo.pr_gid = (gid_t)-1;
397 398 fdinfo.pr_rmajor = 0;
398 399 fdinfo.pr_rminor = 0;
399 400 fdinfo.pr_size = -1;
400 401
401 402 error = elfnote(vp, &offset, NT_FDINFO,
402 403 sizeof (fdinfo), &fdinfo, rlimit, credp);
403 404 VN_RELE(fvp);
404 405 if (error) {
405 406 VN_RELE(vroot);
406 407 goto done;
407 408 }
408 409 continue;
409 410 }
410 411
411 412 if (fvp->v_type == VSOCK)
412 413 fdinfo.pr_fileflags |= sock_getfasync(fvp);
413 414
414 415 VN_RELE(fvp);
415 416
416 417 /*
417 418 * This logic mirrors fstat(), which we cannot use
418 419 * directly, as it calls copyout().
419 420 */
420 421 fdinfo.pr_major = getmajor(vattr.va_fsid);
421 422 fdinfo.pr_minor = getminor(vattr.va_fsid);
422 423 fdinfo.pr_ino = (ino64_t)vattr.va_nodeid;
423 424 fdinfo.pr_mode = VTTOIF(vattr.va_type) | vattr.va_mode;
424 425 fdinfo.pr_uid = vattr.va_uid;
425 426 fdinfo.pr_gid = vattr.va_gid;
426 427 fdinfo.pr_rmajor = getmajor(vattr.va_rdev);
427 428 fdinfo.pr_rminor = getminor(vattr.va_rdev);
428 429 fdinfo.pr_size = (off64_t)vattr.va_size;
429 430
430 431 error = elfnote(vp, &offset, NT_FDINFO,
431 432 sizeof (fdinfo), &fdinfo, rlimit, credp);
432 433 if (error) {
433 434 VN_RELE(vroot);
434 435 goto done;
435 436 }
436 437 }
437 438
438 439 VN_RELE(vroot);
439 440
440 441 #if defined(__i386) || defined(__i386_COMPAT)
441 442 mutex_enter(&p->p_ldtlock);
442 443 ssdsize = prnldt(p) * sizeof (struct ssd);
443 444 if (ssdsize != 0) {
444 445 ssd = kmem_alloc(ssdsize, KM_SLEEP);
445 446 prgetldt(p, ssd);
446 447 error = elfnote(vp, &offset, NT_LDT, ssdsize,
447 448 (caddr_t)ssd, rlimit, credp);
448 449 kmem_free(ssd, ssdsize);
↓ open down ↓ |
329 lines elided |
↑ open up ↑ |
449 450 }
450 451 mutex_exit(&p->p_ldtlock);
451 452 if (error)
452 453 goto done;
453 454 #endif /* __i386 || defined(__i386_COMPAT) */
454 455
455 456 nlwp = p->p_lwpcnt;
456 457 nzomb = p->p_zombcnt;
457 458 /* for each entry in the lwp directory ... */
458 459 for (ldp = p->p_lwpdir; nlwp + nzomb != 0; ldp++) {
460 + prlwpname_t name = { 0, };
459 461
460 462 if ((lep = ldp->ld_entry) == NULL) /* empty slot */
461 463 continue;
462 464
463 465 if ((t = lep->le_thread) != NULL) { /* active lwp */
464 466 ASSERT(nlwp != 0);
465 467 nlwp--;
466 468 lwp = ttolwp(t);
467 469 mutex_enter(&p->p_lock);
468 470 prgetlwpsinfo(t, &bigwad->lwpsinfo);
471 + if (t->t_name != NULL) {
472 + (void) strlcpy(name.pr_lwpname, t->t_name,
473 + sizeof (name.pr_lwpname));
474 + }
469 475 mutex_exit(&p->p_lock);
470 476 } else { /* zombie lwp */
471 477 ASSERT(nzomb != 0);
472 478 nzomb--;
473 479 bzero(&bigwad->lwpsinfo, sizeof (bigwad->lwpsinfo));
474 480 bigwad->lwpsinfo.pr_lwpid = lep->le_lwpid;
475 481 bigwad->lwpsinfo.pr_state = SZOMB;
476 482 bigwad->lwpsinfo.pr_sname = 'Z';
477 483 bigwad->lwpsinfo.pr_start.tv_sec = lep->le_start;
478 484 }
485 +
486 + name.pr_lwpid = bigwad->lwpsinfo.pr_lwpid;
487 +
479 488 error = elfnote(vp, &offset, NT_LWPSINFO,
480 489 sizeof (bigwad->lwpsinfo), (caddr_t)&bigwad->lwpsinfo,
481 490 rlimit, credp);
482 491 if (error)
483 492 goto done;
493 +
484 494 if (t == NULL) /* nothing more to do for a zombie */
485 495 continue;
486 496
487 497 mutex_enter(&p->p_lock);
488 498 if (t == curthread) {
489 499 /*
490 500 * Modify t_whystop and lwp_cursig so it appears that
491 501 * the current LWP is stopped after faulting on the
492 502 * signal that caused the core dump. As a result,
493 503 * prgetlwpstatus() will record that signal, the saved
494 504 * lwp_siginfo, and its signal handler in the core file
495 505 * status. We restore lwp_cursig in case a subsequent
496 506 * signal was received while dumping core.
497 507 */
498 508 oldsig = lwp->lwp_cursig;
499 509 lwp->lwp_cursig = (uchar_t)sig;
500 510 t->t_whystop = PR_FAULTED;
501 511
502 512 prgetlwpstatus(t, &bigwad->lwpstatus, p->p_zone);
503 513 bigwad->lwpstatus.pr_why = 0;
504 514
505 515 t->t_whystop = 0;
506 516 lwp->lwp_cursig = oldsig;
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
507 517 } else {
508 518 prgetlwpstatus(t, &bigwad->lwpstatus, p->p_zone);
509 519 }
510 520 mutex_exit(&p->p_lock);
511 521 error = elfnote(vp, &offset, NT_LWPSTATUS,
512 522 sizeof (bigwad->lwpstatus), (caddr_t)&bigwad->lwpstatus,
513 523 rlimit, credp);
514 524 if (error)
515 525 goto done;
516 526
527 + if ((error = elfnote(vp, &offset, NT_LWPNAME, sizeof (name),
528 + (caddr_t)&name, rlimit, credp)) != 0)
529 + goto done;
530 +
531 +
517 532 #if defined(__sparc)
518 533 /*
519 534 * Unspilled SPARC register windows.
520 535 */
521 536 {
522 537 size_t size = prnwindows(lwp);
523 538
524 539 if (size != 0) {
525 540 size = sizeof (gwindows_t) -
526 541 (SPARC_MAXREGWINDOW - size) *
527 542 sizeof (struct rwindow);
528 543 prgetwindows(lwp, &bigwad->gwindows);
529 544 error = elfnote(vp, &offset, NT_GWINDOWS,
530 545 size, (caddr_t)&bigwad->gwindows,
531 546 rlimit, credp);
532 547 if (error)
533 548 goto done;
534 549 }
535 550 }
536 551 /*
537 552 * Ancillary State Registers.
538 553 */
539 554 if (p->p_model == DATAMODEL_LP64) {
540 555 prgetasregs(lwp, bigwad->asrset);
541 556 error = elfnote(vp, &offset, NT_ASRS,
542 557 sizeof (asrset_t), (caddr_t)bigwad->asrset,
543 558 rlimit, credp);
544 559 if (error)
545 560 goto done;
546 561 }
547 562 #endif /* __sparc */
548 563
549 564 if (xregsize) {
550 565 prgetprxregs(lwp, bigwad->xregs);
551 566 error = elfnote(vp, &offset, NT_PRXREG,
552 567 xregsize, bigwad->xregs, rlimit, credp);
553 568 if (error)
554 569 goto done;
555 570 }
556 571
557 572 if (t->t_lwp->lwp_spymaster != NULL) {
558 573 void *psaddr = t->t_lwp->lwp_spymaster;
559 574 #ifdef _ELF32_COMPAT
560 575 /*
561 576 * On a 64-bit kernel with 32-bit ELF compatibility,
562 577 * this file is compiled into two different objects:
563 578 * one is compiled normally, and the other is compiled
564 579 * with _ELF32_COMPAT set -- and therefore with a
565 580 * psinfo_t defined to be a psinfo32_t. However, the
566 581 * psinfo_t denoting our spymaster is always of the
567 582 * native type; if we are in the _ELF32_COMPAT case,
568 583 * we need to explicitly convert it.
569 584 */
570 585 if (p->p_model == DATAMODEL_ILP32) {
571 586 psinfo_kto32(psaddr, &bigwad->psinfo);
572 587 psaddr = &bigwad->psinfo;
573 588 }
574 589 #endif
575 590
576 591 error = elfnote(vp, &offset, NT_SPYMASTER,
577 592 sizeof (psinfo_t), psaddr, rlimit, credp);
578 593 if (error)
579 594 goto done;
580 595 }
581 596 }
582 597 ASSERT(nlwp == 0);
583 598
584 599 done:
585 600 kmem_free(bigwad, bigsize);
586 601 return (error);
587 602 }
↓ open down ↓ |
61 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX