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

           Branch data     Line data    Source code
       1                 :            : /* Return dynamic tag 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 <inttypes.h>
      35                 :            : #include <stdio.h>
      36                 :            : #include <libeblP.h>
      37                 :            : #include "system.h"
      38                 :            : 
      39                 :            : 
      40                 :            : const char *
      41                 :       2053 : ebl_dynamic_tag_name (Ebl *ebl, int64_t tag, char *buf, size_t len)
      42                 :            : {
      43         [ +  - ]:       2053 :   const char *res = ebl != NULL ? ebl->dynamic_tag_name (tag, buf, len) : NULL;
      44                 :            : 
      45         [ +  - ]:       2053 :   if (res == NULL)
      46                 :            :     {
      47         [ +  + ]:       2053 :       if (tag >= 0 && tag < DT_NUM)
      48                 :            :         {
      49                 :       1638 :           static const char *stdtags[] =
      50                 :            :             {
      51                 :            :               "NULL", "NEEDED", "PLTRELSZ", "PLTGOT", "HASH", "STRTAB",
      52                 :            :               "SYMTAB", "RELA", "RELASZ", "RELAENT", "STRSZ", "SYMENT",
      53                 :            :               "INIT", "FINI", "SONAME", "RPATH", "SYMBOLIC", "REL", "RELSZ",
      54                 :            :               "RELENT", "PLTREL", "DEBUG", "TEXTREL", "JMPREL", "BIND_NOW",
      55                 :            :               "INIT_ARRAY", "FINI_ARRAY", "INIT_ARRAYSZ", "FINI_ARRAYSZ",
      56                 :            :               "RUNPATH", "FLAGS", "ENCODING", "PREINIT_ARRAY",
      57                 :            :               "PREINIT_ARRAYSZ", "SYMTAB_SHNDX", "RELRSZ", "RELR", "RELRENT"
      58                 :            :             };
      59                 :       1638 :           eu_static_assert (sizeof (stdtags) / sizeof (const char *) == DT_NUM);
      60                 :            : 
      61                 :       1638 :           res = stdtags[tag];
      62                 :            :         }
      63         [ +  + ]:        415 :       else if (tag == DT_VERSYM)
      64                 :            :         res = "VERSYM";
      65         [ +  + ]:        335 :       else if (tag >= DT_GNU_PRELINKED && tag <= DT_SYMINENT)
      66                 :            :         {
      67                 :         11 :           static const char *valrntags[] =
      68                 :            :             {
      69                 :            :               "GNU_PRELINKED", "GNU_CONFLICTSZ", "GNU_LIBLISTSZ",
      70                 :            :               "CHECKSUM", "PLTPADSZ", "MOVEENT", "MOVESZ", "FEATURE_1",
      71                 :            :               "POSFLAG_1", "SYMINSZ", "SYMINENT"
      72                 :            :             };
      73                 :            : 
      74                 :         11 :           res = valrntags[tag - DT_GNU_PRELINKED];
      75                 :            :         }
      76         [ +  + ]:        324 :       else if (tag >= DT_GNU_HASH && tag <= DT_SYMINFO)
      77                 :            :         {
      78                 :         90 :           static const char *addrrntags[] =
      79                 :            :             {
      80                 :            :               "GNU_HASH", "TLSDESC_PLT", "TLSDESC_GOT",
      81                 :            :               "GNU_CONFLICT", "GNU_LIBLIST", "CONFIG", "DEPAUDIT", "AUDIT",
      82                 :            :               "PLTPAD", "MOVETAB", "SYMINFO"
      83                 :            :             };
      84                 :            : 
      85                 :         90 :           res = addrrntags[tag - DT_GNU_HASH];
      86                 :            :         }
      87         [ +  + ]:        234 :       else if (tag >= DT_RELACOUNT && tag <= DT_VERNEEDNUM)
      88                 :            :         {
      89                 :        231 :           static const char *suntags[] =
      90                 :            :             {
      91                 :            :               "RELACOUNT", "RELCOUNT", "FLAGS_1", "VERDEF", "VERDEFNUM",
      92                 :            :               "VERNEED", "VERNEEDNUM"
      93                 :            :             };
      94                 :            : 
      95                 :        231 :           res = suntags[tag - DT_RELACOUNT];
      96                 :            :         }
      97         [ +  + ]:          3 :       else if (tag == DT_AUXILIARY)
      98                 :            :         res = "AUXILIARY";
      99         [ +  + ]:          2 :       else if (tag == DT_FILTER)
     100                 :            :         res = "FILTER";
     101                 :            :       else
     102                 :            :         {
     103                 :          1 :           snprintf (buf, len, _("<unknown>: %#" PRIx64), tag);
     104                 :            : 
     105                 :          1 :           res = buf;
     106                 :            : 
     107                 :            :         }
     108                 :            :     }
     109                 :            : 
     110                 :       2053 :   return res;
     111                 :            : }

Generated by: LCOV version 1.16