LCOV - code coverage report
Current view: top level - backends - arm_symbol.c (source / functions) Hit Total Coverage
Test: elfutils-0.191 Lines: 10 27 37.0 %
Date: 2024-04-17 19:42:11 Functions: 2 7 28.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 8 24 33.3 %

           Branch data     Line data    Source code
       1                 :            : /* Arm specific symbolic name handling.
       2                 :            :    Copyright (C) 2002-2009, 2014, 2015, 2017 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 <system.h>
      34                 :            : 
      35                 :            : #include <elf.h>
      36                 :            : #include <stddef.h>
      37                 :            : #include <string.h>
      38                 :            : 
      39                 :            : #define BACKEND         arm_
      40                 :            : #include "libebl_CPU.h"
      41                 :            : 
      42                 :            : 
      43                 :            : const char *
      44                 :          0 : arm_segment_type_name (int segment, char *buf __attribute__ ((unused)),
      45                 :            :                        size_t len __attribute__ ((unused)))
      46                 :            : {
      47         [ #  # ]:          0 :   switch (segment)
      48                 :            :     {
      49                 :            :     case PT_ARM_EXIDX:
      50                 :            :       return "ARM_EXIDX";
      51                 :            :     }
      52                 :          0 :   return NULL;
      53                 :            : }
      54                 :            : 
      55                 :            : /* Return symbolic representation of section type.  */
      56                 :            : const char *
      57                 :        142 : arm_section_type_name (int type,
      58                 :            :                        char *buf __attribute__ ((unused)),
      59                 :            :                        size_t len __attribute__ ((unused)))
      60                 :            : {
      61   [ -  +  +  + ]:        142 :   switch (type)
      62                 :            :     {
      63                 :            :     case SHT_ARM_EXIDX:
      64                 :            :       return "ARM_EXIDX";
      65                 :          0 :     case SHT_ARM_PREEMPTMAP:
      66                 :          0 :       return "ARM_PREEMPTMAP";
      67                 :          2 :     case SHT_ARM_ATTRIBUTES:
      68                 :          2 :       return "ARM_ATTRIBUTES";
      69                 :            :     }
      70                 :            : 
      71                 :        138 :   return NULL;
      72                 :            : }
      73                 :            : 
      74                 :            : /* Check whether machine flags are valid.  */
      75                 :            : bool
      76                 :          0 : arm_machine_flag_check (GElf_Word flags)
      77                 :            : {
      78         [ #  # ]:          0 :   switch (flags & EF_ARM_EABIMASK)
      79                 :            :     {
      80                 :            :     case EF_ARM_EABI_UNKNOWN:
      81                 :            :     case EF_ARM_EABI_VER1:
      82                 :            :     case EF_ARM_EABI_VER2:
      83                 :            :     case EF_ARM_EABI_VER3:
      84                 :            :     case EF_ARM_EABI_VER4:
      85                 :            :     case EF_ARM_EABI_VER5:
      86                 :          0 :       break;
      87                 :            :     default:
      88                 :            :       return false;
      89                 :            :     }
      90                 :            : 
      91                 :          0 :   return ((flags &~ (EF_ARM_EABIMASK
      92                 :            :                      | EF_ARM_RELEXEC
      93                 :            :                      | EF_ARM_HASENTRY
      94                 :            :                      | EF_ARM_INTERWORK
      95                 :            :                      | EF_ARM_APCS_26
      96                 :            :                      | EF_ARM_APCS_FLOAT
      97                 :            :                      | EF_ARM_PIC
      98                 :            :                      | EF_ARM_ALIGN8
      99                 :            :                      | EF_ARM_NEW_ABI
     100                 :            :                      | EF_ARM_OLD_ABI
     101                 :            :                      | EF_ARM_SOFT_FLOAT
     102                 :            :                      | EF_ARM_VFP_FLOAT
     103                 :            :                      | EF_ARM_MAVERICK_FLOAT
     104                 :            :                      | EF_ARM_SYMSARESORTED
     105                 :            :                      | EF_ARM_DYNSYMSUSESEGIDX
     106                 :            :                      | EF_ARM_MAPSYMSFIRST
     107                 :            :                      | EF_ARM_EABIMASK
     108                 :            :                      | EF_ARM_BE8
     109                 :          0 :                      | EF_ARM_LE8)) == 0);
     110                 :            : }
     111                 :            : 
     112                 :            : /* Check for the simple reloc types.  */
     113                 :            : Elf_Type
     114                 :          0 : arm_reloc_simple_type (Ebl *ebl __attribute__ ((unused)), int type,
     115                 :            :                        int *addsub __attribute__ ((unused)))
     116                 :            : {
     117         [ #  # ]:          0 :   switch (type)
     118                 :            :     {
     119                 :            :     case R_ARM_ABS32:
     120                 :            :       return ELF_T_WORD;
     121                 :            :     case R_ARM_ABS16:
     122                 :            :       return ELF_T_HALF;
     123                 :            :     case R_ARM_ABS8:
     124                 :            :       return ELF_T_BYTE;
     125                 :            :     default:
     126                 :            :       return ELF_T_NUM;
     127                 :            :     }
     128                 :            : }
     129                 :            : 
     130                 :            : /* The SHT_ARM_EXIDX section type is a valid target for relocation.  */
     131                 :            : bool
     132                 :          0 : arm_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)), Elf64_Word sh_type)
     133                 :            : {
     134                 :          0 :   return sh_type == SHT_ARM_EXIDX;
     135                 :            : }
     136                 :            : 
     137                 :            : const char *
     138                 :          0 : arm_symbol_type_name (int type,
     139                 :            :                       char *buf __attribute__ ((unused)),
     140                 :            :                       size_t len __attribute__ ((unused)))
     141                 :            : {
     142         [ #  # ]:          0 :   switch (type)
     143                 :            :     {
     144                 :            :     case STT_ARM_TFUNC:
     145                 :            :       return "ARM_TFUNC";
     146                 :            :     }
     147                 :          0 :   return NULL;
     148                 :            : }
     149                 :            : 
     150                 :            : /* A data mapping symbol is a symbol with "$d" name or "$d.<any...>" name,
     151                 :            :  *    STT_NOTYPE, STB_LOCAL and st_size of zero. The indicate the stat of a
     152                 :            :  *       sequence of data items.  */
     153                 :            : bool
     154                 :          8 : arm_data_marker_symbol (const GElf_Sym *sym, const char *sname)
     155                 :            : {
     156                 :          8 :   return (sym != NULL && sname != NULL
     157   [ +  -  +  - ]:          8 :           && sym->st_size == 0 && GELF_ST_BIND (sym->st_info) == STB_LOCAL
     158         [ +  - ]:          8 :           && GELF_ST_TYPE (sym->st_info) == STT_NOTYPE
     159   [ +  -  -  +  :         16 :           && (strcmp (sname, "$d") == 0 || startswith (sname, "$d.")));
                   -  - ]
     160                 :            : }

Generated by: LCOV version 1.16