LCOV - code coverage report
Current view: top level - elfutils/libelf - gnuhash_xlate.h (source / functions) Hit Total Coverage
Test: lcov.out Lines: 19 19 100.0 %
Date: 2012-10-31 Functions: 1 1 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 12 18 66.7 %

           Branch data     Line data    Source code
       1                 :            : /* Conversion functions for versioning information.
       2                 :            :    Copyright (C) 2006, 2007 Red Hat, Inc.
       3                 :            :    This file is part of elfutils.
       4                 :            :    Written by Ulrich Drepper <drepper@redhat.com>, 2006.
       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                 :            : #include <assert.h>
      31                 :            : #include <gelf.h>
      32                 :            : 
      33                 :            : #include "libelfP.h"
      34                 :            : 
      35                 :            : 
      36                 :            : static void
      37                 :          1 : elf_cvt_gnuhash (void *dest, const void *src, size_t len, int encode)
      38                 :            : {
      39                 :            :   /* The GNU hash table format on 64 bit machines mixes 32 bit and 64 bit
      40                 :            :      words.  We must detangle them here.   */
      41                 :          1 :   Elf32_Word *dest32 = dest;
      42                 :          1 :   const Elf32_Word *src32 = src;
      43                 :            : 
      44                 :            :   /* First four control words, 32 bits.  */
      45         [ +  + ]:          5 :   for (unsigned int cnt = 0; cnt < 4; ++cnt)
      46                 :            :     {
      47         [ +  - ]:          4 :       if (len < 4)
      48                 :            :         return;
      49         [ -  + ]:          4 :       dest32[cnt] = bswap_32 (src32[cnt]);
      50                 :          4 :       len -= 4;
      51                 :            :     }
      52                 :            : 
      53         [ -  + ]:          1 :   Elf32_Word bitmask_words = encode ? src32[2] : dest32[2];
      54                 :            : 
      55                 :            :   /* Now the 64 bit words.  */
      56                 :          1 :   Elf64_Xword *dest64 = (Elf64_Xword *) &dest32[4];
      57                 :          1 :   const Elf64_Xword *src64 = (const Elf64_Xword *) &src32[4];
      58         [ +  + ]:          2 :   for (unsigned int cnt = 0; cnt < bitmask_words; ++cnt)
      59                 :            :     {
      60         [ +  - ]:          1 :       if (len < 8)
      61                 :            :         return;
      62         [ -  + ]:          1 :       dest64[cnt] = bswap_64 (src64[cnt]);
      63                 :          1 :       len -= 8;
      64                 :            :     }
      65                 :            : 
      66                 :            :   /* The rest are 32 bit words again.  */
      67                 :          1 :   src32 = (const Elf32_Word *) &src64[bitmask_words];
      68                 :          1 :   dest32 = (Elf32_Word *) &dest64[bitmask_words];
      69         [ +  + ]:          5 :   while (len >= 4)
      70                 :            :     {
      71         [ -  + ]:          4 :       *dest32++ = bswap_32 (*src32++);
      72                 :          4 :       len -= 4;
      73                 :            :     }
      74                 :            : }

Generated by: LCOV version 1.9