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,100 @@
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
+
31
+ /* relocation section names */
32
+ extern const char *_dwarf_rel_section_names[];
33
+
34
+ /* section names */
35
+ extern const char *_dwarf_sectnames[];
36
+
37
+ /* struct to hold relocation entries. Its mantained as a linked
38
+ list of relocation structs, and will then be written at as a
39
+ whole into the relocation section. Whether its 32 bit or
40
+ 64 bit will be obtained from Dwarf_Debug pointer. */
41
+
42
+
43
+
44
+
45
+
46
+ /* struct stores a chunk of data pertaining to a section */
47
+ struct Dwarf_P_Section_Data_s {
48
+ int ds_elf_sect_no; /* elf section number */
49
+ char *ds_data; /* data contained in section */
50
+ unsigned long ds_nbytes; /* bytes of data used so far */
51
+ unsigned long ds_orig_alloc; /* bytes allocated originally */
52
+ Dwarf_P_Section_Data ds_next; /* next on the list */
53
+ };
54
+
55
+ /* Used to allow a dummy initial struct (which we
56
+ drop before it gets used
57
+ This must not match any legitimate 'section' number.
58
+ */
59
+ #define MAGIC_SECT_NO -3
60
+
61
+ /* Size of chunk of data allocated in one alloc
62
+ Not clear if this is the best size.
63
+ Used to be just 4096 for user data, the section data struct
64
+ was a separate malloc.
65
+ */
66
+ #define CHUNK_SIZE (4096 - sizeof (struct Dwarf_P_Section_Data_s))
67
+
68
+ /*
69
+ chunk alloc routine -
70
+ if chunk->ds_data is nil, it will alloc CHUNK_SIZE bytes,
71
+ and return pointer to the beginning. If chunk is not nil,
72
+ it will see if there's enoungh space for nbytes in current
73
+ chunk, if not, add new chunk to linked list, and return
74
+ a char * pointer to it. Return null if unsuccessful.
75
+ */
76
+ Dwarf_Small *_dwarf_pro_buffer(Dwarf_P_Debug dbg, int sectno,
77
+ unsigned long nbytes);
78
+
79
+ #define GET_CHUNK(dbg,sectno,ptr,nbytes,error) \
80
+ { \
81
+ (ptr) = _dwarf_pro_buffer((dbg),(sectno),(nbytes)); \
82
+ if ((ptr) == NULL) { \
83
+ DWARF_P_DBG_ERROR(dbg,DW_DLE_CHUNK_ALLOC,-1); \
84
+ } \
85
+ }
86
+
87
+
88
+
89
+ int
90
+ _dwarf_transform_arange_to_disk(Dwarf_P_Debug dbg,
91
+ Dwarf_Error * error);
92
+
93
+ /* These are for creating ELF section type codes.
94
+ */
95
+ #if defined(linux) || defined(__BEOS__) || !defined(SHT_MIPS_DWARF)
96
+ /* Intel's SoftSdv accepts only this */
97
+ #define SECTION_TYPE SHT_PROGBITS
98
+ #else
99
+ #define SECTION_TYPE SHT_MIPS_DWARF
100
+ #endif
@@ -0,0 +1,274 @@
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
+ #include "pro_types.h"
38
+
39
+
40
+ /*
41
+ This function adds another type name to the
42
+ list of type names for the given Dwarf_P_Debug.
43
+ It returns 0 on error, and 1 otherwise.
44
+ */
45
+ Dwarf_Unsigned
46
+ dwarf_add_typename(Dwarf_P_Debug dbg,
47
+ Dwarf_P_Die die,
48
+ char *type_name, Dwarf_Error * error)
49
+ {
50
+ return
51
+ _dwarf_add_simple_name_entry(dbg, die, type_name,
52
+ dwarf_snk_typename, error);
53
+ }
54
+
55
+ /*
56
+ The following is the generic 'add a simple name entry'
57
+ for any of the simple name sections.
58
+
59
+ See enum dwarf_sn_kind in pro_opaque.h
60
+
61
+ */
62
+ Dwarf_Unsigned
63
+ _dwarf_add_simple_name_entry(Dwarf_P_Debug dbg,
64
+ Dwarf_P_Die die,
65
+ char *entry_name,
66
+ enum dwarf_sn_kind entrykind,
67
+ Dwarf_Error * error)
68
+ {
69
+ Dwarf_P_Simple_nameentry nameentry;
70
+ Dwarf_P_Simple_name_header hdr;
71
+ char *name;
72
+ int uword_size;
73
+
74
+ if (dbg == NULL) {
75
+ _dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
76
+ return (0);
77
+ }
78
+
79
+ if (die == NULL) {
80
+ _dwarf_p_error(NULL, error, DW_DLE_DIE_NULL);
81
+ return (0);
82
+ }
83
+
84
+
85
+ nameentry = (Dwarf_P_Simple_nameentry)
86
+ _dwarf_p_get_alloc(dbg,
87
+ sizeof(struct Dwarf_P_Simple_nameentry_s));
88
+ if (nameentry == NULL) {
89
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
90
+ return (0);
91
+ }
92
+
93
+ name = _dwarf_p_get_alloc(dbg, strlen(entry_name) + 1);
94
+ if (name == NULL) {
95
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
96
+ return (0);
97
+ }
98
+ strcpy(name, entry_name);
99
+
100
+ nameentry->sne_die = die;
101
+ nameentry->sne_name = name;
102
+ nameentry->sne_name_len = strlen(name);
103
+ uword_size = dbg->de_offset_size;
104
+
105
+ hdr = &dbg->de_simple_name_headers[entrykind];
106
+ if (hdr->sn_head == NULL)
107
+ hdr->sn_head = hdr->sn_tail = nameentry;
108
+ else {
109
+ hdr->sn_tail->sne_next = nameentry;
110
+ hdr->sn_tail = nameentry;
111
+ }
112
+ hdr->sn_count++;
113
+ hdr->sn_net_len += uword_size + nameentry->sne_name_len + 1;
114
+
115
+ return (1);
116
+ }
117
+
118
+
119
+
120
+ /*
121
+ _dwarf_transform_simplename_to_disk writes
122
+ ".rel.debug_pubnames",
123
+ ".rel.debug_funcnames", sgi extension
124
+ ".rel.debug_typenames", sgi extension
125
+ ".rel.debug_varnames", sgi extension
126
+ ".rel.debug_weaknames", sgi extension
127
+ to disk.
128
+ section_index indexes one of those sections.
129
+ entrykind is one of those 'kind's. */
130
+ int
131
+ _dwarf_transform_simplename_to_disk(Dwarf_P_Debug dbg,
132
+ enum dwarf_sn_kind entrykind,
133
+ int section_index, /* in de_elf_sects etc */
134
+ Dwarf_Error * error)
135
+ {
136
+
137
+
138
+ /* Used to fill in 0. */
139
+ const Dwarf_Signed big_zero = 0;
140
+
141
+ /* Used to scan the section data buffers. */
142
+ Dwarf_P_Section_Data debug_sect;
143
+
144
+ Dwarf_Signed debug_info_size;
145
+
146
+ Dwarf_P_Simple_nameentry nameentry_original;
147
+ Dwarf_P_Simple_nameentry nameentry;
148
+ Dwarf_Small *stream_bytes;
149
+ Dwarf_Small *cur_stream_bytes_ptr;
150
+ Dwarf_Unsigned stream_bytes_count;
151
+ Dwarf_Unsigned adjusted_length; /* count excluding length field */
152
+
153
+
154
+ int uword_size = dbg->de_offset_size;
155
+ int extension_size = dbg->de_64bit_extension ? 4 : 0;
156
+
157
+ Dwarf_P_Simple_name_header hdr;
158
+
159
+
160
+ /* ***** BEGIN CODE ***** */
161
+
162
+ debug_info_size = 0;
163
+ for (debug_sect = dbg->de_debug_sects; debug_sect != NULL;
164
+ debug_sect = debug_sect->ds_next) {
165
+ /* We want the size of the .debug_info section for this CU
166
+ because the dwarf spec requires us to output it below so we
167
+ look for it specifically. */
168
+ if (debug_sect->ds_elf_sect_no == dbg->de_elf_sects[DEBUG_INFO]) {
169
+ debug_info_size += debug_sect->ds_nbytes;
170
+ }
171
+ }
172
+
173
+ hdr = &dbg->de_simple_name_headers[entrykind];
174
+ /* Size of the .debug_typenames (or similar) section header. */
175
+ stream_bytes_count = extension_size + uword_size + /* Size of
176
+ length field. */
177
+ sizeof(Dwarf_Half) + /* Size of version field. */
178
+ uword_size + /* Size of .debug_info offset. */
179
+ uword_size; /* Size of .debug_names. */
180
+
181
+
182
+
183
+ nameentry_original = hdr->sn_head;
184
+ nameentry = nameentry_original;
185
+ /* add in the content size */
186
+ stream_bytes_count += hdr->sn_net_len;
187
+
188
+ /* Size of the last 0 offset. */
189
+ stream_bytes_count += uword_size;
190
+
191
+ /* Now we know how long the entire section is */
192
+ GET_CHUNK(dbg, dbg->de_elf_sects[section_index],
193
+ stream_bytes, (unsigned long) stream_bytes_count, error);
194
+ if (stream_bytes == NULL) {
195
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
196
+ return (0);
197
+ }
198
+ cur_stream_bytes_ptr = stream_bytes;
199
+
200
+ if (extension_size) {
201
+ Dwarf_Unsigned x = DISTINGUISHED_VALUE;
202
+
203
+ WRITE_UNALIGNED(dbg, cur_stream_bytes_ptr,
204
+ (const void *) &x, sizeof(x), extension_size);
205
+ cur_stream_bytes_ptr += extension_size;
206
+
207
+ }
208
+ /* Write the adjusted length of .debug_*names section. */
209
+ adjusted_length = stream_bytes_count - uword_size - extension_size;
210
+ WRITE_UNALIGNED(dbg, cur_stream_bytes_ptr,
211
+ (const void *) &adjusted_length,
212
+ sizeof(adjusted_length), uword_size);
213
+ cur_stream_bytes_ptr += uword_size;
214
+
215
+ /* Write the version as 2 bytes. */
216
+ {
217
+ Dwarf_Half verstamp = CURRENT_VERSION_STAMP;
218
+
219
+ WRITE_UNALIGNED(dbg, cur_stream_bytes_ptr,
220
+ (const void *) &verstamp,
221
+ sizeof(verstamp), sizeof(Dwarf_Half));
222
+ cur_stream_bytes_ptr += sizeof(Dwarf_Half);
223
+ }
224
+
225
+ /* Write the offset of the compile-unit. */
226
+ WRITE_UNALIGNED(dbg, cur_stream_bytes_ptr,
227
+ (const void *) &big_zero,
228
+ sizeof(big_zero), uword_size);
229
+ cur_stream_bytes_ptr += uword_size;
230
+
231
+ /* now create the relocation for the compile_unit offset */
232
+ {
233
+ int res = dbg->de_reloc_name(dbg,
234
+ section_index,
235
+ extension_size + uword_size +
236
+ sizeof(Dwarf_Half) /* r_offset */ ,
237
+ /* debug_info section name symbol */
238
+ dbg->de_sect_name_idx[DEBUG_INFO],
239
+ dwarf_drt_data_reloc,
240
+ uword_size);
241
+
242
+ if (res != DW_DLV_OK) {
243
+ _dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
244
+ return (0);
245
+ }
246
+ }
247
+
248
+ /* Write the size of .debug_info section. */
249
+ WRITE_UNALIGNED(dbg, cur_stream_bytes_ptr,
250
+ (const void *) &debug_info_size,
251
+ sizeof(debug_info_size), uword_size);
252
+ cur_stream_bytes_ptr += uword_size;
253
+
254
+
255
+ for (nameentry = nameentry_original;
256
+ nameentry != NULL; nameentry = nameentry->sne_next) {
257
+
258
+ /* Copy offset of die from start of compile-unit. */
259
+ WRITE_UNALIGNED(dbg, cur_stream_bytes_ptr,
260
+ (const void *) &nameentry->sne_die->di_offset,
261
+ sizeof(nameentry->sne_die->di_offset),
262
+ uword_size);
263
+ cur_stream_bytes_ptr += uword_size;
264
+
265
+ /* Copy the type name. */
266
+ strcpy((char *) cur_stream_bytes_ptr, nameentry->sne_name);
267
+ cur_stream_bytes_ptr += nameentry->sne_name_len + 1;
268
+ }
269
+
270
+ WRITE_UNALIGNED(dbg, cur_stream_bytes_ptr,
271
+ (const void *) &big_zero,
272
+ sizeof(big_zero), uword_size);
273
+ return (int) dbg->de_n_debug_sect;
274
+ }
@@ -0,0 +1,34 @@
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
+ /* pro_types.h */
29
+
30
+
31
+ int _dwarf_transform_simplename_to_disk(Dwarf_P_Debug dbg,
32
+ enum dwarf_sn_kind entrykind,
33
+ int section_index,/* in de_elf_sects etc */
34
+ Dwarf_Error * error);
@@ -0,0 +1,38 @@
1
+ /*
2
+
3
+ Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
4
+ Portions Copyright 2014-2014 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
+ /* Definition of sizes of types. Independent of
29
+ target or host, these are. */
30
+ #define sizeof_sbyte(dbg) sizeof(Dwarf_Sbyte)
31
+ #define sizeof_ubyte(dbg) sizeof(Dwarf_Ubyte)
32
+ #define sizeof_uhalf(dbg) sizeof(Dwarf_Half)
33
+
34
+ /* Computes amount of padding necessary to align n to a k-boundary. */
35
+ /* Important: Assumes n, k both GREATER than zero. */
36
+ #define PADDING(n, k) ( (k)-1 - ((n)-1)%(k) )
37
+
38
+
@@ -0,0 +1,52 @@
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 variable name to the
40
+ list of variable names for the given Dwarf_P_Debug.
41
+ It returns 0 on error, and 1 otherwise.
42
+ */
43
+ Dwarf_Unsigned
44
+ dwarf_add_varname(Dwarf_P_Debug dbg,
45
+ Dwarf_P_Die die, char *var_name, Dwarf_Error * error)
46
+ {
47
+ return
48
+ _dwarf_add_simple_name_entry(dbg, die, var_name,
49
+ dwarf_snk_varname, error);
50
+
51
+
52
+ }