LCOV - code coverage report
Current view: top level - libebl - eblopenbackend.c (source / functions) Hit Total Coverage
Test: lcov.out Lines: 117 178 65.7 %
Date: 2017-05-05 10:17:09 Functions: 22 39 56.4 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* Generate ELF backend handle.
       2             :    Copyright (C) 2000-2016 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 <assert.h>
      34             : #include <dlfcn.h>
      35             : #include <error.h>
      36             : #include <libelfP.h>
      37             : #include <dwarf.h>
      38             : #include <stdlib.h>
      39             : #include <string.h>
      40             : #include <stdio.h>
      41             : 
      42             : #include <system.h>
      43             : #include <libeblP.h>
      44             : 
      45             : 
      46             : /* This table should contain the complete list of architectures as far
      47             :    as the ELF specification is concerned.  */
      48             : /* XXX When things are stable replace the string pointers with char
      49             :    arrays to avoid relocations.  */
      50             : static const struct
      51             : {
      52             :   const char *dsoname;
      53             :   const char *emulation;
      54             :   const char *prefix;
      55             :   int prefix_len;
      56             :   int em;
      57             :   int class;
      58             :   int data;
      59             : } machines[] =
      60             : {
      61             :   { "i386", "elf_i386", "i386", 4, EM_386, ELFCLASS32, ELFDATA2LSB },
      62             :   { "ia64", "elf_ia64", "ia64", 4, EM_IA_64, ELFCLASS64, ELFDATA2LSB },
      63             :   { "alpha", "elf_alpha", "alpha", 5, EM_ALPHA, ELFCLASS64, ELFDATA2LSB },
      64             :   { "x86_64", "elf_x86_64", "x86_64", 6, EM_X86_64, ELFCLASS64, ELFDATA2LSB },
      65             :   { "ppc", "elf_ppc", "ppc", 3, EM_PPC, ELFCLASS32, ELFDATA2MSB },
      66             :   { "ppc64", "elf_ppc64", "ppc64", 5, EM_PPC64, ELFCLASS64, ELFDATA2MSB },
      67             :   { "tilegx", "elf_tilegx", "tilegx", 6, EM_TILEGX, ELFCLASS64, ELFDATA2LSB },
      68             :   // XXX class and machine fields need to be filled in for all archs.
      69             :   { "sh", "elf_sh", "sh", 2, EM_SH, 0, 0 },
      70             :   { "arm", "ebl_arm", "arm", 3, EM_ARM, 0, 0 },
      71             :   { "sparc", "elf_sparcv9", "sparc", 5, EM_SPARCV9, 0, 0 },
      72             :   { "sparc", "elf_sparc", "sparc", 5, EM_SPARC, 0, 0 },
      73             :   { "sparc", "elf_sparcv8plus", "sparc", 5, EM_SPARC32PLUS, 0, 0 },
      74             :   { "s390", "ebl_s390", "s390", 4, EM_S390, 0, 0 },
      75             : 
      76             :   { "m32", "elf_m32", "m32", 3, EM_M32, 0, 0 },
      77             :   { "m68k", "elf_m68k", "m68k", 4, EM_68K, ELFCLASS32, ELFDATA2MSB },
      78             :   { "m88k", "elf_m88k", "m88k", 4, EM_88K, 0, 0 },
      79             :   { "i860", "elf_i860", "i860", 4, EM_860, 0, 0 },
      80             :   { "s370", "ebl_s370", "s370", 4, EM_S370, 0, 0 },
      81             :   { "parisc", "elf_parisc", "parisc", 6, EM_PARISC, 0, 0 },
      82             :   { "vpp500", "elf_vpp500", "vpp500", 5, EM_VPP500, 0, 0 },
      83             :   { "sparc", "elf_v8plus", "v8plus", 6, EM_SPARC32PLUS, 0, 0 },
      84             :   { "i960", "elf_i960", "i960", 4, EM_960, 0, 0 },
      85             :   { "v800", "ebl_v800", "v800", 4, EM_V800, 0, 0 },
      86             :   { "fr20", "ebl_fr20", "fr20", 4, EM_FR20, 0, 0 },
      87             :   { "rh32", "ebl_rh32", "rh32", 4, EM_RH32, 0, 0 },
      88             :   { "rce", "ebl_rce", "rce", 3, EM_RCE, 0, 0 },
      89             :   { "tricore", "elf_tricore", "tricore", 7, EM_TRICORE, 0, 0 },
      90             :   { "arc", "elf_arc", "arc", 3, EM_ARC, 0, 0 },
      91             :   { "h8", "elf_h8_300", "h8_300", 6, EM_H8_300, 0, 0 },
      92             :   { "h8", "elf_h8_300h", "h8_300h", 6, EM_H8_300H, 0, 0 },
      93             :   { "h8", "elf_h8s", "h8s", 6, EM_H8S, 0, 0 },
      94             :   { "h8", "elf_h8_500", "h8_500", 6, EM_H8_500, 0, 0 },
      95             :   { "coldfire", "elf_coldfire", "coldfire", 8, EM_COLDFIRE, 0, 0 },
      96             :   { "m68k", "elf_68hc12", "68hc12", 6, EM_68HC12, 0, 0 },
      97             :   { "mma", "elf_mma", "mma", 3, EM_MMA, 0, 0 },
      98             :   { "pcp", "elf_pcp", "pcp", 3, EM_PCP, 0, 0 },
      99             :   { "ncpu", "elf_ncpu", "ncpu", 4, EM_NCPU, 0, 0 },
     100             :   { "ndr1", "elf_ndr1", "ndr1", 4, EM_NDR1, 0, 0 },
     101             :   { "starcore", "elf_starcore", "starcore", 8, EM_STARCORE, 0, 0 },
     102             :   { "me16", "elf_me16", "em16", 4, EM_ME16, 0, 0 },
     103             :   { "st100", "elf_st100", "st100", 5, EM_ST100, 0, 0 },
     104             :   { "tinyj", "elf_tinyj", "tinyj", 5, EM_TINYJ, 0, 0 },
     105             :   { "pdsp", "elf_pdsp", "pdsp", 4, EM_PDSP, 0, 0 },
     106             :   { "fx66", "elf_fx66", "fx66", 4, EM_FX66, 0, 0 },
     107             :   { "st9plus", "elf_st9plus", "st9plus", 7, EM_ST9PLUS, 0, 0 },
     108             :   { "st7", "elf_st7", "st7", 3, EM_ST7, 0, 0 },
     109             :   { "m68k", "elf_68hc16", "68hc16", 6, EM_68HC16, 0, 0 },
     110             :   { "m68k", "elf_68hc11", "68hc11", 6, EM_68HC11, 0, 0 },
     111             :   { "m68k", "elf_68hc08", "68hc08", 6, EM_68HC08, 0, 0 },
     112             :   { "m68k", "elf_68hc05", "68hc05", 6, EM_68HC05, 0, 0 },
     113             :   { "svx", "elf_svx", "svx", 3, EM_SVX, 0, 0 },
     114             :   { "st19", "elf_st19", "st19", 4, EM_ST19, 0, 0 },
     115             :   { "vax", "elf_vax", "vax", 3, EM_VAX, 0, 0 },
     116             :   { "cris", "elf_cris", "cris", 4, EM_CRIS, 0, 0 },
     117             :   { "javelin", "elf_javelin", "javelin", 7, EM_JAVELIN, 0, 0 },
     118             :   { "firepath", "elf_firepath", "firepath", 8, EM_FIREPATH, 0, 0 },
     119             :   { "zsp", "elf_zsp", "zsp", 3, EM_ZSP, 0, 0 },
     120             :   { "mmix", "elf_mmix", "mmix", 4, EM_MMIX, 0, 0 },
     121             :   { "hunay", "elf_huany", "huany", 5, EM_HUANY, 0, 0 },
     122             :   { "prism", "elf_prism", "prism", 5, EM_PRISM, 0, 0 },
     123             :   { "avr", "elf_avr", "avr", 3, EM_AVR, 0, 0 },
     124             :   { "fr30", "elf_fr30", "fr30", 4, EM_FR30, 0, 0 },
     125             :   { "dv10", "elf_dv10", "dv10", 4, EM_D10V, 0, 0 },
     126             :   { "dv30", "elf_dv30", "dv30", 4, EM_D30V, 0, 0 },
     127             :   { "v850", "elf_v850", "v850", 4, EM_V850, 0, 0 },
     128             :   { "m32r", "elf_m32r", "m32r", 4, EM_M32R, 0, 0 },
     129             :   { "mn10300", "elf_mn10300", "mn10300", 7, EM_MN10300, 0, 0 },
     130             :   { "mn10200", "elf_mn10200", "mn10200", 7, EM_MN10200, 0, 0 },
     131             :   { "pj", "elf_pj", "pj", 2, EM_PJ, 0, 0 },
     132             :   { "openrisc", "elf_openrisc", "openrisc", 8, EM_OPENRISC, 0, 0 },
     133             :   { "arc", "elf_arc_a5", "arc_a5", 6, EM_ARC_A5, 0, 0 },
     134             :   { "xtensa", "elf_xtensa", "xtensa", 6, EM_XTENSA, 0, 0 },
     135             :   { "aarch64", "elf_aarch64", "aarch64", 7, EM_AARCH64, ELFCLASS64, 0 },
     136             :   { "bpf", "elf_bpf", "bpf", 3, EM_BPF, 0, 0 },
     137             : };
     138             : #define nmachines (sizeof (machines) / sizeof (machines[0]))
     139             : 
     140             : /* No machine prefix should be larger than this.  */
     141             : #define MAX_PREFIX_LEN 16
     142             : 
     143             : /* Default callbacks.  Mostly they just return the error value.  */
     144             : static const char *default_reloc_type_name (int ignore, char *buf, size_t len);
     145             : static bool default_reloc_type_check (int ignore);
     146             : static bool default_reloc_valid_use (Elf *elf, int ignore);
     147             : static Elf_Type default_reloc_simple_type (Ebl *ebl, int ignore);
     148             : static bool default_gotpc_reloc_check (Elf *elf, int ignore);
     149             : static const char *default_segment_type_name (int ignore, char *buf,
     150             :                                               size_t len);
     151             : static const char *default_section_type_name (int ignore, char *buf,
     152             :                                               size_t len);
     153             : static const char *default_section_name (int ignore, int ignore2, char *buf,
     154             :                                          size_t len);
     155             : static const char *default_machine_flag_name (Elf64_Word *ignore);
     156             : static bool default_machine_flag_check (Elf64_Word flags);
     157             : static bool default_machine_section_flag_check (GElf_Xword flags);
     158             : static const char *default_symbol_type_name (int ignore, char *buf,
     159             :                                              size_t len);
     160             : static const char *default_symbol_binding_name (int ignore, char *buf,
     161             :                                                 size_t len);
     162             : static const char *default_dynamic_tag_name (int64_t ignore, char *buf,
     163             :                                              size_t len);
     164             : static bool default_dynamic_tag_check (int64_t ignore);
     165             : static const char *default_osabi_name (int ignore, char *buf, size_t len);
     166             : static void default_destr (struct ebl *ignore);
     167             : static const char *default_core_note_type_name (uint32_t, char *buf,
     168             :                                                 size_t len);
     169             : static const char *default_object_note_type_name (const char *name, uint32_t,
     170             :                                                   char *buf, size_t len);
     171             : static int default_core_note (const GElf_Nhdr *nhdr, const char *name,
     172             :                               GElf_Word *regs_offset, size_t *nregloc,
     173             :                               const Ebl_Register_Location **reglocs,
     174             :                               size_t *nitems, const Ebl_Core_Item **);
     175             : static int default_auxv_info (GElf_Xword a_type,
     176             :                               const char **name, const char **format);
     177             : static bool default_object_note (const char *name, uint32_t type,
     178             :                                  uint32_t descsz, const char *desc);
     179             : static bool default_debugscn_p (const char *name);
     180             : static bool default_copy_reloc_p (int reloc);
     181             : static bool default_none_reloc_p (int reloc);
     182             : static bool default_relative_reloc_p (int reloc);
     183             : static bool default_check_special_symbol (Elf *elf, GElf_Ehdr *ehdr,
     184             :                                           const GElf_Sym *sym,
     185             :                                           const char *name,
     186             :                                           const GElf_Shdr *destshdr);
     187             : static bool default_check_st_other_bits (unsigned char st_other);
     188             : static bool default_check_special_section (Ebl *, int,
     189             :                                            const GElf_Shdr *, const char *);
     190             : static bool default_bss_plt_p (Elf *elf);
     191             : static int default_return_value_location (Dwarf_Die *functypedie,
     192             :                                           const Dwarf_Op **locops);
     193             : static ssize_t default_register_info (Ebl *ebl,
     194             :                                       int regno, char *name, size_t namelen,
     195             :                                       const char **prefix,
     196             :                                       const char **setname,
     197             :                                       int *bits, int *type);
     198             : static int default_syscall_abi (Ebl *ebl, int *sp, int *pc,
     199             :                                 int *callno, int args[6]);
     200             : static bool default_check_object_attribute (Ebl *ebl, const char *vendor,
     201             :                                             int tag, uint64_t value,
     202             :                                             const char **tag_name,
     203             :                                             const char **value_name);
     204             : static bool default_check_reloc_target_type (Ebl *ebl, Elf64_Word sh_type);
     205             : static int default_abi_cfi (Ebl *ebl, Dwarf_CIE *abi_info);
     206             : 
     207             : 
     208             : static void
     209         892 : fill_defaults (Ebl *result)
     210             : {
     211         892 :   result->reloc_type_name = default_reloc_type_name;
     212         892 :   result->reloc_type_check = default_reloc_type_check;
     213         892 :   result->reloc_valid_use = default_reloc_valid_use;
     214         892 :   result->reloc_simple_type = default_reloc_simple_type;
     215         892 :   result->gotpc_reloc_check = default_gotpc_reloc_check;
     216         892 :   result->segment_type_name = default_segment_type_name;
     217         892 :   result->section_type_name = default_section_type_name;
     218         892 :   result->section_name = default_section_name;
     219         892 :   result->machine_flag_name = default_machine_flag_name;
     220         892 :   result->machine_flag_check = default_machine_flag_check;
     221         892 :   result->machine_section_flag_check = default_machine_section_flag_check;
     222         892 :   result->check_special_section = default_check_special_section;
     223         892 :   result->symbol_type_name = default_symbol_type_name;
     224         892 :   result->symbol_binding_name = default_symbol_binding_name;
     225         892 :   result->dynamic_tag_name = default_dynamic_tag_name;
     226         892 :   result->dynamic_tag_check = default_dynamic_tag_check;
     227         892 :   result->osabi_name = default_osabi_name;
     228         892 :   result->core_note_type_name = default_core_note_type_name;
     229         892 :   result->object_note_type_name = default_object_note_type_name;
     230         892 :   result->core_note = default_core_note;
     231         892 :   result->auxv_info = default_auxv_info;
     232         892 :   result->object_note = default_object_note;
     233         892 :   result->debugscn_p = default_debugscn_p;
     234         892 :   result->copy_reloc_p = default_copy_reloc_p;
     235         892 :   result->none_reloc_p = default_none_reloc_p;
     236         892 :   result->relative_reloc_p = default_relative_reloc_p;
     237         892 :   result->check_special_symbol = default_check_special_symbol;
     238         892 :   result->check_st_other_bits = default_check_st_other_bits;
     239         892 :   result->bss_plt_p = default_bss_plt_p;
     240         892 :   result->return_value_location = default_return_value_location;
     241         892 :   result->register_info = default_register_info;
     242         892 :   result->syscall_abi = default_syscall_abi;
     243         892 :   result->check_object_attribute = default_check_object_attribute;
     244         892 :   result->check_reloc_target_type = default_check_reloc_target_type;
     245         892 :   result->disasm = NULL;
     246         892 :   result->abi_cfi = default_abi_cfi;
     247         892 :   result->destr = default_destr;
     248         892 :   result->sysvhash_entrysize = sizeof (Elf32_Word);
     249         892 : }
     250             : 
     251             : 
     252             : /* Find an appropriate backend for the file associated with ELF.  */
     253             : static Ebl *
     254         892 : openbackend (Elf *elf, const char *emulation, GElf_Half machine)
     255             : {
     256             :   Ebl *result;
     257             :   size_t cnt;
     258             : 
     259             :   /* First allocate the data structure for the result.  We do this
     260             :      here since this assures that the structure is always large
     261             :      enough.  */
     262         892 :   result = (Ebl *) calloc (1, sizeof (Ebl));
     263         892 :   if (result == NULL)
     264             :     {
     265             :       // XXX uncomment
     266             :       // __libebl_seterror (ELF_E_NOMEM);
     267             :       return NULL;
     268             :     }
     269             : 
     270             :   /* Fill in the default callbacks.  The initializer for the machine
     271             :      specific module can overwrite the values.  */
     272         892 :   fill_defaults (result);
     273             : 
     274             :   /* XXX Currently all we do is to look at 'e_machine' value in the
     275             :      ELF header.  With an internal mapping table from EM_* value to
     276             :      DSO name we try to load the appropriate module to handle this
     277             :      binary type.
     278             : 
     279             :      Multiple modules for the same machine type are possible and they
     280             :      will be tried in sequence.  The lookup process will only stop
     281             :      when a module which can handle the machine type is found or all
     282             :      available matching modules are tried.  */
     283        5734 :   for (cnt = 0; cnt < nmachines; ++cnt)
     284        5734 :     if ((emulation != NULL && strcmp (emulation, machines[cnt].emulation) == 0)
     285        5734 :         || (emulation == NULL && machines[cnt].em == machine))
     286             :       {
     287             :         /* Well, we know the emulation name now.  */
     288         892 :         result->emulation = machines[cnt].emulation;
     289             : 
     290             :         /* We access some data structures directly.  Make sure the 32 and
     291             :            64 bit variants are laid out the same.  */
     292             :         assert (offsetof (Elf32_Ehdr, e_machine)
     293             :                 == offsetof (Elf64_Ehdr, e_machine));
     294             :         assert (sizeof (((Elf32_Ehdr *) 0)->e_machine)
     295             :                 == sizeof (((Elf64_Ehdr *) 0)->e_machine));
     296             :         assert (offsetof (Elf, state.elf32.ehdr)
     297             :                 == offsetof (Elf, state.elf64.ehdr));
     298             : 
     299             :         /* Prefer taking the information from the ELF file.  */
     300         892 :         if (elf == NULL)
     301             :           {
     302           9 :             result->machine = machines[cnt].em;
     303           9 :             result->class = machines[cnt].class;
     304           9 :             result->data = machines[cnt].data;
     305             :           }
     306             :         else
     307             :           {
     308         883 :             result->machine = elf->state.elf32.ehdr->e_machine;
     309         883 :             result->class = elf->state.elf32.ehdr->e_ident[EI_CLASS];
     310         883 :             result->data = elf->state.elf32.ehdr->e_ident[EI_DATA];
     311             :           }
     312             : 
     313             : #ifndef LIBEBL_SUBDIR
     314             : # define LIBEBL_SUBDIR PACKAGE
     315             : #endif
     316             : #define ORIGINDIR "$ORIGIN/../$LIB/" LIBEBL_SUBDIR "/"
     317             : 
     318             :         /* Give it a try.  At least the machine type matches.  First
     319             :            try to load the module.  */
     320             :         char dsoname[100];
     321        2676 :         strcpy (stpcpy (stpcpy (dsoname, ORIGINDIR "libebl_"),
     322             :                         machines[cnt].dsoname),
     323             :                 ".so");
     324             : 
     325         892 :         void *h = dlopen (dsoname, RTLD_LAZY);
     326         892 :         if (h == NULL)
     327             :           {
     328        2676 :             strcpy (stpcpy (stpcpy (dsoname, "libebl_"),
     329             :                             machines[cnt].dsoname),
     330             :                     ".so");
     331         892 :             h = dlopen (dsoname, RTLD_LAZY);
     332             :           }
     333             : 
     334             :           /* Try without an explicit path.  */
     335         892 :         if (h != NULL)
     336             :           {
     337             :             /* We managed to load the object.  Now see whether the
     338             :                initialization function likes our file.  */
     339             :             static const char version[] = MODVERSION;
     340             :             const char *modversion;
     341             :             ebl_bhinit_t initp;
     342             : 
     343             :             // We use a static number to help the compiler see we don't
     344             :             // overflow the stack with an arbitrary number.
     345         892 :             assert (machines[cnt].prefix_len <= MAX_PREFIX_LEN);
     346             :             char symname[MAX_PREFIX_LEN + sizeof "_init"];
     347             : 
     348        2676 :             strcpy (mempcpy (symname, machines[cnt].prefix,
     349             :                              machines[cnt].prefix_len), "_init");
     350             : 
     351         892 :             initp = (ebl_bhinit_t) dlsym (h, symname);
     352         892 :             if (initp != NULL
     353         892 :                 && (modversion = initp (elf, machine, result, sizeof (Ebl)))
     354         892 :                 && strcmp (version, modversion) == 0)
     355             :               {
     356             :                 /* We found a module to handle our file.  */
     357         892 :                 result->dlhandle = h;
     358         892 :                 result->elf = elf;
     359             : 
     360             :                 /* A few entries are mandatory.  */
     361         892 :                 assert (result->name != NULL);
     362         892 :                 assert (result->destr != NULL);
     363             : 
     364         892 :                 return result;
     365             :               }
     366             : 
     367             :             /* Not the module we need.  */
     368           0 :             (void) dlclose (h);
     369             :           }
     370             : 
     371             :         /* We cannot find a DSO but the emulation/machine ID matches.
     372             :            Return that information.  */
     373           0 :         result->dlhandle = NULL;
     374           0 :         result->elf = elf;
     375           0 :         result->name = machines[cnt].prefix;
     376           0 :         fill_defaults (result);
     377             : 
     378           0 :         return result;
     379             :       }
     380             : 
     381             :   /* Nothing matched.  We use only the default callbacks.   */
     382           0 :   result->dlhandle = NULL;
     383           0 :   result->elf = elf;
     384           0 :   result->emulation = "<unknown>";
     385           0 :   result->name = "<unknown>";
     386           0 :   fill_defaults (result);
     387             : 
     388           0 :   return result;
     389             : }
     390             : 
     391             : 
     392             : /* Find an appropriate backend for the file associated with ELF.  */
     393             : Ebl *
     394         883 : ebl_openbackend (Elf *elf)
     395             : {
     396             :   GElf_Ehdr ehdr_mem;
     397             :   GElf_Ehdr *ehdr;
     398             : 
     399             :   /* Get the ELF header of the object.  */
     400         883 :   ehdr = gelf_getehdr (elf, &ehdr_mem);
     401         883 :   if (ehdr == NULL)
     402             :     {
     403             :       // XXX uncomment
     404             :       // __libebl_seterror (elf_errno ());
     405             :       return NULL;
     406             :     }
     407             : 
     408         883 :   return openbackend (elf, NULL, ehdr->e_machine);
     409             : }
     410             : 
     411             : 
     412             : /* Find backend without underlying ELF file.  */
     413             : Ebl *
     414           9 : ebl_openbackend_machine (GElf_Half machine)
     415             : {
     416           9 :   return openbackend (NULL, NULL, machine);
     417             : }
     418             : 
     419             : 
     420             : /* Find backend with given emulation name.  */
     421             : Ebl *
     422           0 : ebl_openbackend_emulation (const char *emulation)
     423             : {
     424           0 :   return openbackend (NULL, emulation, EM_NONE);
     425             : }
     426             : 
     427             : 
     428             : /* Default callbacks.  Mostly they just return the error value.  */
     429             : static const char *
     430           0 : default_reloc_type_name (int ignore __attribute__ ((unused)),
     431             :                          char *buf __attribute__ ((unused)),
     432             :                          size_t len __attribute__ ((unused)))
     433             : {
     434           0 :   return NULL;
     435             : }
     436             : 
     437             : static bool
     438           0 : default_reloc_type_check (int ignore __attribute__ ((unused)))
     439             : {
     440           0 :   return false;
     441             : }
     442             : 
     443             : static bool
     444           0 : default_reloc_valid_use (Elf *elf __attribute__ ((unused)),
     445             :                          int ignore __attribute__ ((unused)))
     446             : {
     447           0 :   return false;
     448             : }
     449             : 
     450             : static Elf_Type
     451           0 : default_reloc_simple_type (Ebl *eh __attribute__ ((unused)),
     452             :                            int ignore __attribute__ ((unused)))
     453             : {
     454           0 :   return ELF_T_NUM;
     455             : }
     456             : 
     457             : static bool
     458       32671 : default_gotpc_reloc_check (Elf *elf __attribute__ ((unused)),
     459             :                            int ignore __attribute__ ((unused)))
     460             : {
     461       32671 :   return false;
     462             : }
     463             : 
     464             : static const char *
     465         110 : default_segment_type_name (int ignore __attribute__ ((unused)),
     466             :                            char *buf __attribute__ ((unused)),
     467             :                            size_t len __attribute__ ((unused)))
     468             : {
     469         110 :   return NULL;
     470             : }
     471             : 
     472             : static const char *
     473        1283 : default_section_type_name (int ignore __attribute__ ((unused)),
     474             :                            char *buf __attribute__ ((unused)),
     475             :                            size_t len __attribute__ ((unused)))
     476             : {
     477        1283 :   return NULL;
     478             : }
     479             : 
     480             : static const char *
     481       34759 : default_section_name (int ignore __attribute__ ((unused)),
     482             :                       int ignore2 __attribute__ ((unused)),
     483             :                       char *buf __attribute__ ((unused)),
     484             :                       size_t len __attribute__ ((unused)))
     485             : {
     486       34759 :   return NULL;
     487             : }
     488             : 
     489             : static const char *
     490           0 : default_machine_flag_name (Elf64_Word *ignore __attribute__ ((unused)))
     491             : {
     492           0 :   return NULL;
     493             : }
     494             : 
     495             : static bool
     496         117 : default_machine_flag_check (Elf64_Word flags __attribute__ ((unused)))
     497             : {
     498         117 :   return flags == 0;
     499             : }
     500             : 
     501             : static bool
     502           0 : default_machine_section_flag_check (GElf_Xword flags)
     503             : {
     504           0 :   return flags == 0;
     505             : }
     506             : 
     507             : static bool
     508           0 : default_check_special_section (Ebl *ebl __attribute__ ((unused)),
     509             :                                int ndx __attribute__ ((unused)),
     510             :                                const GElf_Shdr *shdr __attribute__ ((unused)),
     511             :                                const char *sname __attribute__ ((unused)))
     512             : {
     513           0 :   return false;
     514             : }
     515             : 
     516             : static const char *
     517       69519 : default_symbol_type_name (int ignore __attribute__ ((unused)),
     518             :                           char *buf __attribute__ ((unused)),
     519             :                           size_t len __attribute__ ((unused)))
     520             : {
     521       69519 :   return NULL;
     522             : }
     523             : 
     524             : static const char *
     525           0 : default_symbol_binding_name (int ignore __attribute__ ((unused)),
     526             :                              char *buf __attribute__ ((unused)),
     527             :                              size_t len __attribute__ ((unused)))
     528             : {
     529           0 :   return NULL;
     530             : }
     531             : 
     532             : static const char *
     533         511 : default_dynamic_tag_name (int64_t ignore __attribute__ ((unused)),
     534             :                           char *buf __attribute__ ((unused)),
     535             :                           size_t len __attribute__ ((unused)))
     536             : {
     537         511 :   return NULL;
     538             : }
     539             : 
     540             : static bool
     541        1445 : default_dynamic_tag_check (int64_t ignore __attribute__ ((unused)))
     542             : {
     543        1445 :   return false;
     544             : }
     545             : 
     546             : static void
     547         881 : default_destr (struct ebl *ignore __attribute__ ((unused)))
     548             : {
     549         881 : }
     550             : 
     551             : static const char *
     552          32 : default_osabi_name (int ignore __attribute__ ((unused)),
     553             :                     char *buf __attribute__ ((unused)),
     554             :                     size_t len __attribute__ ((unused)))
     555             : {
     556          32 :   return NULL;
     557             : }
     558             : 
     559             : static const char *
     560          54 : default_core_note_type_name (uint32_t ignore __attribute__ ((unused)),
     561             :                              char *buf __attribute__ ((unused)),
     562             :                              size_t len __attribute__ ((unused)))
     563             : {
     564          54 :   return NULL;
     565             : }
     566             : 
     567             : static int
     568          74 : default_auxv_info (GElf_Xword a_type __attribute__ ((unused)),
     569             :                    const char **name __attribute__ ((unused)),
     570             :                    const char **format __attribute__ ((unused)))
     571             : {
     572          74 :   return 0;
     573             : }
     574             : 
     575             : static int
     576           0 : default_core_note (const GElf_Nhdr *nhdr __attribute__ ((unused)),
     577             :                    const char *name __attribute__ ((unused)),
     578             :                    GElf_Word *ro __attribute__ ((unused)),
     579             :                    size_t *nregloc  __attribute__ ((unused)),
     580             :                    const Ebl_Register_Location **reglocs
     581             :                    __attribute__ ((unused)),
     582             :                    size_t *nitems __attribute__ ((unused)),
     583             :                    const Ebl_Core_Item **items __attribute__ ((unused)))
     584             : {
     585           0 :   return 0;
     586             : }
     587             : 
     588             : static const char *
     589          34 : default_object_note_type_name (const char *name __attribute__ ((unused)),
     590             :                                uint32_t ignore __attribute__ ((unused)),
     591             :                                char *buf __attribute__ ((unused)),
     592             :                                size_t len __attribute__ ((unused)))
     593             : {
     594          34 :   return NULL;
     595             : }
     596             : 
     597             : static bool
     598          34 : default_object_note (const char *name __attribute__ ((unused)),
     599             :                      uint32_t type __attribute__ ((unused)),
     600             :                      uint32_t descsz __attribute__ ((unused)),
     601             :                      const char *desc __attribute__ ((unused)))
     602             : {
     603          34 :   return NULL;
     604             : }
     605             : 
     606             : static bool
     607       31237 : default_debugscn_p (const char *name)
     608             : {
     609             :   /* We know by default only about the DWARF debug sections which have
     610             :      fixed names.  */
     611             :   static const char *dwarf_scn_names[] =
     612             :     {
     613             :       /* DWARF 1 */
     614             :       ".debug",
     615             :       ".line",
     616             :       /* GNU DWARF 1 extensions */
     617             :       ".debug_srcinfo",
     618             :       ".debug_sfnames",
     619             :       /* DWARF 1.1 and DWARF 2 */
     620             :       ".debug_aranges",
     621             :       ".debug_pubnames",
     622             :       /* DWARF 2 */
     623             :       ".debug_info",
     624             :       ".debug_abbrev",
     625             :       ".debug_line",
     626             :       ".debug_frame",
     627             :       ".debug_str",
     628             :       ".debug_loc",
     629             :       ".debug_macinfo",
     630             :       /* DWARF 3 */
     631             :       ".debug_ranges",
     632             :       ".debug_pubtypes",
     633             :       /* DWARF 4 */
     634             :       ".debug_types",
     635             :       /* GDB DWARF 4 extension */
     636             :       ".gdb_index",
     637             :       /* GNU/DWARF 5 extension/proposal */
     638             :       ".debug_macro",
     639             :       /* SGI/MIPS DWARF 2 extensions */
     640             :       ".debug_weaknames",
     641             :       ".debug_funcnames",
     642             :       ".debug_typenames",
     643             :       ".debug_varnames"
     644             :     };
     645       31237 :   const size_t ndwarf_scn_names = (sizeof (dwarf_scn_names)
     646             :                                    / sizeof (dwarf_scn_names[0]));
     647      456225 :   for (size_t cnt = 0; cnt < ndwarf_scn_names; ++cnt)
     648      446920 :     if (strcmp (name, dwarf_scn_names[cnt]) == 0
     649      424988 :         || (strncmp (name, ".zdebug", strlen (".zdebug")) == 0
     650           0 :             && strcmp (&name[2], &dwarf_scn_names[cnt][1]) == 0))
     651             :       return true;
     652             : 
     653             :   return false;
     654             : }
     655             : 
     656             : static bool
     657           0 : default_copy_reloc_p (int reloc __attribute__ ((unused)))
     658             : {
     659           0 :   return false;
     660             : }
     661             : strong_alias (default_copy_reloc_p, default_none_reloc_p)
     662             : strong_alias (default_copy_reloc_p, default_relative_reloc_p)
     663             : 
     664             : static bool
     665      118133 : default_check_special_symbol (Elf *elf __attribute__ ((unused)),
     666             :                               GElf_Ehdr *ehdr __attribute__ ((unused)),
     667             :                               const GElf_Sym *sym __attribute__ ((unused)),
     668             :                               const char *name __attribute__ ((unused)),
     669             :                               const GElf_Shdr *destshdr __attribute__ ((unused)))
     670             : {
     671      118133 :   return false;
     672             : }
     673             : 
     674             : static bool
     675           0 : default_check_st_other_bits (unsigned char st_other __attribute__ ((unused)))
     676             : {
     677           0 :   return false;
     678             : }
     679             : 
     680             : 
     681             : static bool
     682          57 : default_bss_plt_p (Elf *elf __attribute__ ((unused)))
     683             : {
     684          57 :   return false;
     685             : }
     686             : 
     687             : static int
     688           0 : default_return_value_location (Dwarf_Die *functypedie __attribute__ ((unused)),
     689             :                                const Dwarf_Op **locops __attribute__ ((unused)))
     690             : {
     691           0 :   return -2;
     692             : }
     693             : 
     694             : static ssize_t
     695           0 : default_register_info (Ebl *ebl __attribute__ ((unused)),
     696             :                        int regno, char *name, size_t namelen,
     697             :                        const char **prefix,
     698             :                        const char **setname,
     699             :                        int *bits, int *type)
     700             : {
     701           0 :   if (name == NULL)
     702             :     return 0;
     703             : 
     704           0 :   *setname = "???";
     705           0 :   *prefix = "";
     706           0 :   *bits = -1;
     707           0 :   *type = DW_ATE_void;
     708           0 :   return snprintf (name, namelen, "reg%d", regno);
     709             : }
     710             : 
     711             : static int
     712           0 : default_syscall_abi (Ebl *ebl __attribute__ ((unused)),
     713             :                      int *sp, int *pc, int *callno, int args[6])
     714             : {
     715           0 :   *sp = *pc = *callno = -1;
     716           0 :   args[0] = -1;
     717           0 :   args[1] = -1;
     718           0 :   args[2] = -1;
     719           0 :   args[3] = -1;
     720           0 :   args[4] = -1;
     721           0 :   args[5] = -1;
     722           0 :   return -1;
     723             : }
     724             : 
     725             : static bool
     726           0 : default_check_object_attribute (Ebl *ebl __attribute__ ((unused)),
     727             :                                 const char *vendor  __attribute__ ((unused)),
     728             :                                 int tag __attribute__ ((unused)),
     729             :                                 uint64_t value __attribute__ ((unused)),
     730             :                                 const char **tag_name, const char **value_name)
     731             : {
     732           0 :   *tag_name = NULL;
     733           0 :   *value_name = NULL;
     734           0 :   return false;
     735             : }
     736             : 
     737             : static bool
     738         197 : default_check_reloc_target_type (Ebl *ebl __attribute__ ((unused)),
     739             :                                  Elf64_Word sh_type __attribute__ ((unused)))
     740             : {
     741         197 :   return false;
     742             : }
     743             : 
     744             : static int
     745           0 : default_abi_cfi (Ebl *ebl __attribute__ ((unused)),
     746             :                  Dwarf_CIE *abi_info __attribute__ ((unused)))
     747             : {
     748           0 :   return -1;
     749             : }

Generated by: LCOV version 1.12