1 /* Definitions for PRPSINFO structures under ELF on GNU/Linux.
2 Copyright (C) 2013-2014 Free Software Foundation, Inc.
4 This file is part of BFD, the Binary File Descriptor library.
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
19 MA 02110-1301, USA. */
21 #ifndef ELF_LINUX_PSINFO_H
22 #define ELF_LINUX_PSINFO_H
24 /* The PRPSINFO structures defined below are used by most
25 architectures, although some of them define their own versions
28 /* External 32-bit structure for PRPSINFO. This structure is
29 ABI-defined, thus we choose to use char arrays here in order to
30 avoid dealing with different types in different architectures.
32 This structure will ultimately be written in the corefile's note
33 section, as the PRPSINFO. */
35 struct elf_external_linux_prpsinfo32
37 char pr_state; /* Numeric process state. */
38 char pr_sname; /* Char for pr_state. */
39 char pr_zomb; /* Zombie. */
40 char pr_nice; /* Nice val. */
41 char pr_flag[4]; /* Flags. */
48 char pr_fname[16]; /* Filename of executable. */
49 char pr_psargs[80]; /* Initial part of arg list. */
52 /* Helper macro to swap (properly handling endianess) things from the
53 `elf_internal_linux_prpsinfo' structure to the
54 `elf_external_linux_prpsinfo32' structure.
56 Note that FROM should be a pointer, and TO should be the explicit
59 #define LINUX_PRPSINFO32_SWAP_FIELDS(abfd, from, to) \
62 H_PUT_8 (abfd, from->pr_state, &to.pr_state); \
63 H_PUT_8 (abfd, from->pr_sname, &to.pr_sname); \
64 H_PUT_8 (abfd, from->pr_zomb, &to.pr_zomb); \
65 H_PUT_8 (abfd, from->pr_nice, &to.pr_nice); \
66 H_PUT_32 (abfd, from->pr_flag, to.pr_flag); \
67 H_PUT_16 (abfd, from->pr_uid, to.pr_uid); \
68 H_PUT_16 (abfd, from->pr_gid, to.pr_gid); \
69 H_PUT_32 (abfd, from->pr_pid, to.pr_pid); \
70 H_PUT_32 (abfd, from->pr_ppid, to.pr_ppid); \
71 H_PUT_32 (abfd, from->pr_pgrp, to.pr_pgrp); \
72 H_PUT_32 (abfd, from->pr_sid, to.pr_sid); \
73 strncpy (to.pr_fname, from->pr_fname, sizeof (to.pr_fname)); \
74 strncpy (to.pr_psargs, from->pr_psargs, sizeof (to.pr_psargs)); \
77 /* External 64-bit structure for PRPSINFO. This structure is
78 ABI-defined, thus we choose to use char arrays here in order to
79 avoid dealing with different types in different architectures.
81 This structure will ultimately be written in the corefile's note
82 section, as the PRPSINFO. */
84 struct elf_external_linux_prpsinfo64
86 char pr_state; /* Numeric process state. */
87 char pr_sname; /* Char for pr_state. */
88 char pr_zomb; /* Zombie. */
89 char pr_nice; /* Nice val. */
90 char pr_flag[8]; /* Flags. */
98 char pr_fname[16]; /* Filename of executable. */
99 char pr_psargs[80]; /* Initial part of arg list. */
102 /* Helper macro to swap (properly handling endianess) things from the
103 `elf_internal_linux_prpsinfo' structure to the
104 `elf_external_linux_prpsinfo64' structure.
106 Note that FROM should be a pointer, and TO should be the explicit
109 #define LINUX_PRPSINFO64_SWAP_FIELDS(abfd, from, to) \
112 H_PUT_8 (abfd, from->pr_state, &to.pr_state); \
113 H_PUT_8 (abfd, from->pr_sname, &to.pr_sname); \
114 H_PUT_8 (abfd, from->pr_zomb, &to.pr_zomb); \
115 H_PUT_8 (abfd, from->pr_nice, &to.pr_nice); \
116 H_PUT_64 (abfd, from->pr_flag, to.pr_flag); \
117 H_PUT_32 (abfd, from->pr_uid, to.pr_uid); \
118 H_PUT_32 (abfd, from->pr_gid, to.pr_gid); \
119 H_PUT_32 (abfd, from->pr_pid, to.pr_pid); \
120 H_PUT_32 (abfd, from->pr_ppid, to.pr_ppid); \
121 H_PUT_32 (abfd, from->pr_pgrp, to.pr_pgrp); \
122 H_PUT_32 (abfd, from->pr_sid, to.pr_sid); \
123 strncpy (to.pr_fname, from->pr_fname, sizeof (to.pr_fname)); \
124 strncpy (to.pr_psargs, from->pr_psargs, sizeof (to.pr_psargs)); \