imgact_elf.c (6f3544cd7084abbadd83637993a4f41fd30e6ccd) | imgact_elf.c (7f08176ee8b672feebd8a12572b43dddcb88046e) |
---|---|
1/*- 2 * Copyright (c) 2000 David O'Brien 3 * Copyright (c) 1995-1996 S�ren Schmidt 4 * Copyright (c) 1996 Peter Wemm 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 1302 unchanged lines hidden (view full) --- 1311#if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 1312#include <compat/freebsd32/freebsd32.h> 1313 1314typedef struct prstatus32 elf_prstatus_t; 1315typedef struct prpsinfo32 elf_prpsinfo_t; 1316typedef struct fpreg32 elf_prfpregset_t; 1317typedef struct fpreg32 elf_fpregset_t; 1318typedef struct reg32 elf_gregset_t; | 1/*- 2 * Copyright (c) 2000 David O'Brien 3 * Copyright (c) 1995-1996 S�ren Schmidt 4 * Copyright (c) 1996 Peter Wemm 5 * All rights reserved. 6 * 7 * Redistribution and use in source and binary forms, with or without 8 * modification, are permitted provided that the following conditions --- 1302 unchanged lines hidden (view full) --- 1311#if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 1312#include <compat/freebsd32/freebsd32.h> 1313 1314typedef struct prstatus32 elf_prstatus_t; 1315typedef struct prpsinfo32 elf_prpsinfo_t; 1316typedef struct fpreg32 elf_prfpregset_t; 1317typedef struct fpreg32 elf_fpregset_t; 1318typedef struct reg32 elf_gregset_t; |
1319typedef struct thrmisc32 elf_thrmisc_t; |
|
1319#else 1320typedef prstatus_t elf_prstatus_t; 1321typedef prpsinfo_t elf_prpsinfo_t; 1322typedef prfpregset_t elf_prfpregset_t; 1323typedef prfpregset_t elf_fpregset_t; 1324typedef gregset_t elf_gregset_t; | 1320#else 1321typedef prstatus_t elf_prstatus_t; 1322typedef prpsinfo_t elf_prpsinfo_t; 1323typedef prfpregset_t elf_prfpregset_t; 1324typedef prfpregset_t elf_fpregset_t; 1325typedef gregset_t elf_gregset_t; |
1326typedef thrmisc_t elf_thrmisc_t; |
|
1325#endif 1326 1327static void 1328__elfN(puthdr)(struct thread *td, void *dst, size_t *off, int numsegs) 1329{ 1330 struct { 1331 elf_prstatus_t status; 1332 elf_prfpregset_t fpregset; 1333 elf_prpsinfo_t psinfo; | 1327#endif 1328 1329static void 1330__elfN(puthdr)(struct thread *td, void *dst, size_t *off, int numsegs) 1331{ 1332 struct { 1333 elf_prstatus_t status; 1334 elf_prfpregset_t fpregset; 1335 elf_prpsinfo_t psinfo; |
1336 elf_thrmisc_t thrmisc; |
|
1334 } *tempdata; 1335 elf_prstatus_t *status; 1336 elf_prfpregset_t *fpregset; 1337 elf_prpsinfo_t *psinfo; | 1337 } *tempdata; 1338 elf_prstatus_t *status; 1339 elf_prfpregset_t *fpregset; 1340 elf_prpsinfo_t *psinfo; |
1341 elf_thrmisc_t *thrmisc; |
|
1338 struct proc *p; 1339 struct thread *thr; 1340 size_t ehoff, noteoff, notesz, phoff; 1341 1342 p = td->td_proc; 1343 1344 ehoff = *off; 1345 *off += sizeof(Elf_Ehdr); --- 6 unchanged lines hidden (view full) --- 1352 * Don't allocate space for the notes if we're just calculating 1353 * the size of the header. We also don't collect the data. 1354 */ 1355 if (dst != NULL) { 1356 tempdata = malloc(sizeof(*tempdata), M_TEMP, M_ZERO|M_WAITOK); 1357 status = &tempdata->status; 1358 fpregset = &tempdata->fpregset; 1359 psinfo = &tempdata->psinfo; | 1342 struct proc *p; 1343 struct thread *thr; 1344 size_t ehoff, noteoff, notesz, phoff; 1345 1346 p = td->td_proc; 1347 1348 ehoff = *off; 1349 *off += sizeof(Elf_Ehdr); --- 6 unchanged lines hidden (view full) --- 1356 * Don't allocate space for the notes if we're just calculating 1357 * the size of the header. We also don't collect the data. 1358 */ 1359 if (dst != NULL) { 1360 tempdata = malloc(sizeof(*tempdata), M_TEMP, M_ZERO|M_WAITOK); 1361 status = &tempdata->status; 1362 fpregset = &tempdata->fpregset; 1363 psinfo = &tempdata->psinfo; |
1364 thrmisc = &tempdata->thrmisc; |
|
1360 } else { 1361 tempdata = NULL; 1362 status = NULL; 1363 fpregset = NULL; 1364 psinfo = NULL; | 1365 } else { 1366 tempdata = NULL; 1367 status = NULL; 1368 fpregset = NULL; 1369 psinfo = NULL; |
1370 thrmisc = NULL; |
|
1365 } 1366 1367 if (dst != NULL) { 1368 psinfo->pr_version = PRPSINFO_VERSION; 1369 psinfo->pr_psinfosz = sizeof(elf_prpsinfo_t); 1370 strlcpy(psinfo->pr_fname, p->p_comm, sizeof(psinfo->pr_fname)); 1371 /* 1372 * XXX - We don't fill in the command line arguments properly --- 23 unchanged lines hidden (view full) --- 1396 status->pr_pid = thr->td_tid; 1397#if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 1398 fill_regs32(thr, &status->pr_reg); 1399 fill_fpregs32(thr, fpregset); 1400#else 1401 fill_regs(thr, &status->pr_reg); 1402 fill_fpregs(thr, fpregset); 1403#endif | 1371 } 1372 1373 if (dst != NULL) { 1374 psinfo->pr_version = PRPSINFO_VERSION; 1375 psinfo->pr_psinfosz = sizeof(elf_prpsinfo_t); 1376 strlcpy(psinfo->pr_fname, p->p_comm, sizeof(psinfo->pr_fname)); 1377 /* 1378 * XXX - We don't fill in the command line arguments properly --- 23 unchanged lines hidden (view full) --- 1402 status->pr_pid = thr->td_tid; 1403#if defined(COMPAT_FREEBSD32) && __ELF_WORD_SIZE == 32 1404 fill_regs32(thr, &status->pr_reg); 1405 fill_fpregs32(thr, fpregset); 1406#else 1407 fill_regs(thr, &status->pr_reg); 1408 fill_fpregs(thr, fpregset); 1409#endif |
1410 memset(&thrmisc->_pad, 0, sizeof (thrmisc->_pad)); 1411 strcpy(thrmisc->pr_tname, thr->td_name); |
|
1404 } 1405 __elfN(putnote)(dst, off, "FreeBSD", NT_PRSTATUS, status, 1406 sizeof *status); 1407 __elfN(putnote)(dst, off, "FreeBSD", NT_FPREGSET, fpregset, 1408 sizeof *fpregset); | 1412 } 1413 __elfN(putnote)(dst, off, "FreeBSD", NT_PRSTATUS, status, 1414 sizeof *status); 1415 __elfN(putnote)(dst, off, "FreeBSD", NT_FPREGSET, fpregset, 1416 sizeof *fpregset); |
1417 __elfN(putnote)(dst, off, "FreeBSD", NT_THRMISC, thrmisc, 1418 sizeof *thrmisc); |
|
1409 /* 1410 * Allow for MD specific notes, as well as any MD 1411 * specific preparations for writing MI notes. 1412 */ 1413 __elfN(dump_thread)(thr, dst, off); 1414 1415 thr = (thr == td) ? TAILQ_FIRST(&p->p_threads) : 1416 TAILQ_NEXT(thr, td_plist); --- 209 unchanged lines hidden --- | 1419 /* 1420 * Allow for MD specific notes, as well as any MD 1421 * specific preparations for writing MI notes. 1422 */ 1423 __elfN(dump_thread)(thr, dst, off); 1424 1425 thr = (thr == td) ? TAILQ_FIRST(&p->p_threads) : 1426 TAILQ_NEXT(thr, td_plist); --- 209 unchanged lines hidden --- |