LCOV - code coverage report
Current view: top level - libebl - eblcorenote.c (source / functions) Hit Total Coverage
Test: elfutils-0.189 Lines: 6 13 46.2 %
Date: 2023-08-29 13:46:25 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* Describe known core note formats.
       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 <assert.h>
      34                 :            : #include <byteswap.h>
      35                 :            : #include <endian.h>
      36                 :            : #include <inttypes.h>
      37                 :            : #include <stdio.h>
      38                 :            : #include <stddef.h>
      39                 :            : #include <string.h>
      40                 :            : #include <libeblP.h>
      41                 :            : 
      42                 :            : 
      43                 :            : int
      44                 :        327 : ebl_core_note (Ebl *ebl, const GElf_Nhdr *nhdr, const char *name,
      45                 :            :                const char *desc,
      46                 :            :                GElf_Word *regs_offset, size_t *nregloc,
      47                 :            :                const Ebl_Register_Location **reglocs, size_t *nitems,
      48                 :            :                const Ebl_Core_Item **items)
      49                 :            : {
      50                 :        327 :   int result = ebl->core_note (nhdr, name,
      51                 :            :                                regs_offset, nregloc, reglocs, nitems, items);
      52         [ +  + ]:        327 :   if (result == 0)
      53                 :            :     {
      54                 :            :       /* The machine specific function did not know this type.  */
      55                 :            : 
      56                 :            :       /* NT_PLATFORM is kind of special since it needs a zero terminated
      57                 :            :          string (other notes often have a fixed size string).  */
      58                 :         75 :       static const Ebl_Core_Item platform[] =
      59                 :            :         {
      60                 :            :           {
      61                 :            :             .name = "Platform",
      62                 :            :             .type = ELF_T_BYTE, .count = 0, .format = 's'
      63                 :            :           }
      64                 :            :         };
      65                 :            : 
      66         [ -  + ]:         75 :       if (nhdr->n_type == NT_PLATFORM
      67         [ #  # ]:          0 :           && memchr (desc, '\0', nhdr->n_descsz) != NULL)
      68                 :            :         {
      69                 :          0 :           *regs_offset = 0;
      70                 :          0 :           *nregloc = 0;
      71                 :          0 :           *reglocs = NULL;
      72                 :          0 :           *items = platform;
      73                 :          0 :           *nitems = 1;
      74                 :          0 :           result = 1;
      75                 :            :         }
      76                 :            :     }
      77                 :            : 
      78                 :        327 :   return result;
      79                 :            : }

Generated by: LCOV version 1.16