LCOV - code coverage report
Current view: top level - libebl - eblsectionname.c (source / functions) Coverage Total Hit
Test: elfutils-0.193 Lines: 65.4 % 26 17
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: 50.0 % 30 15

             Branch data     Line data    Source code
       1                 :             : /* Return section name.
       2                 :             :    Copyright (C) 2001, 2002, 2004 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                 :      157024 : ebl_section_name (Ebl *ebl, int section, int xsection, char *buf, size_t len,
      40                 :             :                   const char *scnnames[], size_t shnum)
      41                 :             : {
      42                 :      157024 :   const char *res = ebl != NULL ? ebl->section_name (section, xsection,
      43         [ +  - ]:      157024 :                                                      buf, len) : NULL;
      44                 :             : 
      45         [ +  - ]:      157024 :   if (res == NULL)
      46                 :             :     {
      47         [ +  + ]:      157024 :       if (section == SHN_UNDEF)
      48                 :             :         res = "UNDEF";
      49         [ +  + ]:      145568 :       else if (section == SHN_ABS)
      50                 :             :         res = "ABS";
      51         [ +  + ]:      140402 :       else if (section == SHN_COMMON)
      52                 :             :         res = "COMMON";
      53         [ +  - ]:      140398 :       else if (section == SHN_BEFORE)
      54                 :             :         res = "BEFORE";
      55         [ +  - ]:      140398 :       else if (section == SHN_AFTER)
      56                 :             :         res = "AFTER";
      57         [ +  - ]:      140398 :       else if ((section < SHN_LORESERVE || section == SHN_XINDEX)
      58         [ +  - ]:      140398 :                && (size_t) section < shnum)
      59                 :             :         {
      60         [ -  + ]:      140398 :           int idx = section != SHN_XINDEX ? section : xsection;
      61                 :             : 
      62         [ +  + ]:      140398 :           if (scnnames != NULL)
      63                 :       70744 :             res = scnnames[idx];
      64                 :             :           else
      65                 :             :             {
      66                 :       69654 :               snprintf (buf, len, "%d", idx);
      67                 :       69654 :               res = buf;
      68                 :             :             }
      69                 :             :         }
      70                 :             :       else
      71                 :             :         {
      72                 :             :           /* Handle OS-specific section names.  */
      73         [ #  # ]:           0 :           if (section == SHN_XINDEX)
      74                 :           0 :             snprintf (buf, len, "%s: %d", "XINDEX", xsection);
      75         [ #  # ]:           0 :           else if (section >= SHN_LOOS && section <= SHN_HIOS)
      76                 :           0 :             snprintf (buf, len, "LOOS+%x", section - SHN_LOOS);
      77                 :             :           /* Handle processor-specific section names.  */
      78         [ #  # ]:           0 :           else if (section >= SHN_LOPROC && section <= SHN_HIPROC)
      79                 :           0 :             snprintf (buf, len, "LOPROC+%x", section - SHN_LOPROC);
      80         [ #  # ]:           0 :           else if (section >= SHN_LORESERVE && section <= SHN_HIRESERVE)
      81                 :           0 :             snprintf (buf, len, "LORESERVE+%x", section - SHN_LORESERVE);
      82                 :             :           else
      83                 :           0 :             snprintf (buf, len, "%s: %d", _("<unknown>"), section);
      84                 :             : 
      85                 :             :           res = buf;
      86                 :             :         }
      87                 :             :     }
      88                 :             : 
      89                 :      157024 :   return res;
      90                 :             : }
        

Generated by: LCOV version 2.0-1