LCOV - code coverage report
Current view: top level - backends - i386_corenote.c (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 8 8 100.0 %
Date: 2024-04-17 19:42:11 Functions: 0 0 -
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 1 2 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* i386 specific core note handling.
       2                 :            :    Copyright (C) 2007-2010 Red Hat, Inc.
       3                 :            :    This file is part of elfutils.
       4                 :            : 
       5                 :            :    This file is free software; you can redistribute it and/or modify
       6                 :            :    it under the terms of either
       7                 :            : 
       8                 :            :      * the GNU Lesser General Public License as published by the Free
       9                 :            :        Software Foundation; either version 3 of the License, or (at
      10                 :            :        your option) any later version
      11                 :            : 
      12                 :            :    or
      13                 :            : 
      14                 :            :      * the GNU General Public License as published by the Free
      15                 :            :        Software Foundation; either version 2 of the License, or (at
      16                 :            :        your option) any later version
      17                 :            : 
      18                 :            :    or both in parallel, as here.
      19                 :            : 
      20                 :            :    elfutils is distributed in the hope that it will be useful, but
      21                 :            :    WITHOUT ANY WARRANTY; without even the implied warranty of
      22                 :            :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      23                 :            :    General Public License for more details.
      24                 :            : 
      25                 :            :    You should have received copies of the GNU General Public License and
      26                 :            :    the GNU Lesser General Public License along with this program.  If
      27                 :            :    not, see <http://www.gnu.org/licenses/>.  */
      28                 :            : 
      29                 :            : #ifdef HAVE_CONFIG_H
      30                 :            : # include <config.h>
      31                 :            : #endif
      32                 :            : 
      33                 :            : #include <elf.h>
      34                 :            : #include <inttypes.h>
      35                 :            : #include <stddef.h>
      36                 :            : #include <stdio.h>
      37                 :            : #include <sys/time.h>
      38                 :            : 
      39                 :            : #define BACKEND i386_
      40                 :            : #include "libebl_CPU.h"
      41                 :            : 
      42                 :            : 
      43                 :            : static const Ebl_Register_Location prstatus_regs[] =
      44                 :            :   {
      45                 :            : #define GR(at, n, dwreg)                                                \
      46                 :            :     { .offset = at * 4, .regno = dwreg, .count = n, .bits = 32 }
      47                 :            : #define SR(at, n, dwreg)                                                \
      48                 :            :     { .offset = at * 4, .regno = dwreg, .count = n, .bits = 16, .pad = 2 }
      49                 :            : 
      50                 :            :     GR (0, 1, 3),               /* %ebx */
      51                 :            :     GR (1, 2, 1),               /* %ecx-%edx */
      52                 :            :     GR (3, 2, 6),               /* %esi-%edi */
      53                 :            :     GR (5, 1, 5),               /* %ebp */
      54                 :            :     GR (6, 1, 0),               /* %eax */
      55                 :            :     SR (7, 1, 43),              /* %ds */
      56                 :            :     SR (8, 1, 40),              /* %es */
      57                 :            :     SR (9, 1, 44),              /* %fs */
      58                 :            :     SR (10, 1, 45),             /* %gs */
      59                 :            :     /*  11, 1,                     orig_eax */
      60                 :            :     GR (12, 1, 8),              /* %eip */
      61                 :            :     SR (13, 1, 41),             /* %cs */
      62                 :            :     GR (14, 1, 9),              /* eflags */
      63                 :            :     GR (15, 1, 4),              /* %esp */
      64                 :            :     SR (16, 1, 42),             /* %ss */
      65                 :            : 
      66                 :            : #undef  GR
      67                 :            : #undef  SR
      68                 :            :   };
      69                 :            : #define PRSTATUS_REGS_SIZE      (17 * 4)
      70                 :            : 
      71                 :            : #define ULONG                   uint32_t
      72                 :            : #define PID_T                   int32_t
      73                 :            : #define UID_T                   uint16_t
      74                 :            : #define GID_T                   uint16_t
      75                 :            : #define ALIGN_ULONG             4
      76                 :            : #define ALIGN_PID_T             4
      77                 :            : #define ALIGN_UID_T             2
      78                 :            : #define ALIGN_GID_T             2
      79                 :            : #define TYPE_ULONG              ELF_T_WORD
      80                 :            : #define TYPE_PID_T              ELF_T_SWORD
      81                 :            : #define TYPE_UID_T              ELF_T_HALF
      82                 :            : #define TYPE_GID_T              ELF_T_HALF
      83                 :            : 
      84                 :            : #define PRSTATUS_REGSET_ITEMS                                                 \
      85                 :            :   {                                                                           \
      86                 :            :     .name = "orig_eax", .type = ELF_T_SWORD, .format = 'd',                 \
      87                 :            :     .offset = offsetof (struct EBLHOOK(prstatus), pr_reg) + (4 * 11),         \
      88                 :            :     .group = "register"                                                             \
      89                 :            :   }
      90                 :            : 
      91                 :            : static const Ebl_Register_Location fpregset_regs[] =
      92                 :            :   {
      93                 :            :     { .offset = 0, .regno = 37, .count = 2, .bits = 32 }, /* fctrl-fstat */
      94                 :            :     { .offset = 7 * 4, .regno = 11, .count = 8, .bits = 80 }, /* stN */
      95                 :            :   };
      96                 :            : #define FPREGSET_SIZE   108
      97                 :            : 
      98                 :            : static const Ebl_Register_Location prxfpreg_regs[] =
      99                 :            :   {
     100                 :            :     { .offset = 0, .regno = 37, .count = 2, .bits = 16 }, /* fctrl-fstat */
     101                 :            :     { .offset = 24, .regno = 39, .count = 1, .bits = 32 }, /* mxcsr */
     102                 :            :     { .offset = 32, .regno = 11, .count = 8, .bits = 80, .pad = 6 }, /* stN */
     103                 :            :     { .offset = 32 + 128, .regno = 21, .count = 8, .bits = 128 }, /* xmm */
     104                 :            :   };
     105                 :            : 
     106                 :            : #define EXTRA_NOTES \
     107                 :            :   EXTRA_REGSET (NT_PRXFPREG, 512, prxfpreg_regs) \
     108                 :            :   case NT_386_TLS: \
     109                 :            :     return tls_info (nhdr->n_descsz, regs_offset, nregloc, reglocs, \
     110                 :            :                      nitems, items);                                \
     111                 :            :   EXTRA_NOTES_IOPERM
     112                 :            : 
     113                 :            : static const Ebl_Core_Item tls_items[] =
     114                 :            :   {
     115                 :            :     { .type = ELF_T_WORD, .offset = 0x0, .format = 'd', .name = "index" },
     116                 :            :     { .type = ELF_T_WORD, .offset = 0x4, .format = 'x', .name = "base" },
     117                 :            :     { .type = ELF_T_WORD, .offset = 0x8, .format = 'x', .name = "limit" },
     118                 :            :     { .type = ELF_T_WORD, .offset = 0xc, .format = 'x', .name = "flags" },
     119                 :            :   };
     120                 :            : 
     121                 :            : static int
     122                 :         10 : tls_info (GElf_Word descsz, GElf_Word *regs_offset,
     123                 :            :           size_t *nregloc, const Ebl_Register_Location **reglocs,
     124                 :            :           size_t *nitems, const Ebl_Core_Item **items)
     125                 :            : {
     126         [ +  - ]:         10 :   if (descsz % 16 != 0)
     127                 :            :     return 0;
     128                 :            : 
     129                 :         10 :   *regs_offset = 0;
     130                 :         10 :   *nregloc = 0;
     131                 :         10 :   *reglocs = NULL;
     132                 :         10 :   *nitems = sizeof tls_items / sizeof tls_items[0];
     133                 :         10 :   *items = tls_items;
     134                 :         10 :   return 1;
     135                 :            : }
     136                 :            : 
     137                 :            : #include "x86_corenote.c"
     138                 :            : #include "linux-core-note.c"

Generated by: LCOV version 1.16