1 /*
2 
3   Copyright (C) 2014-2014 David Anderson. All Rights Reserved.
4 
5   This program is free software; you can redistribute it and/or modify it
6   under the terms of version 2.1 of the GNU Lesser General Public License
7   as published by the Free Software Foundation.
8 
9   This program is distributed in the hope that it would be useful, but
10   WITHOUT ANY WARRANTY; without even the implied warranty of
11   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 
13   Further, this software is distributed without any warranty that it is
14   free of the rightful claim of any third person regarding infringement
15   or the like.  Any license provided herein, whether implied or
16   otherwise, applies only to this software file.  Patent licenses, if
17   any, provided herein do not apply to combinations of this program with
18   other software, or any other product whatsoever.
19 
20   You should have received a copy of the GNU Lesser General Public
21   License along with this program; if not, write the Free Software
22   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
23   USA.
24 
25 
26 */
27 
28 
29 
30 /*  The following is based on
31     The gdb online documentation at
32     https://sourceware.org/gdb/onlinedocs/gdb/
33     Appendix J, ".gdb_index section format".
34 */
35 
36 
37 /*  These are the two types .gdb_index uses.
38     the offset_type (32 bits) and other fields
39     defined 64 bits.   We use our own Dwarf_Unsigned
40     for all the interfaces, these are just for reading
41     the section data.
42 
43     The section data is defined to be in little-endian regardless of
44     the target machine.
45     We use our host endianness in all interfaces.
46 
47     We simply assume unsigned int is 32 bits FIXME.
48 */
49 
50 typedef unsigned int gdbindex_offset_type;
51 typedef Dwarf_Unsigned gdbindex_64;
52 
53 enum gdbindex_type_e {
54    git_unknown,
55    git_std,
56    git_address,
57    git_cuvec
58 };
59 
60 struct Dwarf_Gdbindex_array_instance_s {
61     Dwarf_Small *  dg_base;
62     Dwarf_Unsigned dg_count;
63     /* the in_object struct size. */
64     Dwarf_Unsigned dg_entry_length;
65     /* The size of a single field in the in-object struct */
66     int            dg_fieldlen;
67     /* The address_area type is a bit irregular. */
68     enum gdbindex_type_e dg_type;
69 };
70 
71 struct Dwarf_Gdbindex_s {
72     Dwarf_Debug      gi_dbg;
73     Dwarf_Small    * gi_section_data;
74     Dwarf_Unsigned   gi_section_length;
75 
76     Dwarf_Unsigned   gi_version;
77     Dwarf_Unsigned   gi_cu_list_offset;
78     Dwarf_Unsigned   gi_types_cu_list_offset;
79     Dwarf_Unsigned   gi_address_area_offset;
80     Dwarf_Unsigned   gi_symbol_table_offset;
81     Dwarf_Unsigned   gi_constant_pool_offset;
82     struct Dwarf_Gdbindex_array_instance_s  gi_culisthdr;
83     struct Dwarf_Gdbindex_array_instance_s  gi_typesculisthdr;
84     struct Dwarf_Gdbindex_array_instance_s  gi_addressareahdr;
85     struct Dwarf_Gdbindex_array_instance_s  gi_symboltablehdr;
86     struct Dwarf_Gdbindex_array_instance_s  gi_cuvectorhdr;
87 
88     Dwarf_Small *    gi_string_pool;
89 };
90