LCOV - code coverage report
Current view: top level - libebl - eblsectionname.c (source / functions) Hit Total Coverage
Test: lcov.out Lines: 17 26 65.4 %
Date: 2017-01-05 09:15:16 Functions: 1 1 100.0 %
Legend: Lines: hit not hit

          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       34675 : ebl_section_name (Ebl *ebl, int section, int xsection, char *buf, size_t len,
      40             :                   const char *scnnames[], size_t shnum)
      41             : {
      42       69350 :   const char *res = ebl != NULL ? ebl->section_name (section, xsection,
      43       69350 :                                                      buf, len) : NULL;
      44             : 
      45       34675 :   if (res == NULL)
      46             :     {
      47       34675 :       if (section == SHN_UNDEF)
      48             :         res = "UNDEF";
      49       29963 :       else if (section == SHN_ABS)
      50             :         res = "ABS";
      51       27011 :       else if (section == SHN_COMMON)
      52             :         res = "COMMON";
      53       27011 :       else if (section == SHN_BEFORE)
      54             :         res = "BEFORE";
      55       27011 :       else if (section == SHN_AFTER)
      56             :         res = "AFTER";
      57       27011 :       else if ((section < SHN_LORESERVE || section == SHN_XINDEX)
      58       27011 :                && (size_t) section < shnum)
      59             :         {
      60       27011 :           int idx = section != SHN_XINDEX ? section : xsection;
      61             : 
      62       27011 :           if (scnnames != NULL)
      63       14712 :             res = scnnames[idx];
      64             :           else
      65             :             {
      66       12299 :               snprintf (buf, len, "%d", idx);
      67       12299 :               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", gettext ("<unknown>"), section);
      84             : 
      85             :           res = buf;
      86             :         }
      87             :     }
      88             : 
      89       34675 :   return res;
      90             : }

Generated by: LCOV version 1.12