(root)/
binutils-2.41/
bfd/
hosts/
x86-64linux.h
       1  /* Copyright (C) 2006-2023 Free Software Foundation, Inc.
       2     This file is part of the GNU C Library.
       3  
       4     The GNU C Library is free software; you can redistribute it and/or
       5     modify it under the terms of the GNU Lesser General Public
       6     License as published by the Free Software Foundation; either
       7     version 2.1 of the License, or (at your option) any later version.
       8  
       9     The GNU C Library is distributed in the hope that it will be useful,
      10     but WITHOUT ANY WARRANTY; without even the implied warranty of
      11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      12     Lesser General Public License for more details.
      13  
      14     You should have received a copy of the GNU General Public License
      15     along with this program; if not, write to the Free Software
      16     Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
      17     MA 02110-1301, USA.  */
      18  
      19  /* This is somewhat modelled after the file of the same name on SVR4
      20     systems.  It provides a definition of the core file format for ELF
      21     used on Linux.  It doesn't have anything to do with the /proc file
      22     system, even though Linux has one.
      23  
      24     Anyway, the whole purpose of this file is for GDB and GDB only.
      25     Don't read too much into it.  Don't use it for anything other than
      26     GDB unless you know what you are doing.  */
      27  
      28  #include <features.h>
      29  #include <sys/time.h>
      30  #include <sys/types.h>
      31  
      32  /* We define here only the symbols differing from their 64-bit variant.  */
      33  #include <sys/procfs.h>
      34  #include <stdint.h>
      35  
      36  /* Unsigned 64-bit integer aligned to 8 bytes.  */
      37  typedef uint64_t __attribute__ ((__aligned__ (8))) a8_uint64_t;
      38  
      39  #undef HAVE_PRPSINFO32_T
      40  #define HAVE_PRPSINFO32_T
      41  #undef HAVE_PRPSINFO32_T_PR_PID
      42  #define HAVE_PRPSINFO32_T_PR_PID
      43  
      44  #undef HAVE_PRSTATUS32_T
      45  #define HAVE_PRSTATUS32_T
      46  
      47  /* These are the 32-bit x86 structures.  */
      48  
      49  struct user_regs32_struct
      50  {
      51    int32_t ebx;
      52    int32_t ecx;
      53    int32_t edx;
      54    int32_t esi;
      55    int32_t edi;
      56    int32_t ebp;
      57    int32_t eax;
      58    int32_t xds;
      59    int32_t xes;
      60    int32_t xfs;
      61    int32_t xgs;
      62    int32_t orig_eax;
      63    int32_t eip;
      64    int32_t xcs;
      65    int32_t eflags;
      66    int32_t esp;
      67    int32_t xss;
      68  };
      69  
      70  struct user_regs64_struct
      71  {
      72    a8_uint64_t r15;
      73    a8_uint64_t r14;
      74    a8_uint64_t r13;
      75    a8_uint64_t r12;
      76    a8_uint64_t rbp;
      77    a8_uint64_t rbx;
      78    a8_uint64_t r11;
      79    a8_uint64_t r10;
      80    a8_uint64_t r9;
      81    a8_uint64_t r8;
      82    a8_uint64_t rax;
      83    a8_uint64_t rcx;
      84    a8_uint64_t rdx;
      85    a8_uint64_t rsi;
      86    a8_uint64_t rdi;
      87    a8_uint64_t orig_rax;
      88    a8_uint64_t rip;
      89    a8_uint64_t cs;
      90    a8_uint64_t eflags;
      91    a8_uint64_t rsp;
      92    a8_uint64_t ss;
      93    a8_uint64_t fs_base;
      94    a8_uint64_t gs_base;
      95    a8_uint64_t ds;
      96    a8_uint64_t es;
      97    a8_uint64_t fs;
      98    a8_uint64_t gs;
      99  };
     100  
     101  /* Type for a general-purpose register.  */
     102  typedef uint32_t elf_greg32_t;
     103  typedef a8_uint64_t elf_greg64_t;
     104  
     105  /* And the whole bunch of them.  We could have used `struct
     106     user_regs_struct' directly in the typedef, but tradition says that
     107     the register set is an array, which does have some peculiar
     108     semantics, so leave it that way.  */
     109  #define ELF_NGREG32 (sizeof (struct user_regs32_struct) / sizeof(elf_greg32_t))
     110  typedef elf_greg32_t elf_gregset32_t[ELF_NGREG32];
     111  #define ELF_NGREG64 (sizeof (struct user_regs64_struct) / sizeof(elf_greg64_t))
     112  typedef elf_greg64_t elf_gregset64_t[ELF_NGREG64];
     113  
     114  /* Definitions to generate Intel SVR4-like core files.  These mostly
     115     have the same names as the SVR4 types with "elf_" tacked on the
     116     front to prevent clashes with Linux definitions, and the typedef
     117     forms have been avoided.  This is mostly like the SVR4 structure,
     118     but more Linuxy, with things that Linux does not support and which
     119     GDB doesn't really use excluded.  */
     120  
     121  struct prstatus32_timeval
     122    {
     123      int tv_sec;
     124      int tv_usec;
     125    };
     126  
     127  struct prstatus64_timeval
     128    {
     129      a8_uint64_t tv_sec;
     130      a8_uint64_t tv_usec;
     131    };
     132  
     133  struct elf_prstatus32
     134    {
     135      struct elf_siginfo pr_info;		/* Info associated with signal.  */
     136      short int pr_cursig;		/* Current signal.  */
     137      unsigned int pr_sigpend;		/* Set of pending signals.  */
     138      unsigned int pr_sighold;		/* Set of held signals.  */
     139      pid_t pr_pid;
     140      pid_t pr_ppid;
     141      pid_t pr_pgrp;
     142      pid_t pr_sid;
     143      struct prstatus32_timeval pr_utime;		/* User time.  */
     144      struct prstatus32_timeval pr_stime;		/* System time.  */
     145      struct prstatus32_timeval pr_cutime;	/* Cumulative user time.  */
     146      struct prstatus32_timeval pr_cstime;	/* Cumulative system time.  */
     147      elf_gregset32_t pr_reg;		/* GP registers.  */
     148      int pr_fpvalid;			/* True if math copro being used.  */
     149    };
     150  
     151  struct elf_prstatusx32
     152    {
     153      struct elf_siginfo pr_info;		/* Info associated with signal.  */
     154      short int pr_cursig;		/* Current signal.  */
     155      unsigned int pr_sigpend;		/* Set of pending signals.  */
     156      unsigned int pr_sighold;		/* Set of held signals.  */
     157      pid_t pr_pid;
     158      pid_t pr_ppid;
     159      pid_t pr_pgrp;
     160      pid_t pr_sid;
     161      struct prstatus32_timeval pr_utime;		/* User time.  */
     162      struct prstatus32_timeval pr_stime;		/* System time.  */
     163      struct prstatus32_timeval pr_cutime;	/* Cumulative user time.  */
     164      struct prstatus32_timeval pr_cstime;	/* Cumulative system time.  */
     165      elf_gregset64_t pr_reg;		/* GP registers.  */
     166      int pr_fpvalid;			/* True if math copro being used.  */
     167    };
     168  
     169  struct elf_prstatus64
     170    {
     171      struct elf_siginfo pr_info;	/* Info associated with signal.  */
     172      short int pr_cursig;		/* Current signal.  */
     173      a8_uint64_t pr_sigpend;		/* Set of pending signals.  */
     174      a8_uint64_t pr_sighold;		/* Set of held signals.  */
     175      pid_t pr_pid;
     176      pid_t pr_ppid;
     177      pid_t pr_pgrp;
     178      pid_t pr_sid;
     179      struct prstatus64_timeval pr_utime;		/* User time.  */
     180      struct prstatus64_timeval pr_stime;		/* System time.  */
     181      struct prstatus64_timeval pr_cutime;	/* Cumulative user time.  */
     182      struct prstatus64_timeval pr_cstime;	/* Cumulative system time.  */
     183      elf_gregset64_t pr_reg;		/* GP registers.  */
     184      int pr_fpvalid;			/* True if math copro being used.  */
     185    };
     186  
     187  struct elf_prpsinfo32
     188    {
     189      char pr_state;			/* Numeric process state.  */
     190      char pr_sname;			/* Char for pr_state.  */
     191      char pr_zomb;			/* Zombie.  */
     192      char pr_nice;			/* Nice val.  */
     193      unsigned int pr_flag;		/* Flags.  */
     194      unsigned short int pr_uid;
     195      unsigned short int pr_gid;
     196      int pr_pid, pr_ppid, pr_pgrp, pr_sid;
     197      /* Lots missing */
     198      char pr_fname[16];			/* Filename of executable.  */
     199      char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
     200    };
     201  
     202  struct elf_prpsinfo64
     203    {
     204      char pr_state;			/* Numeric process state.  */
     205      char pr_sname;			/* Char for pr_state.  */
     206      char pr_zomb;			/* Zombie.  */
     207      char pr_nice;			/* Nice val.  */
     208      a8_uint64_t pr_flag;		/* Flags.  */
     209      unsigned int pr_uid;
     210      unsigned int pr_gid;
     211      int pr_pid, pr_ppid, pr_pgrp, pr_sid;
     212      /* Lots missing */
     213      char pr_fname[16];			/* Filename of executable.  */
     214      char pr_psargs[ELF_PRARGSZ];	/* Initial part of arg list.  */
     215    };
     216  
     217  /* The rest of this file provides the types for emulation of the
     218     Solaris <proc_service.h> interfaces that should be implemented by
     219     users of libthread_db.  */
     220  
     221  /* Process status and info.  In the end we do provide typedefs for them.  */
     222  typedef struct elf_prstatus32 prstatus32_t;
     223  typedef struct elf_prstatusx32 prstatusx32_t;
     224  typedef struct elf_prstatus64 prstatus64_t;
     225  typedef struct elf_prpsinfo32 prpsinfo32_t;
     226  typedef struct elf_prpsinfo64 prpsinfo64_t;