LCOV - code coverage report
Current view: top level - libdw - libdwP.h (source / functions) Hit Total Coverage
Test: elfutils-0.189 Lines: 206 268 76.9 %
Date: 2023-04-14 15:57:06 Functions: 18 18 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 127 222 57.2 %

           Branch data     Line data    Source code
       1                 :            : /* Internal definitions for libdw.
       2                 :            :    Copyright (C) 2002-2011, 2013-2018 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                 :            : #ifndef _LIBDWP_H
      30                 :            : #define _LIBDWP_H 1
      31                 :            : 
      32                 :            : #include <stdbool.h>
      33                 :            : #include <pthread.h>
      34                 :            : 
      35                 :            : #include <libdw.h>
      36                 :            : #include <dwarf.h>
      37                 :            : 
      38                 :            : 
      39                 :            : /* Known location expressions already decoded.  */
      40                 :            : struct loc_s
      41                 :            : {
      42                 :            :   void *addr;
      43                 :            :   Dwarf_Op *loc;
      44                 :            :   size_t nloc;
      45                 :            : };
      46                 :            : 
      47                 :            : /* Known DW_OP_implicit_value blocks already decoded.
      48                 :            :    This overlaps struct loc_s exactly, but only the
      49                 :            :    first member really has to match.  */
      50                 :            : struct loc_block_s
      51                 :            : {
      52                 :            :   void *addr;
      53                 :            :   unsigned char *data;
      54                 :            :   size_t length;
      55                 :            : };
      56                 :            : 
      57                 :            : /* Already decoded .debug_line units.  */
      58                 :            : struct files_lines_s
      59                 :            : {
      60                 :            :   Dwarf_Off debug_line_offset;
      61                 :            :   Dwarf_Files *files;
      62                 :            :   Dwarf_Lines *lines;
      63                 :            : };
      64                 :            : 
      65                 :            : /* Valid indices for the section data.  */
      66                 :            : enum
      67                 :            :   {
      68                 :            :     IDX_debug_info = 0,
      69                 :            :     IDX_debug_types,
      70                 :            :     IDX_debug_abbrev,
      71                 :            :     IDX_debug_aranges,
      72                 :            :     IDX_debug_addr,
      73                 :            :     IDX_debug_line,
      74                 :            :     IDX_debug_line_str,
      75                 :            :     IDX_debug_frame,
      76                 :            :     IDX_debug_loc,
      77                 :            :     IDX_debug_loclists,
      78                 :            :     IDX_debug_pubnames,
      79                 :            :     IDX_debug_str,
      80                 :            :     IDX_debug_str_offsets,
      81                 :            :     IDX_debug_macinfo,
      82                 :            :     IDX_debug_macro,
      83                 :            :     IDX_debug_ranges,
      84                 :            :     IDX_debug_rnglists,
      85                 :            :     IDX_gnu_debugaltlink,
      86                 :            :     IDX_last
      87                 :            :   };
      88                 :            : 
      89                 :            : /* Valid indices for the string section's information.  */
      90                 :            : enum string_section_index
      91                 :            :   {
      92                 :            :     STR_SCN_IDX_debug_line_str,
      93                 :            :     STR_SCN_IDX_debug_str,
      94                 :            :     STR_SCN_IDX_last
      95                 :            :   };
      96                 :            : 
      97                 :            : /* Error values.  */
      98                 :            : enum
      99                 :            : {
     100                 :            :   DWARF_E_NOERROR = 0,
     101                 :            :   DWARF_E_UNKNOWN_ERROR,
     102                 :            :   DWARF_E_INVALID_ACCESS,
     103                 :            :   DWARF_E_NO_REGFILE,
     104                 :            :   DWARF_E_IO_ERROR,
     105                 :            :   DWARF_E_INVALID_ELF,
     106                 :            :   DWARF_E_NO_DWARF,
     107                 :            :   DWARF_E_COMPRESSED_ERROR,
     108                 :            :   DWARF_E_NOELF,
     109                 :            :   DWARF_E_GETEHDR_ERROR,
     110                 :            :   DWARF_E_NOMEM,
     111                 :            :   DWARF_E_UNIMPL,
     112                 :            :   DWARF_E_INVALID_CMD,
     113                 :            :   DWARF_E_INVALID_VERSION,
     114                 :            :   DWARF_E_INVALID_FILE,
     115                 :            :   DWARF_E_NO_ENTRY,
     116                 :            :   DWARF_E_INVALID_DWARF,
     117                 :            :   DWARF_E_NO_STRING,
     118                 :            :   DWARF_E_NO_DEBUG_STR,
     119                 :            :   DWARF_E_NO_DEBUG_LINE_STR,
     120                 :            :   DWARF_E_NO_STR_OFFSETS,
     121                 :            :   DWARF_E_NO_ADDR,
     122                 :            :   DWARF_E_NO_CONSTANT,
     123                 :            :   DWARF_E_NO_REFERENCE,
     124                 :            :   DWARF_E_INVALID_REFERENCE,
     125                 :            :   DWARF_E_NO_DEBUG_LINE,
     126                 :            :   DWARF_E_INVALID_DEBUG_LINE,
     127                 :            :   DWARF_E_TOO_BIG,
     128                 :            :   DWARF_E_VERSION,
     129                 :            :   DWARF_E_INVALID_DIR_IDX,
     130                 :            :   DWARF_E_ADDR_OUTOFRANGE,
     131                 :            :   DWARF_E_NO_DEBUG_LOC,
     132                 :            :   DWARF_E_NO_DEBUG_LOCLISTS,
     133                 :            :   DWARF_E_NO_LOC_VALUE,
     134                 :            :   DWARF_E_NO_BLOCK,
     135                 :            :   DWARF_E_INVALID_LINE_IDX,
     136                 :            :   DWARF_E_INVALID_ARANGE_IDX,
     137                 :            :   DWARF_E_NO_MATCH,
     138                 :            :   DWARF_E_NO_FLAG,
     139                 :            :   DWARF_E_INVALID_OFFSET,
     140                 :            :   DWARF_E_NO_DEBUG_RANGES,
     141                 :            :   DWARF_E_NO_DEBUG_RNGLISTS,
     142                 :            :   DWARF_E_INVALID_CFI,
     143                 :            :   DWARF_E_NO_ALT_DEBUGLINK,
     144                 :            :   DWARF_E_INVALID_OPCODE,
     145                 :            :   DWARF_E_NOT_CUDIE,
     146                 :            :   DWARF_E_UNKNOWN_LANGUAGE,
     147                 :            :   DWARF_E_NO_DEBUG_ADDR,
     148                 :            : };
     149                 :            : 
     150                 :            : 
     151                 :            : #include "dwarf_sig8_hash.h"
     152                 :            : 
     153                 :            : /* The type of Dwarf object, sorted by preference
     154                 :            :    (if there is a higher order type, we pick that one over the others).  */
     155                 :            : enum dwarf_type
     156                 :            :   {
     157                 :            :     TYPE_UNKNOWN = 0,
     158                 :            :     TYPE_GNU_LTO = 16,
     159                 :            :     TYPE_DWO = 32,
     160                 :            :     TYPE_PLAIN = 64,
     161                 :            :   };
     162                 :            : 
     163                 :            : /* This is the structure representing the debugging state.  */
     164                 :            : struct Dwarf
     165                 :            : {
     166                 :            :   /* The underlying ELF file.  */
     167                 :            :   Elf *elf;
     168                 :            : 
     169                 :            :   /* The (absolute) path to the ELF dir, if known.  To help locating
     170                 :            :      alt and dwo files.  */
     171                 :            :   char *debugdir;
     172                 :            : 
     173                 :            :   /* dwz alternate DWARF file.  */
     174                 :            :   Dwarf *alt_dwarf;
     175                 :            : 
     176                 :            :   /* The section data.  */
     177                 :            :   Elf_Data *sectiondata[IDX_last];
     178                 :            : 
     179                 :            :   /* Size of a prefix of string sections, where any string will be
     180                 :            :      null-terminated. */
     181                 :            :   size_t string_section_size[STR_SCN_IDX_last];
     182                 :            : 
     183                 :            :   /* True if the file has a byte order different from the host.  */
     184                 :            :   bool other_byte_order;
     185                 :            : 
     186                 :            :   /* If true, we allocated the ELF descriptor ourselves.  */
     187                 :            :   bool free_elf;
     188                 :            : 
     189                 :            :   /* If >= 0, we allocated the alt_dwarf ourselves and must end it and
     190                 :            :      close this file descriptor.  */
     191                 :            :   int alt_fd;
     192                 :            : 
     193                 :            :   /* Information for traversing the .debug_pubnames section.  This is
     194                 :            :      an array and separately allocated with malloc.  */
     195                 :            :   struct pubnames_s
     196                 :            :   {
     197                 :            :     Dwarf_Off cu_offset;
     198                 :            :     Dwarf_Off set_start;
     199                 :            :     unsigned int cu_header_size;
     200                 :            :     int address_len;
     201                 :            :   } *pubnames_sets;
     202                 :            :   size_t pubnames_nsets;
     203                 :            : 
     204                 :            :   /* Search tree for the CUs.  */
     205                 :            :   void *cu_tree;
     206                 :            :   Dwarf_Off next_cu_offset;
     207                 :            : 
     208                 :            :   /* Search tree and sig8 hash table for .debug_types type units.  */
     209                 :            :   void *tu_tree;
     210                 :            :   Dwarf_Off next_tu_offset;
     211                 :            :   Dwarf_Sig8_Hash sig8_hash;
     212                 :            : 
     213                 :            :   /* Search tree for split Dwarf associated with CUs in this debug.  */
     214                 :            :   void *split_tree;
     215                 :            : 
     216                 :            :   /* Search tree for .debug_macro operator tables.  */
     217                 :            :   void *macro_ops;
     218                 :            : 
     219                 :            :   /* Search tree for decoded .debug_line units.  */
     220                 :            :   void *files_lines;
     221                 :            : 
     222                 :            :   /* Address ranges.  */
     223                 :            :   Dwarf_Aranges *aranges;
     224                 :            : 
     225                 :            :   /* Cached info from the CFI section.  */
     226                 :            :   struct Dwarf_CFI_s *cfi;
     227                 :            : 
     228                 :            :   /* Fake loc CU.  Used when synthesizing attributes for Dwarf_Ops that
     229                 :            :      came from a location list entry in dwarf_getlocation_attr.
     230                 :            :      Depending on version this is the .debug_loc or .debug_loclists
     231                 :            :      section (could be both if mixing CUs with different DWARF versions).  */
     232                 :            :   struct Dwarf_CU *fake_loc_cu;
     233                 :            :   struct Dwarf_CU *fake_loclists_cu;
     234                 :            : 
     235                 :            :   /* Similar for addrx/constx, which will come from .debug_addr section.  */
     236                 :            :   struct Dwarf_CU *fake_addr_cu;
     237                 :            : 
     238                 :            :   enum dwarf_type type;
     239                 :            : 
     240                 :            :   /* Supporting lock for internal memory handling.  Ensures threads that have
     241                 :            :      an entry in the mem_tails array are not disturbed by new threads doing
     242                 :            :      allocations for this Dwarf.  */
     243                 :            :   pthread_rwlock_t mem_rwl;
     244                 :            : 
     245                 :            :   /* Internal memory handling.  This is basically a simplified thread-local
     246                 :            :      reimplementation of obstacks.  Unfortunately the standard obstack
     247                 :            :      implementation is not usable in libraries.  */
     248                 :            :   size_t mem_stacks;
     249                 :            :   struct libdw_memblock
     250                 :            :   {
     251                 :            :     size_t size;
     252                 :            :     size_t remaining;
     253                 :            :     struct libdw_memblock *prev;
     254                 :            :     char mem[0];
     255                 :            :   } **mem_tails;
     256                 :            : 
     257                 :            :   /* Default size of allocated memory blocks.  */
     258                 :            :   size_t mem_default_size;
     259                 :            : 
     260                 :            :   /* Registered OOM handler.  */
     261                 :            :   Dwarf_OOM oom_handler;
     262                 :            : };
     263                 :            : 
     264                 :            : 
     265                 :            : /* Abbreviation representation.  */
     266                 :            : struct Dwarf_Abbrev
     267                 :            : {
     268                 :            :   Dwarf_Off offset;       /* Offset to start of abbrev into .debug_abbrev.  */
     269                 :            :   unsigned char *attrp;   /* Pointer to start of attribute name/form pairs. */
     270                 :            :   bool has_children : 1;  /* Whether or not the DIE has children. */
     271                 :            :   unsigned int code : 31; /* The (unique) abbrev code.  */
     272                 :            :   unsigned int tag;       /* The tag of the DIE. */
     273                 :            : } attribute_packed;
     274                 :            : 
     275                 :            : #include "dwarf_abbrev_hash.h"
     276                 :            : 
     277                 :            : 
     278                 :            : /* Files in line information records.  */
     279                 :            : struct Dwarf_Files_s
     280                 :            :   {
     281                 :            :     unsigned int ndirs;
     282                 :            :     unsigned int nfiles;
     283                 :            :     struct Dwarf_Fileinfo_s
     284                 :            :     {
     285                 :            :       char *name;
     286                 :            :       Dwarf_Word mtime;
     287                 :            :       Dwarf_Word length;
     288                 :            :     } info[0];
     289                 :            :     /* nfiles of those, followed by char *[ndirs].  */
     290                 :            :   };
     291                 :            : typedef struct Dwarf_Fileinfo_s Dwarf_Fileinfo;
     292                 :            : 
     293                 :            : 
     294                 :            : /* Representation of a row in the line table.  */
     295                 :            : 
     296                 :            : struct Dwarf_Line_s
     297                 :            : {
     298                 :            :   Dwarf_Files *files;
     299                 :            : 
     300                 :            :   Dwarf_Addr addr;
     301                 :            :   unsigned int file;
     302                 :            :   int line;
     303                 :            :   unsigned short int column;
     304                 :            :   unsigned int is_stmt:1;
     305                 :            :   unsigned int basic_block:1;
     306                 :            :   unsigned int end_sequence:1;
     307                 :            :   unsigned int prologue_end:1;
     308                 :            :   unsigned int epilogue_begin:1;
     309                 :            :   /* The remaining bit fields are not flags, but hold values presumed to be
     310                 :            :      small.  All the flags and other bit fields should add up to 48 bits
     311                 :            :      to give the whole struct a nice round size.  */
     312                 :            :   unsigned int op_index:8;
     313                 :            :   unsigned int isa:8;
     314                 :            :   unsigned int discriminator:24;
     315                 :            :   /* These are currently only used for the NVIDIA extensions.  */
     316                 :            :   unsigned int context;
     317                 :            :   unsigned int function_name;
     318                 :            : };
     319                 :            : 
     320                 :            : struct Dwarf_Lines_s
     321                 :            : {
     322                 :            :   size_t nlines;
     323                 :            :   struct Dwarf_Line_s info[0];
     324                 :            : };
     325                 :            : 
     326                 :            : /* Representation of address ranges.  */
     327                 :            : struct Dwarf_Aranges_s
     328                 :            : {
     329                 :            :   Dwarf *dbg;
     330                 :            :   size_t naranges;
     331                 :            : 
     332                 :            :   struct Dwarf_Arange_s
     333                 :            :   {
     334                 :            :     Dwarf_Addr addr;
     335                 :            :     Dwarf_Word length;
     336                 :            :     Dwarf_Off offset;
     337                 :            :   } info[0];
     338                 :            : };
     339                 :            : 
     340                 :            : 
     341                 :            : /* CU representation.  */
     342                 :            : struct Dwarf_CU
     343                 :            : {
     344                 :            :   Dwarf *dbg;
     345                 :            :   Dwarf_Off start;
     346                 :            :   Dwarf_Off end;
     347                 :            :   uint8_t address_size;
     348                 :            :   uint8_t offset_size;
     349                 :            :   uint16_t version;
     350                 :            : 
     351                 :            :   size_t sec_idx; /* Normally .debug_info, could be .debug_type or "fake". */
     352                 :            : 
     353                 :            :   /* The unit type if version >= 5.  Otherwise 0 for normal CUs (from
     354                 :            :      .debug_info) or 1 for v4 type units (from .debug_types).  */
     355                 :            :   uint8_t unit_type;
     356                 :            : 
     357                 :            :   /* Zero if the unit type doesn't support a die/type offset and/or id/sig.
     358                 :            :      Nonzero if it is a v4 type unit or for DWARFv5 units depending on
     359                 :            :      unit_type.  */
     360                 :            :   size_t subdie_offset;
     361                 :            :   uint64_t unit_id8;
     362                 :            : 
     363                 :            :   /* If this is a skeleton unit this points to the split compile unit.
     364                 :            :      Or the other way around if this is a split compile unit.  Set to -1
     365                 :            :      if not yet searched.  Always use __libdw_find_split_unit to access
     366                 :            :      this field.  */
     367                 :            :   struct Dwarf_CU *split;
     368                 :            : 
     369                 :            :   /* Hash table for the abbreviations.  */
     370                 :            :   Dwarf_Abbrev_Hash abbrev_hash;
     371                 :            :   /* Offset of the first abbreviation.  */
     372                 :            :   size_t orig_abbrev_offset;
     373                 :            :   /* Offset past last read abbreviation.  */
     374                 :            :   size_t last_abbrev_offset;
     375                 :            : 
     376                 :            :   /* The srcline information.  */
     377                 :            :   Dwarf_Lines *lines;
     378                 :            : 
     379                 :            :   /* The source file information.  */
     380                 :            :   Dwarf_Files *files;
     381                 :            : 
     382                 :            :   /* Known location lists.  */
     383                 :            :   void *locs;
     384                 :            : 
     385                 :            :   /* Base address for use with ranges and locs.
     386                 :            :      Don't access directly, call __libdw_cu_base_address.  */
     387                 :            :   Dwarf_Addr base_address;
     388                 :            : 
     389                 :            :   /* The offset into the .debug_addr section where index zero begins.
     390                 :            :      Don't access directly, call __libdw_cu_addr_base.  */
     391                 :            :   Dwarf_Off addr_base;
     392                 :            : 
     393                 :            :   /* The offset into the .debug_str_offsets section where index zero begins.
     394                 :            :      Don't access directly, call __libdw_cu_str_off_base.  */
     395                 :            :   Dwarf_Off str_off_base;
     396                 :            : 
     397                 :            :   /* The offset into the .debug_ranges section to use for GNU
     398                 :            :      DebugFission split units.  Don't access directly, call
     399                 :            :      __libdw_cu_ranges_base.  */
     400                 :            :   Dwarf_Off ranges_base;
     401                 :            : 
     402                 :            :   /* The start of the offset table in .debug_loclists.
     403                 :            :      Don't access directly, call __libdw_cu_locs_base.  */
     404                 :            :   Dwarf_Off locs_base;
     405                 :            : 
     406                 :            :   /* Memory boundaries of this CU.  */
     407                 :            :   void *startp;
     408                 :            :   void *endp;
     409                 :            : };
     410                 :            : 
     411                 :            : #define ISV4TU(cu) ((cu)->version == 4 && (cu)->sec_idx == IDX_debug_types)
     412                 :            : 
     413                 :            : /* Compute the offset of a CU's first DIE from the CU offset.
     414                 :            :    CU must be a valid/known version/unit_type.  */
     415                 :            : static inline Dwarf_Off
     416                 :    3093876 : __libdw_first_die_from_cu_start (Dwarf_Off cu_start,
     417                 :            :                                  uint8_t offset_size,
     418                 :            :                                  uint16_t version,
     419                 :            :                                  uint8_t unit_type)
     420                 :            : {
     421                 :            : /*
     422                 :            :   assert (offset_size == 4 || offset_size == 8);
     423                 :            :   assert (version >= 2 && version <= 5);
     424                 :            :   assert (unit_type == DW_UT_compile
     425                 :            :           || unit_type == DW_UT_partial
     426                 :            :           || unit_type == DW_UT_skeleton
     427                 :            :           || unit_type == DW_UT_split_compile
     428                 :            :           || unit_type == DW_UT_type
     429                 :            :           || unit_type == DW_UT_split_type);
     430                 :            : */
     431                 :            : 
     432                 :    3093876 :   Dwarf_Off off = cu_start;
     433         [ +  + ]:    3093876 :   if (version < 5)
     434                 :            :     {
     435                 :            :    /*
     436                 :            :         LEN       VER     OFFSET    ADDR
     437                 :            :       4-bytes + 2-bytes + 4-bytes + 1-byte  for 32-bit dwarf
     438                 :            :      12-bytes + 2-bytes + 8-bytes + 1-byte  for 64-bit dwarf
     439                 :            :    or in .debug_types,                       SIGNATURE TYPE-OFFSET
     440                 :            :       4-bytes + 2-bytes + 4-bytes + 1-byte + 8-bytes + 4-bytes  for 32-bit
     441                 :            :      12-bytes + 2-bytes + 8-bytes + 1-byte + 8-bytes + 8-bytes  for 64-bit
     442                 :            : 
     443                 :            :    Note the trick in the computation.  If the offset_size is 4
     444                 :            :    the '- 4' term changes the '3 *' (or '4 *') into a '2 *' (or '3 *).
     445                 :            :    If the offset_size is 8 it accounts for the 4-byte escape value
     446                 :            :    used at the start of the length.  */
     447         [ +  + ]:    3093003 :       if (unit_type != DW_UT_type)
     448                 :    3092952 :         off += 3 * offset_size - 4 + 3;
     449                 :            :       else
     450                 :         51 :         off += 4 * offset_size - 4 + 3 + 8;
     451                 :            :     }
     452                 :            :   else
     453                 :            :     {
     454                 :            :      /*
     455                 :            :         LEN       VER      TYPE     ADDR     OFFSET   SIGNATURE  TYPE-OFFSET
     456                 :            :       4-bytes + 2-bytes + 1-byte + 1-byte + 4-bytes + 8-bytes + 4-bytes 32-bit
     457                 :            :      12-bytes + 2-bytes + 1-byte + 1-byte + 8-bytes + 8-bytes + 8-bytes 64-bit
     458                 :            :         Both signature and type offset are optional.
     459                 :            : 
     460                 :            :         Note same 4/8 offset size trick as above.
     461                 :            :         We explicitly ignore unknown unit types (see asserts above).  */
     462                 :        873 :       off += 3 * offset_size - 4 + 4;
     463                 :        873 :       if (unit_type == DW_UT_skeleton || unit_type == DW_UT_split_compile
     464   [ +  +  -  + ]:        873 :           || unit_type == DW_UT_type || unit_type == DW_UT_split_type)
     465                 :            :         {
     466                 :        601 :           off += 8;
     467         [ -  + ]:        601 :           if (unit_type == DW_UT_type || unit_type == DW_UT_split_type)
     468                 :          0 :             off += offset_size;
     469                 :            :         }
     470                 :            :     }
     471                 :            : 
     472                 :    3093876 :   return off;
     473                 :            : }
     474                 :            : 
     475                 :            : static inline Dwarf_Off
     476                 :    3055618 : __libdw_first_die_off_from_cu (struct Dwarf_CU *cu)
     477                 :            : {
     478                 :    3055618 :   return __libdw_first_die_from_cu_start (cu->start,
     479                 :    3055618 :                                           cu->offset_size,
     480                 :    3055618 :                                           cu->version,
     481                 :    3055618 :                                           cu->unit_type);
     482                 :            : }
     483                 :            : 
     484                 :            : #define CUDIE(fromcu)                                                         \
     485                 :            :   ((Dwarf_Die)                                                                \
     486                 :            :    {                                                                          \
     487                 :            :      .cu = (fromcu),                                                          \
     488                 :            :      .addr = ((char *) (fromcu)->dbg->sectiondata[cu_sec_idx (fromcu)]->d_buf \
     489                 :            :               + __libdw_first_die_off_from_cu (fromcu))                       \
     490                 :            :    })
     491                 :            : 
     492                 :            : #define SUBDIE(fromcu)                                                        \
     493                 :            :   ((Dwarf_Die)                                                                \
     494                 :            :    {                                                                          \
     495                 :            :      .cu = (fromcu),                                                          \
     496                 :            :      .addr = ((char *) (fromcu)->dbg->sectiondata[cu_sec_idx (fromcu)]->d_buf \
     497                 :            :               + (fromcu)->start + (fromcu)->subdie_offset)                      \
     498                 :            :    })
     499                 :            : 
     500                 :            : 
     501                 :            : /* Prototype of a single .debug_macro operator.  */
     502                 :            : typedef struct
     503                 :            : {
     504                 :            :   Dwarf_Word nforms;
     505                 :            :   unsigned char const *forms;
     506                 :            : } Dwarf_Macro_Op_Proto;
     507                 :            : 
     508                 :            : /* Prototype table.  */
     509                 :            : typedef struct
     510                 :            : {
     511                 :            :   /* Offset of .debug_macro section.  */
     512                 :            :   Dwarf_Off offset;
     513                 :            : 
     514                 :            :   /* Offset of associated .debug_line section.  */
     515                 :            :   Dwarf_Off line_offset;
     516                 :            : 
     517                 :            :   /* The source file information.  */
     518                 :            :   Dwarf_Files *files;
     519                 :            : 
     520                 :            :   /* If this macro unit was opened through dwarf_getmacros or
     521                 :            :      dwarf_getmacros_die, this caches value of DW_AT_comp_dir, if
     522                 :            :      present.  */
     523                 :            :   const char *comp_dir;
     524                 :            : 
     525                 :            :   /* Header length.  */
     526                 :            :   Dwarf_Half header_len;
     527                 :            : 
     528                 :            :   uint16_t version;
     529                 :            :   bool is_64bit;
     530                 :            :   uint8_t sec_index;    /* IDX_debug_macro or IDX_debug_macinfo.  */
     531                 :            : 
     532                 :            :   /* Shows where in TABLE each opcode is defined.  Since opcode 0 is
     533                 :            :      never used, it stores index of opcode X in X-1'th element.  The
     534                 :            :      value of 0xff means not stored at all.  */
     535                 :            :   unsigned char opcodes[255];
     536                 :            : 
     537                 :            :   /* Individual opcode prototypes.  */
     538                 :            :   Dwarf_Macro_Op_Proto table[];
     539                 :            : } Dwarf_Macro_Op_Table;
     540                 :            : 
     541                 :            : struct Dwarf_Macro_s
     542                 :            : {
     543                 :            :   Dwarf_Macro_Op_Table *table;
     544                 :            :   Dwarf_Attribute *attributes;
     545                 :            :   uint8_t opcode;
     546                 :            : };
     547                 :            : 
     548                 :            : static inline Dwarf_Word
     549                 :        648 : libdw_macro_nforms (Dwarf_Macro *macro)
     550                 :            : {
     551         [ +  - ]:        648 :   return macro->table->table[macro->table->opcodes[macro->opcode - 1]].nforms;
     552                 :            : }
     553                 :            : 
     554                 :            : /* Returns true for any allowed FORM in the opcode_operands_table as
     555                 :            :    mentioned in the DWARF5 spec (6.3.1 Macro Information Header).
     556                 :            :    Or those mentioned in DWARF5 spec (6.2.4.2 Vendor-defined Content
     557                 :            :    Descriptions) for the directory/file table (plus DW_FORM_strp_sup).  */
     558                 :            : static inline bool
     559                 :       1397 : libdw_valid_user_form (int form)
     560                 :            : {
     561         [ -  + ]:       1397 :   switch (form)
     562                 :            :     {
     563                 :            :       case DW_FORM_block:
     564                 :            :       case DW_FORM_block1:
     565                 :            :       case DW_FORM_block2:
     566                 :            :       case DW_FORM_block4:
     567                 :            :       case DW_FORM_data1:
     568                 :            :       case DW_FORM_data2:
     569                 :            :       case DW_FORM_data4:
     570                 :            :       case DW_FORM_data8:
     571                 :            :       case DW_FORM_data16:
     572                 :            :       case DW_FORM_flag:
     573                 :            :       case DW_FORM_line_strp:
     574                 :            :       case DW_FORM_sdata:
     575                 :            :       case DW_FORM_sec_offset:
     576                 :            :       case DW_FORM_string:
     577                 :            :       case DW_FORM_strp:
     578                 :            :       case DW_FORM_strp_sup:
     579                 :            :       case DW_FORM_strx:
     580                 :            :       case DW_FORM_strx1:
     581                 :            :       case DW_FORM_strx2:
     582                 :            :       case DW_FORM_strx3:
     583                 :            :       case DW_FORM_strx4:
     584                 :            :       case DW_FORM_udata:
     585                 :            :         return true;
     586                 :          0 :       default:
     587                 :          0 :         return false;
     588                 :            :     }
     589                 :            : }
     590                 :            : 
     591                 :            : 
     592                 :            : /* We have to include the file at this point because the inline
     593                 :            :    functions access internals of the Dwarf structure.  */
     594                 :            : #include "memory-access.h"
     595                 :            : 
     596                 :            : 
     597                 :            : /* Set error value.  */
     598                 :            : extern void __libdw_seterrno (int value) internal_function;
     599                 :            : 
     600                 :            : 
     601                 :            : /* Memory handling, the easy parts.  */
     602                 :            : #define libdw_alloc(dbg, type, tsize, cnt) \
     603                 :            :   ({ struct libdw_memblock *_tail = __libdw_alloc_tail(dbg);                  \
     604                 :            :      size_t _required = (tsize) * (cnt);                                      \
     605                 :            :      type *_result = (type *) (_tail->mem + (_tail->size - _tail->remaining));\
     606                 :            :      size_t _padding = ((__alignof (type)                                     \
     607                 :            :                          - ((uintptr_t) _result & (__alignof (type) - 1)))    \
     608                 :            :                         & (__alignof (type) - 1));                        \
     609                 :            :      if (unlikely (_tail->remaining < _required + _padding))                    \
     610                 :            :        _result = (type *) __libdw_allocate (dbg, _required, __alignof (type));\
     611                 :            :      else                                                                     \
     612                 :            :        {                                                                      \
     613                 :            :          _required += _padding;                                               \
     614                 :            :          _result = (type *) ((char *) _result + _padding);                    \
     615                 :            :          _tail->remaining -= _required;                                            \
     616                 :            :        }                                                                      \
     617                 :            :      _result; })
     618                 :            : 
     619                 :            : #define libdw_typed_alloc(dbg, type) \
     620                 :            :   libdw_alloc (dbg, type, sizeof (type), 1)
     621                 :            : 
     622                 :            : /* Can only be used to undo the last libdw_alloc.  */
     623                 :            : #define libdw_unalloc(dbg, type, tsize, cnt) \
     624                 :            :   ({ struct libdw_memblock *_tail = __libdw_thread_tail (dbg);                \
     625                 :            :      size_t _required = (tsize) * (cnt);                                      \
     626                 :            :      /* We cannot know the padding, it is lost.  */                           \
     627                 :            :      _tail->remaining += _required; })                                             \
     628                 :            : 
     629                 :            : #define libdw_typed_unalloc(dbg, type) \
     630                 :            :   libdw_unalloc (dbg, type, sizeof (type), 1)
     631                 :            : 
     632                 :            : /* Callback to choose a thread-local memory allocation stack.  */
     633                 :            : extern struct libdw_memblock *__libdw_alloc_tail (Dwarf* dbg)
     634                 :            :      __nonnull_attribute__ (1);
     635                 :            : 
     636                 :            : extern struct libdw_memblock *__libdw_thread_tail (Dwarf* dbg)
     637                 :            :      __nonnull_attribute__ (1);
     638                 :            : 
     639                 :            : /* Callback to allocate more.  */
     640                 :            : extern void *__libdw_allocate (Dwarf *dbg, size_t minsize, size_t align)
     641                 :            :      __attribute__ ((__malloc__)) __nonnull_attribute__ (1);
     642                 :            : 
     643                 :            : /* Default OOM handler.  */
     644                 :            : extern void __libdw_oom (void) __attribute ((noreturn)) attribute_hidden;
     645                 :            : 
     646                 :            : /* Read next unit (or v4 debug type) and return next offset.  Doesn't
     647                 :            :    create an actual Dwarf_CU just provides necessary header fields.  */
     648                 :            : extern int
     649                 :            : internal_function
     650                 :            : __libdw_next_unit (Dwarf *dbg, bool v4_debug_types, Dwarf_Off off,
     651                 :            :                    Dwarf_Off *next_off, size_t *header_sizep,
     652                 :            :                    Dwarf_Half *versionp, uint8_t *unit_typep,
     653                 :            :                    Dwarf_Off *abbrev_offsetp, uint8_t *address_sizep,
     654                 :            :                    uint8_t *offset_sizep, uint64_t *unit_id8p,
     655                 :            :                    Dwarf_Off *subdie_offsetp)
     656                 :            :      __nonnull_attribute__ (4) internal_function;
     657                 :            : 
     658                 :            : /* Allocate the internal data for a unit not seen before.  */
     659                 :            : extern struct Dwarf_CU *__libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
     660                 :            :      __nonnull_attribute__ (1) internal_function;
     661                 :            : 
     662                 :            : /* Find CU for given offset.  */
     663                 :            : extern struct Dwarf_CU *__libdw_findcu (Dwarf *dbg, Dwarf_Off offset, bool tu)
     664                 :            :      __nonnull_attribute__ (1) internal_function;
     665                 :            : 
     666                 :            : /* Find CU for given DIE address.  */
     667                 :            : extern struct Dwarf_CU *__libdw_findcu_addr (Dwarf *dbg, void *addr)
     668                 :            :      __nonnull_attribute__ (1) internal_function;
     669                 :            : 
     670                 :            : /* Find split Dwarf for given DIE address.  */
     671                 :            : extern struct Dwarf *__libdw_find_split_dbg_addr (Dwarf *dbg, void *addr)
     672                 :            :      __nonnull_attribute__ (1) internal_function;
     673                 :            : 
     674                 :            : /* Find the split (or skeleton) unit.  */
     675                 :            : extern struct Dwarf_CU *__libdw_find_split_unit (Dwarf_CU *cu)
     676                 :            :      internal_function;
     677                 :            : 
     678                 :            : /* Get abbreviation with given code.  */
     679                 :            : extern Dwarf_Abbrev *__libdw_findabbrev (struct Dwarf_CU *cu,
     680                 :            :                                          unsigned int code)
     681                 :            :      __nonnull_attribute__ (1) internal_function;
     682                 :            : 
     683                 :            : /* Get abbreviation at given offset.  */
     684                 :            : extern Dwarf_Abbrev *__libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu,
     685                 :            :                                         Dwarf_Off offset, size_t *lengthp,
     686                 :            :                                         Dwarf_Abbrev *result)
     687                 :            :      __nonnull_attribute__ (1) internal_function;
     688                 :            : 
     689                 :            : /* Get abbreviation of given DIE, and optionally set *READP to the DIE memory
     690                 :            :    just past the abbreviation code.  */
     691                 :            : static inline Dwarf_Abbrev *
     692                 :            : __nonnull_attribute__ (1)
     693                 :   62944147 : __libdw_dieabbrev (Dwarf_Die *die, const unsigned char **readp)
     694                 :            : {
     695                 :            :   /* Do we need to get the abbreviation, or need to read after the code?  */
     696   [ +  +  +  + ]:   62944147 :   if (die->abbrev == NULL || readp != NULL)
     697                 :            :     {
     698                 :            :       /* Get the abbreviation code.  */
     699                 :   33923722 :       unsigned int code;
     700                 :   33923722 :       const unsigned char *addr = die->addr;
     701   [ +  +  -  + ]:   33923722 :       if (unlikely (die->cu == NULL
     702                 :            :                     || addr >= (const unsigned char *) die->cu->endp))
     703                 :      11288 :         return die->abbrev = DWARF_END_ABBREV;
     704                 :   33912434 :       get_uleb128 (code, addr, die->cu->endp);
     705         [ +  + ]:   33912434 :       if (readp != NULL)
     706                 :   22314933 :         *readp = addr;
     707                 :            : 
     708                 :            :       /* Find the abbreviation.  */
     709         [ +  + ]:   33912434 :       if (die->abbrev == NULL)
     710                 :   15271104 :         die->abbrev = __libdw_findabbrev (die->cu, code);
     711                 :            :     }
     712                 :   62932859 :   return die->abbrev;
     713                 :            : }
     714                 :            : 
     715                 :            : /* Helper functions for form handling.  */
     716                 :            : extern size_t __libdw_form_val_compute_len (struct Dwarf_CU *cu,
     717                 :            :                                             unsigned int form,
     718                 :            :                                             const unsigned char *valp)
     719                 :            :      __nonnull_attribute__ (1, 3) internal_function;
     720                 :            : 
     721                 :            : /* Find the length of a form attribute in DIE/info data.  */
     722                 :            : static inline size_t
     723                 :            : __nonnull_attribute__ (1, 3)
     724                 :   88226479 : __libdw_form_val_len (struct Dwarf_CU *cu, unsigned int form,
     725                 :            :                       const unsigned char *valp)
     726                 :            : {
     727                 :            :   /* Small lookup table of forms with fixed lengths.  Absent indexes are
     728                 :            :      initialized 0, so any truly desired 0 is set to 0x80 and masked.  */
     729                 :   88226479 :   static const uint8_t form_lengths[] =
     730                 :            :     {
     731                 :            :       [DW_FORM_flag_present] = 0x80,
     732                 :            :       [DW_FORM_implicit_const] = 0x80, /* Value is in abbrev, not in info.  */
     733                 :            : 
     734                 :            :       [DW_FORM_flag] = 1,
     735                 :            :       [DW_FORM_data1] = 1, [DW_FORM_ref1] = 1,
     736                 :            :       [DW_FORM_addrx1] = 1, [DW_FORM_strx1] = 1,
     737                 :            : 
     738                 :            :       [DW_FORM_data2] = 2, [DW_FORM_ref2] = 2,
     739                 :            :       [DW_FORM_addrx2] = 2, [DW_FORM_strx2] = 2,
     740                 :            : 
     741                 :            :       [DW_FORM_addrx3] = 3, [DW_FORM_strx3] = 3,
     742                 :            : 
     743                 :            :       [DW_FORM_data4] = 4, [DW_FORM_ref4] = 4, [DW_FORM_ref_sup4] = 4,
     744                 :            :       [DW_FORM_addrx4] = 4, [DW_FORM_strx4] = 4,
     745                 :            : 
     746                 :            :       [DW_FORM_ref_sig8] = 8,
     747                 :            :       [DW_FORM_data8] = 8, [DW_FORM_ref8] = 8, [DW_FORM_ref_sup8] = 8,
     748                 :            : 
     749                 :            :       [DW_FORM_data16] = 16,
     750                 :            :     };
     751                 :            : 
     752                 :            :   /* Return immediately for forms with fixed lengths.  */
     753         [ +  + ]:   88226479 :   if (form < sizeof form_lengths / sizeof form_lengths[0])
     754                 :            :     {
     755                 :   88223845 :       uint8_t len = form_lengths[form];
     756         [ +  + ]:   88223845 :       if (len != 0)
     757                 :            :         {
     758                 :   63176081 :           const unsigned char *endp = cu->endp;
     759                 :   63176081 :           len &= 0x7f; /* Mask to allow 0x80 -> 0.  */
     760         [ -  + ]:   63176081 :           if (unlikely (len > (size_t) (endp - valp)))
     761                 :            :             {
     762                 :          0 :               __libdw_seterrno (DWARF_E_INVALID_DWARF);
     763                 :          0 :               return -1;
     764                 :            :             }
     765                 :            :           return len;
     766                 :            :         }
     767                 :            :     }
     768                 :            : 
     769                 :            :   /* Other forms require some computation.  */
     770                 :   25050398 :   return __libdw_form_val_compute_len (cu, form, valp);
     771                 :            : }
     772                 :            : 
     773                 :            : /* Helper function for DW_FORM_ref* handling.  */
     774                 :            : extern int __libdw_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
     775                 :            :      __nonnull_attribute__ (1, 2) internal_function;
     776                 :            : 
     777                 :            : 
     778                 :            : /* Helper function to locate attribute.  */
     779                 :            : extern unsigned char *__libdw_find_attr (Dwarf_Die *die,
     780                 :            :                                          unsigned int search_name,
     781                 :            :                                          unsigned int *codep,
     782                 :            :                                          unsigned int *formp)
     783                 :            :      __nonnull_attribute__ (1) internal_function;
     784                 :            : 
     785                 :            : /* Helper function to access integer attribute.  */
     786                 :            : extern int __libdw_attr_intval (Dwarf_Die *die, int *valp, int attval)
     787                 :            :      __nonnull_attribute__ (1, 2) internal_function;
     788                 :            : 
     789                 :            : /* Helper function to walk scopes.  */
     790                 :            : struct Dwarf_Die_Chain
     791                 :            : {
     792                 :            :   Dwarf_Die die;
     793                 :            :   struct Dwarf_Die_Chain *parent;
     794                 :            :   bool prune;                   /* The PREVISIT function can set this.  */
     795                 :            : };
     796                 :            : extern int __libdw_visit_scopes (unsigned int depth,
     797                 :            :                                  struct Dwarf_Die_Chain *root,
     798                 :            :                                  struct Dwarf_Die_Chain *imports,
     799                 :            :                                  int (*previsit) (unsigned int depth,
     800                 :            :                                                   struct Dwarf_Die_Chain *,
     801                 :            :                                                   void *arg),
     802                 :            :                                  int (*postvisit) (unsigned int depth,
     803                 :            :                                                    struct Dwarf_Die_Chain *,
     804                 :            :                                                    void *arg),
     805                 :            :                                  void *arg)
     806                 :            :   __nonnull_attribute__ (2, 4) internal_function;
     807                 :            : 
     808                 :            : /* Parse a DWARF Dwarf_Block into an array of Dwarf_Op's,
     809                 :            :    and cache the result (via tsearch).  */
     810                 :            : extern int __libdw_intern_expression (Dwarf *dbg,
     811                 :            :                                       bool other_byte_order,
     812                 :            :                                       unsigned int address_size,
     813                 :            :                                       unsigned int ref_size,
     814                 :            :                                       void **cache, const Dwarf_Block *block,
     815                 :            :                                       bool cfap, bool valuep,
     816                 :            :                                       Dwarf_Op **llbuf, size_t *listlen,
     817                 :            :                                       int sec_index)
     818                 :            :   __nonnull_attribute__ (5, 6, 9, 10) internal_function;
     819                 :            : 
     820                 :            : extern Dwarf_Die *__libdw_offdie (Dwarf *dbg, Dwarf_Off offset,
     821                 :            :                                   Dwarf_Die *result, bool debug_types)
     822                 :            :   internal_function;
     823                 :            : 
     824                 :            : 
     825                 :            : /* Return error code of last failing function call.  This value is kept
     826                 :            :    separately for each thread.  */
     827                 :            : extern int __dwarf_errno_internal (void);
     828                 :            : 
     829                 :            : 
     830                 :            : /* Reader hooks.  */
     831                 :            : 
     832                 :            : /* Relocation hooks return -1 on error (in that case the error code
     833                 :            :    must already have been set), 0 if there is no relocation and 1 if a
     834                 :            :    relocation was present.*/
     835                 :            : 
     836                 :            : static inline int
     837                 :    3834954 : __libdw_relocate_address (Dwarf *dbg __attribute__ ((unused)),
     838                 :            :                           int sec_index __attribute__ ((unused)),
     839                 :            :                           const void *addr __attribute__ ((unused)),
     840                 :            :                           int width __attribute__ ((unused)),
     841                 :            :                           Dwarf_Addr *val __attribute__ ((unused)))
     842                 :            : {
     843         [ +  + ]:    3834923 :   return 0;
     844                 :            : }
     845                 :            : 
     846                 :            : static inline int
     847                 :    1593117 : __libdw_relocate_offset (Dwarf *dbg __attribute__ ((unused)),
     848                 :            :                          int sec_index __attribute__ ((unused)),
     849                 :            :                          const void *addr __attribute__ ((unused)),
     850                 :            :                          int width __attribute__ ((unused)),
     851                 :            :                          Dwarf_Off *val __attribute__ ((unused)))
     852                 :            : {
     853                 :    1593117 :   return 0;
     854                 :            : }
     855                 :            : 
     856                 :            : static inline Elf_Data *
     857                 :    7364454 : __libdw_checked_get_data (Dwarf *dbg, int sec_index)
     858                 :            : {
     859                 :    7364454 :   Elf_Data *data = dbg->sectiondata[sec_index];
     860         [ +  - ]:    7364454 :   if (unlikely (data == NULL)
     861         [ -  + ]:    7364454 :       || unlikely (data->d_buf == NULL))
     862                 :            :     {
     863                 :          0 :       __libdw_seterrno (DWARF_E_INVALID_DWARF);
     864                 :          0 :       return NULL;
     865                 :            :     }
     866                 :            :   return data;
     867                 :            : }
     868                 :            : 
     869                 :            : static inline int
     870                 :    1602076 : __libdw_offset_in_section (Dwarf *dbg, int sec_index,
     871                 :            :                            Dwarf_Off offset, size_t size)
     872                 :            : {
     873                 :    1602076 :   Elf_Data *data = __libdw_checked_get_data (dbg, sec_index);
     874         [ +  - ]:    1602076 :   if (data == NULL)
     875                 :            :     return -1;
     876         [ +  - ]:    1602076 :   if (unlikely (offset > data->d_size)
     877         [ +  - ]:    1602076 :       || unlikely (data->d_size < size)
     878         [ -  + ]:    1602076 :       || unlikely (offset > data->d_size - size))
     879                 :            :     {
     880                 :          0 :       __libdw_seterrno (DWARF_E_INVALID_OFFSET);
     881                 :          0 :       return -1;
     882                 :            :     }
     883                 :            : 
     884                 :            :   return 0;
     885                 :            : }
     886                 :            : 
     887                 :            : static inline bool
     888                 :    5753473 : __libdw_in_section (Dwarf *dbg, int sec_index,
     889                 :            :                     const void *addr, size_t size)
     890                 :            : {
     891                 :    5753473 :   Elf_Data *data = __libdw_checked_get_data (dbg, sec_index);
     892         [ +  - ]:    5753473 :   if (data == NULL)
     893                 :            :     return false;
     894         [ +  - ]:    5753473 :   if (unlikely (addr < data->d_buf)
     895         [ +  - ]:    5753473 :       || unlikely (data->d_size < size)
     896         [ -  + ]:    5753473 :       || unlikely ((size_t)(addr - data->d_buf) > data->d_size - size))
     897                 :            :     {
     898                 :          0 :       __libdw_seterrno (DWARF_E_INVALID_OFFSET);
     899                 :          0 :       return false;
     900                 :            :     }
     901                 :            : 
     902                 :            :   return true;
     903                 :            : }
     904                 :            : 
     905                 :            : #define READ_AND_RELOCATE(RELOC_HOOK, VAL)                              \
     906                 :            :   ({                                                                    \
     907                 :            :     if (!__libdw_in_section (dbg, sec_index, addr, width))              \
     908                 :            :       return -1;                                                        \
     909                 :            :                                                                         \
     910                 :            :     const unsigned char *orig_addr = addr;                              \
     911                 :            :     if (width == 4)                                                     \
     912                 :            :       VAL = read_4ubyte_unaligned_inc (dbg, addr);                      \
     913                 :            :     else                                                                \
     914                 :            :       VAL = read_8ubyte_unaligned_inc (dbg, addr);                      \
     915                 :            :                                                                         \
     916                 :            :     int status = RELOC_HOOK (dbg, sec_index, orig_addr, width, &VAL);       \
     917                 :            :     if (status < 0)                                                  \
     918                 :            :       return status;                                                    \
     919                 :            :     status > 0;                                                              \
     920                 :            :    })
     921                 :            : 
     922                 :            : static inline int
     923                 :      24624 : __libdw_read_address_inc (Dwarf *dbg,
     924                 :            :                           int sec_index, const unsigned char **addrp,
     925                 :            :                           int width, Dwarf_Addr *ret)
     926                 :            : {
     927                 :      24624 :   const unsigned char *addr = *addrp;
     928   [ +  -  +  +  :      24624 :   READ_AND_RELOCATE (__libdw_relocate_address, (*ret));
             +  +  +  + ]
     929                 :      24624 :   *addrp = addr;
     930                 :      24624 :   return 0;
     931                 :            : }
     932                 :            : 
     933                 :            : static inline int
     934                 :     325402 : __libdw_read_address (Dwarf *dbg,
     935                 :            :                       int sec_index, const unsigned char *addr,
     936                 :            :                       int width, Dwarf_Addr *ret)
     937                 :            : {
     938   [ +  -  +  +  :     325402 :   READ_AND_RELOCATE (__libdw_relocate_address, (*ret));
             +  +  +  + ]
     939                 :            :   return 0;
     940                 :            : }
     941                 :            : 
     942                 :            : static inline int
     943                 :      42512 : __libdw_read_offset_inc (Dwarf *dbg,
     944                 :            :                          int sec_index, const unsigned char **addrp,
     945                 :            :                          int width, Dwarf_Off *ret, int sec_ret,
     946                 :            :                          size_t size)
     947                 :            : {
     948                 :      42512 :   const unsigned char *addr = *addrp;
     949   [ +  -  +  -  :      42512 :   READ_AND_RELOCATE (__libdw_relocate_offset, (*ret));
             +  +  -  - ]
     950                 :      42512 :   *addrp = addr;
     951                 :      42512 :   return __libdw_offset_in_section (dbg, sec_ret, *ret, size);
     952                 :            : }
     953                 :            : 
     954                 :            : static inline int
     955                 :    1550605 : __libdw_read_offset (Dwarf *dbg, Dwarf *dbg_ret,
     956                 :            :                      int sec_index, const unsigned char *addr,
     957                 :            :                      int width, Dwarf_Off *ret, int sec_ret,
     958                 :            :                      size_t size)
     959                 :            : {
     960   [ +  -  +  -  :    1550605 :   READ_AND_RELOCATE (__libdw_relocate_offset, (*ret));
             +  +  -  - ]
     961                 :    1550605 :   return __libdw_offset_in_section (dbg_ret, sec_ret, *ret, size);
     962                 :            : }
     963                 :            : 
     964                 :            : static inline size_t
     965                 :    4855944 : cu_sec_idx (struct Dwarf_CU *cu)
     966                 :            : {
     967         [ +  + ]:    4055802 :   return cu->sec_idx;
     968                 :            : }
     969                 :            : 
     970                 :            : static inline bool
     971                 :    2229236 : is_cudie (Dwarf_Die *cudie)
     972                 :            : {
     973   [ +  +  +  + ]:    2229236 :   return cudie->cu != NULL && CUDIE (cudie->cu).addr == cudie->addr;
     974                 :            : }
     975                 :            : 
     976                 :            : /* Read up begin/end pair and increment read pointer.
     977                 :            :     - If it's normal range record, set up *BEGINP and *ENDP and return 0.
     978                 :            :     - If it's base address selection record, set up *BASEP and return 1.
     979                 :            :     - If it's end of rangelist, don't set anything and return 2
     980                 :            :     - If an error occurs, don't set anything and return <0.  */
     981                 :            : int __libdw_read_begin_end_pair_inc (Dwarf_CU *cu, int sec_index,
     982                 :            :                                      const unsigned char **readp,
     983                 :            :                                      const unsigned char *readend,
     984                 :            :                                      int width,
     985                 :            :                                      Dwarf_Addr *beginp, Dwarf_Addr *endp,
     986                 :            :                                      Dwarf_Addr *basep)
     987                 :            :   internal_function;
     988                 :            : 
     989                 :            : const unsigned char * __libdw_formptr (Dwarf_Attribute *attr, int sec_index,
     990                 :            :                                        int err_nodata,
     991                 :            :                                        const unsigned char **endpp,
     992                 :            :                                        Dwarf_Off *offsetp)
     993                 :            :   internal_function;
     994                 :            : 
     995                 :            : /* Fills in the given attribute to point at an empty location expression.  */
     996                 :            : void __libdw_empty_loc_attr (Dwarf_Attribute *attr)
     997                 :            :   internal_function;
     998                 :            : 
     999                 :            : /* Load .debug_line unit at DEBUG_LINE_OFFSET.  COMP_DIR is a value of
    1000                 :            :    DW_AT_comp_dir or NULL if that attribute is not available.  Caches
    1001                 :            :    the loaded unit and optionally set *LINESP and/or *FILESP (if not
    1002                 :            :    NULL) with loaded information.  Returns 0 for success or a negative
    1003                 :            :    value for failure.  */
    1004                 :            : int __libdw_getsrclines (Dwarf *dbg, Dwarf_Off debug_line_offset,
    1005                 :            :                          const char *comp_dir, unsigned address_size,
    1006                 :            :                          Dwarf_Lines **linesp, Dwarf_Files **filesp)
    1007                 :            :   internal_function
    1008                 :            :   __nonnull_attribute__ (1);
    1009                 :            : 
    1010                 :            : /* Load and return value of DW_AT_comp_dir from CUDIE.  */
    1011                 :            : const char *__libdw_getcompdir (Dwarf_Die *cudie);
    1012                 :            : 
    1013                 :            : /* Get the base address for the CU, fetches it when not yet set.
    1014                 :            :    This is used as initial base address for ranges and loclists.  */
    1015                 :            : Dwarf_Addr __libdw_cu_base_address (Dwarf_CU *cu);
    1016                 :            : 
    1017                 :            : /* Get the address base for the CU, fetches it when not yet set.  */
    1018                 :            : static inline Dwarf_Off
    1019                 :        635 : __libdw_cu_addr_base (Dwarf_CU *cu)
    1020                 :            : {
    1021         [ +  + ]:        635 :   if (cu->addr_base == (Dwarf_Off) -1)
    1022                 :            :     {
    1023                 :         50 :       Dwarf_Die cu_die = CUDIE(cu);
    1024                 :         50 :       Dwarf_Attribute attr;
    1025                 :         50 :       Dwarf_Off offset = 0;
    1026         [ +  + ]:         50 :       if (dwarf_attr (&cu_die, DW_AT_GNU_addr_base, &attr) != NULL
    1027         [ +  - ]:         24 :           || dwarf_attr (&cu_die, DW_AT_addr_base, &attr) != NULL)
    1028                 :            :         {
    1029                 :         50 :           Dwarf_Word off;
    1030         [ +  - ]:         50 :           if (dwarf_formudata (&attr, &off) == 0)
    1031                 :         50 :             offset = off;
    1032                 :            :         }
    1033                 :         50 :       cu->addr_base = offset;
    1034                 :            :     }
    1035                 :            : 
    1036                 :        635 :   return cu->addr_base;
    1037                 :            : }
    1038                 :            : 
    1039                 :            : /* Gets the .debug_str_offsets base offset to use.  static inline to
    1040                 :            :    be shared between libdw and eu-readelf.  */
    1041                 :            : static inline Dwarf_Off
    1042                 :       2535 : str_offsets_base_off (Dwarf *dbg, Dwarf_CU *cu)
    1043                 :            : {
    1044                 :            :   /* If we don't have a CU, then find and use the first one in the
    1045                 :            :      debug file (when we support .dwp files, we must actually find the
    1046                 :            :      one matching our "caller" - aka macro or line).  If we (now) have
    1047                 :            :      a cu and str_offsets_base attribute, just use that.  Otherwise
    1048                 :            :      use the first offset.  But we might have to parse the header
    1049                 :            :      first, but only if this is version 5.  Assume if all else fails,
    1050                 :            :      this is version 4, without header.  */
    1051                 :            : 
    1052         [ +  + ]:       2535 :   if (cu == NULL && dbg != NULL)
    1053                 :            :     {
    1054                 :       1851 :       Dwarf_CU *first_cu;
    1055         [ +  + ]:       1851 :       if (dwarf_get_units (dbg, NULL, &first_cu,
    1056                 :            :                            NULL, NULL, NULL, NULL) == 0)
    1057                 :       1850 :         cu = first_cu;
    1058                 :            :     }
    1059                 :            : 
    1060         [ +  + ]:       2535 :   if (cu != NULL)
    1061                 :            :     {
    1062         [ +  + ]:       2534 :       if (cu->str_off_base == (Dwarf_Off) -1)
    1063                 :            :         {
    1064                 :         90 :           Dwarf_Die cu_die = CUDIE(cu);
    1065                 :         90 :           Dwarf_Attribute attr;
    1066         [ +  + ]:         90 :           if (dwarf_attr (&cu_die, DW_AT_str_offsets_base, &attr) != NULL)
    1067                 :            :             {
    1068                 :          2 :               Dwarf_Word off;
    1069         [ +  - ]:          2 :               if (dwarf_formudata (&attr, &off) == 0)
    1070                 :            :                 {
    1071                 :          2 :                   cu->str_off_base = off;
    1072                 :          2 :                   return cu->str_off_base;
    1073                 :            :                 }
    1074                 :            :             }
    1075                 :            :           /* For older DWARF simply assume zero (no header).  */
    1076         [ +  + ]:         88 :           if (cu->version < 5)
    1077                 :            :             {
    1078                 :         73 :               cu->str_off_base = 0;
    1079                 :         73 :               return cu->str_off_base;
    1080                 :            :             }
    1081                 :            : 
    1082         [ +  + ]:         15 :           if (dbg == NULL)
    1083                 :         14 :             dbg = cu->dbg;
    1084                 :            :         }
    1085                 :            :       else
    1086                 :            :         return cu->str_off_base;
    1087                 :            :     }
    1088                 :            : 
    1089                 :            :   /* No str_offsets_base attribute, we have to assume "zero".
    1090                 :            :      But there could be a header first.  */
    1091                 :         16 :   Dwarf_Off off = 0;
    1092         [ -  + ]:         16 :   if (dbg == NULL)
    1093                 :          0 :     goto no_header;
    1094                 :            : 
    1095                 :         16 :   Elf_Data *data =  dbg->sectiondata[IDX_debug_str_offsets];
    1096         [ +  + ]:         16 :   if (data == NULL)
    1097                 :          2 :     goto no_header;
    1098                 :            : 
    1099                 :         14 :   const unsigned char *start;
    1100                 :         14 :   const unsigned char *readp;
    1101                 :         14 :   const unsigned char *readendp;
    1102                 :         14 :   start = readp = (const unsigned char *) data->d_buf;
    1103                 :         14 :   readendp = (const unsigned char *) data->d_buf + data->d_size;
    1104                 :            : 
    1105                 :         14 :   uint64_t unit_length;
    1106                 :         14 :   uint16_t version;
    1107                 :            : 
    1108         [ -  + ]:         14 :   unit_length = read_4ubyte_unaligned_inc (dbg, readp);
    1109         [ -  + ]:         14 :   if (unlikely (unit_length == 0xffffffff))
    1110                 :            :     {
    1111         [ #  # ]:          0 :       if (unlikely (readendp - readp < 8))
    1112                 :          0 :         goto no_header;
    1113         [ #  # ]:          0 :       unit_length = read_8ubyte_unaligned_inc (dbg, readp);
    1114                 :            :       /* In theory the offset size could be different
    1115                 :            :          between CU and str_offsets unit.  But we just
    1116                 :            :          ignore that here. */
    1117                 :            :     }
    1118                 :            : 
    1119                 :            :   /* We need at least 2-bytes (version) + 2-bytes (padding) =
    1120                 :            :      4 bytes to complete the header.  And this unit cannot go
    1121                 :            :      beyond the section data.  */
    1122         [ +  - ]:         14 :   if (readendp - readp < 4
    1123         [ +  - ]:         14 :       || unit_length < 4
    1124         [ -  + ]:         14 :       || (uint64_t) (readendp - readp) < unit_length)
    1125                 :          0 :     goto no_header;
    1126                 :            : 
    1127         [ -  + ]:         14 :   version = read_2ubyte_unaligned_inc (dbg, readp);
    1128         [ -  + ]:         14 :   if (version != 5)
    1129                 :          0 :     goto no_header;
    1130                 :            :   /* padding */
    1131                 :         14 :   read_2ubyte_unaligned_inc (dbg, readp);
    1132                 :            : 
    1133                 :         14 :   off = (Dwarf_Off) (readp - start);
    1134                 :            : 
    1135                 :         16 :  no_header:
    1136         [ +  + ]:         16 :   if (cu != NULL)
    1137                 :         15 :     cu->str_off_base = off;
    1138                 :            : 
    1139                 :            :   return off;
    1140                 :            : }
    1141                 :            : 
    1142                 :            : 
    1143                 :            : /* Get the string offsets base for the CU, fetches it when not yet set.  */
    1144                 :        150 : static inline Dwarf_Off __libdw_cu_str_off_base (Dwarf_CU *cu)
    1145                 :            : {
    1146                 :        150 :   return str_offsets_base_off (NULL, cu);
    1147                 :            : }
    1148                 :            : 
    1149                 :            : 
    1150                 :            : /* Either a direct offset into .debug_ranges for version < 5, or the
    1151                 :            :    start of the offset table in .debug_rnglists for version > 5.  */
    1152                 :            : static inline Dwarf_Off
    1153                 :         14 : __libdw_cu_ranges_base (Dwarf_CU *cu)
    1154                 :            : {
    1155         [ +  + ]:         14 :   if (cu->ranges_base == (Dwarf_Off) -1)
    1156                 :            :     {
    1157                 :          5 :       Dwarf_Off offset = 0;
    1158                 :          5 :       Dwarf_Die cu_die = CUDIE(cu);
    1159                 :          5 :       Dwarf_Attribute attr;
    1160         [ +  + ]:          5 :       if (cu->version < 5)
    1161                 :            :         {
    1162         [ +  - ]:          4 :           if (dwarf_attr (&cu_die, DW_AT_GNU_ranges_base, &attr) != NULL)
    1163                 :            :             {
    1164                 :          4 :               Dwarf_Word off;
    1165         [ +  - ]:          4 :               if (dwarf_formudata (&attr, &off) == 0)
    1166                 :          4 :                 offset = off;
    1167                 :            :             }
    1168                 :            :         }
    1169                 :            :       else
    1170                 :            :         {
    1171         [ +  - ]:          1 :           if (dwarf_attr (&cu_die, DW_AT_rnglists_base, &attr) != NULL)
    1172                 :            :             {
    1173                 :          1 :               Dwarf_Word off;
    1174         [ +  - ]:          1 :               if (dwarf_formudata (&attr, &off) == 0)
    1175                 :          1 :                 offset = off;
    1176                 :            :             }
    1177                 :            : 
    1178                 :            :           /* There wasn't an rnglists_base, if the Dwarf does have a
    1179                 :            :              .debug_rnglists section, then it might be we need the
    1180                 :            :              base after the first header. */
    1181                 :          1 :           Elf_Data *data = cu->dbg->sectiondata[IDX_debug_rnglists];
    1182         [ +  - ]:          1 :           if (offset == 0 && data != NULL)
    1183                 :            :             {
    1184                 :          0 :               Dwarf *dbg = cu->dbg;
    1185                 :          0 :               const unsigned char *readp = data->d_buf;
    1186                 :          0 :               const unsigned char *const dataend
    1187                 :          0 :                 = (unsigned char *) data->d_buf + data->d_size;
    1188                 :            : 
    1189         [ #  # ]:          0 :               uint64_t unit_length = read_4ubyte_unaligned_inc (dbg, readp);
    1190                 :          0 :               unsigned int offset_size = 4;
    1191         [ #  # ]:          0 :               if (unlikely (unit_length == 0xffffffff))
    1192                 :            :                 {
    1193         [ #  # ]:          0 :                   if (unlikely (readp > dataend - 8))
    1194                 :          0 :                     goto no_header;
    1195                 :            : 
    1196         [ #  # ]:          0 :                   unit_length = read_8ubyte_unaligned_inc (dbg, readp);
    1197                 :          0 :                   offset_size = 8;
    1198                 :            :                 }
    1199                 :            : 
    1200         [ #  # ]:          0 :               if (readp > dataend - 8
    1201         [ #  # ]:          0 :                   || unit_length < 8
    1202         [ #  # ]:          0 :                   || unit_length > (uint64_t) (dataend - readp))
    1203                 :          0 :                 goto no_header;
    1204                 :            : 
    1205         [ #  # ]:          0 :               uint16_t version = read_2ubyte_unaligned_inc (dbg, readp);
    1206         [ #  # ]:          0 :               if (version != 5)
    1207                 :          0 :                 goto no_header;
    1208                 :            : 
    1209                 :          0 :               uint8_t address_size = *readp++;
    1210         [ #  # ]:          0 :               if (address_size != 4 && address_size != 8)
    1211                 :          0 :                 goto no_header;
    1212                 :            : 
    1213                 :          0 :               uint8_t segment_size = *readp++;
    1214         [ #  # ]:          0 :               if (segment_size != 0)
    1215                 :          0 :                 goto no_header;
    1216                 :            : 
    1217                 :          0 :               uint32_t offset_entry_count;
    1218         [ #  # ]:          0 :               offset_entry_count = read_4ubyte_unaligned_inc (dbg, readp);
    1219                 :            : 
    1220                 :          0 :               const unsigned char *offset_array_start = readp;
    1221         [ #  # ]:          0 :               if (offset_entry_count <= 0)
    1222                 :          0 :                 goto no_header;
    1223                 :            : 
    1224                 :          0 :               uint64_t needed = offset_entry_count * offset_size;
    1225         [ #  # ]:          0 :               if (unit_length - 8 < needed)
    1226                 :          0 :                 goto no_header;
    1227                 :            : 
    1228                 :          0 :               offset = (Dwarf_Off) (offset_array_start
    1229                 :          0 :                                     - (unsigned char *) data->d_buf);
    1230                 :            :             }
    1231                 :            :         }
    1232                 :          1 :     no_header:
    1233                 :          5 :       cu->ranges_base = offset;
    1234                 :            :     }
    1235                 :            : 
    1236                 :         14 :   return cu->ranges_base;
    1237                 :            : }
    1238                 :            : 
    1239                 :            : 
    1240                 :            : /* The start of the offset table in .debug_loclists for DWARF5.  */
    1241                 :            : static inline Dwarf_Off
    1242                 :         67 : __libdw_cu_locs_base (Dwarf_CU *cu)
    1243                 :            : {
    1244         [ +  + ]:         67 :   if (cu->locs_base == (Dwarf_Off) -1)
    1245                 :            :     {
    1246                 :          2 :       Dwarf_Off offset = 0;
    1247                 :          2 :       Dwarf_Die cu_die = CUDIE(cu);
    1248                 :          2 :       Dwarf_Attribute attr;
    1249         [ +  - ]:          2 :       if (dwarf_attr (&cu_die, DW_AT_loclists_base, &attr) != NULL)
    1250                 :            :         {
    1251                 :          2 :           Dwarf_Word off;
    1252         [ +  - ]:          2 :           if (dwarf_formudata (&attr, &off) == 0)
    1253                 :          2 :             offset = off;
    1254                 :            :         }
    1255                 :            : 
    1256                 :            :       /* There wasn't an loclists_base, if the Dwarf does have a
    1257                 :            :          .debug_loclists section, then it might be we need the
    1258                 :            :          base after the first header. */
    1259                 :          2 :       Elf_Data *data = cu->dbg->sectiondata[IDX_debug_loclists];
    1260         [ -  + ]:          2 :       if (offset == 0 && data != NULL)
    1261                 :            :         {
    1262                 :          2 :           Dwarf *dbg = cu->dbg;
    1263                 :          2 :           const unsigned char *readp = data->d_buf;
    1264                 :          2 :           const unsigned char *const dataend
    1265                 :          2 :             = (unsigned char *) data->d_buf + data->d_size;
    1266                 :            : 
    1267         [ -  + ]:          2 :           uint64_t unit_length = read_4ubyte_unaligned_inc (dbg, readp);
    1268                 :          2 :           unsigned int offset_size = 4;
    1269         [ -  + ]:          2 :           if (unlikely (unit_length == 0xffffffff))
    1270                 :            :             {
    1271         [ #  # ]:          0 :               if (unlikely (readp > dataend - 8))
    1272                 :          0 :                 goto no_header;
    1273                 :            : 
    1274         [ #  # ]:          0 :               unit_length = read_8ubyte_unaligned_inc (dbg, readp);
    1275                 :          0 :               offset_size = 8;
    1276                 :            :             }
    1277                 :            : 
    1278         [ +  - ]:          2 :           if (readp > dataend - 8
    1279         [ +  - ]:          2 :               || unit_length < 8
    1280         [ -  + ]:          2 :               || unit_length > (uint64_t) (dataend - readp))
    1281                 :          0 :             goto no_header;
    1282                 :            : 
    1283         [ -  + ]:          2 :           uint16_t version = read_2ubyte_unaligned_inc (dbg, readp);
    1284         [ -  + ]:          2 :           if (version != 5)
    1285                 :          0 :             goto no_header;
    1286                 :            : 
    1287                 :          2 :           uint8_t address_size = *readp++;
    1288         [ -  + ]:          2 :           if (address_size != 4 && address_size != 8)
    1289                 :          0 :             goto no_header;
    1290                 :            : 
    1291                 :          2 :           uint8_t segment_size = *readp++;
    1292         [ -  + ]:          2 :           if (segment_size != 0)
    1293                 :          0 :             goto no_header;
    1294                 :            : 
    1295                 :          2 :           uint32_t offset_entry_count;
    1296         [ -  + ]:          2 :           offset_entry_count = read_4ubyte_unaligned_inc (dbg, readp);
    1297                 :            : 
    1298                 :          2 :           const unsigned char *offset_array_start = readp;
    1299         [ -  + ]:          2 :           if (offset_entry_count <= 0)
    1300                 :          0 :             goto no_header;
    1301                 :            : 
    1302                 :          2 :           uint64_t needed = offset_entry_count * offset_size;
    1303         [ -  + ]:          2 :           if (unit_length - 8 < needed)
    1304                 :          0 :             goto no_header;
    1305                 :            : 
    1306                 :          2 :           offset = (Dwarf_Off) (offset_array_start
    1307                 :          2 :                                 - (unsigned char *) data->d_buf);
    1308                 :            :         }
    1309                 :            : 
    1310                 :          0 :     no_header:
    1311                 :          2 :       cu->locs_base = offset;
    1312                 :            :     }
    1313                 :            : 
    1314                 :         67 :   return cu->locs_base;
    1315                 :            : }
    1316                 :            : 
    1317                 :            : /* Helper function for tsearch/tfind split_tree Dwarf.  */
    1318                 :            : int __libdw_finddbg_cb (const void *arg1, const void *arg2);
    1319                 :            : 
    1320                 :            : /* Link skeleton and split compile units.  */
    1321                 :            : static inline void
    1322                 :         48 : __libdw_link_skel_split (Dwarf_CU *skel, Dwarf_CU *split)
    1323                 :            : {
    1324                 :         48 :   skel->split = split;
    1325                 :         48 :   split->split = skel;
    1326                 :            : 
    1327                 :            :   /* Get .debug_addr and addr_base greedy.
    1328                 :            :      We also need it for the fake addr cu.
    1329                 :            :      There is only one per split debug.  */
    1330                 :         48 :   Dwarf *dbg = skel->dbg;
    1331                 :         48 :   Dwarf *sdbg = split->dbg;
    1332         [ +  - ]:         48 :   if (sdbg->sectiondata[IDX_debug_addr] == NULL
    1333         [ +  - ]:         48 :       && dbg->sectiondata[IDX_debug_addr] != NULL)
    1334                 :            :     {
    1335                 :         48 :       sdbg->sectiondata[IDX_debug_addr]
    1336                 :         48 :         = dbg->sectiondata[IDX_debug_addr];
    1337                 :         48 :       split->addr_base = __libdw_cu_addr_base (skel);
    1338                 :         48 :       sdbg->fake_addr_cu = dbg->fake_addr_cu;
    1339                 :            :     }
    1340                 :         48 : }
    1341                 :            : 
    1342                 :            : 
    1343                 :            : /* Given an address index for a CU return the address.
    1344                 :            :    Returns -1 and sets libdw_errno if an error occurs.  */
    1345                 :            : int __libdw_addrx (Dwarf_CU *cu, Dwarf_Word idx, Dwarf_Addr *addr);
    1346                 :            : 
    1347                 :            : 
    1348                 :            : /* Helper function to set debugdir field in Dwarf, used from dwarf_begin_elf
    1349                 :            :    and libdwfl process_file.  */
    1350                 :            : char * __libdw_debugdir (int fd);
    1351                 :            : 
    1352                 :            : 
    1353                 :            : /* Given the directory of a debug file, an absolute or relative dir
    1354                 :            :    to look in, and file returns a full path.
    1355                 :            : 
    1356                 :            :    If the file is absolute (starts with a /) a copy of file is returned.
    1357                 :            :    the file isn't absolute, but dir is absolute, then a path that is
    1358                 :            :    the concatenation of dir and file is returned.  If neither file,
    1359                 :            :    nor dir is absolute, the path will be constructed using dir (if not
    1360                 :            :    NULL) and file relative to the debugdir (if valid).
    1361                 :            : 
    1362                 :            :    The debugdir and the dir may be NULL (in which case they aren't used).
    1363                 :            :    If file is NULL, or no full path can be constructed NULL is returned.
    1364                 :            : 
    1365                 :            :    The caller is responsible for freeing the result if not NULL.  */
    1366                 :            : char * __libdw_filepath (const char *debugdir, const char *dir,
    1367                 :            :                          const char *file)
    1368                 :            :   internal_function;
    1369                 :            : 
    1370                 :            : 
    1371                 :            : /* Aliases to avoid PLTs.  */
    1372                 :            : INTDECL (dwarf_aggregate_size)
    1373                 :            : INTDECL (dwarf_attr)
    1374                 :            : INTDECL (dwarf_attr_integrate)
    1375                 :            : INTDECL (dwarf_begin)
    1376                 :            : INTDECL (dwarf_begin_elf)
    1377                 :            : INTDECL (dwarf_child)
    1378                 :            : INTDECL (dwarf_default_lower_bound)
    1379                 :            : INTDECL (dwarf_dieoffset)
    1380                 :            : INTDECL (dwarf_diename)
    1381                 :            : INTDECL (dwarf_end)
    1382                 :            : INTDECL (dwarf_entrypc)
    1383                 :            : INTDECL (dwarf_errmsg)
    1384                 :            : INTDECL (dwarf_formaddr)
    1385                 :            : INTDECL (dwarf_formblock)
    1386                 :            : INTDECL (dwarf_formref_die)
    1387                 :            : INTDECL (dwarf_formsdata)
    1388                 :            : INTDECL (dwarf_formstring)
    1389                 :            : INTDECL (dwarf_formudata)
    1390                 :            : INTDECL (dwarf_getabbrevattr_data)
    1391                 :            : INTDECL (dwarf_getalt)
    1392                 :            : INTDECL (dwarf_getarange_addr)
    1393                 :            : INTDECL (dwarf_getarangeinfo)
    1394                 :            : INTDECL (dwarf_getaranges)
    1395                 :            : INTDECL (dwarf_getlocation_die)
    1396                 :            : INTDECL (dwarf_getsrcfiles)
    1397                 :            : INTDECL (dwarf_getsrclines)
    1398                 :            : INTDECL (dwarf_hasattr)
    1399                 :            : INTDECL (dwarf_haschildren)
    1400                 :            : INTDECL (dwarf_haspc)
    1401                 :            : INTDECL (dwarf_highpc)
    1402                 :            : INTDECL (dwarf_lowpc)
    1403                 :            : INTDECL (dwarf_nextcu)
    1404                 :            : INTDECL (dwarf_next_unit)
    1405                 :            : INTDECL (dwarf_offdie)
    1406                 :            : INTDECL (dwarf_peel_type)
    1407                 :            : INTDECL (dwarf_ranges)
    1408                 :            : INTDECL (dwarf_setalt)
    1409                 :            : INTDECL (dwarf_siblingof)
    1410                 :            : INTDECL (dwarf_srclang)
    1411                 :            : INTDECL (dwarf_tag)
    1412                 :            : 
    1413                 :            : #endif  /* libdwP.h */

Generated by: LCOV version 1.14