LCOV - code coverage report
Current view: top level - libelf - gelf_update_auxv.c (source / functions) Coverage Total Hit
Test: elfutils-0.194 Lines: 0.0 % 34 0
Test Date: 2025-12-15 22:31:38 Functions: 0.0 % 1 0
Legend: Lines:     hit not hit
Branches: + taken - not taken # not executed
Branches: 0.0 % 16 0

             Branch data     Line data    Source code
       1                 :             : /* Update information in dynamic table at the given index.
       2                 :             :    Copyright (C) 2007, 2015 Red Hat, Inc.
       3                 :             :    This file is part of elfutils.
       4                 :             : 
       5                 :             :    This file is free software; you can redistribute it and/or modify
       6                 :             :    it under the terms of either
       7                 :             : 
       8                 :             :      * the GNU Lesser General Public License as published by the Free
       9                 :             :        Software Foundation; either version 3 of the License, or (at
      10                 :             :        your option) any later version
      11                 :             : 
      12                 :             :    or
      13                 :             : 
      14                 :             :      * the GNU General Public License as published by the Free
      15                 :             :        Software Foundation; either version 2 of the License, or (at
      16                 :             :        your option) any later version
      17                 :             : 
      18                 :             :    or both in parallel, as here.
      19                 :             : 
      20                 :             :    elfutils is distributed in the hope that it will be useful, but
      21                 :             :    WITHOUT ANY WARRANTY; without even the implied warranty of
      22                 :             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      23                 :             :    General Public License for more details.
      24                 :             : 
      25                 :             :    You should have received copies of the GNU General Public License and
      26                 :             :    the GNU Lesser General Public License along with this program.  If
      27                 :             :    not, see <http://www.gnu.org/licenses/>.  */
      28                 :             : 
      29                 :             : #ifdef HAVE_CONFIG_H
      30                 :             : # include <config.h>
      31                 :             : #endif
      32                 :             : 
      33                 :             : #include <gelf.h>
      34                 :             : #include <string.h>
      35                 :             : 
      36                 :             : #include "libelfP.h"
      37                 :             : 
      38                 :             : 
      39                 :             : int
      40                 :           0 : gelf_update_auxv (Elf_Data *data, int ndx, GElf_auxv_t *src)
      41                 :             : {
      42                 :           0 :   Elf_Data_Scn *data_scn = (Elf_Data_Scn *) data;
      43                 :           0 :   Elf_Scn *scn;
      44                 :           0 :   int result = 0;
      45                 :             : 
      46         [ #  # ]:           0 :   if (data == NULL)
      47                 :             :     return 0;
      48                 :             : 
      49         [ #  # ]:           0 :   if (unlikely (ndx < 0))
      50                 :             :     {
      51                 :           0 :       __libelf_seterrno (ELF_E_INVALID_INDEX);
      52                 :           0 :       return 0;
      53                 :             :     }
      54                 :             : 
      55         [ #  # ]:           0 :   if (unlikely (data_scn->d.d_type != ELF_T_AUXV))
      56                 :             :     {
      57                 :             :       /* The type of the data better should match.  */
      58                 :           0 :       __libelf_seterrno (ELF_E_DATA_MISMATCH);
      59                 :           0 :       return 0;
      60                 :             :     }
      61                 :             : 
      62                 :           0 :   scn = data_scn->s;
      63                 :           0 :   rwlock_wrlock (scn->elf->lock);
      64                 :             : 
      65         [ #  # ]:           0 :   if (scn->elf->class == ELFCLASS32)
      66                 :             :     {
      67                 :           0 :       Elf32_auxv_t *auxv;
      68                 :             : 
      69                 :             :       /* There is the possibility that the values in the input are
      70                 :             :          too large.  */
      71         [ #  # ]:           0 :       if (unlikely (src->a_type > 0xffffffffll)
      72         [ #  # ]:           0 :           || unlikely (src->a_un.a_val > 0xffffffffull))
      73                 :             :         {
      74                 :           0 :           __libelf_seterrno (ELF_E_INVALID_DATA);
      75                 :           0 :           goto out;
      76                 :             :         }
      77                 :             : 
      78                 :             :       /* Check whether we have to resize the data buffer.  */
      79         [ #  # ]:           0 :       if (unlikely ((ndx + 1) * sizeof (Elf32_auxv_t) > data_scn->d.d_size))
      80                 :             :         {
      81                 :           0 :           __libelf_seterrno (ELF_E_INVALID_INDEX);
      82                 :           0 :           goto out;
      83                 :             :         }
      84                 :             : 
      85                 :           0 :       auxv = &((Elf32_auxv_t *) data_scn->d.d_buf)[ndx];
      86                 :             : 
      87                 :           0 :       auxv->a_type = src->a_type;
      88                 :           0 :       auxv->a_un.a_val = src->a_un.a_val;
      89                 :             :     }
      90                 :             :   else
      91                 :             :     {
      92                 :             :       /* Check whether we have to resize the data buffer.  */
      93         [ #  # ]:           0 :       if (unlikely ((ndx + 1) * sizeof (Elf64_auxv_t) > data_scn->d.d_size))
      94                 :             :         {
      95                 :           0 :           __libelf_seterrno (ELF_E_INVALID_INDEX);
      96                 :           0 :           goto out;
      97                 :             :         }
      98                 :             : 
      99                 :           0 :       ((Elf64_auxv_t *) data_scn->d.d_buf)[ndx] = *src;
     100                 :             :     }
     101                 :             : 
     102                 :           0 :   result = 1;
     103                 :             : 
     104                 :             :   /* Mark the section as modified.  */
     105                 :           0 :   scn->flags |= ELF_F_DIRTY;
     106                 :             : 
     107                 :           0 :  out:
     108                 :           0 :   rwlock_unlock (scn->elf->lock);
     109                 :             : 
     110                 :           0 :   return result;
     111                 :             : }
        

Generated by: LCOV version 2.0-1