rdwarf 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (163) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.travis.yml +4 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +28 -0
  6. data/README.md +39 -0
  7. data/Rakefile +8 -0
  8. data/bin/console +14 -0
  9. data/bin/setup +7 -0
  10. data/ext/rdwarf/depend +5 -0
  11. data/ext/rdwarf/extconf.rb +29 -0
  12. data/ext/rdwarf/libdwarf/CHANGES +102 -0
  13. data/ext/rdwarf/libdwarf/CODINGSTYLE +71 -0
  14. data/ext/rdwarf/libdwarf/COPYING +28 -0
  15. data/ext/rdwarf/libdwarf/ChangeLog +619 -0
  16. data/ext/rdwarf/libdwarf/ChangeLog2006 +835 -0
  17. data/ext/rdwarf/libdwarf/ChangeLog2007 +217 -0
  18. data/ext/rdwarf/libdwarf/ChangeLog2008 +263 -0
  19. data/ext/rdwarf/libdwarf/ChangeLog2009 +348 -0
  20. data/ext/rdwarf/libdwarf/ChangeLog2010 +175 -0
  21. data/ext/rdwarf/libdwarf/ChangeLog2011 +297 -0
  22. data/ext/rdwarf/libdwarf/ChangeLog2012 +131 -0
  23. data/ext/rdwarf/libdwarf/ChangeLog2013 +238 -0
  24. data/ext/rdwarf/libdwarf/ChangeLog2014 +399 -0
  25. data/ext/rdwarf/libdwarf/LGPL.txt +504 -0
  26. data/ext/rdwarf/libdwarf/LIBDWARFCOPYRIGHT +40 -0
  27. data/ext/rdwarf/libdwarf/Makefile.in +220 -0
  28. data/ext/rdwarf/libdwarf/NEWS +535 -0
  29. data/ext/rdwarf/libdwarf/README +235 -0
  30. data/ext/rdwarf/libdwarf/checkexamples.c +1179 -0
  31. data/ext/rdwarf/libdwarf/cmplrs/dwarf_addr_finder.h +55 -0
  32. data/ext/rdwarf/libdwarf/common.c +62 -0
  33. data/ext/rdwarf/libdwarf/common.h +38 -0
  34. data/ext/rdwarf/libdwarf/config.h.in +146 -0
  35. data/ext/rdwarf/libdwarf/configure +5581 -0
  36. data/ext/rdwarf/libdwarf/configure.in +167 -0
  37. data/ext/rdwarf/libdwarf/dw-linetableheader.txt +39 -0
  38. data/ext/rdwarf/libdwarf/dwarf.h +1342 -0
  39. data/ext/rdwarf/libdwarf/dwarf_abbrev.c +291 -0
  40. data/ext/rdwarf/libdwarf/dwarf_abbrev.h +45 -0
  41. data/ext/rdwarf/libdwarf/dwarf_addr_finder.c +676 -0
  42. data/ext/rdwarf/libdwarf/dwarf_alloc.c +685 -0
  43. data/ext/rdwarf/libdwarf/dwarf_alloc.h +38 -0
  44. data/ext/rdwarf/libdwarf/dwarf_arange.c +595 -0
  45. data/ext/rdwarf/libdwarf/dwarf_arange.h +62 -0
  46. data/ext/rdwarf/libdwarf/dwarf_base_types.h +157 -0
  47. data/ext/rdwarf/libdwarf/dwarf_die_deliv.c +1802 -0
  48. data/ext/rdwarf/libdwarf/dwarf_die_deliv.h +46 -0
  49. data/ext/rdwarf/libdwarf/dwarf_elf_access.c +1348 -0
  50. data/ext/rdwarf/libdwarf/dwarf_elf_access.h +46 -0
  51. data/ext/rdwarf/libdwarf/dwarf_error.c +492 -0
  52. data/ext/rdwarf/libdwarf/dwarf_error.h +53 -0
  53. data/ext/rdwarf/libdwarf/dwarf_form.c +1302 -0
  54. data/ext/rdwarf/libdwarf/dwarf_frame.c +2454 -0
  55. data/ext/rdwarf/libdwarf/dwarf_frame.h +418 -0
  56. data/ext/rdwarf/libdwarf/dwarf_frame2.c +1533 -0
  57. data/ext/rdwarf/libdwarf/dwarf_frame3.c +282 -0
  58. data/ext/rdwarf/libdwarf/dwarf_funcs.c +123 -0
  59. data/ext/rdwarf/libdwarf/dwarf_funcs.h +33 -0
  60. data/ext/rdwarf/libdwarf/dwarf_gdbindex.c +520 -0
  61. data/ext/rdwarf/libdwarf/dwarf_gdbindex.h +97 -0
  62. data/ext/rdwarf/libdwarf/dwarf_global.c +612 -0
  63. data/ext/rdwarf/libdwarf/dwarf_global.h +117 -0
  64. data/ext/rdwarf/libdwarf/dwarf_harmless.c +228 -0
  65. data/ext/rdwarf/libdwarf/dwarf_harmless.h +31 -0
  66. data/ext/rdwarf/libdwarf/dwarf_incl.h +61 -0
  67. data/ext/rdwarf/libdwarf/dwarf_init_finish.c +1263 -0
  68. data/ext/rdwarf/libdwarf/dwarf_leb.c +159 -0
  69. data/ext/rdwarf/libdwarf/dwarf_line.c +1822 -0
  70. data/ext/rdwarf/libdwarf/dwarf_line.h +446 -0
  71. data/ext/rdwarf/libdwarf/dwarf_line2.c +98 -0
  72. data/ext/rdwarf/libdwarf/dwarf_line_table_reader_common.c +1583 -0
  73. data/ext/rdwarf/libdwarf/dwarf_loc.c +1525 -0
  74. data/ext/rdwarf/libdwarf/dwarf_loc.h +149 -0
  75. data/ext/rdwarf/libdwarf/dwarf_loc2.c +833 -0
  76. data/ext/rdwarf/libdwarf/dwarf_macro.c +479 -0
  77. data/ext/rdwarf/libdwarf/dwarf_macro.h +35 -0
  78. data/ext/rdwarf/libdwarf/dwarf_opaque.h +778 -0
  79. data/ext/rdwarf/libdwarf/dwarf_original_elf_init.c +219 -0
  80. data/ext/rdwarf/libdwarf/dwarf_print_lines.c +631 -0
  81. data/ext/rdwarf/libdwarf/dwarf_pubtypes.c +132 -0
  82. data/ext/rdwarf/libdwarf/dwarf_query.c +1594 -0
  83. data/ext/rdwarf/libdwarf/dwarf_ranges.c +194 -0
  84. data/ext/rdwarf/libdwarf/dwarf_reloc_arm.h +308 -0
  85. data/ext/rdwarf/libdwarf/dwarf_reloc_mips.h +117 -0
  86. data/ext/rdwarf/libdwarf/dwarf_reloc_ppc.h +242 -0
  87. data/ext/rdwarf/libdwarf/dwarf_reloc_ppc64.h +272 -0
  88. data/ext/rdwarf/libdwarf/dwarf_reloc_x86_64.h +127 -0
  89. data/ext/rdwarf/libdwarf/dwarf_sort_line.c +665 -0
  90. data/ext/rdwarf/libdwarf/dwarf_string.c +82 -0
  91. data/ext/rdwarf/libdwarf/dwarf_stubs.c +38 -0
  92. data/ext/rdwarf/libdwarf/dwarf_tied.c +423 -0
  93. data/ext/rdwarf/libdwarf/dwarf_tsearch.h +125 -0
  94. data/ext/rdwarf/libdwarf/dwarf_tsearchhash.c +675 -0
  95. data/ext/rdwarf/libdwarf/dwarf_types.c +121 -0
  96. data/ext/rdwarf/libdwarf/dwarf_types.h +32 -0
  97. data/ext/rdwarf/libdwarf/dwarf_util.c +913 -0
  98. data/ext/rdwarf/libdwarf/dwarf_util.h +324 -0
  99. data/ext/rdwarf/libdwarf/dwarf_vars.c +125 -0
  100. data/ext/rdwarf/libdwarf/dwarf_vars.h +29 -0
  101. data/ext/rdwarf/libdwarf/dwarf_weaks.c +123 -0
  102. data/ext/rdwarf/libdwarf/dwarf_weaks.h +29 -0
  103. data/ext/rdwarf/libdwarf/dwarf_xu_index.c +579 -0
  104. data/ext/rdwarf/libdwarf/dwarf_xu_index.h +68 -0
  105. data/ext/rdwarf/libdwarf/dwgetopt.c +181 -0
  106. data/ext/rdwarf/libdwarf/dwgetopt.h +51 -0
  107. data/ext/rdwarf/libdwarf/gennames.c +531 -0
  108. data/ext/rdwarf/libdwarf/install.sh +119 -0
  109. data/ext/rdwarf/libdwarf/libdwarf.h.in +3746 -0
  110. data/ext/rdwarf/libdwarf/libdwarf2.1.mm +9805 -0
  111. data/ext/rdwarf/libdwarf/libdwarf2.1.pdf +0 -0
  112. data/ext/rdwarf/libdwarf/libdwarf2p.1.mm +2807 -0
  113. data/ext/rdwarf/libdwarf/libdwarf2p.1.pdf +0 -0
  114. data/ext/rdwarf/libdwarf/libdwarfdefs.h +81 -0
  115. data/ext/rdwarf/libdwarf/malloc_check.c +327 -0
  116. data/ext/rdwarf/libdwarf/malloc_check.h +52 -0
  117. data/ext/rdwarf/libdwarf/mips_extensions.mm +1266 -0
  118. data/ext/rdwarf/libdwarf/mips_extensions.pdf +0 -0
  119. data/ext/rdwarf/libdwarf/pro_alloc.c +179 -0
  120. data/ext/rdwarf/libdwarf/pro_alloc.h +33 -0
  121. data/ext/rdwarf/libdwarf/pro_arange.c +310 -0
  122. data/ext/rdwarf/libdwarf/pro_arange.h +51 -0
  123. data/ext/rdwarf/libdwarf/pro_die.c +431 -0
  124. data/ext/rdwarf/libdwarf/pro_die.h +59 -0
  125. data/ext/rdwarf/libdwarf/pro_encode_nm.c +108 -0
  126. data/ext/rdwarf/libdwarf/pro_encode_nm.h +39 -0
  127. data/ext/rdwarf/libdwarf/pro_error.c +96 -0
  128. data/ext/rdwarf/libdwarf/pro_error.h +43 -0
  129. data/ext/rdwarf/libdwarf/pro_expr.c +575 -0
  130. data/ext/rdwarf/libdwarf/pro_expr.h +36 -0
  131. data/ext/rdwarf/libdwarf/pro_finish.c +45 -0
  132. data/ext/rdwarf/libdwarf/pro_forms.c +1271 -0
  133. data/ext/rdwarf/libdwarf/pro_frame.c +572 -0
  134. data/ext/rdwarf/libdwarf/pro_frame.h +120 -0
  135. data/ext/rdwarf/libdwarf/pro_funcs.c +50 -0
  136. data/ext/rdwarf/libdwarf/pro_incl.h +91 -0
  137. data/ext/rdwarf/libdwarf/pro_init.c +327 -0
  138. data/ext/rdwarf/libdwarf/pro_line.c +373 -0
  139. data/ext/rdwarf/libdwarf/pro_line.h +112 -0
  140. data/ext/rdwarf/libdwarf/pro_macinfo.c +457 -0
  141. data/ext/rdwarf/libdwarf/pro_macinfo.h +31 -0
  142. data/ext/rdwarf/libdwarf/pro_opaque.h +513 -0
  143. data/ext/rdwarf/libdwarf/pro_pubnames.c +60 -0
  144. data/ext/rdwarf/libdwarf/pro_reloc.c +253 -0
  145. data/ext/rdwarf/libdwarf/pro_reloc.h +38 -0
  146. data/ext/rdwarf/libdwarf/pro_reloc_stream.c +256 -0
  147. data/ext/rdwarf/libdwarf/pro_reloc_stream.h +52 -0
  148. data/ext/rdwarf/libdwarf/pro_reloc_symbolic.c +245 -0
  149. data/ext/rdwarf/libdwarf/pro_reloc_symbolic.h +45 -0
  150. data/ext/rdwarf/libdwarf/pro_section.c +2233 -0
  151. data/ext/rdwarf/libdwarf/pro_section.h +100 -0
  152. data/ext/rdwarf/libdwarf/pro_types.c +274 -0
  153. data/ext/rdwarf/libdwarf/pro_types.h +34 -0
  154. data/ext/rdwarf/libdwarf/pro_util.h +38 -0
  155. data/ext/rdwarf/libdwarf/pro_vars.c +52 -0
  156. data/ext/rdwarf/libdwarf/pro_weaks.c +51 -0
  157. data/ext/rdwarf/rdwarf.c +765 -0
  158. data/ext/rdwarf/rdwarf.h +52 -0
  159. data/ext/rdwarf/rdwarf_names_gen.rb +109 -0
  160. data/lib/rdwarf.rb +181 -0
  161. data/lib/rdwarf/version.rb +3 -0
  162. data/rdwarf.gemspec +30 -0
  163. metadata +251 -0
