Subversion Repositories Kolibri OS

Rev

Rev 5197 | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

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