rdwarf 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +28 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/ext/rdwarf/depend +5 -0
- data/ext/rdwarf/extconf.rb +29 -0
- data/ext/rdwarf/libdwarf/CHANGES +102 -0
- data/ext/rdwarf/libdwarf/CODINGSTYLE +71 -0
- data/ext/rdwarf/libdwarf/COPYING +28 -0
- data/ext/rdwarf/libdwarf/ChangeLog +619 -0
- data/ext/rdwarf/libdwarf/ChangeLog2006 +835 -0
- data/ext/rdwarf/libdwarf/ChangeLog2007 +217 -0
- data/ext/rdwarf/libdwarf/ChangeLog2008 +263 -0
- data/ext/rdwarf/libdwarf/ChangeLog2009 +348 -0
- data/ext/rdwarf/libdwarf/ChangeLog2010 +175 -0
- data/ext/rdwarf/libdwarf/ChangeLog2011 +297 -0
- data/ext/rdwarf/libdwarf/ChangeLog2012 +131 -0
- data/ext/rdwarf/libdwarf/ChangeLog2013 +238 -0
- data/ext/rdwarf/libdwarf/ChangeLog2014 +399 -0
- data/ext/rdwarf/libdwarf/LGPL.txt +504 -0
- data/ext/rdwarf/libdwarf/LIBDWARFCOPYRIGHT +40 -0
- data/ext/rdwarf/libdwarf/Makefile.in +220 -0
- data/ext/rdwarf/libdwarf/NEWS +535 -0
- data/ext/rdwarf/libdwarf/README +235 -0
- data/ext/rdwarf/libdwarf/checkexamples.c +1179 -0
- data/ext/rdwarf/libdwarf/cmplrs/dwarf_addr_finder.h +55 -0
- data/ext/rdwarf/libdwarf/common.c +62 -0
- data/ext/rdwarf/libdwarf/common.h +38 -0
- data/ext/rdwarf/libdwarf/config.h.in +146 -0
- data/ext/rdwarf/libdwarf/configure +5581 -0
- data/ext/rdwarf/libdwarf/configure.in +167 -0
- data/ext/rdwarf/libdwarf/dw-linetableheader.txt +39 -0
- data/ext/rdwarf/libdwarf/dwarf.h +1342 -0
- data/ext/rdwarf/libdwarf/dwarf_abbrev.c +291 -0
- data/ext/rdwarf/libdwarf/dwarf_abbrev.h +45 -0
- data/ext/rdwarf/libdwarf/dwarf_addr_finder.c +676 -0
- data/ext/rdwarf/libdwarf/dwarf_alloc.c +685 -0
- data/ext/rdwarf/libdwarf/dwarf_alloc.h +38 -0
- data/ext/rdwarf/libdwarf/dwarf_arange.c +595 -0
- data/ext/rdwarf/libdwarf/dwarf_arange.h +62 -0
- data/ext/rdwarf/libdwarf/dwarf_base_types.h +157 -0
- data/ext/rdwarf/libdwarf/dwarf_die_deliv.c +1802 -0
- data/ext/rdwarf/libdwarf/dwarf_die_deliv.h +46 -0
- data/ext/rdwarf/libdwarf/dwarf_elf_access.c +1348 -0
- data/ext/rdwarf/libdwarf/dwarf_elf_access.h +46 -0
- data/ext/rdwarf/libdwarf/dwarf_error.c +492 -0
- data/ext/rdwarf/libdwarf/dwarf_error.h +53 -0
- data/ext/rdwarf/libdwarf/dwarf_form.c +1302 -0
- data/ext/rdwarf/libdwarf/dwarf_frame.c +2454 -0
- data/ext/rdwarf/libdwarf/dwarf_frame.h +418 -0
- data/ext/rdwarf/libdwarf/dwarf_frame2.c +1533 -0
- data/ext/rdwarf/libdwarf/dwarf_frame3.c +282 -0
- data/ext/rdwarf/libdwarf/dwarf_funcs.c +123 -0
- data/ext/rdwarf/libdwarf/dwarf_funcs.h +33 -0
- data/ext/rdwarf/libdwarf/dwarf_gdbindex.c +520 -0
- data/ext/rdwarf/libdwarf/dwarf_gdbindex.h +97 -0
- data/ext/rdwarf/libdwarf/dwarf_global.c +612 -0
- data/ext/rdwarf/libdwarf/dwarf_global.h +117 -0
- data/ext/rdwarf/libdwarf/dwarf_harmless.c +228 -0
- data/ext/rdwarf/libdwarf/dwarf_harmless.h +31 -0
- data/ext/rdwarf/libdwarf/dwarf_incl.h +61 -0
- data/ext/rdwarf/libdwarf/dwarf_init_finish.c +1263 -0
- data/ext/rdwarf/libdwarf/dwarf_leb.c +159 -0
- data/ext/rdwarf/libdwarf/dwarf_line.c +1822 -0
- data/ext/rdwarf/libdwarf/dwarf_line.h +446 -0
- data/ext/rdwarf/libdwarf/dwarf_line2.c +98 -0
- data/ext/rdwarf/libdwarf/dwarf_line_table_reader_common.c +1583 -0
- data/ext/rdwarf/libdwarf/dwarf_loc.c +1525 -0
- data/ext/rdwarf/libdwarf/dwarf_loc.h +149 -0
- data/ext/rdwarf/libdwarf/dwarf_loc2.c +833 -0
- data/ext/rdwarf/libdwarf/dwarf_macro.c +479 -0
- data/ext/rdwarf/libdwarf/dwarf_macro.h +35 -0
- data/ext/rdwarf/libdwarf/dwarf_opaque.h +778 -0
- data/ext/rdwarf/libdwarf/dwarf_original_elf_init.c +219 -0
- data/ext/rdwarf/libdwarf/dwarf_print_lines.c +631 -0
- data/ext/rdwarf/libdwarf/dwarf_pubtypes.c +132 -0
- data/ext/rdwarf/libdwarf/dwarf_query.c +1594 -0
- data/ext/rdwarf/libdwarf/dwarf_ranges.c +194 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_arm.h +308 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_mips.h +117 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_ppc.h +242 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_ppc64.h +272 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_x86_64.h +127 -0
- data/ext/rdwarf/libdwarf/dwarf_sort_line.c +665 -0
- data/ext/rdwarf/libdwarf/dwarf_string.c +82 -0
- data/ext/rdwarf/libdwarf/dwarf_stubs.c +38 -0
- data/ext/rdwarf/libdwarf/dwarf_tied.c +423 -0
- data/ext/rdwarf/libdwarf/dwarf_tsearch.h +125 -0
- data/ext/rdwarf/libdwarf/dwarf_tsearchhash.c +675 -0
- data/ext/rdwarf/libdwarf/dwarf_types.c +121 -0
- data/ext/rdwarf/libdwarf/dwarf_types.h +32 -0
- data/ext/rdwarf/libdwarf/dwarf_util.c +913 -0
- data/ext/rdwarf/libdwarf/dwarf_util.h +324 -0
- data/ext/rdwarf/libdwarf/dwarf_vars.c +125 -0
- data/ext/rdwarf/libdwarf/dwarf_vars.h +29 -0
- data/ext/rdwarf/libdwarf/dwarf_weaks.c +123 -0
- data/ext/rdwarf/libdwarf/dwarf_weaks.h +29 -0
- data/ext/rdwarf/libdwarf/dwarf_xu_index.c +579 -0
- data/ext/rdwarf/libdwarf/dwarf_xu_index.h +68 -0
- data/ext/rdwarf/libdwarf/dwgetopt.c +181 -0
- data/ext/rdwarf/libdwarf/dwgetopt.h +51 -0
- data/ext/rdwarf/libdwarf/gennames.c +531 -0
- data/ext/rdwarf/libdwarf/install.sh +119 -0
- data/ext/rdwarf/libdwarf/libdwarf.h.in +3746 -0
- data/ext/rdwarf/libdwarf/libdwarf2.1.mm +9805 -0
- data/ext/rdwarf/libdwarf/libdwarf2.1.pdf +0 -0
- data/ext/rdwarf/libdwarf/libdwarf2p.1.mm +2807 -0
- data/ext/rdwarf/libdwarf/libdwarf2p.1.pdf +0 -0
- data/ext/rdwarf/libdwarf/libdwarfdefs.h +81 -0
- data/ext/rdwarf/libdwarf/malloc_check.c +327 -0
- data/ext/rdwarf/libdwarf/malloc_check.h +52 -0
- data/ext/rdwarf/libdwarf/mips_extensions.mm +1266 -0
- data/ext/rdwarf/libdwarf/mips_extensions.pdf +0 -0
- data/ext/rdwarf/libdwarf/pro_alloc.c +179 -0
- data/ext/rdwarf/libdwarf/pro_alloc.h +33 -0
- data/ext/rdwarf/libdwarf/pro_arange.c +310 -0
- data/ext/rdwarf/libdwarf/pro_arange.h +51 -0
- data/ext/rdwarf/libdwarf/pro_die.c +431 -0
- data/ext/rdwarf/libdwarf/pro_die.h +59 -0
- data/ext/rdwarf/libdwarf/pro_encode_nm.c +108 -0
- data/ext/rdwarf/libdwarf/pro_encode_nm.h +39 -0
- data/ext/rdwarf/libdwarf/pro_error.c +96 -0
- data/ext/rdwarf/libdwarf/pro_error.h +43 -0
- data/ext/rdwarf/libdwarf/pro_expr.c +575 -0
- data/ext/rdwarf/libdwarf/pro_expr.h +36 -0
- data/ext/rdwarf/libdwarf/pro_finish.c +45 -0
- data/ext/rdwarf/libdwarf/pro_forms.c +1271 -0
- data/ext/rdwarf/libdwarf/pro_frame.c +572 -0
- data/ext/rdwarf/libdwarf/pro_frame.h +120 -0
- data/ext/rdwarf/libdwarf/pro_funcs.c +50 -0
- data/ext/rdwarf/libdwarf/pro_incl.h +91 -0
- data/ext/rdwarf/libdwarf/pro_init.c +327 -0
- data/ext/rdwarf/libdwarf/pro_line.c +373 -0
- data/ext/rdwarf/libdwarf/pro_line.h +112 -0
- data/ext/rdwarf/libdwarf/pro_macinfo.c +457 -0
- data/ext/rdwarf/libdwarf/pro_macinfo.h +31 -0
- data/ext/rdwarf/libdwarf/pro_opaque.h +513 -0
- data/ext/rdwarf/libdwarf/pro_pubnames.c +60 -0
- data/ext/rdwarf/libdwarf/pro_reloc.c +253 -0
- data/ext/rdwarf/libdwarf/pro_reloc.h +38 -0
- data/ext/rdwarf/libdwarf/pro_reloc_stream.c +256 -0
- data/ext/rdwarf/libdwarf/pro_reloc_stream.h +52 -0
- data/ext/rdwarf/libdwarf/pro_reloc_symbolic.c +245 -0
- data/ext/rdwarf/libdwarf/pro_reloc_symbolic.h +45 -0
- data/ext/rdwarf/libdwarf/pro_section.c +2233 -0
- data/ext/rdwarf/libdwarf/pro_section.h +100 -0
- data/ext/rdwarf/libdwarf/pro_types.c +274 -0
- data/ext/rdwarf/libdwarf/pro_types.h +34 -0
- data/ext/rdwarf/libdwarf/pro_util.h +38 -0
- data/ext/rdwarf/libdwarf/pro_vars.c +52 -0
- data/ext/rdwarf/libdwarf/pro_weaks.c +51 -0
- data/ext/rdwarf/rdwarf.c +765 -0
- data/ext/rdwarf/rdwarf.h +52 -0
- data/ext/rdwarf/rdwarf_names_gen.rb +109 -0
- data/lib/rdwarf.rb +181 -0
- data/lib/rdwarf/version.rb +3 -0
- data/rdwarf.gemspec +30 -0
- metadata +251 -0
|
Binary file
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
|
4
|
+
Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
|
|
5
|
+
Portions Copyright 2011 David Anderson. All Rights Reserved.
|
|
6
|
+
|
|
7
|
+
This program is free software; you can redistribute it and/or modify it
|
|
8
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
|
9
|
+
as published by the Free Software Foundation.
|
|
10
|
+
|
|
11
|
+
This program is distributed in the hope that it would be useful, but
|
|
12
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
14
|
+
|
|
15
|
+
Further, this software is distributed without any warranty that it is
|
|
16
|
+
free of the rightful claim of any third person regarding infringement
|
|
17
|
+
or the like. Any license provided herein, whether implied or
|
|
18
|
+
otherwise, applies only to this software file. Patent licenses, if
|
|
19
|
+
any, provided herein do not apply to combinations of this program with
|
|
20
|
+
other software, or any other product whatsoever.
|
|
21
|
+
|
|
22
|
+
You should have received a copy of the GNU Lesser General Public
|
|
23
|
+
License along with this program; if not, write the Free Software
|
|
24
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
|
25
|
+
USA.
|
|
26
|
+
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
#include "config.h"
|
|
30
|
+
#include "pro_incl.h"
|
|
31
|
+
#include "pro_alloc.h"
|
|
32
|
+
#ifdef HAVE_STDLIB_H
|
|
33
|
+
#include <stdlib.h>
|
|
34
|
+
#else
|
|
35
|
+
#include <malloc.h>
|
|
36
|
+
#endif /* HAVE_STDLIB_H */
|
|
37
|
+
#ifdef HAVE_STRING_H
|
|
38
|
+
#include <string.h>
|
|
39
|
+
#endif /* HAVE_STRING_H */
|
|
40
|
+
|
|
41
|
+
/* When each block is allocated, there is a two-word structure
|
|
42
|
+
allocated at the beginning so the block can go on a list.
|
|
43
|
+
The address returned is the address *after* the two pointers
|
|
44
|
+
at the start. But this allows us to be given a pointer to
|
|
45
|
+
a generic block, and go backwards to find the list-node. Then
|
|
46
|
+
we can remove this block from it's list without the need to search
|
|
47
|
+
through a linked list in order to remove the node. It also allows
|
|
48
|
+
us to 'delete' a memory block without needing the dbg structure.
|
|
49
|
+
We still need the dbg structure on allocation so that we know which
|
|
50
|
+
linked list to add the block to.
|
|
51
|
+
|
|
52
|
+
Only the allocation of the dbg structure itself cannot use
|
|
53
|
+
_dwarf_p_get_alloc.
|
|
54
|
+
That structure should be set up by hand, and the two list pointers
|
|
55
|
+
should be initialized to point at the node itself. That initializes
|
|
56
|
+
the doubly linked list. */
|
|
57
|
+
|
|
58
|
+
#define LIST_TO_BLOCK(lst) ((void*) (((char *)lst) + sizeof(memory_list_t)))
|
|
59
|
+
#define BLOCK_TO_LIST(blk) ((memory_list_t*) (((char*)blk) - sizeof(memory_list_t)))
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
/*
|
|
63
|
+
dbg should be NULL only when allocating dbg itself. In that
|
|
64
|
+
case we initialize it to an empty circular doubly-linked list.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
Dwarf_Ptr
|
|
68
|
+
_dwarf_p_get_alloc(Dwarf_P_Debug dbg, Dwarf_Unsigned size)
|
|
69
|
+
{
|
|
70
|
+
void *sp;
|
|
71
|
+
memory_list_t *lp = NULL;
|
|
72
|
+
memory_list_t *dbglp = NULL;
|
|
73
|
+
memory_list_t *nextblock = NULL;
|
|
74
|
+
|
|
75
|
+
/* alloc control struct and data block together for performance reasons */
|
|
76
|
+
lp = (memory_list_t *) malloc(size + sizeof(memory_list_t));
|
|
77
|
+
if (lp == NULL) {
|
|
78
|
+
/* should throw an error */
|
|
79
|
+
return NULL;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/* point to 'size' bytes just beyond lp struct */
|
|
83
|
+
sp = LIST_TO_BLOCK(lp);
|
|
84
|
+
memset(sp, 0, size);
|
|
85
|
+
|
|
86
|
+
if (dbg == NULL) {
|
|
87
|
+
lp->next = lp->prev = lp;
|
|
88
|
+
} else {
|
|
89
|
+
/* I always have to draw a picture to understand this part. */
|
|
90
|
+
|
|
91
|
+
dbglp = BLOCK_TO_LIST(dbg);
|
|
92
|
+
nextblock = dbglp->next;
|
|
93
|
+
|
|
94
|
+
/* Insert between dbglp and nextblock */
|
|
95
|
+
dbglp->next = lp;
|
|
96
|
+
lp->prev = dbglp;
|
|
97
|
+
lp->next = nextblock;
|
|
98
|
+
nextblock->prev = lp;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return sp;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/*
|
|
105
|
+
This routine is only here in case a caller of an older version of the
|
|
106
|
+
library is calling this for some reason.
|
|
107
|
+
We will clean up any stray blocks when the session is closed.
|
|
108
|
+
No need to remove this block. In theory the user might be
|
|
109
|
+
depending on the fact that we used to just 'free' this.
|
|
110
|
+
In theory they might also be
|
|
111
|
+
passing a block that they got from libdwarf. So we don't know if we
|
|
112
|
+
should try to remove this block from our global list. Safest just to
|
|
113
|
+
do nothing at this point.
|
|
114
|
+
|
|
115
|
+
!!!
|
|
116
|
+
This function is deprecated! Don't call it inside libdwarf or outside of it.
|
|
117
|
+
!!!
|
|
118
|
+
*/
|
|
119
|
+
|
|
120
|
+
void
|
|
121
|
+
dwarf_p_dealloc(Dwarf_Small * ptr)
|
|
122
|
+
{
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/*
|
|
127
|
+
The dbg structure is not needed here anymore.
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
void
|
|
131
|
+
_dwarf_p_dealloc(Dwarf_P_Debug dbg, Dwarf_Small * ptr) /* ARGSUSED */
|
|
132
|
+
{
|
|
133
|
+
memory_list_t *lp;
|
|
134
|
+
lp = BLOCK_TO_LIST(ptr);
|
|
135
|
+
|
|
136
|
+
/*
|
|
137
|
+
Remove from a doubly linked, circular list.
|
|
138
|
+
Read carefully, use a white board if necessary.
|
|
139
|
+
If this is an empty list, the following statements are no-ops, and
|
|
140
|
+
will write to the same memory location they read from.
|
|
141
|
+
This should only happen when we deallocate the dbg structure itself.
|
|
142
|
+
*/
|
|
143
|
+
|
|
144
|
+
lp->prev->next = lp->next;
|
|
145
|
+
lp->next->prev = lp->prev;
|
|
146
|
+
|
|
147
|
+
free((void*)lp);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
/*
|
|
152
|
+
This routine deallocates all the nodes on the dbg list,
|
|
153
|
+
and then deallocates the dbg structure itself.
|
|
154
|
+
*/
|
|
155
|
+
|
|
156
|
+
void
|
|
157
|
+
_dwarf_p_dealloc_all(Dwarf_P_Debug dbg)
|
|
158
|
+
{
|
|
159
|
+
memory_list_t *dbglp;
|
|
160
|
+
|
|
161
|
+
if (dbg == NULL) {
|
|
162
|
+
/* should throw an error */
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
dbglp = BLOCK_TO_LIST(dbg);
|
|
167
|
+
while (dbglp->next != dbglp) {
|
|
168
|
+
_dwarf_p_dealloc(dbg, LIST_TO_BLOCK(dbglp->next));
|
|
169
|
+
}
|
|
170
|
+
if (dbglp->next != dbglp ||
|
|
171
|
+
dbglp->prev != dbglp) {
|
|
172
|
+
|
|
173
|
+
/* should throw error */
|
|
174
|
+
/* For some reason we couldn't free all the blocks? */
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
_dwarf_p_dealloc(NULL, (void*)dbg);
|
|
178
|
+
}
|
|
179
|
+
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. 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
|
+
Dwarf_Ptr _dwarf_p_get_alloc(Dwarf_P_Debug, Dwarf_Unsigned);
|
|
30
|
+
|
|
31
|
+
void _dwarf_p_dealloc(Dwarf_P_Debug dbg, Dwarf_Small * ptr);
|
|
32
|
+
|
|
33
|
+
void _dwarf_p_dealloc_all(Dwarf_P_Debug dbg);
|
|
@@ -0,0 +1,310 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
|
4
|
+
Portions Copyright 2011 David Anderson. All Rights Reserved.
|
|
5
|
+
|
|
6
|
+
This program is free software; you can redistribute it and/or modify it
|
|
7
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
|
8
|
+
as published by the Free Software Foundation.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it would be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
|
|
14
|
+
Further, this software is distributed without any warranty that it is
|
|
15
|
+
free of the rightful claim of any third person regarding infringement
|
|
16
|
+
or the like. Any license provided herein, whether implied or
|
|
17
|
+
otherwise, applies only to this software file. Patent licenses, if
|
|
18
|
+
any, provided herein do not apply to combinations of this program with
|
|
19
|
+
other software, or any other product whatsoever.
|
|
20
|
+
|
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
|
22
|
+
License along with this program; if not, write the Free Software
|
|
23
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
|
24
|
+
USA.
|
|
25
|
+
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#include "config.h"
|
|
29
|
+
#include "libdwarfdefs.h"
|
|
30
|
+
#include <stdio.h>
|
|
31
|
+
#include <string.h>
|
|
32
|
+
#ifdef HAVE_ELFACCESS_H
|
|
33
|
+
#include <elfaccess.h>
|
|
34
|
+
#endif
|
|
35
|
+
#include "pro_incl.h"
|
|
36
|
+
#include "pro_arange.h"
|
|
37
|
+
#include "pro_section.h"
|
|
38
|
+
#include "pro_reloc.h"
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
/* This function adds another address range
|
|
43
|
+
to the list of address ranges for the
|
|
44
|
+
given Dwarf_P_Debug. It returns 0 on error,
|
|
45
|
+
and 1 otherwise. */
|
|
46
|
+
Dwarf_Unsigned
|
|
47
|
+
dwarf_add_arange(Dwarf_P_Debug dbg,
|
|
48
|
+
Dwarf_Addr begin_address,
|
|
49
|
+
Dwarf_Unsigned length,
|
|
50
|
+
Dwarf_Signed symbol_index, Dwarf_Error * error)
|
|
51
|
+
{
|
|
52
|
+
return dwarf_add_arange_b(dbg, begin_address, length, symbol_index,
|
|
53
|
+
/* end_symbol_index */ 0,
|
|
54
|
+
/* offset_from_end_sym */ 0,
|
|
55
|
+
error);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/* This function adds another address range
|
|
59
|
+
to the list of address ranges for the
|
|
60
|
+
given Dwarf_P_Debug. It returns 0 on error,
|
|
61
|
+
and 1 otherwise. */
|
|
62
|
+
Dwarf_Unsigned
|
|
63
|
+
dwarf_add_arange_b(Dwarf_P_Debug dbg,
|
|
64
|
+
Dwarf_Addr begin_address,
|
|
65
|
+
Dwarf_Unsigned length,
|
|
66
|
+
Dwarf_Unsigned symbol_index,
|
|
67
|
+
Dwarf_Unsigned end_symbol_index,
|
|
68
|
+
Dwarf_Addr offset_from_end_sym, Dwarf_Error * error)
|
|
69
|
+
{
|
|
70
|
+
Dwarf_P_Arange arange;
|
|
71
|
+
|
|
72
|
+
if (dbg == NULL) {
|
|
73
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
|
74
|
+
return (0);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
arange = (Dwarf_P_Arange)
|
|
78
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Arange_s));
|
|
79
|
+
if (arange == NULL) {
|
|
80
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
81
|
+
return (0);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
arange->ag_begin_address = begin_address;
|
|
85
|
+
arange->ag_length = length;
|
|
86
|
+
arange->ag_symbol_index = symbol_index;
|
|
87
|
+
arange->ag_end_symbol_index = end_symbol_index;
|
|
88
|
+
arange->ag_end_symbol_offset = offset_from_end_sym;
|
|
89
|
+
|
|
90
|
+
if (dbg->de_arange == NULL)
|
|
91
|
+
dbg->de_arange = dbg->de_last_arange = arange;
|
|
92
|
+
else {
|
|
93
|
+
dbg->de_last_arange->ag_next = arange;
|
|
94
|
+
dbg->de_last_arange = arange;
|
|
95
|
+
}
|
|
96
|
+
dbg->de_arange_count++;
|
|
97
|
+
|
|
98
|
+
return (1);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
int
|
|
103
|
+
_dwarf_transform_arange_to_disk(Dwarf_P_Debug dbg, Dwarf_Error * error)
|
|
104
|
+
{
|
|
105
|
+
/* Total num of bytes in .debug_aranges section. */
|
|
106
|
+
Dwarf_Unsigned arange_num_bytes = 0;
|
|
107
|
+
|
|
108
|
+
/* Adjustment to align the start of the actual address ranges on a
|
|
109
|
+
boundary aligned with twice the address size. */
|
|
110
|
+
Dwarf_Small remainder = 0;
|
|
111
|
+
|
|
112
|
+
/* Total number of bytes excluding the length field. */
|
|
113
|
+
Dwarf_Unsigned adjusted_length = 0;
|
|
114
|
+
|
|
115
|
+
/* Points to first byte of .debug_aranges buffer. */
|
|
116
|
+
Dwarf_Small *arange = 0;
|
|
117
|
+
|
|
118
|
+
/* Fills in the .debug_aranges buffer. */
|
|
119
|
+
Dwarf_Small *arange_ptr = 0;
|
|
120
|
+
|
|
121
|
+
/* Scans the list of address ranges provided by user. */
|
|
122
|
+
Dwarf_P_Arange given_arange = 0;
|
|
123
|
+
|
|
124
|
+
/* Used to fill in 0. */
|
|
125
|
+
const Dwarf_Signed big_zero = 0;
|
|
126
|
+
|
|
127
|
+
int extension_word_size = dbg->de_64bit_extension ? 4 : 0;
|
|
128
|
+
int uword_size = dbg->de_offset_size;
|
|
129
|
+
int upointer_size = dbg->de_pointer_size;
|
|
130
|
+
int res = 0;
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
/* ***** BEGIN CODE ***** */
|
|
134
|
+
|
|
135
|
+
/* Size of the .debug_aranges section header. */
|
|
136
|
+
arange_num_bytes = extension_word_size +
|
|
137
|
+
uword_size + /* Size of length field. */
|
|
138
|
+
sizeof(Dwarf_Half) + /* Size of version field. */
|
|
139
|
+
uword_size + /* Size of .debug_info offset. */
|
|
140
|
+
sizeof(Dwarf_Small) + /* Size of address size field. */
|
|
141
|
+
sizeof(Dwarf_Small); /* Size of segment size field. */
|
|
142
|
+
|
|
143
|
+
/* Adjust the size so that the set of aranges begins on a boundary
|
|
144
|
+
that aligned with twice the address size. This is a Libdwarf
|
|
145
|
+
requirement. */
|
|
146
|
+
remainder = arange_num_bytes % (2 * upointer_size);
|
|
147
|
+
if (remainder != 0)
|
|
148
|
+
arange_num_bytes += (2 * upointer_size) - remainder;
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
/* Add the bytes for the actual address ranges. */
|
|
152
|
+
arange_num_bytes += upointer_size * 2 * (dbg->de_arange_count + 1);
|
|
153
|
+
|
|
154
|
+
GET_CHUNK(dbg, dbg->de_elf_sects[DEBUG_ARANGES],
|
|
155
|
+
arange, (unsigned long) arange_num_bytes, error);
|
|
156
|
+
arange_ptr = arange;
|
|
157
|
+
if (arange == NULL) {
|
|
158
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
159
|
+
return (0);
|
|
160
|
+
}
|
|
161
|
+
if (extension_word_size) {
|
|
162
|
+
Dwarf_Word x = DISTINGUISHED_VALUE;
|
|
163
|
+
|
|
164
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
165
|
+
(const void *) &x,
|
|
166
|
+
sizeof(x), extension_word_size);
|
|
167
|
+
arange_ptr += extension_word_size;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/* Write the total length of .debug_aranges section. */
|
|
171
|
+
adjusted_length = arange_num_bytes - uword_size
|
|
172
|
+
- extension_word_size;
|
|
173
|
+
{
|
|
174
|
+
Dwarf_Unsigned du = adjusted_length;
|
|
175
|
+
|
|
176
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
177
|
+
(const void *) &du, sizeof(du), uword_size);
|
|
178
|
+
arange_ptr += uword_size;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
/* Write the version as 2 bytes. */
|
|
182
|
+
{
|
|
183
|
+
Dwarf_Half verstamp = CURRENT_VERSION_STAMP;
|
|
184
|
+
|
|
185
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
186
|
+
(const void *) &verstamp,
|
|
187
|
+
sizeof(verstamp), sizeof(Dwarf_Half));
|
|
188
|
+
arange_ptr += sizeof(Dwarf_Half);
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
/* Write the .debug_info offset. This is always 0. */
|
|
193
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
194
|
+
(const void *) &big_zero,
|
|
195
|
+
sizeof(big_zero), uword_size);
|
|
196
|
+
arange_ptr += uword_size;
|
|
197
|
+
|
|
198
|
+
{
|
|
199
|
+
unsigned long count = dbg->de_arange_count + 1;
|
|
200
|
+
int res2 = 0;
|
|
201
|
+
|
|
202
|
+
if (dbg->de_reloc_pair) {
|
|
203
|
+
count = (3 * dbg->de_arange_count) + 1;
|
|
204
|
+
}
|
|
205
|
+
/* The following is a small optimization: not needed for
|
|
206
|
+
correctness */
|
|
207
|
+
res2 = _dwarf_pro_pre_alloc_n_reloc_slots(dbg,
|
|
208
|
+
DEBUG_ARANGES, count);
|
|
209
|
+
if (res2 != DW_DLV_OK) {
|
|
210
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
211
|
+
return (0);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
/* reloc for .debug_info */
|
|
216
|
+
res = dbg->de_reloc_name(dbg,
|
|
217
|
+
DEBUG_ARANGES,
|
|
218
|
+
extension_word_size +
|
|
219
|
+
uword_size + sizeof(Dwarf_Half),
|
|
220
|
+
dbg->de_sect_name_idx[DEBUG_INFO],
|
|
221
|
+
dwarf_drt_data_reloc, uword_size);
|
|
222
|
+
|
|
223
|
+
/* Write the size of addresses. */
|
|
224
|
+
*arange_ptr = dbg->de_pointer_size;
|
|
225
|
+
arange_ptr++;
|
|
226
|
+
|
|
227
|
+
/* Write the size of segment addresses. This is zero for MIPS
|
|
228
|
+
architectures. */
|
|
229
|
+
*arange_ptr = 0;
|
|
230
|
+
arange_ptr++;
|
|
231
|
+
|
|
232
|
+
/* Skip over the padding to align the start of the actual address
|
|
233
|
+
ranges to twice the address size. */
|
|
234
|
+
if (remainder != 0)
|
|
235
|
+
arange_ptr += (2 * upointer_size) - remainder;
|
|
236
|
+
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
|
|
240
|
+
|
|
241
|
+
/* The arange address, length are pointer-size fields of the target
|
|
242
|
+
machine. */
|
|
243
|
+
for (given_arange = dbg->de_arange; given_arange != NULL;
|
|
244
|
+
given_arange = given_arange->ag_next) {
|
|
245
|
+
|
|
246
|
+
/* Write relocation record for beginning of address range. */
|
|
247
|
+
res = dbg->de_reloc_name(dbg, DEBUG_ARANGES,
|
|
248
|
+
arange_ptr - arange, /* r_offset */
|
|
249
|
+
(long) given_arange->ag_symbol_index,
|
|
250
|
+
dwarf_drt_data_reloc, upointer_size);
|
|
251
|
+
if (res != DW_DLV_OK) {
|
|
252
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
253
|
+
return (0);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/* Copy beginning address of range. */
|
|
257
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
258
|
+
(const void *) &given_arange->ag_begin_address,
|
|
259
|
+
sizeof(given_arange->ag_begin_address),
|
|
260
|
+
upointer_size);
|
|
261
|
+
arange_ptr += upointer_size;
|
|
262
|
+
|
|
263
|
+
if (dbg->de_reloc_pair &&
|
|
264
|
+
given_arange->ag_end_symbol_index != 0 &&
|
|
265
|
+
given_arange->ag_length == 0) {
|
|
266
|
+
/* symbolic reloc, need reloc for length What if we really
|
|
267
|
+
know the length? If so, should use the other part of
|
|
268
|
+
'if'. */
|
|
269
|
+
Dwarf_Unsigned val;
|
|
270
|
+
|
|
271
|
+
res = dbg->de_reloc_pair(dbg, DEBUG_ARANGES,
|
|
272
|
+
arange_ptr - arange, /* r_offset */
|
|
273
|
+
given_arange->ag_symbol_index,
|
|
274
|
+
given_arange->ag_end_symbol_index,
|
|
275
|
+
dwarf_drt_first_of_length_pair,
|
|
276
|
+
upointer_size);
|
|
277
|
+
if (res != DW_DLV_OK) {
|
|
278
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
279
|
+
return (0);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/* arange pre-calc so assem text can do .word end - begin
|
|
283
|
+
+ val (gets val from stream) */
|
|
284
|
+
val = given_arange->ag_end_symbol_offset -
|
|
285
|
+
given_arange->ag_begin_address;
|
|
286
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
287
|
+
(const void *) &val,
|
|
288
|
+
sizeof(val), upointer_size);
|
|
289
|
+
arange_ptr += upointer_size;
|
|
290
|
+
|
|
291
|
+
} else {
|
|
292
|
+
/* plain old length to copy, no relocation at all */
|
|
293
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
294
|
+
(const void *) &given_arange->ag_length,
|
|
295
|
+
sizeof(given_arange->ag_length),
|
|
296
|
+
upointer_size);
|
|
297
|
+
arange_ptr += upointer_size;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
302
|
+
(const void *) &big_zero,
|
|
303
|
+
sizeof(big_zero), upointer_size);
|
|
304
|
+
|
|
305
|
+
arange_ptr += upointer_size;
|
|
306
|
+
WRITE_UNALIGNED(dbg, (void *) arange_ptr,
|
|
307
|
+
(const void *) &big_zero,
|
|
308
|
+
sizeof(big_zero), upointer_size);
|
|
309
|
+
return (int) dbg->de_n_debug_sect;
|
|
310
|
+
}
|