@@ -0,0 +1,60 @@
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_section.h"
37
+
38
+
39
+ /* This function adds another public name to the
40
+ list of public names for the given Dwarf_P_Debug.
41
+ It returns 0 on error, and 1 otherwise. */
42
+
43
+ Dwarf_Unsigned
44
+ dwarf_add_pubname(Dwarf_P_Debug dbg,
45
+ Dwarf_P_Die die,
46
+ char *pubname_name, Dwarf_Error * error)
47
+ {
48
+ return
49
+ _dwarf_add_simple_name_entry(dbg, die, pubname_name,
50
+ dwarf_snk_pubname, error);
51
+ }
52
+ Dwarf_Unsigned
53
+ dwarf_add_pubtype(Dwarf_P_Debug dbg,
54
+ Dwarf_P_Die die,
55
+ char *pubtype_name, Dwarf_Error * error)
56
+ {
57
+ return
58
+ _dwarf_add_simple_name_entry(dbg, die, pubtype_name,
59
+ dwarf_snk_pubtype, error);
60
+ }
@@ -0,0 +1,253 @@
1
+ /*
2
+
3
+ Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
4
+ Portions Copyright 2008-2011 David Anderson, Inc. 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
+ /*#include <elfaccess.h> */
33
+ #include "pro_incl.h"
34
+ #include "pro_reloc.h"
35
+
36
+
37
+ /* Do initial alloc of newslots slots.
38
+ Fails only if malloc fails.
39
+
40
+ Supposed to be called before any relocs allocated.
41
+ Ignored if after any allocated.
42
+
43
+ Part of an optimization, so that for a known 'newslots'
44
+ relocations count we can preallocate the right size block.
45
+ Called from just 2 places.
46
+
47
+ returns DW_DLV_OK or DW_DLV_ERROR
48
+ */
49
+ int
50
+ _dwarf_pro_pre_alloc_n_reloc_slots(Dwarf_P_Debug dbg,
51
+ int rel_sec_index,
52
+ Dwarf_Unsigned newslots)
53
+ {
54
+ unsigned long len = 0;
55
+ struct Dwarf_P_Relocation_Block_s *data = 0;
56
+ Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[rel_sec_index];
57
+ unsigned long slots_in_blk = (unsigned long) newslots;
58
+ unsigned long rel_rec_size = dbg->de_relocation_record_size;
59
+
60
+ if (prel->pr_first_block)
61
+ return DW_DLV_OK; /* do nothing */
62
+
63
+ len = sizeof(struct Dwarf_P_Relocation_Block_s) +
64
+ slots_in_blk * rel_rec_size;
65
+
66
+
67
+ data = (struct Dwarf_P_Relocation_Block_s *)
68
+ _dwarf_p_get_alloc(dbg, len);
69
+ if (!data) {
70
+ return DW_DLV_ERROR;
71
+ }
72
+ data->rb_slots_in_block = slots_in_blk; /* could use default
73
+ here, as fallback in case our origininal
74
+ estimate wrong. When we call this we
75
+ presumably know what we are doing, so
76
+ keep this count for now */
77
+ data->rb_next_slot_to_use = 0;
78
+ data->rb_where_to_add_next =
79
+ ((char *) data) + sizeof(struct Dwarf_P_Relocation_Block_s);
80
+ data->rb_data = data->rb_where_to_add_next;
81
+
82
+ prel->pr_first_block = data;
83
+ prel->pr_last_block = data;
84
+ prel->pr_block_count = 1;
85
+
86
+
87
+ return DW_DLV_OK;
88
+ }
89
+
90
+
91
+ /*Do alloc of slots.
92
+ Fails only if malloc fails.
93
+
94
+ Only allocator used.
95
+
96
+ returns DW_DLV_OK or DW_DLV_ERROR
97
+ */
98
+ int
99
+ _dwarf_pro_alloc_reloc_slots(Dwarf_P_Debug dbg, int rel_sec_index)
100
+ {
101
+ unsigned long len = 0;
102
+ struct Dwarf_P_Relocation_Block_s *data = 0;
103
+ Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[rel_sec_index];
104
+ unsigned long slots_in_blk = prel->pr_slots_per_block_to_alloc;
105
+ unsigned long rel_rec_size = dbg->de_relocation_record_size;
106
+
107
+ len = sizeof(struct Dwarf_P_Relocation_Block_s) +
108
+ slots_in_blk * rel_rec_size;
109
+
110
+ data = (struct Dwarf_P_Relocation_Block_s *)
111
+ _dwarf_p_get_alloc(dbg, len);
112
+ if (!data) {
113
+ return DW_DLV_ERROR;
114
+ }
115
+
116
+ if (prel->pr_first_block) {
117
+ prel->pr_last_block->rb_next = data;
118
+ prel->pr_last_block = data;
119
+ prel->pr_block_count += 1;
120
+
121
+ } else {
122
+
123
+ prel->pr_first_block = data;
124
+ prel->pr_last_block = data;
125
+ prel->pr_block_count = 1;
126
+ }
127
+
128
+ data->rb_slots_in_block = slots_in_blk;
129
+ data->rb_next_slot_to_use = 0;
130
+ data->rb_where_to_add_next =
131
+ ((char *) data) + sizeof(struct Dwarf_P_Relocation_Block_s);
132
+ data->rb_data = data->rb_where_to_add_next;
133
+
134
+ return DW_DLV_OK;
135
+
136
+ }
137
+
138
+ /* Reserve a slot. return DW_DLV_OK if succeeds.
139
+
140
+ Return DW_DLV_ERROR if fails (malloc error).
141
+
142
+ Use the relrec_to_fill to pass back a pointer to
143
+ a slot space to use. */
144
+ int
145
+ _dwarf_pro_reloc_get_a_slot(Dwarf_P_Debug dbg,
146
+ int base_sec_index, void **relrec_to_fill)
147
+ {
148
+ struct Dwarf_P_Relocation_Block_s *data = 0;
149
+ Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[base_sec_index];
150
+ unsigned long rel_rec_size = dbg->de_relocation_record_size;
151
+
152
+ char *ret_addr = 0;
153
+
154
+ data = prel->pr_last_block;
155
+ if ((data == 0) ||
156
+ (data->rb_next_slot_to_use >= data->rb_slots_in_block)) {
157
+ int res;
158
+
159
+ res = _dwarf_pro_alloc_reloc_slots(dbg, base_sec_index);
160
+ if (res != DW_DLV_OK) {
161
+ return res;
162
+ }
163
+ }
164
+
165
+ data = prel->pr_last_block;
166
+ /* now we have an empty slot */
167
+ ret_addr = data->rb_where_to_add_next;
168
+
169
+ data->rb_where_to_add_next += rel_rec_size;
170
+ data->rb_next_slot_to_use += 1;
171
+
172
+ prel->pr_reloc_total_count += 1;
173
+
174
+ *relrec_to_fill = (void *) ret_addr;
175
+
176
+ return DW_DLV_OK;
177
+
178
+ }
179
+
180
+ /*
181
+ On success returns count of
182
+ .rel.* sections that are symbolic
183
+ thru count_of_relocation_sections.
184
+
185
+ On success, returns DW_DLV_OK.
186
+
187
+ If this is not a 'symbolic' run, returns
188
+ DW_DLV_NO_ENTRY.
189
+
190
+ No errors are possible.
191
+
192
+
193
+
194
+
195
+ */
196
+
197
+ /*ARGSUSED*/ int
198
+ dwarf_get_relocation_info_count(Dwarf_P_Debug dbg,
199
+ Dwarf_Unsigned *
200
+ count_of_relocation_sections,
201
+ int *drd_buffer_version,
202
+ Dwarf_Error * error)
203
+ {
204
+ if (dbg->de_flags & DW_DLC_SYMBOLIC_RELOCATIONS) {
205
+ int i;
206
+ unsigned int count = 0;
207
+
208
+ for (i = 0; i < NUM_DEBUG_SECTIONS; ++i) {
209
+ if (dbg->de_reloc_sect[i].pr_reloc_total_count > 0) {
210
+ ++count;
211
+ }
212
+ }
213
+ *count_of_relocation_sections = (Dwarf_Unsigned) count;
214
+ *drd_buffer_version = DWARF_DRD_BUFFER_VERSION;
215
+ return DW_DLV_OK;
216
+ }
217
+ return DW_DLV_NO_ENTRY;
218
+ }
219
+
220
+ int
221
+ dwarf_get_relocation_info(Dwarf_P_Debug dbg,
222
+ Dwarf_Signed * elf_section_index,
223
+ Dwarf_Signed * elf_section_index_link,
224
+ Dwarf_Unsigned * relocation_buffer_count,
225
+ Dwarf_Relocation_Data * reldata_buffer,
226
+ Dwarf_Error * error)
227
+ {
228
+ int next = dbg->de_reloc_next_to_return;
229
+
230
+ if (dbg->de_flags & DW_DLC_SYMBOLIC_RELOCATIONS) {
231
+ int i;
232
+
233
+ for (i = next; i < NUM_DEBUG_SECTIONS; ++i) {
234
+ Dwarf_P_Per_Reloc_Sect prel = &dbg->de_reloc_sect[i];
235
+
236
+ if (prel->pr_reloc_total_count > 0) {
237
+ dbg->de_reloc_next_to_return = i + 1;
238
+
239
+
240
+ /* ASSERT: prel->.pr_block_count == 1 */
241
+
242
+ *elf_section_index = prel->pr_sect_num_of_reloc_sect;
243
+ *elf_section_index_link = dbg->de_elf_sects[i];
244
+ *relocation_buffer_count = prel->pr_reloc_total_count;
245
+ *reldata_buffer = (Dwarf_Relocation_Data)
246
+ (prel->pr_first_block->rb_data);
247
+ return DW_DLV_OK;
248
+ }
249
+ }
250
+ DWARF_P_DBG_ERROR(dbg, DW_DLE_REL_ALLOC, DW_DLV_ERROR);
251
+ }
252
+ return DW_DLV_NO_ENTRY;
253
+ }
@@ -0,0 +1,38 @@
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
+
30
+ int _dwarf_pro_pre_alloc_n_reloc_slots(Dwarf_P_Debug dbg,
31
+ int rel_sec_index,
32
+ Dwarf_Unsigned newslots);
33
+
34
+ int _dwarf_pro_alloc_reloc_slots(Dwarf_P_Debug dbg, int rel_sec_index);
35
+
36
+ int _dwarf_pro_reloc_get_a_slot(Dwarf_P_Debug dbg,
37
+ int base_sec_index,
38
+ void **relrec_to_fill);
@@ -0,0 +1,256 @@
1
+ /*
2
+
3
+ Copyright (C) 2000,2001,2004 Silicon Graphics, Inc. All Rights Reserved.
4
+ Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
5
+ Portions Copyright 2008-2011 David Anderson, Inc. 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 "libdwarfdefs.h"
31
+ #include <stdio.h>
32
+ #include <string.h>
33
+ #ifdef HAVE_ELFACCESS_H
34
+ #include <elfaccess.h>
35
+ #else
36
+ /* Set r_info as defined by ELF generic ABI */
37
+ #define Set_REL32_info(r,s,t) ((r).r_info = ELF32_R_INFO(s,t))
38
+ #define Set_REL64_info(r,s,t) ((r).r_info = ELF64_R_INFO(s,t))
39
+ #endif
40
+ #include "pro_incl.h"
41
+ #include "pro_section.h"
42
+ #include "pro_reloc.h"
43
+ #include "pro_reloc_stream.h"
44
+
45
+ /* Return DW_DLV_ERROR on malloc error or reltarget_length error.
46
+ Return DW_DLV_OK otherwise */
47
+ /*ARGSUSED*/ int
48
+ _dwarf_pro_reloc_name_stream64(Dwarf_P_Debug dbg,
49
+ int base_sec_index,
50
+ Dwarf_Unsigned offset, /* r_offset of reloc */
51
+ Dwarf_Unsigned symidx,
52
+ enum Dwarf_Rel_Type type,
53
+ int reltarget_length)
54
+ {
55
+ #if HAVE_ELF64_GETEHDR
56
+ REL64 *elf64_reloc = 0;
57
+ void *relrec_to_fill = 0;
58
+ int res = 0;
59
+ int rel_type = 0;
60
+
61
+ res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
62
+ &relrec_to_fill);
63
+ if (res != DW_DLV_OK)
64
+ return res;
65
+
66
+
67
+ if (type == dwarf_drt_data_reloc) {
68
+ if (reltarget_length == dbg->de_offset_size) {
69
+ rel_type = dbg->de_offset_reloc;
70
+ } else if (reltarget_length == dbg->de_pointer_size) {
71
+ rel_type = dbg->de_ptr_reloc;
72
+ } else {
73
+ return DW_DLV_ERROR;
74
+ }
75
+ } else if (type == dwarf_drt_segment_rel) {
76
+ rel_type = dbg->de_exc_reloc;
77
+ } else {
78
+ /* We are in trouble: improper use of stream relocations.
79
+ Someone else will diagnose */
80
+ rel_type = 0;
81
+ }
82
+
83
+ elf64_reloc = (REL64 *)relrec_to_fill;
84
+ elf64_reloc->r_offset = offset;
85
+ Set_REL64_info(*elf64_reloc, symidx, rel_type);
86
+ return DW_DLV_OK;
87
+ #else /* !HAVE_ELF64_GETEHDR */
88
+ return DW_DLV_ERROR;
89
+ #endif /* #if HAVE_ELF64_GETEHDR */
90
+ }
91
+
92
+ /* Return DW_DLV_ERROR on malloc error or reltarget_length error.
93
+ Return DW_DLV_OK otherwise
94
+ a binary reloc: 32bit ABI */ int
95
+ _dwarf_pro_reloc_name_stream32(Dwarf_P_Debug dbg, int base_sec_index,
96
+ Dwarf_Unsigned offset, /* r_offset of reloc */
97
+ Dwarf_Unsigned symidx,
98
+ enum Dwarf_Rel_Type type,
99
+ int reltarget_length)
100
+ {
101
+ REL32 *elf32_reloc = 0;
102
+ void *relrec_to_fill = 0;
103
+ int res = 0;
104
+ int rel_type = 0;
105
+
106
+ res = _dwarf_pro_reloc_get_a_slot(dbg, base_sec_index,
107
+ &relrec_to_fill);
108
+ if (res != DW_DLV_OK)
109
+ return res;
110
+ if (type == dwarf_drt_data_reloc) {
111
+ if (reltarget_length == dbg->de_offset_size) {
112
+ rel_type = dbg->de_offset_reloc;
113
+ } else if (reltarget_length == dbg->de_pointer_size) {
114
+ rel_type = dbg->de_ptr_reloc;
115
+ } else {
116
+ return DW_DLV_ERROR;
117
+ }
118
+ } else if (type == dwarf_drt_segment_rel) {
119
+ rel_type = dbg->de_exc_reloc;
120
+ } else {
121
+ /* We are in trouble: improper use of stream relocations.
122
+ Someone else will diagnose */
123
+ rel_type = 0;
124
+ }
125
+
126
+ elf32_reloc = (REL32*)relrec_to_fill;
127
+ elf32_reloc->r_offset = (Elf32_Addr) offset;
128
+ Set_REL32_info(*elf32_reloc, (Dwarf_Word) symidx, rel_type);
129
+ return DW_DLV_OK;
130
+
131
+ /* get a slot, fill in the slot entry */
132
+ }
133
+
134
+
135
+
136
+ /* Return DW_DLV_OK.
137
+ Never can really do anything: lengths cannot
138
+ be represented as end-start in a stream. */
139
+ /*ARGSUSED*/ int
140
+ _dwarf_pro_reloc_length_stream(Dwarf_P_Debug dbg,
141
+ int base_sec_index,
142
+ Dwarf_Unsigned offset, /* r_offset of reloc */
143
+ Dwarf_Unsigned start_symidx,
144
+ Dwarf_Unsigned end_symidx,
145
+ enum Dwarf_Rel_Type type,
146
+ int reltarget_length)
147
+ {
148
+ /* get a slot, fill in the slot entry */
149
+ return DW_DLV_OK;
150
+ }
151
+
152
+
153
+ /* Ensure each stream is a single buffer and
154
+ add that single buffer to the set of stream buffers.
155
+
156
+ By creating a new buffer and copying if necessary.
157
+
158
+ Free the input set of buffers if we consolidate.
159
+ Return -1 on error (malloc failure)
160
+
161
+ Return DW_DLV_OK on success. Any other return indicates
162
+ malloc failed. */
163
+ int
164
+ _dwarf_stream_relocs_to_disk(Dwarf_P_Debug dbg,
165
+ Dwarf_Signed * new_sec_count)
166
+ {
167
+ unsigned long total_size = 0;
168
+ Dwarf_Small *data = 0;
169
+ int sec_index = 0;
170
+ unsigned long i = 0;
171
+ Dwarf_Error erre = 0;
172
+ Dwarf_Error *error = &erre;
173
+
174
+ Dwarf_Signed sec_count = 0;
175
+
176
+ Dwarf_P_Per_Reloc_Sect p_reloc = &dbg->de_reloc_sect[0];
177
+
178
+ for (i = 0; i < NUM_DEBUG_SECTIONS; ++i, ++p_reloc) {
179
+ unsigned long ct = p_reloc->pr_reloc_total_count;
180
+ unsigned len = 0;
181
+ struct Dwarf_P_Relocation_Block_s *p_blk = 0;
182
+ struct Dwarf_P_Relocation_Block_s *p_blk_last = 0;
183
+ Dwarf_P_Per_Reloc_Sect prb = 0;
184
+
185
+ if (ct == 0) {
186
+ continue;
187
+ }
188
+ prb = &dbg->de_reloc_sect[i];
189
+ len = dbg->de_relocation_record_size;
190
+ ++sec_count;
191
+
192
+ total_size = ct * len;
193
+ sec_index = prb->pr_sect_num_of_reloc_sect;
194
+ if (sec_index == 0) {
195
+ /* Call de_callback_func or de_callback_func_b or _c, getting
196
+ section number of reloc section. */
197
+ int rel_section_index = 0;
198
+ Dwarf_Unsigned name_idx = 0;
199
+ int erri = 0;
200
+
201
+ if (dbg->de_callback_func) {
202
+ rel_section_index =
203
+ dbg->de_callback_func(_dwarf_rel_section_names[i],
204
+ /* size */ dbg->de_relocation_record_size,
205
+ /* type */ SHT_REL,
206
+ /* flags */ 0,
207
+ /* link to symtab, which we cannot
208
+ know */ 0,
209
+ /* info == link to sec rels apply to */
210
+ dbg->de_elf_sects[i],
211
+ &name_idx,
212
+ dbg->de_user_data,
213
+ &erri);
214
+ }
215
+ if (rel_section_index == -1) {
216
+ {
217
+ _dwarf_p_error(dbg, error, DW_DLE_ELF_SECT_ERR);
218
+ return (DW_DLV_ERROR);
219
+ }
220
+
221
+ }
222
+ prb->pr_sect_num_of_reloc_sect = rel_section_index;
223
+ sec_index = rel_section_index;
224
+ }
225
+ GET_CHUNK(dbg, sec_index, data, total_size, &erri);
226
+ p_blk = p_reloc->pr_first_block;
227
+
228
+ /* Following loop executes at least once. Effects the
229
+ consolidation to a single block or, if already a single
230
+ block, simply copies to the output buffer. And frees the
231
+ input block. The new block is in the de_debug_sects list. */
232
+ while (p_blk) {
233
+
234
+ unsigned long lenk =
235
+ p_blk->rb_where_to_add_next - p_blk->rb_data;
236
+
237
+ memcpy(data, p_blk->rb_data, lenk);
238
+
239
+ data += lenk;
240
+
241
+ p_blk_last = p_blk;
242
+ p_blk = p_blk->rb_next;
243
+
244
+ _dwarf_p_dealloc(dbg, (Dwarf_Small *) p_blk_last);
245
+ }
246
+ /* ASSERT: sum of len copied == total_size */
247
+
248
+ /* We have copied the input, now drop the pointers to it. For
249
+ debugging, leave the other data untouched. */
250
+ p_reloc->pr_first_block = 0;
251
+ p_reloc->pr_last_block = 0;
252
+ }
253
+
254
+ *new_sec_count = sec_count;
255
+ return DW_DLV_OK;
256
+ }