libdwP.h revision df85bf99021119fcbb2ced66dd69f1cceafb180c
1b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Internal definitions for libdwarf.
2df85bf99021119fcbb2ced66dd69f1cceafb180cMark Wielaard   Copyright (C) 2002-2011, 2013, 2014 Red Hat, Inc.
3de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is part of elfutils.
4b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   Written by Ulrich Drepper <drepper@redhat.com>, 2002.
5b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
6de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   This file is free software; you can redistribute it and/or modify
7de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   it under the terms of either
8b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
9de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU Lesser General Public License as published by the Free
10de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 3 of the License, or (at
11de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
12de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
13de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or
14de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
15de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard     * the GNU General Public License as published by the Free
16de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       Software Foundation; either version 2 of the License, or (at
17de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard       your option) any later version
18de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
19de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   or both in parallel, as here.
20de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard
21de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   elfutils is distributed in the hope that it will be useful, but
22361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   WITHOUT ANY WARRANTY; without even the implied warranty of
23361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper   General Public License for more details.
25361df7da6dfecd817b27e62b91752ac316d7cdd4Ulrich Drepper
26de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   You should have received copies of the GNU General Public License and
27de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   the GNU Lesser General Public License along with this program.  If
28de2ed97f33139af5c7a0811e4ec66fc896a13cf2Mark Wielaard   not, see <http://www.gnu.org/licenses/>.  */
29b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
30b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#ifndef _LIBDWP_H
31b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#define _LIBDWP_H 1
32b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
33b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <libintl.h>
34b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <stdbool.h>
35b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
36b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include <libdw.h>
37c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone#include <dwarf.h>
38b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
39b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
40b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* gettext helper macros.  */
41b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#define _(Str) dgettext ("elfutils", Str)
42b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
43b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
446724c90d02659f7466b67b357563042e403d154eRoland McGrath/* Known location expressions already decoded.  */
45b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperstruct loc_s
46b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
47b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  void *addr;
486724c90d02659f7466b67b357563042e403d154eRoland McGrath  Dwarf_Op *loc;
49b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  size_t nloc;
50b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper};
51b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
52f0371041995308d197447019eb2ac9285c96477bRoland McGrath/* Known DW_OP_implicit_value blocks already decoded.
53f0371041995308d197447019eb2ac9285c96477bRoland McGrath   This overlaps struct loc_s exactly, but only the
54f0371041995308d197447019eb2ac9285c96477bRoland McGrath   first member really has to match.  */
55f0371041995308d197447019eb2ac9285c96477bRoland McGrathstruct loc_block_s
56f0371041995308d197447019eb2ac9285c96477bRoland McGrath{
57f0371041995308d197447019eb2ac9285c96477bRoland McGrath  void *addr;
58f0371041995308d197447019eb2ac9285c96477bRoland McGrath  unsigned char *data;
59f0371041995308d197447019eb2ac9285c96477bRoland McGrath  size_t length;
60f0371041995308d197447019eb2ac9285c96477bRoland McGrath};
61f0371041995308d197447019eb2ac9285c96477bRoland McGrath
62b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Valid indeces for the section data.  */
63b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperenum
64b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  {
65b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_info = 0,
66827d4d176b989c5d765c7f349edff6f994f8ea78Roland McGrath    IDX_debug_types,
67b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_abbrev,
68b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_aranges,
69b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_line,
70b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_frame,
71b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_loc,
72b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_pubnames,
73b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_str,
74b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_macinfo,
75a0172d75311f36adb6db58000474d31f8a9cd553Mark Wielaard    IDX_debug_macro,
76b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_debug_ranges,
77efa72a02de8a3bbbc43c8de659697df5d425ea7eFlorian Weimer    IDX_gnu_debugaltlink,
78b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    IDX_last
79b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  };
80b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
81b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
82b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Error values.  */
83b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperenum
84b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
85b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NOERROR = 0,
86b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_UNKNOWN_ERROR,
87b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_ACCESS,
88b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_REGFILE,
89b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_IO_ERROR,
90b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_ELF,
91b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_DWARF,
92b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NOELF,
93b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_GETEHDR_ERROR,
94b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NOMEM,
95b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_UNIMPL,
96b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_CMD,
97b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_VERSION,
98b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_FILE,
99b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_ENTRY,
100b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_DWARF,
101b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_STRING,
102b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_ADDR,
103b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_CONSTANT,
104b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_REFERENCE,
105b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_REFERENCE,
106b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_DEBUG_LINE,
107b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_DEBUG_LINE,
108b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_TOO_BIG,
109b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_VERSION,
110b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_DIR_IDX,
111b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_ADDR_OUTOFRANGE,
112b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_LOCLIST,
113b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_BLOCK,
114b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_LINE_IDX,
115b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_ARANGE_IDX,
116b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_MATCH,
117b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_FLAG,
118b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_INVALID_OFFSET,
119b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  DWARF_E_NO_DEBUG_RANGES,
1203c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  DWARF_E_INVALID_CFI,
121775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard  DWARF_E_NO_ALT_DEBUGLINK
122b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper};
123b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
124b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1253e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath#include "dwarf_sig8_hash.h"
1263e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath
127b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* This is the structure representing the debugging state.  */
128b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperstruct Dwarf
129b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
130b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* The underlying ELF file.  */
131b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Elf *elf;
132b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
133775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard  /* dwz alternate DWARF file.  */
134775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard  Dwarf *alt_dwarf;
135775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard
136b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* The section data.  */
137b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Elf_Data *sectiondata[IDX_last];
138b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
139725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath#if USE_ZLIB
140725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath  /* The 1 << N bit is set if sectiondata[N] is malloc'd decompressed data.  */
141725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath  unsigned int sectiondata_gzip_mask:IDX_last;
142725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath#endif
143725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath
144b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* True if the file has a byte order different from the host.  */
145b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  bool other_byte_order;
146b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
147b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* If true, we allocated the ELF descriptor ourselves.  */
148b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  bool free_elf;
149b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
150b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Information for traversing the .debug_pubnames section.  This is
151b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     an array and separately allocated with malloc.  */
152b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  struct pubnames_s
153b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  {
154b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    Dwarf_Off cu_offset;
155b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    Dwarf_Off set_start;
156b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    unsigned int cu_header_size;
157b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    int address_len;
158b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  } *pubnames_sets;
159b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  size_t pubnames_nsets;
160b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
161b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Search tree for the CUs.  */
162b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  void *cu_tree;
163b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Off next_cu_offset;
164b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1652b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrath  /* Search tree and sig8 hash table for .debug_types type units.  */
1662b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrath  void *tu_tree;
1673e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath  Dwarf_Off next_tu_offset;
1682b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrath  Dwarf_Sig8_Hash sig8_hash;
1693e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath
170b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Address ranges.  */
171b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Aranges *aranges;
172b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
1733c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  /* Cached info from the CFI section.  */
1743c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath  struct Dwarf_CFI_s *cfi;
1753c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
176b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Internal memory handling.  This is basically a simplified
177b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     reimplementation of obstacks.  Unfortunately the standard obstack
178b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     implementation is not usable in libraries.  */
179b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  struct libdw_memblock
180b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  {
181b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    size_t size;
182b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    size_t remaining;
183b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    struct libdw_memblock *prev;
184b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    char mem[0];
185b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  } *mem_tail;
186b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
187b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Default size of allocated memory blocks.  */
188b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  size_t mem_default_size;
189b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
190b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Registered OOM handler.  */
191b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_OOM oom_handler;
192b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper};
193b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
194b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
195b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Abbreviation representation.  */
196b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperstruct Dwarf_Abbrev
197b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
1981f6d2010bb26b6bf5395a98651fce9a1a9141ac3Roland McGrath  Dwarf_Off offset;
1991f6d2010bb26b6bf5395a98651fce9a1a9141ac3Roland McGrath  unsigned char *attrp;
2001f6d2010bb26b6bf5395a98651fce9a1a9141ac3Roland McGrath  unsigned int attrcnt;
201b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  unsigned int code;
202b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  unsigned int tag;
2031f6d2010bb26b6bf5395a98651fce9a1a9141ac3Roland McGrath  bool has_children;
204b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper};
205b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
206b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include "dwarf_abbrev_hash.h"
207b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
208b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
209b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Files in line information records.  */
210b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperstruct Dwarf_Files_s
211b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  {
212c5acb304d81cdbe3f8b923f2a6ac1bee3af9f498Roland McGrath    struct Dwarf_CU *cu;
21343da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath    unsigned int ndirs;
214b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    unsigned int nfiles;
215b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    struct Dwarf_Fileinfo_s
216b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    {
217b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper      char *name;
218b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper      Dwarf_Word mtime;
219b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper      Dwarf_Word length;
220b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    } info[0];
22143da9895c6d828ceae65a47f2337e8ef24eb97c1Roland McGrath    /* nfiles of those, followed by char *[ndirs].  */
222b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  };
223b08d5a8fb42f4586d756068065186b5af7e48daUlrich Dreppertypedef struct Dwarf_Fileinfo_s Dwarf_Fileinfo;
224b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
225b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
226b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Representation of a row in the line table.  */
227b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
22803288f0df65115b75cf029825ecc9cf9158870a4Roland McGrathstruct Dwarf_Line_s
22903288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath{
2306e1f4658619e0a6bdbf64d7678b82f4e97645633Roland McGrath  Dwarf_Files *files;
2316e1f4658619e0a6bdbf64d7678b82f4e97645633Roland McGrath
23203288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  Dwarf_Addr addr;
23303288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  unsigned int file;
23403288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  int line;
23503288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  unsigned short int column;
23603288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  unsigned int is_stmt:1;
23703288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  unsigned int basic_block:1;
23803288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  unsigned int end_sequence:1;
23903288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  unsigned int prologue_end:1;
24003288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  unsigned int epilogue_begin:1;
241c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath  /* The remaining bit fields are not flags, but hold values presumed to be
242c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath     small.  All the flags and other bit fields should add up to 48 bits
243c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath     to give the whole struct a nice round size.  */
244c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath  unsigned int op_index:8;
245c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath  unsigned int isa:8;
246c70cf4e5e5a463b64673c4e80bcf60c938b437b4Roland McGrath  unsigned int discriminator:24;
24703288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath};
24803288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath
24903288f0df65115b75cf029825ecc9cf9158870a4Roland McGrathstruct Dwarf_Lines_s
25003288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath{
25103288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  size_t nlines;
25203288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath  struct Dwarf_Line_s info[0];
25303288f0df65115b75cf029825ecc9cf9158870a4Roland McGrath};
254b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
255b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Representation of address ranges.  */
256b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperstruct Dwarf_Aranges_s
257b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
258b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf *dbg;
259b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  size_t naranges;
260b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
261b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  struct Dwarf_Arange_s
262b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  {
263b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    Dwarf_Addr addr;
264b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    Dwarf_Word length;
265b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    Dwarf_Off offset;
266b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  } info[0];
267b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper};
268b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
269b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
270b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* CU representation.  */
271b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperstruct Dwarf_CU
272b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
273b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf *dbg;
274b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Off start;
275b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Off end;
276b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  uint8_t address_size;
277b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  uint8_t offset_size;
278e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath  uint16_t version;
279b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
2803e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath  /* Zero if this is a normal CU.  Nonzero if it is a type unit.  */
2813e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath  size_t type_offset;
2823e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath  uint64_t type_sig8;
2833e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath
284b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Hash table for the abbreviations.  */
285b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Abbrev_Hash abbrev_hash;
286b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Offset of the first abbreviation.  */
287b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  size_t orig_abbrev_offset;
288b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Offset past last read abbreviation.  */
289b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  size_t last_abbrev_offset;
290b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
291b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* The srcline information.  */
292b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Lines *lines;
293b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
294b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* The source file information.  */
295b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Files *files;
296b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
297b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  /* Known location lists.  */
298b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  void *locs;
299b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper};
300b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
30135f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper/* Compute the offset of a CU's first DIE from its offset.  This
30235f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   is either:
30335f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper        LEN       VER     OFFSET    ADDR
30435f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper      4-bytes + 2-bytes + 4-bytes + 1-byte  for 32-bit dwarf
30535f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper     12-bytes + 2-bytes + 8-bytes + 1-byte  for 64-bit dwarf
3063e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath   or in .debug_types, 			     SIGNATURE TYPE-OFFSET
3073e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath      4-bytes + 2-bytes + 4-bytes + 1-byte + 8-bytes + 4-bytes  for 32-bit
3083e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath     12-bytes + 2-bytes + 8-bytes + 1-byte + 8-bytes + 8-bytes  for 64-bit
309a969d8e19470157be1b8b2e1a693ac7702bf4273Ulrich Drepper
31035f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   Note the trick in the computation.  If the offset_size is 4
31135f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   the '- 4' term changes the '3 *' into a '2 *'.  If the
31235f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   offset_size is 8 it accounts for the 4-byte escape value
31335f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper   used at the start of the length.  */
3143e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath#define DIE_OFFSET_FROM_CU_OFFSET(cu_offset, offset_size, type_unit)	\
3153e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath  ((type_unit) ? ((cu_offset) + 4 * (offset_size) - 4 + 3 + 8)		\
3163e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath   : ((cu_offset) + 3 * (offset_size) - 4 + 3))
31735f08c4d52d0ffd9f8aa50f47b84de5603842b1fUlrich Drepper
3183e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath#define CUDIE(fromcu)							      \
3196724c90d02659f7466b67b357563042e403d154eRoland McGrath  ((Dwarf_Die)								      \
3206724c90d02659f7466b67b357563042e403d154eRoland McGrath   {									      \
3216724c90d02659f7466b67b357563042e403d154eRoland McGrath     .cu = (fromcu),							      \
3225cc030d6169713ff4711c28a6ce1250b142cd5b3Roland McGrath     .addr = ((char *) cu_data (fromcu)->d_buf				      \
3233e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath	      + DIE_OFFSET_FROM_CU_OFFSET ((fromcu)->start,		      \
3243e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath					   (fromcu)->offset_size,	      \
3253e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath					   (fromcu)->type_offset != 0))	      \
3263e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath   })									      \
327b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
328b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
329b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Macro information.  */
330b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperstruct Dwarf_Macro_s
331b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper{
332b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  unsigned int opcode;
333b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  Dwarf_Word param1;
334b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  union
335b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  {
336b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    Dwarf_Word u;
337b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper    const char *s;
338b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  } param2;
339b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper};
340b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
341b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
342b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* We have to include the file at this point because the inline
343b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   functions access internals of the Dwarf structure.  */
344b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#include "memory-access.h"
345b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
346b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
347b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Set error value.  */
348b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern void __libdw_seterrno (int value) internal_function;
349b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
350b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
351b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Memory handling, the easy parts.  This macro does not do any locking.  */
352db1d54386fc38a30eff030517cbbfedf758fa32aUlrich Drepper#define libdw_alloc(dbg, type, tsize, cnt) \
353b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  ({ struct libdw_memblock *_tail = (dbg)->mem_tail;			      \
354b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     size_t _required = (tsize) * (cnt);				      \
355b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     type *_result = (type *) (_tail->mem + (_tail->size - _tail->remaining));\
356b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     size_t _padding = ((__alignof (type)				      \
357b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			 - ((uintptr_t) _result & (__alignof (type) - 1)))    \
358b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper			& (__alignof (type) - 1));			      \
359b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     if (unlikely (_tail->remaining < _required + _padding))		      \
360c373d850ec9ca342f4c71d5e287c8d8bf0723cd6Roland McGrath       _result = (type *) __libdw_allocate (dbg, _required, __alignof (type));\
361b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     else								      \
362b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper       {								      \
363b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper	 _required += _padding;						      \
364b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper	 _result = (type *) ((char *) _result + _padding);		      \
365c373d850ec9ca342f4c71d5e287c8d8bf0723cd6Roland McGrath	 _tail->remaining -= _required;					      \
366b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper       }								      \
367b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     _result; })
368b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
369b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#define libdw_typed_alloc(dbg, type) \
370b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper  libdw_alloc (dbg, type, sizeof (type), 1)
371b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
372b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Callback to allocate more.  */
373c373d850ec9ca342f4c71d5e287c8d8bf0723cd6Roland McGrathextern void *__libdw_allocate (Dwarf *dbg, size_t minsize, size_t align)
374b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __attribute__ ((__malloc__)) __nonnull_attribute__ (1);
375b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
376b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Default OOM handler.  */
377b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern void __libdw_oom (void) __attribute ((noreturn, visibility ("hidden")));
378b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
379725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath#if USE_ZLIB
380725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrathextern void __libdw_free_zdata (Dwarf *dwarf) internal_function;
381725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath#else
382725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath# define __libdw_free_zdata(dwarf)	((void) (dwarf))
383725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath#endif
384725aad5d2f8b78ed21a5e253fb38f9722c2c8b2dRoland McGrath
3853e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath/* Allocate the internal data for a unit not seen before.  */
3863e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrathextern struct Dwarf_CU *__libdw_intern_next_unit (Dwarf *dbg, bool debug_types)
3873e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath     __nonnull_attribute__ (1) internal_function;
3883e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath
389b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Find CU for given offset.  */
3902b1f09548b66c2c75d5be6f13cd9374adc95f8d8Roland McGrathextern struct Dwarf_CU *__libdw_findcu (Dwarf *dbg, Dwarf_Off offset, bool tu)
391b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (1) internal_function;
392b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
393b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return tag of given DIE.  */
394b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Abbrev *__libdw_findabbrev (struct Dwarf_CU *cu,
395b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					 unsigned int code)
396b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (1) internal_function;
397b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
398b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Get abbreviation at given offset.  */
399b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern Dwarf_Abbrev *__libdw_getabbrev (Dwarf *dbg, struct Dwarf_CU *cu,
400b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					Dwarf_Off offset, size_t *lengthp,
401b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					Dwarf_Abbrev *result)
402b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (1) internal_function;
403b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
404b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Helper functions for form handling.  */
405c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stoneextern size_t __libdw_form_val_compute_len (Dwarf *dbg, struct Dwarf_CU *cu,
406c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone					    unsigned int form,
407c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone					    const unsigned char *valp)
408b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (1, 2, 4) internal_function;
409b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
410c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone/* Find the length of a form attribute.  */
411c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stonestatic inline size_t
412c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone__nonnull_attribute__ (1, 2, 4)
413c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone__libdw_form_val_len (Dwarf *dbg, struct Dwarf_CU *cu,
414c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone		      unsigned int form, const unsigned char *valp)
415c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone{
416c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone  /* Small lookup table of forms with fixed lengths.  Absent indexes are
417c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone     initialized 0, so any truly desired 0 is set to 0x80 and masked.  */
418c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone  static const uint8_t form_lengths[] =
419c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone    {
420c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone      [DW_FORM_flag_present] = 0x80,
421c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone      [DW_FORM_data1] = 1, [DW_FORM_ref1] = 1, [DW_FORM_flag] = 1,
422c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone      [DW_FORM_data2] = 2, [DW_FORM_ref2] = 2,
423c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone      [DW_FORM_data4] = 4, [DW_FORM_ref4] = 4,
424c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone      [DW_FORM_data8] = 8, [DW_FORM_ref8] = 8, [DW_FORM_ref_sig8] = 8,
425c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone    };
426c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone
427c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone  /* Return immediately for forms with fixed lengths.  */
428c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone  if (form < sizeof form_lengths / sizeof form_lengths[0])
429c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone    {
430c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone      uint8_t len = form_lengths[form];
431c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone      if (len != 0)
432c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone	return len & 0x7f; /* Mask to allow 0x80 -> 0.  */
433c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone    }
434c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone
435c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone  /* Other forms require some computation.  */
436c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone  return __libdw_form_val_compute_len (dbg, cu, form, valp);
437c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone}
438c0d2a0b3a38bfb5164c1cf822d50e46cfad9c071Josh Stone
439e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath/* Helper function for DW_FORM_ref* handling.  */
440e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrathextern int __libdw_formref (Dwarf_Attribute *attr, Dwarf_Off *return_offset)
441e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath     __nonnull_attribute__ (1, 2) internal_function;
442e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath
443e4c22ea004c02a58f5db5eb53794275344c17958Roland McGrath
444b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Helper function to locate attribute.  */
445b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern unsigned char *__libdw_find_attr (Dwarf_Die *die,
446b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					 unsigned int search_name,
447b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					 unsigned int *codep,
448b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper					 unsigned int *formp)
449b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (1) internal_function;
450b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
451b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Helper function to access integer attribute.  */
4526724c90d02659f7466b67b357563042e403d154eRoland McGrathextern int __libdw_attr_intval (Dwarf_Die *die, int *valp, int attval)
453b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper     __nonnull_attribute__ (1, 2) internal_function;
454b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
4551ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath/* Helper function to walk scopes.  */
45671e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrathstruct Dwarf_Die_Chain
45771e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath{
45871e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath  Dwarf_Die die;
45971e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath  struct Dwarf_Die_Chain *parent;
46071e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath  bool prune;			/* The PREVISIT function can set this.  */
46171e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath};
46271e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrathextern int __libdw_visit_scopes (unsigned int depth,
46371e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath				 struct Dwarf_Die_Chain *root,
46471e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath				 int (*previsit) (unsigned int depth,
46571e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath						  struct Dwarf_Die_Chain *,
46671e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath						  void *arg),
46771e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath				 int (*postvisit) (unsigned int depth,
46871e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath						   struct Dwarf_Die_Chain *,
46971e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrath						   void *arg),
4701ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath				 void *arg)
4711ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath  __nonnull_attribute__ (2, 3) internal_function;
4721ecb606f5af22838bf42b50dcc581d2b0f9191feRoland McGrath
4733c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath/* Parse a DWARF Dwarf_Block into an array of Dwarf_Op's,
4743c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath   and cache the result (via tsearch).  */
4753c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrathextern int __libdw_intern_expression (Dwarf *dbg,
4763c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath				      bool other_byte_order,
4773c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath				      unsigned int address_size,
478688f7fcdb395cefef6a098b5ac9ddd167bb5fc3dRoland McGrath				      unsigned int ref_size,
4793c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath				      void **cache, const Dwarf_Block *block,
4800ab97839da3c382ab8799ebdbf5eb0a79bf20bdcRoland McGrath				      bool cfap, bool valuep,
4813c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath				      Dwarf_Op **llbuf, size_t *listlen,
4823c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath				      int sec_index)
483688f7fcdb395cefef6a098b5ac9ddd167bb5fc3dRoland McGrath  __nonnull_attribute__ (5, 6, 9, 10) internal_function;
4843c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
485932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrathextern Dwarf_Die *__libdw_offdie (Dwarf *dbg, Dwarf_Off offset,
486932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath				  Dwarf_Die *result, bool debug_types)
487932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath  internal_function;
488932585d2385c9d4e5686e4ddc9ba30c68172d7f3Roland McGrath
4893c84db3b4b610bf636c4363abb6d3dac5ae020f9Roland McGrath
490b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Return error code of last failing function call.  This value is kept
491b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper   separately for each thread.  */
492b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepperextern int __dwarf_errno_internal (void);
493b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
494b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
49599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper/* Reader hooks.  */
49699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
49799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper/* Relocation hooks return -1 on error (in that case the error code
49899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper   must already have been set), 0 if there is no relocation and 1 if a
49999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper   relocation was present.*/
50099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
50199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline int
50299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper__libdw_relocate_address (Dwarf *dbg __attribute__ ((unused)),
50399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			  int sec_index __attribute__ ((unused)),
50499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			  const void *addr __attribute__ ((unused)),
50599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			  int width __attribute__ ((unused)),
50699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			  Dwarf_Addr *val __attribute__ ((unused)))
50799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
50899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  return 0;
50999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
51099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
51199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline int
51299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper__libdw_relocate_offset (Dwarf *dbg __attribute__ ((unused)),
51399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			 int sec_index __attribute__ ((unused)),
51499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			 const void *addr __attribute__ ((unused)),
51599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			 int width __attribute__ ((unused)),
51699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			 Dwarf_Off *val __attribute__ ((unused)))
51799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
51899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  return 0;
51999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
52099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
52199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline Elf_Data *
52299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper__libdw_checked_get_data (Dwarf *dbg, int sec_index)
52399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
52499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  Elf_Data *data = dbg->sectiondata[sec_index];
52599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  if (unlikely (data == NULL)
52699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      || unlikely (data->d_buf == NULL))
52799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    {
52899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      __libdw_seterrno (DWARF_E_INVALID_DWARF);
52999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      return NULL;
53099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    }
53199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  return data;
53299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
53399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
53499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline int
53599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper__libdw_offset_in_section (Dwarf *dbg, int sec_index,
53699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			   Dwarf_Off offset, size_t size)
53799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
53899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  Elf_Data *data = __libdw_checked_get_data (dbg, sec_index);
53999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  if (data == NULL)
54099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    return -1;
54199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  if (unlikely (offset > data->d_size)
54299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      || unlikely (data->d_size - offset < size))
54399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    {
54499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      __libdw_seterrno (DWARF_E_INVALID_OFFSET);
54599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      return -1;
54699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    }
54799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
54899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  return 0;
54999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
55099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
55199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline bool
55299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper__libdw_in_section (Dwarf *dbg, int sec_index,
55399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper		    const void *addr, size_t size)
55499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
55599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  Elf_Data *data = __libdw_checked_get_data (dbg, sec_index);
55699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  if (data == NULL)
55799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    return false;
55899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  if (unlikely (addr < data->d_buf)
55999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      || unlikely (data->d_size - (addr - data->d_buf) < size))
56099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    {
56199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      __libdw_seterrno (DWARF_E_INVALID_OFFSET);
56299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      return false;
56399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    }
56499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
56599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  return true;
56699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
56799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
56899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper#define READ_AND_RELOCATE(RELOC_HOOK, VAL)				\
56999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  ({									\
57099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    if (!__libdw_in_section (dbg, sec_index, addr, width))		\
57199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      return -1;							\
57299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper									\
57399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    const unsigned char *orig_addr = addr;				\
57499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    if (width == 4)							\
57599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      VAL = read_4ubyte_unaligned_inc (dbg, addr);			\
57699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    else								\
57799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      VAL = read_8ubyte_unaligned_inc (dbg, addr);			\
57899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper									\
57999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    int status = RELOC_HOOK (dbg, sec_index, orig_addr, width, &VAL);	\
58099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    if (status < 0)							\
58199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper      return status;							\
58299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    status > 0;								\
58399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper   })
58499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
58599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline int
58699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper__libdw_read_address_inc (Dwarf *dbg,
58705c4e04640d173a4d1ce6e2f25a24060c21a67abRoland McGrath			  int sec_index, const unsigned char **addrp,
58899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			  int width, Dwarf_Addr *ret)
58999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
59005c4e04640d173a4d1ce6e2f25a24060c21a67abRoland McGrath  const unsigned char *addr = *addrp;
59199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  READ_AND_RELOCATE (__libdw_relocate_address, (*ret));
59299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  *addrp = addr;
59399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  return 0;
59499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
59599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
59699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline int
59799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper__libdw_read_address (Dwarf *dbg,
59899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper		      int sec_index, const unsigned char *addr,
59999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper		      int width, Dwarf_Addr *ret)
60099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
60199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  READ_AND_RELOCATE (__libdw_relocate_address, (*ret));
60299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  return 0;
60399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
60499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
60599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline int
60699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper__libdw_read_offset_inc (Dwarf *dbg,
60705c4e04640d173a4d1ce6e2f25a24060c21a67abRoland McGrath			 int sec_index, const unsigned char **addrp,
60899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			 int width, Dwarf_Off *ret, int sec_ret,
60999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper			 size_t size)
61099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
61105c4e04640d173a4d1ce6e2f25a24060c21a67abRoland McGrath  const unsigned char *addr = *addrp;
61299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  READ_AND_RELOCATE (__libdw_relocate_offset, (*ret));
61399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  *addrp = addr;
61499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  return __libdw_offset_in_section (dbg, sec_ret, *ret, size);
61599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
61699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
61799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperstatic inline int
618775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard__libdw_read_offset (Dwarf *dbg, Dwarf *dbg_ret,
61999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper		     int sec_index, const unsigned char *addr,
62099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper		     int width, Dwarf_Off *ret, int sec_ret,
62199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper		     size_t size)
62299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper{
62399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  READ_AND_RELOCATE (__libdw_relocate_offset, (*ret));
624775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard  return __libdw_offset_in_section (dbg_ret, sec_ret, *ret, size);
62599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper}
62699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
6273e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrathstatic inline size_t
6283e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrathcu_sec_idx (struct Dwarf_CU *cu)
6293e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath{
6303e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath  return cu->type_offset == 0 ? IDX_debug_info : IDX_debug_types;
6313e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath}
6323e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath
6333e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrathstatic inline Elf_Data *
6343e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrathcu_data (struct Dwarf_CU *cu)
6353e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath{
6363e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath  return cu->dbg->sectiondata[cu_sec_idx (cu)];
6373e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath}
6383e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrath
63999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper/* Read up begin/end pair and increment read pointer.
64099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    - If it's normal range record, set up *BEGINP and *ENDP and return 0.
64199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    - If it's base address selection record, set up *BASEP and return 1.
64299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    - If it's end of rangelist, don't set anything and return 2
64399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper    - If an error occurs, don't set anything and return <0.  */
64499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperint __libdw_read_begin_end_pair_inc (Dwarf *dbg, int sec_index,
64599d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper				     unsigned char **addr, int width,
64699d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper				     Dwarf_Addr *beginp, Dwarf_Addr *endp,
64799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper				     Dwarf_Addr *basep)
64899d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  internal_function;
64999d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
65099d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepperunsigned char * __libdw_formptr (Dwarf_Attribute *attr, int sec_index,
65199d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper				 int err_nodata, unsigned char **endpp,
65299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper				 Dwarf_Off *offsetp)
65399d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper  internal_function;
65499d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
655f5519fc244d95dc04b3e3de88644d149a36a76b6Mark Wielaard#ifdef ENABLE_DWZ
656775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard/* Checks that the build_id of the underlying Elf matches the expected.
657775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard   Returns zero on match, -1 on error or no build_id found or 1 when
658775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard   build_id doesn't match.  */
659775375e3bd177cb19acb5020b6e0917551807276Mark Wielaardint __check_build_id (Dwarf *dw, const uint8_t *build_id, const size_t id_len)
660775375e3bd177cb19acb5020b6e0917551807276Mark Wielaard  internal_function;
661f5519fc244d95dc04b3e3de88644d149a36a76b6Mark Wielaard#endif /* ENABLE_DWZ */
66299d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
6633951f2ec0aaca021c77a2c7a464dcf43433261c3Mark Wielaard/* Fills in the given attribute to point at an empty location expression.  */
6643951f2ec0aaca021c77a2c7a464dcf43433261c3Mark Wielaardvoid __libdw_empty_loc_attr (Dwarf_Attribute *attr, struct Dwarf_CU *cu)
6653951f2ec0aaca021c77a2c7a464dcf43433261c3Mark Wielaard  internal_function;
6663951f2ec0aaca021c77a2c7a464dcf43433261c3Mark Wielaard
66799d2372b25d1231d786b70278478c7a112f2b27cUlrich Drepper
668b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper/* Aliases to avoid PLTs.  */
669ebc5c885e696cdc4961916113c50e1396d8d3d48Roland McGrathINTDECL (dwarf_aggregate_size)
670b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_attr)
671b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_attr_integrate)
672775375e3bd177cb19acb5020b6e0917551807276Mark WielaardINTDECL (dwarf_begin)
673b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_begin_elf)
674b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_child)
675b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_dieoffset)
67671e15a01742e5d5de9c6260d4526146be54e5a8aRoland McGrathINTDECL (dwarf_diename)
6774959bf89d92b59ba72bea5786d7b3f9b5564f750Roland McGrathINTDECL (dwarf_end)
67807d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathINTDECL (dwarf_entrypc)
6794959bf89d92b59ba72bea5786d7b3f9b5564f750Roland McGrathINTDECL (dwarf_errmsg)
680b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_formaddr)
681b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_formblock)
682b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_formref_die)
683b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_formsdata)
684b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_formstring)
685b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_formudata)
68635e2a765c002374f1b88dc81ce154bed42f9b1d8Florian WeimerINTDECL (dwarf_getalt)
687b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_getarange_addr)
688b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_getarangeinfo)
689b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_getaranges)
690b2535b6a6be7717cdd41834d76e5cb48cb446b83Mark WielaardINTDECL (dwarf_getlocation_die)
691b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_getsrcfiles)
692b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_getsrclines)
693b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_hasattr)
694b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_haschildren)
695b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_haspc)
696b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_highpc)
697b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_lowpc)
698b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_nextcu)
6993e0f7d1d1b817040cef82f41879f471ab59b663eRoland McGrathINTDECL (dwarf_next_unit)
700b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_offdie)
70107d4f2fc1cb53f170a71bc13617bbdd9cb1c3c60Roland McGrathINTDECL (dwarf_ranges)
70235e2a765c002374f1b88dc81ce154bed42f9b1d8Florian WeimerINTDECL (dwarf_setalt)
703b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_siblingof)
704ebc5c885e696cdc4961916113c50e1396d8d3d48Roland McGrathINTDECL (dwarf_srclang)
705b08d5a8fb42f4586d756068065186b5af7e48daUlrich DrepperINTDECL (dwarf_tag)
706b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper
707b08d5a8fb42f4586d756068065186b5af7e48daUlrich Drepper#endif	/* libdwP.h */
708