Automatic date update in version.in
[binutils-gdb.git] / bfd / elf-linux-core.h
blob4dcc488b39cf3f822395a123439008ba98395bce
1 /* Definitions for PRPSINFO structures under ELF on GNU/Linux.
2 Copyright (C) 2013-2017 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
26 (like e.g., PPC). */
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. */
42 char pr_uid[2];
43 char pr_gid[2];
44 char pr_pid[4];
45 char pr_ppid[4];
46 char pr_pgrp[4];
47 char pr_sid[4];
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. */
55 static inline void
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. */
89 char gap[4];
90 char pr_uid[4];
91 char pr_gid[4];
92 char pr_pid[4];
93 char pr_ppid[4];
94 char pr_pgrp[4];
95 char pr_sid[4];
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. */
103 static inline void
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));
123 #endif