1 /* Definitions for PRPSINFO structures under ELF on GNU/Linux.
2 Copyright (C) 2013-2016 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_CORE_H
22 #define ELF_LINUX_CORE_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 function to copy an elf_internal_linux_prpsinfo in host
53 endian to an elf_external_linux_prpsinfo32 in target endian. */
56 swap_linux_prpsinfo32_out (bfd
*obfd
,
57 const struct elf_internal_linux_prpsinfo
*from
,
58 struct elf_external_linux_prpsinfo32
*to
)
60 bfd_put_8 (obfd
, from
->pr_state
, &to
->pr_state
);
61 bfd_put_8 (obfd
, from
->pr_sname
, &to
->pr_sname
);
62 bfd_put_8 (obfd
, from
->pr_zomb
, &to
->pr_zomb
);
63 bfd_put_8 (obfd
, from
->pr_nice
, &to
->pr_nice
);
64 bfd_put_32 (obfd
, from
->pr_flag
, to
->pr_flag
);
65 bfd_put_16 (obfd
, from
->pr_uid
, to
->pr_uid
);
66 bfd_put_16 (obfd
, from
->pr_gid
, to
->pr_gid
);
67 bfd_put_32 (obfd
, from
->pr_pid
, to
->pr_pid
);
68 bfd_put_32 (obfd
, from
->pr_ppid
, to
->pr_ppid
);
69 bfd_put_32 (obfd
, from
->pr_pgrp
, to
->pr_pgrp
);
70 bfd_put_32 (obfd
, from
->pr_sid
, to
->pr_sid
);
71 strncpy (to
->pr_fname
, from
->pr_fname
, sizeof (to
->pr_fname
));
72 strncpy (to
->pr_psargs
, from
->pr_psargs
, sizeof (to
->pr_psargs
));
75 /* External 64-bit structure for PRPSINFO. This structure is
76 ABI-defined, thus we choose to use char arrays here in order to
77 avoid dealing with different types in different architectures.
79 This structure will ultimately be written in the corefile's note
80 section, as the PRPSINFO. */
82 struct elf_external_linux_prpsinfo64
84 char pr_state
; /* Numeric process state. */
85 char pr_sname
; /* Char for pr_state. */
86 char pr_zomb
; /* Zombie. */
87 char pr_nice
; /* Nice val. */
88 char pr_flag
[8]; /* Flags. */
96 char pr_fname
[16]; /* Filename of executable. */
97 char pr_psargs
[80]; /* Initial part of arg list. */
100 /* Helper function to copy an elf_internal_linux_prpsinfo in host
101 endian to an elf_external_linux_prpsinfo64 in target endian. */
104 swap_linux_prpsinfo64_out (bfd
*obfd
,
105 const struct elf_internal_linux_prpsinfo
*from
,
106 struct elf_external_linux_prpsinfo64
*to
)
108 bfd_put_8 (obfd
, from
->pr_state
, &to
->pr_state
);
109 bfd_put_8 (obfd
, from
->pr_sname
, &to
->pr_sname
);
110 bfd_put_8 (obfd
, from
->pr_zomb
, &to
->pr_zomb
);
111 bfd_put_8 (obfd
, from
->pr_nice
, &to
->pr_nice
);
112 bfd_put_64 (obfd
, from
->pr_flag
, to
->pr_flag
);
113 bfd_put_32 (obfd
, from
->pr_uid
, to
->pr_uid
);
114 bfd_put_32 (obfd
, from
->pr_gid
, to
->pr_gid
);
115 bfd_put_32 (obfd
, from
->pr_pid
, to
->pr_pid
);
116 bfd_put_32 (obfd
, from
->pr_ppid
, to
->pr_ppid
);
117 bfd_put_32 (obfd
, from
->pr_pgrp
, to
->pr_pgrp
);
118 bfd_put_32 (obfd
, from
->pr_sid
, to
->pr_sid
);
119 strncpy (to
->pr_fname
, from
->pr_fname
, sizeof (to
->pr_fname
));
120 strncpy (to
->pr_psargs
, from
->pr_psargs
, sizeof (to
->pr_psargs
));