LCOV - code coverage report
Current view: top level - libebl - eblsectiontypename.c (source / functions) Coverage Total Hit
Test: elfutils-0.193 Lines: 48.3 % 29 14
Test Date: 2025-08-30 14:31:09 Functions: 100.0 % 1 1
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 42.1 % 19 8

             Branch data     Line data    Source code
       1                 :             : /* Return section type name.
       2                 :             :    Copyright (C) 2001, 2002, 2006, 2008 Red Hat, Inc.
       3                 :             :    This file is part of elfutils.
       4                 :             :    Written by Ulrich Drepper <drepper@redhat.com>, 2001.
       5                 :             : 
       6                 :             :    This file is free software; you can redistribute it and/or modify
       7                 :             :    it under the terms of either
       8                 :             : 
       9                 :             :      * the GNU Lesser General Public License as published by the Free
      10                 :             :        Software Foundation; either version 3 of the License, or (at
      11                 :             :        your option) any later version
      12                 :             : 
      13                 :             :    or
      14                 :             : 
      15                 :             :      * the GNU General Public License as published by the Free
      16                 :             :        Software Foundation; either version 2 of the License, or (at
      17                 :             :        your option) any later version
      18                 :             : 
      19                 :             :    or both in parallel, as here.
      20                 :             : 
      21                 :             :    elfutils is distributed in the hope that it will be useful, but
      22                 :             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      23                 :             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      24                 :             :    General Public License for more details.
      25                 :             : 
      26                 :             :    You should have received copies of the GNU General Public License and
      27                 :             :    the GNU Lesser General Public License along with this program.  If
      28                 :             :    not, see <http://www.gnu.org/licenses/>.  */
      29                 :             : 
      30                 :             : #ifdef HAVE_CONFIG_H
      31                 :             : # include <config.h>
      32                 :             : #endif
      33                 :             : 
      34                 :             : #include <stdio.h>
      35                 :             : #include <libeblP.h>
      36                 :             : 
      37                 :             : 
      38                 :             : const char *
      39                 :     1585928 : ebl_section_type_name (Ebl *ebl, int section, char *buf, size_t len)
      40                 :             : {
      41                 :     1585928 :   const char *res = ebl->section_type_name (section, buf, len);
      42                 :             : 
      43         [ +  + ]:     1585928 :   if (res == NULL)
      44                 :             :     {
      45                 :     1585922 :       static const char *knowntypes[] =
      46                 :             :         {
      47                 :             : #define KNOWNSTYPE(name) [SHT_##name] = #name
      48                 :             :           KNOWNSTYPE (NULL),
      49                 :             :           KNOWNSTYPE (PROGBITS),
      50                 :             :           KNOWNSTYPE (SYMTAB),
      51                 :             :           KNOWNSTYPE (STRTAB),
      52                 :             :           KNOWNSTYPE (RELA),
      53                 :             :           KNOWNSTYPE (HASH),
      54                 :             :           KNOWNSTYPE (DYNAMIC),
      55                 :             :           KNOWNSTYPE (NOTE),
      56                 :             :           KNOWNSTYPE (NOBITS),
      57                 :             :           KNOWNSTYPE (REL),
      58                 :             :           KNOWNSTYPE (SHLIB),
      59                 :             :           KNOWNSTYPE (DYNSYM),
      60                 :             :           KNOWNSTYPE (INIT_ARRAY),
      61                 :             :           KNOWNSTYPE (FINI_ARRAY),
      62                 :             :           KNOWNSTYPE (PREINIT_ARRAY),
      63                 :             :           KNOWNSTYPE (GROUP),
      64                 :             :           KNOWNSTYPE (SYMTAB_SHNDX),
      65                 :             :           KNOWNSTYPE (RELR)
      66                 :             :         };
      67                 :             : 
      68                 :             :       /* Handle standard names.  */
      69         [ +  + ]:     1585922 :       if ((size_t) section < sizeof (knowntypes) / sizeof (knowntypes[0])
      70         [ -  + ]:     1585070 :           && knowntypes[section] != NULL)
      71                 :             :         res = knowntypes[section];
      72                 :             :       /* The symbol versioning/Sun extensions.  */
      73         [ +  + ]:         852 :       else if (section >= SHT_LOSUNW && section <= SHT_HISUNW)
      74                 :             :         {
      75                 :         548 :           static const char *sunwtypes[] =
      76                 :             :             {
      77                 :             : #undef KNOWNSTYPE
      78                 :             : #define KNOWNSTYPE(name) [SHT_##name - SHT_LOSUNW] = #name
      79                 :             :               KNOWNSTYPE (SUNW_move),
      80                 :             :               KNOWNSTYPE (SUNW_COMDAT),
      81                 :             :               KNOWNSTYPE (SUNW_syminfo),
      82                 :             :               KNOWNSTYPE (GNU_verdef),
      83                 :             :               KNOWNSTYPE (GNU_verneed),
      84                 :             :               KNOWNSTYPE (GNU_versym)
      85                 :             :             };
      86                 :         548 :           res = sunwtypes[section - SHT_LOSUNW];
      87                 :             :         }
      88                 :             :       else
      89                 :             :         /* A few GNU additions.  */
      90   [ -  +  -  -  :         304 :         switch (section)
                      - ]
      91                 :             :           {
      92                 :             :           case SHT_CHECKSUM:
      93                 :             :             res = "CHECKSUM";
      94                 :             :             break;
      95                 :           0 :           case SHT_GNU_LIBLIST:
      96                 :           0 :             res = "GNU_LIBLIST";
      97                 :           0 :             break;
      98                 :         304 :           case SHT_GNU_HASH:
      99                 :         304 :             res = "GNU_HASH";
     100                 :         304 :             break;
     101                 :           0 :           case SHT_GNU_ATTRIBUTES:
     102                 :           0 :             res = "GNU_ATTRIBUTES";
     103                 :           0 :             break;
     104                 :             : 
     105                 :           0 :           default:
     106                 :             :             /* Handle OS-specific section names.  */
     107         [ #  # ]:           0 :             if (section >= SHT_LOOS && section <= SHT_HIOS)
     108                 :           0 :               snprintf (buf, len, "SHT_LOOS+%x", section - SHT_LOOS);
     109                 :             :             /* Handle processor-specific section names.  */
     110         [ #  # ]:           0 :             else if (section >= SHT_LOPROC && section <= SHT_HIPROC)
     111                 :           0 :               snprintf (buf, len, "SHT_LOPROC+%x", section - SHT_LOPROC);
     112                 :           0 :             else if ((unsigned int) section >= SHT_LOUSER
     113         [ #  # ]:           0 :                      && (unsigned int) section <= SHT_HIUSER)
     114                 :           0 :               snprintf (buf, len, "SHT_LOUSER+%x", section - SHT_LOUSER);
     115                 :             :             else
     116                 :           0 :               snprintf (buf, len, "%s: %d", _("<unknown>"), section);
     117                 :             : 
     118                 :             :             res = buf;
     119                 :             :             break;
     120                 :             :           }
     121                 :             :     }
     122                 :             : 
     123                 :     1585928 :   return res;
     124                 :             : }
        

Generated by: LCOV version 2.0-1