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,2807 @@
1
+ \." $Revision: 1.12 $
2
+ \." $Date: 2002/01/14 23:40:11 $
3
+ \."
4
+ \."
5
+ \." the following line may be removed if the ff ligature works on your machine
6
+ .lg 0
7
+ \." set up heading formats
8
+ .ds HF 3 3 3 3 3 2 2
9
+ .ds HP +2 +2 +1 +0 +0
10
+ .nr Hs 5
11
+ .nr Hb 5
12
+ \." ==============================================
13
+ \." Put current date in the following at each rev
14
+ .ds vE rev 1.38, 03 January 2015
15
+ \." ==============================================
16
+ \." ==============================================
17
+ .ds | |
18
+ .ds ~ ~
19
+ .ds ' '
20
+ .if t .ds Cw \&\f(CW
21
+ .if n .ds Cw \fB
22
+ .de Cf \" Place every other arg in Cw font, beginning with first
23
+ .if \\n(.$=1 \&\*(Cw\\$1\fP
24
+ .if \\n(.$=2 \&\*(Cw\\$1\fP\\$2
25
+ .if \\n(.$=3 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP
26
+ .if \\n(.$=4 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4
27
+ .if \\n(.$=5 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP
28
+ .if \\n(.$=6 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6
29
+ .if \\n(.$=7 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP
30
+ .if \\n(.$=8 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP\\$8
31
+ .if \\n(.$=9 \&\*(Cw\\$1\fP\\$2\*(Cw\\$3\fP\\$4\*(Cw\\$5\fP\\$6\*(Cw\\$7\fP\\$8\
32
+ *(Cw
33
+ ..
34
+ .nr Cl 3
35
+ .SA 1
36
+ .TL
37
+ A Producer Library Interface to DWARF
38
+ .AF ""
39
+ .AU "David Anderson"
40
+ .PF "'\*(vE '- \\\\nP -''"
41
+ .AS 1
42
+ This document describes an interface to a library of functions
43
+ to create DWARF debugging information entries and DWARF line number
44
+ information. It does not make recommendations as to how the functions
45
+ described in this document should be implemented nor does it
46
+ suggest possible optimizations.
47
+ .P
48
+ The document is oriented to creating DWARF version 2.
49
+ Support for creating DWARF3 is intended but such support
50
+ is not yet fully present.
51
+ DWARF4 support is also intended.
52
+ .P
53
+ \*(vE
54
+ .AE
55
+ .MT 4
56
+ .H 1 "INTRODUCTION"
57
+ This document describes an interface to \f(CWlibdwarf\fP, a
58
+ library of functions to provide creation of DWARF debugging information
59
+ records, DWARF line number information, DWARF address range and
60
+ pubnames information, weak names information, and DWARF frame description
61
+ information.
62
+
63
+
64
+ .H 2 "Copyright"
65
+ Copyright 1993-2006 Silicon Graphics, Inc.
66
+
67
+ Copyright 2007-2014 David Anderson.
68
+
69
+ Permission is hereby granted to
70
+ copy or republish or use any or all of this document without
71
+ restriction except that when publishing more than a small amount
72
+ of the document
73
+ please acknowledge Silicon Graphics, Inc and David Anderson.
74
+
75
+ This document is distributed in the hope that it would be useful, but
76
+ WITHOUT ANY WARRANTY; without even the implied warranty of
77
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
78
+ .H 2 "Purpose and Scope"
79
+ The purpose of this document is to propose a library of functions to
80
+ create DWARF debugging information. Reading (consuming) of such records
81
+ is discussed in a separate document.
82
+
83
+ The functions in this document have mostly been implemented at
84
+ Silicon Graphics
85
+ and are being used by the code generator to provide debugging information.
86
+ Some functions (and support for some extensions) were provided
87
+ by Sun Microsystems.
88
+
89
+ Example code showing one use of the functionality
90
+ may be found in the dwarfgen \f(CWdwarfgen\fP application
91
+ (provided in the source distribution along with libdwarf).
92
+
93
+ .P
94
+ The focus of this document is the functional interface,
95
+ and as such, implementation and optimization issues are
96
+ intentionally ignored.
97
+
98
+ .P
99
+ Error handling, error codes, and certain \f(CWLibdwarf\fP codes are discussed
100
+ in the "\fIA Consumer Library Interface to DWARF\fP", which should
101
+ be read before reading this document.
102
+ .P
103
+ A very few functions in the Producer Library follow the error-returns
104
+ as defined in "\fIA Consumer Library Interface to DWARF\fP".
105
+ .P
106
+ However the general style of functions here
107
+ in the producer library is rather C-traditional
108
+ with various types as return values (quite different
109
+ from the consumer library interfaces). The style
110
+ generally follows the style of the original DWARF1 reader
111
+ proposed as an interface to DWARF.
112
+ When the style of the reader interfaces was changed (1994) in the
113
+ dwarf reader ( See the "Document History"
114
+ section of "A Consumer Library Interface to DWARF")
115
+ the interfaces here were not changed as it seemed like
116
+ too much of a change for the two applications then using
117
+ the interface! So this interface remains in the traditional C style
118
+ of returning various data types with various (somewhat inconsistent)
119
+ means of indicating failure.
120
+ .P
121
+ The error handling code in the library may either
122
+ return a value or abort.
123
+ The library user can provide a function that the producer code
124
+ will call on errors (which would allow callers avoid testing
125
+ for error returns if the user function exits or aborts).
126
+ See the \f(CWdwarf_producer_init()\fP
127
+ description below for more details.
128
+
129
+
130
+ .H 2 "Document History"
131
+ This document originally prominently referenced
132
+ "UNIX International Programming Languages Special Interest Group "
133
+ (PLSIG).
134
+ Both UNIX International and the
135
+ affiliated Programming Languages Special Interest Group
136
+ are defunct
137
+ (UNIX is a registered trademark of UNIX System Laboratories, Inc.
138
+ in the United States and other countries).
139
+ Nothing except the general interface style is actually
140
+ related to anything shown to the PLSIG
141
+ (this document was open sourced with libdwarf in the mid 1990's).
142
+ .P
143
+ See "http://www.dwarfstd.org" for information on current
144
+ DWARF standards and committee activities.
145
+
146
+ .H 2 "Definitions"
147
+ DWARF debugging information entries (DIEs) are the segments of information
148
+ placed in the \f(CW.debug_info\fP and related
149
+ sections by compilers, assemblers, and linkage
150
+ editors that, in conjunction with line number entries, are necessary for
151
+ symbolic source-level debugging.
152
+ Refer to the document
153
+ "\fIDWARF Debugging Information Format\fP" from UI PLSIG for a more complete
154
+ description of these entries.
155
+
156
+ .P
157
+ This document adopts all the terms and definitions in
158
+ "\fIDWARF Debugging Information Format\fP" version 2.
159
+ and the "\fIA Consumer Library Interface to DWARF\fP".
160
+
161
+ .P
162
+ In addition, this document refers to Elf, the ATT/USL System V
163
+ Release 4 object format.
164
+ This is because the library was first developed for that object
165
+ format.
166
+ Hopefully the functions defined here can easily be
167
+ applied to other object formats.
168
+
169
+ .H 2 "Overview"
170
+ The remaining sections of this document describe a proposed producer
171
+ (compiler or assembler) interface to \fILibdwarf\fP, first by describing
172
+ the purpose of additional types defined by the interface, followed by
173
+ descriptions of the available operations.
174
+ This document assumes you
175
+ are thoroughly familiar with the information contained in the
176
+ \fIDWARF
177
+ Debugging Information Format\fP document, and
178
+ "\fIA Consumer Library Interface to DWARF\fP".
179
+
180
+ .P
181
+ The interface necessarily knows a little bit about the object format
182
+ (which is assumed to be Elf). We make an attempt to make this knowledge
183
+ as limited as possible. For example, \fILibdwarf\fP does not do the
184
+ writing of object data to the disk. The producer program does that.
185
+
186
+ .H 2 "Revision History"
187
+ .VL 15
188
+ .LI "March 1993"
189
+ Work on dwarf2 sgi producer draft begins
190
+ .LI "March 1999"
191
+ Adding a function to allow any number of trips
192
+ through the dwarf_get_section_bytes() call.
193
+ .LI "April 10 1999"
194
+ Added support for assembler text output of dwarf
195
+ (as when the output must pass through an assembler).
196
+ Revamped internals for better performance and
197
+ simpler provision for differences in ABI.
198
+ .LI "Sep 1, 1999"
199
+ Added support for little- and cross- endian
200
+ debug info creation.
201
+ .LI "May 7 2007"
202
+ This library interface now cleans up, deallocating
203
+ all memory it uses (the application simply calls
204
+ dwarf_producer_finish(dbg)).
205
+ .LI "September 20 2010"
206
+ Now documents the marker feature of DIE creation.
207
+ .LI "May 01 2014"
208
+ The dwarf_producer_init() code has a new interface
209
+ and DWARF is configured at run time by its arguments.
210
+ The producer code used to be configured at configure
211
+ time, but the configure time producer configure options
212
+ are no longer used.
213
+ The configuration was unneccesarily compilated:
214
+ the run-time configuration is simpler to understand.
215
+ .LE
216
+
217
+ .H 1 "Type Definitions"
218
+
219
+ .H 2 "General Description"
220
+ The \fIlibdwarf.h\fP
221
+ header file contains typedefs and preprocessor
222
+ definitions of types and symbolic names
223
+ used to reference objects of \fI Libdwarf \fP .
224
+ The types defined by typedefs contained in \fI libdwarf.h\fP
225
+ all use the convention of adding \fI Dwarf_ \fP
226
+ as a prefix to
227
+ indicate that they refer to objects used by Libdwarf.
228
+ The prefix \fI Dwarf_P_\fP is used for objects
229
+ referenced by the \fI Libdwarf\fP
230
+ Producer when there are similar but distinct
231
+ objects used by the Consumer.
232
+
233
+ .H 2 "Namespace issues"
234
+ Application programs should avoid creating names
235
+ beginning with
236
+ \f(CWDwarf_\fP
237
+ \f(CWdwarf_\fP
238
+ or
239
+ \f(CWDW_\fP
240
+ as these are reserved to dwarf and libdwarf.
241
+
242
+ .H 1 "libdwarf and Elf and relocations"
243
+ Much of the description below presumes that Elf is the object
244
+ format in use.
245
+ The library is probably usable with other object formats
246
+ that allow arbitrary sections to be created.
247
+
248
+ .H 2 "binary or assembler output"
249
+ With
250
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
251
+ (see below)
252
+ it is assumed that the calling app will simply
253
+ write the streams and relocations directly into
254
+ an Elf file, without going through an assembler.
255
+
256
+ With
257
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
258
+ the calling app must either
259
+ A) generate binary relocation streams and write
260
+ the generated debug information streams and
261
+ the relocation streams direct to an elf file
262
+ or
263
+ B) generate assembler output text for an assembler
264
+ to read and produce an object file.
265
+
266
+ With case B) the libdwarf-calling application must
267
+ use the relocation information to change
268
+ points of each binary stream into references to
269
+ symbolic names.
270
+ It is necessary for the assembler to be
271
+ willing to accept and generate relocations
272
+ for references from arbitrary byte boundaries.
273
+ For example:
274
+ .sp
275
+ .nf
276
+ .in +4
277
+ .data 0a0bcc #producing 3 bytes of data.
278
+ .word mylabel #producing a reference
279
+ .word endlabel - startlable #producing absolute length
280
+ .in -4
281
+ .fi
282
+ .sp
283
+
284
+
285
+
286
+
287
+ .H 2 "libdwarf relationship to Elf"
288
+ When the documentation below refers to 'an elf section number'
289
+ it is really only dependent on getting (via the callback
290
+ function passed by the caller of
291
+ \f(CWdwarf_producer_init()\fP.
292
+ a sequence of integers back (with 1 as the lowest).
293
+
294
+ When the documentation below refers to 'an Elf symbol index'
295
+ it is really dependent on
296
+ Elf symbol numbers
297
+ only if
298
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
299
+ are being generated (see below).
300
+ With
301
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
302
+ the library is generating Elf relocations
303
+ and the section numbers in binary form so
304
+ the section numbers and symbol indices must really
305
+ be Elf (or elf-like) numbers.
306
+
307
+
308
+ With
309
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
310
+ the values passed as symbol indexes can be any
311
+ integer set or even pointer set.
312
+ All that libdwarf assumes is that where values
313
+ are unique they get unique values.
314
+ Libdwarf does not generate any kind of symbol table
315
+ from the numbers and does not check their
316
+ uniqueness or lack thereof.
317
+
318
+ .H 2 "libdwarf and relocations"
319
+ With
320
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
321
+ libdwarf creates binary streams of debug information
322
+ and arrays of relocation information describing
323
+ the necessary relocation.
324
+ The Elf section numbers and symbol numbers appear
325
+ nowhere in the binary streams. Such appear
326
+ only in the relocation information and the passed-back
327
+ information from calls requesting the relocation information.
328
+ As a consequence, the 'symbol indices' can be
329
+ any pointer or integer value as the caller must
330
+ arrange that the output deal with relocations.
331
+
332
+ With
333
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
334
+ all the relocations are directly created by libdwarf
335
+ as binary streams (libdwarf only creates the streams
336
+ in memory,
337
+ it does not write them to disk).
338
+
339
+ .H 2 "symbols, addresses, and offsets"
340
+ The following applies to calls that
341
+ pass in symbol indices, addresses, and offsets, such
342
+ as
343
+ \f(CWdwarf_add_AT_targ_address() \fP
344
+ \f(CWdwarf_add_arange_b()\fP
345
+ and
346
+ \f(CWdwarf_add_frame_fde_b()\fP.
347
+
348
+ With
349
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
350
+ a passed in address is one of:
351
+ a) a section offset and the (non-global) symbol index of
352
+ a section symbol.
353
+ b) A symbol index (global symbol) and a zero offset.
354
+
355
+ With \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
356
+ the same approach can be used, or, instead,
357
+ a passed in address may be
358
+ c) a symbol handle and an offset.
359
+ In this case, since it is up to the calling app to
360
+ generate binary relocations (if appropriate)
361
+ or to turn the binary stream into
362
+ a text stream (for input to an assembler, if appropriate)
363
+ the application has complete control of the interpretation
364
+ of the symbol handles.
365
+
366
+
367
+
368
+ .H 1 "Memory Management"
369
+
370
+ Several of the functions that comprise the \fILibdwarf\fP
371
+ producer interface dynamically allocate values and some
372
+ return pointers to those spaces.
373
+ The dynamically allocated spaces
374
+ can not be reclaimed (and must
375
+ not be freed) except that
376
+ all such libdwarf-allocated memory
377
+ is freed by \f(CWdwarf_producer_finish(dbg)\fP.
378
+
379
+ All data for a particular \f(CWDwarf_P_Debug\fP descriptor
380
+ is separate from the data for any other
381
+ \f(CWDwarf_P_Debug\fP descriptor in use in the library-calling
382
+ application.
383
+
384
+ .H 2 "Read-only Properties"
385
+ All pointers returned by or as a result of a \fILibdwarf\fP call should
386
+ be assumed to point to read-only memory.
387
+ Except as defined by this document, the results are undefined for
388
+ \fILibdwarf\fP clients that attempt to write to a region pointed to by a
389
+ return value from a \fILibdwarf\fP call.
390
+
391
+ .H 2 "Storage Deallocation"
392
+ Calling \f(CWdwarf_producer_finish(dbg)\fP frees all the space, and
393
+ invalidates all pointers returned from \f(CWLibdwarf\fP functions on
394
+ or descended from \f(CWdbg\fP).
395
+
396
+ .H 1 "Functional Interface"
397
+ This section describes the functions available in the \fILibdwarf\fP
398
+ library. Each function description includes its definition, followed
399
+ by a paragraph describing the function's operation.
400
+
401
+ .P
402
+ The functions may be categorized into groups:
403
+ \fIinitialization and termination operations\fP,
404
+ \fIdebugging information entry creation\fP,
405
+ \fIElf section callback function\fP,
406
+ \fIattribute creation\fP,
407
+ \fIexpression creation\fP,
408
+ \fIline number creation\fP,
409
+ \fIfast-access (aranges) creation\fP,
410
+ \fIfast-access (pubnames) creation\fP,
411
+ \fIfast-access (weak names) creation\fP,
412
+ \fImacro information creation\fP,
413
+ \fIlow level (.debug_frame) creation\fP,
414
+ and
415
+ \fIlocation list (.debug_loc) creation\fP.
416
+
417
+ .P
418
+ The following sections describe these functions.
419
+
420
+ .H 2 "Initialization and Termination Operations"
421
+ These functions setup \f(CWLibdwarf\fP to accumulate debugging information
422
+ for an object, usually a compilation-unit, provided by the producer.
423
+ The actual addition of information is done by functions in the other
424
+ sections of this document. Once all the information has been added,
425
+ functions from this section are used to transform the information to
426
+ appropriate byte streams, and help to write out the byte streams to
427
+ disk.
428
+
429
+ Typically then, a producer application
430
+ would create a \f(CWDwarf_P_Debug\fP
431
+ descriptor to gather debugging information for a particular
432
+ compilation-unit using \f(CWdwarf_producer_init()\fP.
433
+
434
+ The producer application would
435
+ use this \f(CWDwarf_P_Debug\fP descriptor to accumulate debugging
436
+ information for this object using functions from other sections of
437
+ this document.
438
+ Once all the information had been added, it would
439
+ call \f(CWdwarf_transform_to_disk_form()\fP to convert the accumulated
440
+ information into byte streams in accordance with the \f(CWDWARF\fP
441
+ standard.
442
+ The application would then repeatedly call
443
+ \f(CWdwarf_get_section_bytes()\fP
444
+ for each of the \f(CW.debug_*\fP created.
445
+ This gives the producer
446
+ information about the data bytes to be written to disk.
447
+ At this point,
448
+ the producer would release all resource used by \f(CWLibdwarf\fP for
449
+ this object by calling \f(CWdwarf_producer_finish()\fP.
450
+
451
+ It is also possible to create assembler-input character streams
452
+ from the byte streams created by this library.
453
+ This feature requires slightly different interfaces than
454
+ direct binary output.
455
+ The details are mentioned in the text.
456
+
457
+ .H 3 "dwarf_producer_init()"
458
+
459
+ .DS
460
+ \f(CWint dwarf_producer_init(
461
+ Dwarf_Unsigned flags,
462
+ Dwarf_Callback_Func func,
463
+ Dwarf_Handler errhand,
464
+ Dwarf_Ptr errarg,
465
+ void * user_data
466
+ const char *isa_name,
467
+ const char *dwarf_version,
468
+ const char *extra,
469
+ Dwarf_P_Debug *dbg_returned,
470
+ Dwarf_Error *error) \fP
471
+ .DE
472
+ .P
473
+ The function \f(CWdwarf_producer_init() \fP returns a new
474
+ \f(CWDwarf_P_Debug\fP descriptor that can be used to add \f(CWDwarf\fP
475
+ information to the object.
476
+ On success it returns \f(CWDW_DLV_OK\fP.
477
+ On error it returns \f(CWDW_DLV_ERROR\fP.
478
+ \f(CWflags\fP determine whether the target object is 64-bit or 32-bit.
479
+ \f(CWfunc\fP is a pointer to a function called-back from \f(CWLibdwarf\fP
480
+ whenever \f(CWLibdwarf\fP needs to create a new object section (as it will
481
+ for each .debug_* section and related relocation section).
482
+
483
+ .P
484
+ The \f(CWflags\fP
485
+ values (to be OR'd together in the flags field
486
+ in the calling code) are as follows:
487
+ .in +4
488
+ \f(CWDW_DLC_WRITE\fP
489
+ is required.
490
+ The values
491
+ \f(CWDW_DLC_READ\fP
492
+ \f(CWDW_DLC_RDWR\fP
493
+ are not supported by the producer and must not be passed.
494
+
495
+ The flag bit
496
+ \f(CWDW_DLC_POINTER64\fP
497
+ (or
498
+ \f(CWDW_DLC_SIZE_64\fP)
499
+ Indicates the target has a 64 bit (8 byte) address size.
500
+ The flag bit
501
+ \f(CWDW_DLC_POINTER32\fP
502
+ (or
503
+ \f(CWDW_DLC_SIZE_32\fP)
504
+ Indicates the target has a 32 bit (4 byte) address size.
505
+ If none of these pointer sizes is passed in
506
+ \f(CWDW_DLC_POINTER32\fP
507
+ is assumed.
508
+
509
+
510
+
511
+ The flag bit
512
+ \f(CWDW_DLC_OFFSET32\fP
513
+ indicates that 32bit offsets should be used in the generated DWARF.
514
+ The flag bit
515
+ \f(CWDW_DLC_OFFSET64\fP
516
+ \f(CWDW_DLC_OFFSET_SIZE_64\fP
517
+ indicates that 64bit offsets should be used in the generated DWARF.
518
+
519
+ The flag bit
520
+ \f(CWDW_DLC_IRIX_OFFSET64\fP
521
+ indicates that the generated DWARF should use the
522
+ early (pre DWARF3) IRIX method of generating 64 bit offsets.
523
+ In this case \f(CWDW_DLC_POINTER64\fP should also be passed in,
524
+ and the \f(CWisa_name\fP
525
+ passed in (see below) should be "irix".
526
+
527
+
528
+
529
+ If
530
+ \f(CWDW_DLC_TARGET_BIGENDIAN\fP
531
+ or
532
+ \f(CWDW_DLC_TARGET_LITTLEENDIAN\fP
533
+ is not ORed into \f(CWflags\fP
534
+ then
535
+ endianness the same as the host is assumed.
536
+ If both
537
+ \f(CWDW_DLC_TARGET_LITTLEENDIAN\fP
538
+ and
539
+ \f(CWDW_DLC_TARGET_BIGENDIAN\fP
540
+ are OR-d in it is an error.
541
+
542
+
543
+
544
+ Either one of two output forms is specifiable:
545
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
546
+ or
547
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP .
548
+
549
+ The default is
550
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP .
551
+ The
552
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
553
+ are relocations in a binary stream (as used
554
+ in a MIPS/IRIX Elf object).
555
+
556
+ The
557
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
558
+ are the same relocations but expressed in an
559
+ array of structures defined by libdwarf,
560
+ which the caller of the relevant function
561
+ (see below) must deal with appropriately.
562
+ This method of expressing relocations allows
563
+ the producer-application to easily produce
564
+ assembler text output of debugging information.
565
+
566
+ When
567
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
568
+ is ORed into \f(CWflags\fP
569
+ then relocations are returned not as streams
570
+ but through an array of structures.
571
+
572
+ .in -4
573
+
574
+ .P
575
+ The function \f(CWfunc\fP
576
+ must be provided by the user of this library.
577
+ Its prototype is:
578
+ .DS
579
+ \f(CWtypedef int (*Dwarf_Callback_Func)(
580
+ char* name,
581
+ int size,
582
+ Dwarf_Unsigned type,
583
+ Dwarf_Unsigned flags,
584
+ Dwarf_Unsigned link,
585
+ Dwarf_Unsigned info,
586
+ Dwarf_Unsigned* sect_name_index,
587
+ void * user_data,
588
+ int* error) \fP
589
+ .DE
590
+ For each section in the object file that \f(CWlibdwarf\fP
591
+ needs to create, it calls this function once (calling it
592
+ from \f(CWdwarf_transform_to_disk_form()\fP), passing in
593
+ the section \f(CWname\fP, the section \f(CWtype\fP,
594
+ the section \f(CWflags\fP, the \f(CWlink\fP field, and
595
+ the \f(CWinfo\fP field.
596
+ For an Elf object file these values
597
+ should be appropriate Elf section header values.
598
+ For example, for relocation callbacks, the \f(CWlink\fP
599
+ field is supposed to be set (by the app) to the index
600
+ of the symtab section (the link field passed through the
601
+ callback must be ignored by the app).
602
+ And, for relocation callbacks, the \f(CWinfo\fP field
603
+ is passed as the elf section number of the section
604
+ the relocations apply to.
605
+ .P
606
+ The \f(CWsect_name_index\fP field is a field you use
607
+ to pass a symbol index back to libdwarf.
608
+ In Elf, each section gets an elf symbol table entry
609
+ so that relocations have an address to refer to
610
+ (relocations rely on addresses in the Elf symbol table).
611
+ You will create the Elf symbol table, so you have to tell
612
+ libdwarf the index to put into relocation records for the
613
+ section newly defined here.
614
+ .P
615
+ On success
616
+ the user function should return the Elf section number of the
617
+ newly created Elf section.
618
+ .P
619
+ On success, the function should also set the integer
620
+ pointed to by \f(CWsect_name_index\fP to the
621
+ Elf symbol number assigned in the Elf symbol table of the
622
+ new Elf section.
623
+ This symbol number is needed with relocations
624
+ dependent on the relocation of this new section.
625
+ .P
626
+ Use the
627
+ \f(CWdwarf_producer_init_c()\fP
628
+ interface instead of this interface.
629
+ .P
630
+ For example, the \f(CW.debug_line\fP section's third
631
+ data element (in a compilation unit) is the offset from the
632
+ beginning of the \f(CW.debug_info\fP section of the compilation
633
+ unit entry for this \f(CW.debug_line\fP set.
634
+ The relocation entry in \f(CW.rel.debug_line\fP
635
+ for this offset
636
+ must have the relocation symbol index of the
637
+ symbol \f(CW.debug_info\fP returned
638
+ by the callback of that section-creation through
639
+ the pointer \f(CWsect_name_index\fP.
640
+ .P
641
+ On failure, the function should return -1 and set the \f(CWerror\fP
642
+ integer to an error code.
643
+ .P
644
+ Nothing in libdwarf actually depends on the section index
645
+ returned being a real Elf section.
646
+ The Elf section is simply useful for generating relocation
647
+ records.
648
+ Similarly, the Elf symbol table index returned through
649
+ the \f(CWsect_name_index\fP must be an index
650
+ that can be used in relocations against this section.
651
+ The application will probably want to note the
652
+ values passed to this function in some form, even if
653
+ no Elf file is being produced.
654
+
655
+ .P
656
+ \f(CWerrhand\fP
657
+ is a pointer to a function that will be used as
658
+ a default fall-back function for handling errors detected
659
+ by \f(CWLibdwarf\fP.
660
+
661
+ .P
662
+ \f(CWerrarg\fP is the default error argument used
663
+ by the function pointed to by \f(CWerrhand\fP.
664
+ .P
665
+ For historical reasons the error handling is complicated
666
+ and the following three paragraphs describe the three
667
+ possible scenarios when a producer function detects an error.
668
+ In all cases a short error message is printed on
669
+ stdout if the error number
670
+ is negative (as all such should be, see libdwarf.h).
671
+ Then further action is taken as follows.
672
+ .P
673
+ First,
674
+ if the Dwarf_Error argument to any specific producer function
675
+ (see the functions documented below) is non-null
676
+ the \f(CWerrhand\fP argument here is ignored in that call and
677
+ the specific producer function sets the Dwarf_Error and returns
678
+ some specific value (for dwarf_producer_init it is DW_DLV_OK
679
+ as mentioned just above) indicating there is an error.
680
+ .P
681
+ Second,
682
+ if the Dwarf_Error argument to any specific producer function
683
+ (see the functions documented below) is NULL and the
684
+ \f(CWerrarg\fP to \f(CWdwarf_producer_init() \fP is non-NULL
685
+ then on an error in the producer code the Dwarf_Handler function is called
686
+ and if that called function returns the producer code returns
687
+ a specific value (for dwarf_producer_init it is DW_DLV_OK
688
+ as mentioned just above) indicating there is an error.
689
+ .P
690
+ Third,
691
+ if the Dwarf_Error argument to any specific producer function
692
+ (see the functions documented below) is NULL and the
693
+ \f(CWerrarg\fP to \f(CWdwarf_producer_init()\fP is NULL
694
+ then on an error \f(CWabort()\fP is called.
695
+
696
+ .P
697
+ The \f(CWuser_data\fP argument is not examined by libdwarf.
698
+ It is passed to user code in all
699
+ calls by libdwarf to the \f(CWDwarf_Callback_Func()\fP
700
+ function and
701
+ may be used by consumer code for the consumer's own purposes.
702
+ Typical uses might be to pass in a pointer to some user
703
+ data structure or to pass an integer that somehow
704
+ is useful to the libdwarf-using code.
705
+
706
+ .P
707
+ The \f(CWisa_name\fP argument
708
+ must be non-null and contain one of the
709
+ strings defined in the isa_relocs array
710
+ in pro_init.c: "irix","mips","x86",
711
+ "x86_64","arm","arm64","ppc","ppc64",
712
+ "sparc".
713
+ Tthe names are not strictly ISA
714
+ names (nor ABI names) but a hopefully-meaningful
715
+ mixing of the concepts of ISA and ABI.
716
+ The intent is mainly to
717
+ define relocation codes applicable to DW_DLC_STREAM_RELOCATIONS.
718
+ New \f(CWisa_name\fP values will be provided as users
719
+ request. In the "irix" case a special relocation is defined
720
+ so a special CIE reference field can be created (if and
721
+ only if the augmentation
722
+ string is "z").
723
+ .P
724
+ The \f(CWdwarf_version\fP argument
725
+ should be one of
726
+ "V2",
727
+ "V3",
728
+ "V4",
729
+ "V5"
730
+ to indicate which DWARF version is the overall format
731
+ to be emitted. Individual section version numbers will obey
732
+ the standard for that overall DWARF version.
733
+ Initially only "V2" is supported.
734
+ .P
735
+ The \f(CWextra\fP argument
736
+ is intended to support a comma-separated
737
+ list of as-yet-undefined options.
738
+ Passing in a null pointer or an empty string
739
+ is acceptable if no such options are needed
740
+ or used. All-lowercase option names are reserved to
741
+ the libdwarf implementation itself (specific implemenations
742
+ may want to use a leading upper-case letter for
743
+ additional options).
744
+
745
+ .P
746
+ The \f(CWerror\fP argument
747
+ is set throught he pointer to return specific error
748
+ if \f(CWerror\fP is non-null and
749
+ and there is an error. The error details
750
+ will be passed back through this pointer argument.
751
+
752
+
753
+
754
+ .H 3 "dwarf_transform_to_disk_form()"
755
+ .DS
756
+ \f(CWDwarf_Signed dwarf_transform_to_disk_form(
757
+ Dwarf_P_Debug dbg,
758
+ Dwarf_Error* error)\fP
759
+ .DE
760
+ The function
761
+ \f(CWdwarf_transform_to_disk_form()\fP
762
+ turns the DIE and other information specified
763
+ for this \f(CWDwarf_P_Debug\fP into a stream of
764
+ bytes for each section being produced.
765
+ These byte streams can be retrieved from
766
+ the \f(CWDwarf_P_Debug\fP by calls to
767
+ \f(CWdwarf_get_section_bytes()\fP (see below).
768
+ .P
769
+ In case of error
770
+ \f(CWdwarf_transform_to_disk_form()\fP
771
+ returns
772
+ \f(CWDW_DLV_NOCOUNT\fP.
773
+ .P
774
+ When successful
775
+ \f(CWdwarf_transform_to_disk_form()\fP
776
+ returns
777
+ the number of chunks of section data to be
778
+ accessed by
779
+ \f(CWdwarf_get_section_bytes()\fP
780
+ (see below) and the section data
781
+ provided your code will insert
782
+ into an object file or the like.
783
+ Each section of the resulting object is typically
784
+ many small chunks.
785
+ Each chunk has a section index
786
+ and a length as well as a pointer to a block of data
787
+ (see
788
+ \f(CWdwarf_get_section_bytes()\fP
789
+ ).
790
+ .P
791
+ For each unique section being produced
792
+ \f(CWdwarf_transform_to_disk_form()\fP
793
+ calls the
794
+ \f(CWDwarf_Callback_Func\fP exactly once.
795
+ The callback provides the connection
796
+ between Elf sections (which we presume
797
+ is the object format to be emitted) and
798
+ the
799
+ \f(CWlibdwarf()\fP
800
+ internal section numbering.
801
+ .P
802
+ For \f(CWDW_DLC_STREAM_RELOCATIONS\fP
803
+ a call to
804
+ \f(CWDwarf_Callback_Func\fP is made
805
+ by libdwarf for each relocation section.
806
+ Calls to \f(CWdwarf_get_section_bytes()\fP (see below).
807
+ allow the
808
+ \f(CWdwarf_transform_to_disk_form()\fP caller
809
+ to get byte streams and write them to
810
+ an object file as desired, just as with
811
+ the other sections of the object being created.
812
+ .P
813
+ For \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
814
+ the user code should use
815
+ \f(CWdwarf_get_relocation_info_count()\fP
816
+ and
817
+ \f(CWdwarf_get_relocation_info()\fP
818
+ to retrieve the relocation info
819
+ generated by
820
+ \f(CWdwarf_transform_to_disk_form()\fP
821
+ and do something with it.
822
+
823
+
824
+ .H 3 "dwarf_get_section_bytes()"
825
+
826
+ .DS
827
+ \f(CWDwarf_Ptr dwarf_get_section_bytes(
828
+ Dwarf_P_Debug dbg,
829
+ Dwarf_Signed dwarf_section,
830
+ Dwarf_Signed *elf_section_index,
831
+ Dwarf_Unsigned *length,
832
+ Dwarf_Error* error)\fP
833
+ .DE
834
+ The function \f(CWdwarf_get_section_bytes() \fP must be called repetitively,
835
+ with the index \f(CWdwarf_section\fP starting at 0 and continuing for the
836
+ number of sections
837
+ returned by \f(CWdwarf_transform_to_disk_form() \fP.
838
+ It returns \f(CWNULL\fP to indicate that there are no more sections of
839
+ \f(CWDwarf\fP information.
840
+ For each non-NULL return, the return value
841
+ points to \f(CW*length\fP bytes of data that are normally
842
+ added to the output
843
+ object in \f(CWElf\fP section \f(CW*elf_section\fP by the producer application.
844
+ It is illegal to call these in any order other than 0 through N-1 where
845
+ N is the number of dwarf sections
846
+ returned by \f(CWdwarf_transform_to_disk_form() \fP.
847
+ The \f(CWdwarf_section\fP
848
+ number is actually ignored: the data is returned as if the
849
+ caller passed in the correct dwarf_section numbers in the
850
+ required sequence.
851
+ The \f(CWerror\fP argument is not used.
852
+ .P
853
+ There is no requirement that the section bytes actually
854
+ be written to an elf file.
855
+ For example, consider the .debug_info section and its
856
+ relocation section (the call back function would resulted in
857
+ assigning 'section' numbers and the link field to tie these
858
+ together (.rel.debug_info would have a link to .debug_info).
859
+ One could examine the relocations, split the .debug_info
860
+ data at relocation boundaries, emit byte streams (in hex)
861
+ as assembler output, and at each relocation point,
862
+ emit an assembler directive with a symbol name for the assembler.
863
+ Examining the relocations is awkward though.
864
+ It is much better to use \f(CWdwarf_get_section_relocation_info() \fP
865
+ .P
866
+
867
+ The memory space of the section byte stream is freed
868
+ by the \f(CWdwarf_producer_finish() \fP call
869
+ (or would be if the \f(CWdwarf_producer_finish() \fP
870
+ was actually correct), along
871
+ with all the other space in use with that Dwarf_P_Debug.
872
+
873
+ .H 3 "dwarf_get_relocation_info_count()"
874
+ .DS
875
+ \f(CWint dwarf_get_relocation_info_count(
876
+ Dwarf_P_Debug dbg,
877
+ Dwarf_Unsigned *count_of_relocation_sections ,
878
+ int *drd_buffer_version,
879
+ Dwarf_Error* error)\fP
880
+ .DE
881
+ The function \f(CWdwarf_get_relocation_info() \fP
882
+ returns, through the pointer \f(CWcount_of_relocation_sections\fP, the
883
+ number of times that \f(CWdwarf_get_relocation_info() \fP
884
+ should be called.
885
+
886
+ The function \f(CWdwarf_get_relocation_info() \fP
887
+ returns DW_DLV_OK if the call was successful (the
888
+ \f(CWcount_of_relocation_sections\fP is therefore meaningful,
889
+ though \f(CWcount_of_relocation_sections\fP
890
+ could be zero).
891
+
892
+ \f(CW*drd_buffer_version\fP
893
+ is the value 2.
894
+ If the structure pointed to by
895
+ the \f(CW*reldata_buffer\fP
896
+ changes this number will change.
897
+ The application should verify that the number is
898
+ the version it understands (that it matches
899
+ the value of DWARF_DRD_BUFFER_VERSION (from libdwarf.h)).
900
+ The value 1 version was never used in production
901
+ MIPS libdwarf (version 1 did exist in source).
902
+
903
+ It returns DW_DLV_NO_ENTRY if
904
+ \f(CWcount_of_relocation_sections\fP is not meaningful
905
+ because \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP was not
906
+ passed to the
907
+ \f(CWdwarf_producer_init_c()\fP
908
+ \f(CWdwarf_producer_init_b()\fP or
909
+ \f(CWdwarf_producer_init()\fP call
910
+ (whichever one was used).
911
+
912
+ It returns DW_DLV_ERROR if there was an error,
913
+ in which case
914
+ \f(CWcount_of_relocation_sections\fP is not meaningful.
915
+
916
+ .H 3 "dwarf_get_relocation_info()"
917
+ .DS
918
+ \f(CWint dwarf_get_relocation_info(
919
+ Dwarf_P_Debug dbg,
920
+ Dwarf_Signed *elf_section_index,
921
+ Dwarf_Signed *elf_section_index_link,
922
+ Dwarf_Unsigned *relocation_buffer_count,
923
+ Dwarf_Relocation_Data *reldata_buffer,
924
+ Dwarf_Error* error)\fP
925
+ .DE
926
+
927
+ The function \f(CWdwarf_get_relocation_info() \fP
928
+ should normally be called repetitively,
929
+ for the number of relocation sections that
930
+ \f(CWdwarf_get_relocation_info_count() \fP
931
+ indicated exist.
932
+
933
+ It returns \f(CWDW_DLV_OK\fP to indicate that
934
+ valid values are returned through the pointer arguments.
935
+ The \f(CWerror\fP argument is not set.
936
+
937
+ It returns DW_DLV_NO_ENTRY if there are no entries
938
+ (the count of relocation arrays is zero.).
939
+ The \f(CWerror\fP argument is not set.
940
+
941
+ It returns \f(CWDW_DLV_ERROR\fP if there is an error.
942
+ Calling \f(CWdwarf_get_relocation_info() \fP
943
+ more than the number of times indicated by
944
+ \f(CWdwarf_get_relocation_info_count() \fP
945
+ (without an intervening call to
946
+ \f(CWdwarf_reset_section_bytes() \fP )
947
+ results in a return of \f(CWDW_DLV_ERROR\fP once past
948
+ the valid count.
949
+ The \f(CWerror\fP argument is set to indicate the error.
950
+
951
+ Now consider the returned-through-pointer values for
952
+ \f(CWDW_DLV_OK\fP .
953
+
954
+ \f(CW*elf_section_index\fP
955
+ is the 'elf section index' of the section implied by
956
+ this group of relocations.
957
+
958
+
959
+ \f(CW*elf_section_index_link\fP
960
+ is the section index of the section that these
961
+ relocations apply to.
962
+
963
+ \f(CW*relocation_buffer_count\fP
964
+ is the number of array entries of relocation information
965
+ in the array pointed to by
966
+ \f(CW*reldata_buffer\fP .
967
+
968
+
969
+ \f(CW*reldata_buffer\fP
970
+ points to an array of 'struct Dwarf_Relocation_Data_s'
971
+ structures.
972
+
973
+ The version 2 array information is as follows:
974
+
975
+ .nf
976
+ enum Dwarf_Rel_Type {dwarf_drt_none,
977
+ dwarf_drt_data_reloc,
978
+ dwarf_drt_segment_rel,
979
+ dwarf_drt_first_of_length_pair,
980
+ dwarf_drt_second_of_length_pair
981
+ };
982
+ typedef struct Dwarf_Relocation_Data_s * Dwarf_Relocation_Data;
983
+ struct Dwarf_Relocation_Data_s {
984
+ unsigned char drd_type; /* contains Dwarf_Rel_Type */
985
+ unsigned char drd_length; /* typically 4 or 8 */
986
+ Dwarf_Unsigned drd_offset; /* where the data to reloc is */
987
+ Dwarf_Unsigned drd_symbol_index;
988
+ };
989
+
990
+ .fi
991
+
992
+ The \f(CWDwarf_Rel_Type\fP enum is encoded (via casts if necessary)
993
+ into the single unsigned char \f(CWdrd_type\fP field to control
994
+ the space used for this information (keep the space to 1 byte).
995
+
996
+ The unsigned char \f(CWdrd_length\fP field
997
+ holds the size in bytes of the field to be relocated.
998
+ So for elf32 object formats with 32 bit apps, \f(CWdrd_length\fP
999
+ will be 4. For objects with MIPS -64 contents,
1000
+ \f(CWdrd_length\fP will be 8.
1001
+ For some dwarf 64 bit environments, such as ia64, \f(CWdrd_length\fP
1002
+ is 4 for some relocations (file offsets, for example)
1003
+ and 8 for others (run time
1004
+ addresses, for example).
1005
+
1006
+ If \f(CWdrd_type\fP is \f(CWdwarf_drt_none\fP, this is an unused slot
1007
+ and it should be ignored.
1008
+
1009
+ If \f(CWdrd_type\fP is \f(CWdwarf_drt_data_reloc\fP
1010
+ this is an ordinary relocation.
1011
+ The relocation type means either
1012
+ (R_MIPS_64) or (R_MIPS_32) (or the like for
1013
+ the particular ABI.
1014
+ \f(CWdrd_length\fP gives the length of the field to be relocated.
1015
+ \f(CWdrd_offset\fP is an offset (of the
1016
+ value to be relocated) in
1017
+ the section this relocation stuff is linked to.
1018
+ \f(CWdrd_symbol_index\fP is the symbol index (if elf symbol
1019
+ indices were provided) or the handle to arbitrary
1020
+ information (if that is what the caller passed in
1021
+ to the relocation-creating dwarf calls) of the symbol
1022
+ that the relocation is relative to.
1023
+
1024
+
1025
+ When \f(CWdrd_type\fP is \f(CWdwarf_drt_first_of_length_pair\fP
1026
+ the next data record will be \f(CWdrt_second_of_length_pair\fP
1027
+ and the \f(CWdrd_offset\fP of the two data records will match.
1028
+ The relevant 'offset' in the section this reloc applies to
1029
+ should contain a symbolic pair like
1030
+ .nf
1031
+ .in +4
1032
+ .word second_symbol - first_symbol
1033
+ .in -4
1034
+ .fi
1035
+ to generate a length.
1036
+ \f(CWdrd_length\fP gives the length of the field to be relocated.
1037
+
1038
+ \f(CWdrt_segment_rel\fP means (R_MIPS_SCN_DISP)
1039
+ is the real relocation (R_MIPS_SCN_DISP applies to
1040
+ exception tables and this part may need further work).
1041
+ \f(CWdrd_length\fP gives the length of the field to be relocated.
1042
+
1043
+ .P
1044
+ The memory space of the section byte stream is freed
1045
+ by the \f(CWdwarf_producer_finish() \fP call
1046
+ (or would be if the \f(CWdwarf_producer_finish() \fP
1047
+ was actually correct), along
1048
+ with all the other space in use with that Dwarf_P_Debug.
1049
+
1050
+ .H 3 "dwarf_reset_section_bytes()"
1051
+
1052
+ .DS
1053
+ \f(CWvoid dwarf_reset_section_bytes(
1054
+ Dwarf_P_Debug dbg
1055
+ ) \fP
1056
+ .DE
1057
+ The function \f(CWdwarf_reset_section_bytes() \fP
1058
+ is used to reset the internal information so that
1059
+ \f(CWdwarf_get_section_bytes() \fP will begin (on the next
1060
+ call) at the initial dwarf section again.
1061
+ It also resets so that calls to
1062
+ \f(CWdwarf_get_relocation_info() \fP
1063
+ will begin again at the initial array of relocation information.
1064
+
1065
+ Some dwarf producers need to be able to run through
1066
+ the \f(CWdwarf_get_section_bytes()\fP
1067
+ and/or
1068
+ the \f(CWdwarf_get_relocation_info()\fP
1069
+ calls more than once and this call makes additional
1070
+ passes possible.
1071
+ The set of Dwarf_Ptr values returned is identical to the
1072
+ set returned by the first pass.
1073
+ It is acceptable to call this before finishing a pass
1074
+ of \f(CWdwarf_get_section_bytes()\fP
1075
+ or
1076
+ \f(CWdwarf_get_relocation_info()\fP
1077
+ calls.
1078
+ No errors are possible as this just resets some
1079
+ internal pointers.
1080
+ It is unwise to call this before
1081
+ \f(CWdwarf_transform_to_disk_form() \fP has been called.
1082
+ .P
1083
+
1084
+ .H 3 "dwarf_producer_finish()"
1085
+ .DS
1086
+ \f(CWDwarf_Unsigned dwarf_producer_finish(
1087
+ Dwarf_P_Debug dbg,
1088
+ Dwarf_Error* error) \fP
1089
+ .DE
1090
+ The function \f(CWdwarf_producer_finish() \fP should be called after all
1091
+ the bytes of data have been copied somewhere
1092
+ (normally the bytes are written to disk).
1093
+ It frees all dynamic space
1094
+ allocated for \f(CWdbg\fP, include space for the structure pointed to by
1095
+ \f(CWdbg\fP.
1096
+ This should not be called till the data have been
1097
+ copied or written
1098
+ to disk or are no longer of interest.
1099
+ It returns non-zero if successful, and \f(CWDW_DLV_NOCOUNT\fP
1100
+ if there is an error.
1101
+
1102
+ .H 2 "Debugging Information Entry Creation"
1103
+ The functions in this section add new \f(CWDIE\fPs to the object,
1104
+ and also the relationships among the \f(CWDIE\fP to be specified
1105
+ by linking them up as parents, children, left or right siblings
1106
+ of each other.
1107
+ In addition, there is a function that marks the
1108
+ root of the graph thus created.
1109
+
1110
+ .H 3 "dwarf_add_die_to_debug()"
1111
+ .DS
1112
+ \f(CWDwarf_Unsigned dwarf_add_die_to_debug(
1113
+ Dwarf_P_Debug dbg,
1114
+ Dwarf_P_Die first_die,
1115
+ Dwarf_Error *error) \fP
1116
+ .DE
1117
+ The function \f(CWdwarf_add_die_to_debug() \fP indicates to \f(CWLibdwarf\fP
1118
+ the root \f(CWDIE\fP of the \f(CWDIE\fP graph that has been built so
1119
+ far.
1120
+ It is intended to mark the compilation-unit \f(CWDIE\fP for the
1121
+ object represented by \f(CWdbg\fP.
1122
+ The root \f(CWDIE\fP is specified
1123
+ by \f(CWfirst_die\fP.
1124
+
1125
+ It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error.
1126
+
1127
+ .H 3 "dwarf_new_die()"
1128
+ .DS
1129
+ \f(CWDwarf_P_Die dwarf_new_die(
1130
+ Dwarf_P_Debug dbg,
1131
+ Dwarf_Tag new_tag,
1132
+ Dwarf_P_Die parent,
1133
+ Dwarf_P_Die child,
1134
+ Dwarf_P_Die left_sibling,
1135
+ Dwarf_P_Die right_sibling,
1136
+ Dwarf_Error *error) \fP
1137
+ .DE
1138
+ The function \f(CWdwarf_new_die() \fP creates a new \f(CWDIE\fP with
1139
+ its parent, child, left sibling, and right sibling \f(CWDIE\fPs
1140
+ specified by \f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP,
1141
+ and \f(CWright_sibling\fP, respectively.
1142
+ There is no requirement
1143
+ that all of these \f(CWDIE\fPs be specified, i.e. any of these
1144
+ descriptors may be \f(CWNULL\fP.
1145
+ If none is specified, this will
1146
+ be an isolated \f(CWDIE\fP.
1147
+ A \f(CWDIE\fP is
1148
+ transformed to disk form by \f(CWdwarf_transform_to_disk_form() \fP
1149
+ only if there is a path from
1150
+ the \f(CWDIE\fP specified by \f(CWdwarf_add_die_to_debug\fP to it.
1151
+ This function returns \f(CWDW_DLV_BADADDR\fP on error.
1152
+
1153
+ \f(CWnew_tag\fP is the tag which is given to the new \f(CWDIE\fP.
1154
+ \f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP, and
1155
+ \f(CWright_sibling\fP are pointers to establish links to existing
1156
+ \f(CWDIE\fPs. Only one of \f(CWparent\fP, \f(CWchild\fP,
1157
+ \f(CWleft_sibling\fP, and \f(CWright_sibling\fP may be non-NULL.
1158
+ If \f(CWparent\fP (\f(CWchild\fP) is given, the \f(CWDIE\fP is
1159
+ linked into the list after (before) the \f(CWDIE\fP pointed to.
1160
+ If \f(CWleft_sibling\fP (\f(CWright_sibling\fP) is given, the
1161
+ \f(CWDIE\fP is linked into the list after (before) the \f(CWDIE\fP
1162
+ pointed to.
1163
+
1164
+ To add attributes to the new \f(CWDIE\fP, use the \f(CWAttribute Creation\fP
1165
+ functions defined in the next section.
1166
+
1167
+ .H 3 "dwarf_die_link()"
1168
+ .DS
1169
+ \f(CWDwarf_P_Die dwarf_die_link(
1170
+ Dwarf_P_Die die,
1171
+ Dwarf_P_Die parent,
1172
+ Dwarf_P_Die child,
1173
+ Dwarf_P_Die left-sibling,
1174
+ Dwarf_P_Die right_sibling,
1175
+ Dwarf_Error *error) \fP
1176
+ .DE
1177
+ The function \f(CWdwarf_die_link() \fP links an existing \f(CWDIE\fP
1178
+ described by the given \f(CWdie\fP to other existing \f(CWDIE\fPs.
1179
+ The given \f(CWdie\fP can be linked to a parent \f(CWDIE\fP, a child
1180
+ \f(CWDIE\fP, a left sibling \f(CWDIE\fP, or a right sibling \f(CWDIE\fP
1181
+ by specifying non-NULL \f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP,
1182
+ and \f(CWright_sibling\fP \f(CWDwarf_P_Die\fP descriptors.
1183
+ It returns
1184
+ the given \f(CWDwarf_P_Die\fP descriptor, \f(CWdie\fP, on success,
1185
+ and \f(CWDW_DLV_BADADDR\fP on error.
1186
+
1187
+ Only one of \f(CWparent\fP, \f(CWchild\fP, \f(CWleft_sibling\fP,
1188
+ and \f(CWright_sibling\fP may be non-NULL.
1189
+ If \f(CWparent\fP
1190
+ (\f(CWchild\fP) is given, the \f(CWDIE\fP is linked into the list
1191
+ after (before) the \f(CWDIE\fP pointed to.
1192
+ If \f(CWleft_sibling\fP
1193
+ (\f(CWright_sibling\fP) is given, the \f(CWDIE\fP is linked into
1194
+ the list after (before) the \f(CWDIE\fP pointed to.
1195
+ Non-NULL links
1196
+ overwrite the corresponding links the given \f(CWdie\fP may have
1197
+ had before the call to \f(CWdwarf_die_link() \fP.
1198
+
1199
+ .H 2 "DIE Markers"
1200
+ DIE markers provide a way for a producer to extract DIE offsets
1201
+ from DIE generation. The markers do not influence the
1202
+ generation of DWARF, they simply allow a producer to
1203
+ extract .debug_info offsets for whatever purpose the
1204
+ producer finds useful (for example, a producer might
1205
+ want some unique other section unknown
1206
+ to libdwarf to know a particular DIE offset).
1207
+
1208
+ One marks one or more DIEs as desired any time before
1209
+ calling \f(CWdwarf_transform_to_disk_form()\fP.
1210
+
1211
+ After calling \f(CWdwarf_transform_to_disk_form()\fP
1212
+ call
1213
+ \f(CWdwarf_get_die_markers()\fP
1214
+ which has the offsets where the marked DIEs were written
1215
+ in the generated .debug_info data.
1216
+
1217
+
1218
+ .H 3 "dwarf_add_die_marker()"
1219
+ .DS
1220
+ \f(CWDwarf_Unsigned dwarf_add_die_marker(
1221
+ Dwarf_P_Debug dbg,
1222
+ Dwarf_P_Die die,
1223
+ Dwarf_Unsigned marker,
1224
+ Dwarf_Error *error) \fP
1225
+ .DE
1226
+ The function \f(CWdwarf_add_die_marker() \fP writes the
1227
+ value \f(CWmarker\fP to the \f(CWDIE\fP descriptor given by
1228
+ \f(CWdie\fP.
1229
+ Passing in a marker of 0 means 'there is no marker'
1230
+ (zero is the default in DIEs).
1231
+
1232
+ It returns \f(CW0\fP, on success.
1233
+ On error it returns \f(CWDW_DLV_NOCOUNT\fP.
1234
+
1235
+ .H 3 "dwarf_get_die_marker()"
1236
+ .DS
1237
+ \f(CWDwarf_Unsigned dwarf_get_die_marker(
1238
+ Dwarf_P_Debug dbg,
1239
+ Dwarf_P_Die die,
1240
+ Dwarf_Unsigned *marker,
1241
+ Dwarf_Error *error) \fP
1242
+ .DE
1243
+ The function \f(CWdwarf_get_die_marker() \fP returns the
1244
+ current marker value for this DIE
1245
+ through the pointer \f(CWmarker\fP.
1246
+ A marker value of 0 means 'no marker was set'.
1247
+
1248
+ It returns \f(CW0\fP, on success.
1249
+ On error it returns \f(CWDW_DLV_NOCOUNT\fP.
1250
+
1251
+ .H 3 "dwarf_get_die_markers()"
1252
+ .DS
1253
+ \f(CWDwarf_Unsigned dwarf_get_die_markers(
1254
+ Dwarf_P_Debug dbg,
1255
+ Dwarf_P_Marker * marker_list,
1256
+ Dwarf_Unsigned *marker_count,
1257
+ Dwarf_Error *error) \fP
1258
+ .DE
1259
+ The function \f(CWdwarf_get_die_marker() \fP returns
1260
+ a pointer to an array of \f(CWDwarf_P_Marker\fP pointers to
1261
+ \f(CWstruct Dwarf_P_Marker_s\fP structures through
1262
+ the pointer \f(CWmarker_list\fP.
1263
+ The array length is returned through the
1264
+ pointer \f(CWmarker_count\fP.
1265
+
1266
+ The call is only meaningful after
1267
+ a call to \f(CWdwarf_transform_to_disk_form()\fP as the
1268
+ transform call creates the \f(CWstruct Dwarf_P_Marker_s\fP
1269
+ structures, one for each DIE generated for .debug_info
1270
+ (but only for DIEs that had a non-zero marker value).
1271
+ The field \f(CWma_offset\fP in the structure is set
1272
+ during generation of the .debug_info byte stream.
1273
+ The field \f(CWma_marker\fP in the structure is a copy
1274
+ of the DIE marker of the DIE given that offset.
1275
+
1276
+ It returns \f(CW0\fP, on success.
1277
+ On error it returns \f(CWDW_DLV_BADADDR\fP (if there are no
1278
+ markers it returns \f(CWDW_DLV_BADADDR\fP).
1279
+
1280
+ .H 2 "Attribute Creation"
1281
+ The functions in this section add attributes to a \f(CWDIE\fP.
1282
+ These functions return a \f(CWDwarf_P_Attribute\fP descriptor
1283
+ that represents the attribute added to the given \f(CWDIE\fP.
1284
+ In most cases the return value is only useful to determine if
1285
+ an error occurred.
1286
+
1287
+ Some of the attributes have values that are relocatable.
1288
+ They
1289
+ need a symbol with respect to which the linker will perform
1290
+ relocation.
1291
+ This symbol is specified by means of an index into
1292
+ the Elf symbol table for the object
1293
+ (of course, the symbol index can be more general than an index).
1294
+
1295
+ .H 3 "dwarf_add_AT_location_expr()"
1296
+ .DS
1297
+ \f(CWDwarf_P_Attribute dwarf_add_AT_location_expr(
1298
+ Dwarf_P_Debug dbg,
1299
+ Dwarf_P_Die ownerdie,
1300
+ Dwarf_Half attr,
1301
+ Dwarf_P_Expr loc_expr,
1302
+ Dwarf_Error *error) \fP
1303
+ .DE
1304
+ The function \f(CWdwarf_add_AT_location_expr() \fP adds the attribute
1305
+ specified by \f(CWattr\fP to the \f(CWDIE\fP descriptor given by
1306
+ \f(CWownerdie\fP. The attribute should be one that has a location
1307
+ expression as its value. The location expression that is the value
1308
+ is represented by the \f(CWDwarf_P_Expr\fP descriptor \f(CWloc_expr\fP.
1309
+ It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
1310
+ given, on success. On error it returns \f(CWDW_DLV_BADADDR\fP.
1311
+
1312
+ .H 3 "dwarf_add_AT_name()"
1313
+ .DS
1314
+ \f(CWDwarf_P_Attribute dwarf_add_AT_name(
1315
+ Dwarf_P_Die ownerdie,
1316
+ char *name,
1317
+ Dwarf_Error *error) \fP
1318
+ .DE
1319
+ The function \f(CWdwarf_add_AT_name() \fP adds the string specified
1320
+ by \f(CWname\fP as the value of the \f(CWDW_AT_name\fP attribute
1321
+ for the given \f(CWDIE\fP, \f(CWownerdie\fP. It returns the
1322
+ \f(CWDwarf_P_attribute\fP descriptor for the \f(CWDW_AT_name\fP
1323
+ attribute on success. On error, it returns \f(CWDW_DLV_BADADDR\fP.
1324
+
1325
+ .H 3 "dwarf_add_AT_comp_dir()"
1326
+ .DS
1327
+ \f(CWDwarf_P_Attribute dwarf_add_AT_comp_dir(
1328
+ Dwarf_P_Die ownerdie,
1329
+ char *current_working_directory,
1330
+ Dwarf_Error *error) \fP
1331
+ .DE
1332
+ The function \f(CWdwarf_add_AT_comp_dir() \fP adds the string given by
1333
+ \f(CWcurrent_working_directory\fP as the value of the \f(CWDW_AT_comp_dir\fP
1334
+ attribute for the \f(CWDIE\fP described by the given \f(CWownerdie\fP.
1335
+ It returns the \f(CWDwarf_P_Attribute\fP for this attribute on success.
1336
+ On error, it returns \f(CWDW_DLV_BADADDR\fP.
1337
+
1338
+ .H 3 "dwarf_add_AT_producer()"
1339
+ .DS
1340
+ \f(CWDwarf_P_Attribute dwarf_add_AT_producer(
1341
+ Dwarf_P_Die ownerdie,
1342
+ char *producer_string,
1343
+ Dwarf_Error *error) \fP
1344
+ .DE
1345
+ The function \f(CWdwarf_add_AT_producer() \fP adds the string given by
1346
+ \f(CWproducer_string\fP as the value of the \f(CWDW_AT_producer\fP
1347
+ attribute for the \f(CWDIE\fP given by \f(CWownerdie\fP. It returns
1348
+ the \f(CWDwarf_P_Attribute\fP descriptor representing this attribute
1349
+ on success. On error, it returns \f(CWDW_DLV_BADADDR\fP.
1350
+
1351
+ .H 3 "dwarf_add_AT_any_value_sleb()"
1352
+ .DS
1353
+ \f(CWDwarf_P_Attribute dwarf_add_AT_any_value_sleb(
1354
+ Dwarf_P_Die ownerdie,
1355
+ Dwarf_Half attrnum,
1356
+ Dwarf_Signed signed_value,
1357
+ Dwarf_Error *error) \fP
1358
+ .DE
1359
+ The function \f(CWdwarf_add_AT_any_value_sleb() \fP adds the
1360
+ given \f(CWDwarf_Signed\fP value \f(CWsigned_value\fP as the value
1361
+ of the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP
1362
+ described by the given \f(CWownerdie\fP.
1363
+
1364
+ The FORM of the output value is \f(CWDW_FORM_sdata\fP (signed leb number)
1365
+ and the attribute will be \f(CWDW_AT_const_value\fP.
1366
+
1367
+ It returns the
1368
+ \f(CWDwarf_P_Attribute\fP descriptor for this attribute on success.
1369
+
1370
+ On error, it returns \f(CWDW_DLV_BADADDR\fP.
1371
+
1372
+ The function was created 13 August 2013.
1373
+
1374
+ .H 3 "dwarf_add_AT_const_value_signedint()"
1375
+ .DS
1376
+ \f(CWDwarf_P_Attribute dwarf_add_AT_const_value_signedint(
1377
+ Dwarf_P_Die ownerdie,
1378
+ Dwarf_Signed signed_value,
1379
+ Dwarf_Error *error) \fP
1380
+ .DE
1381
+ The function \f(CWdwarf_add_AT_const_value_signedint() \fP adds the
1382
+ given \f(CWDwarf_Signed\fP value \f(CWsigned_value\fP as the value
1383
+ of the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP
1384
+ described by the given \f(CWownerdie\fP.
1385
+
1386
+ The FORM of the output value is \f(CWDW_FORM_data<n>\fP (signed leb number)
1387
+ and the attribute will be \f(CWDW_AT_const_value\fP.
1388
+
1389
+ With this interface and output, there is no way for consumers
1390
+ to know from the FORM that the value is signed.
1391
+
1392
+
1393
+ It returns the
1394
+ \f(CWDwarf_P_Attribute\fP descriptor for this attribute on success.
1395
+
1396
+ On error, it returns \f(CWDW_DLV_BADADDR\fP.
1397
+
1398
+ .H 3 "dwarf_add_AT_any_value_uleb()"
1399
+ .DS
1400
+ \f(CWDwarf_P_Attribute dwarf_add_AT_any_value_uleb(
1401
+ Dwarf_P_Die ownerdie,
1402
+ Dwarf_Half attrnum,
1403
+ Dwarf_Unsigned unsigned_value,
1404
+ Dwarf_Error *error) \fP
1405
+ .DE
1406
+ The function \f(CWdwarf_add_AT_any_value_uleb() \fP adds the
1407
+ given \f(CWDwarf_Unsigned\fP value \f(CWunsigned_value\fP as the value
1408
+ of the \f(CWattrnum\fP attribute for the \f(CWDIE\fP described
1409
+ by the given \f(CWownerdie\fP.
1410
+
1411
+ The FORM of the output value is \f(CWDW_FORM_udata\fP (unsigned leb number)
1412
+ and the attribute is \f(CWattrnum\fP.
1413
+
1414
+ It returns the \f(CWDwarf_P_Attribute\fP
1415
+ descriptor for this attribute on success.
1416
+
1417
+ On error, it returns \f(CWDW_DLV_BADADDR\fP.
1418
+
1419
+ The function was created 13 August 2013.
1420
+
1421
+ .H 3 "dwarf_add_AT_const_value_unsignedint()"
1422
+ .DS
1423
+ \f(CWDwarf_P_Attribute dwarf_add_AT_const_value_unsignedint(
1424
+ Dwarf_P_Die ownerdie,
1425
+ Dwarf_Unsigned unsigned_value,
1426
+ Dwarf_Error *error) \fP
1427
+ .DE
1428
+ The function \f(CWdwarf_add_AT_const_value_unsignedint() \fP adds the
1429
+ given \f(CWDwarf_Unsigned\fP value \f(CWunsigned_value\fP as the value
1430
+ of the \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP described
1431
+ by the given \f(CWownerdie\fP.
1432
+
1433
+ The FORM of the output value is \f(CWDW_FORM_data<n>\fP
1434
+ and the attribute will be \f(CWDW_AT_const_value\fP.
1435
+
1436
+ With this interface and output, there is no way for consumers
1437
+ to know from the FORM that the value is signed.
1438
+
1439
+ It returns the \f(CWDwarf_P_Attribute\fP
1440
+ descriptor for this attribute on success.
1441
+
1442
+ On error, it returns \f(CWDW_DLV_BADADDR\fP.
1443
+
1444
+ .H 3 "dwarf_add_AT_const_value_string()"
1445
+ .DS
1446
+ \f(CWDwarf_P_Attribute dwarf_add_AT_const_value_string(
1447
+ Dwarf_P_Die ownerdie,
1448
+ char *string_value,
1449
+ Dwarf_Error *error) \fP
1450
+ .DE
1451
+ The function \f(CWdwarf_add_AT_const_value_string() \fP adds the
1452
+ string value given by \f(CWstring_value\fP as the value of the
1453
+ \f(CWDW_AT_const_value\fP attribute for the \f(CWDIE\fP described
1454
+ by the given \f(CWownerdie\fP. It returns the \f(CWDwarf_P_Attribute\fP
1455
+ descriptor for this attribute on success. On error, it returns
1456
+ \f(CWDW_DLV_BADADDR\fP.
1457
+
1458
+ .H 3 "dwarf_add_AT_targ_address()"
1459
+ .DS
1460
+ \f(CWDwarf_P_Attribute dwarf_add_AT_targ_address(
1461
+ Dwarf_P_Debug dbg,
1462
+ Dwarf_P_Die ownerdie,
1463
+ Dwarf_Half attr,
1464
+ Dwarf_Unsigned pc_value,
1465
+ Dwarf_Signed sym_index,
1466
+ Dwarf_Error *error) \fP
1467
+ .DE
1468
+ The function \f(CWdwarf_add_AT_targ_address() \fP adds an attribute that
1469
+ belongs to the "address" class to the die specified by \f(CWownerdie\fP.
1470
+ The attribute is specified by \f(CWattr\fP, and the object that the
1471
+ \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The relocatable
1472
+ address that is the value of the attribute is specified by \f(CWpc_value\fP.
1473
+ The symbol to be used for relocation is specified by the \f(CWsym_index\fP,
1474
+ which is the index of the symbol in the Elf symbol table.
1475
+
1476
+ It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
1477
+ on success, and \f(CWDW_DLV_BADADDR\fP on error.
1478
+
1479
+
1480
+ .H 3 "dwarf_add_AT_targ_address_b()"
1481
+ .DS
1482
+ \f(CWDwarf_P_Attribute dwarf_add_AT_targ_address_b(
1483
+ Dwarf_P_Debug dbg,
1484
+ Dwarf_P_Die ownerdie,
1485
+ Dwarf_Half attr,
1486
+ Dwarf_Unsigned pc_value,
1487
+ Dwarf_Unsigned sym_index,
1488
+ Dwarf_Error *error) \fP
1489
+ .DE
1490
+ The function \f(CWdwarf_add_AT_targ_address_b() \fP
1491
+ is identical to \f(CWdwarf_add_AT_targ_address() \fP
1492
+ except that \f(CWsym_index() \fP is guaranteed to
1493
+ be large enough that it can contain a pointer to
1494
+ arbitrary data (so the caller can pass in a real elf
1495
+ symbol index, an arbitrary number, or a pointer
1496
+ to arbitrary data).
1497
+ The ability to pass in a pointer through \f(CWsym_index() \fP
1498
+ is only usable with
1499
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.
1500
+
1501
+ The \f(CWpc_value\fP
1502
+ is put into the section stream output and
1503
+ the \f(CWsym_index\fP is applied to the relocation
1504
+ information.
1505
+
1506
+ Do not use this function for attr \f(CWDW_AT_high_pc\fP
1507
+ if the value to be recorded is an offset (not a pc)
1508
+ [ use \f(CWdwarf_add_AT_unsigned_const()\fP
1509
+ or \f(CWdwarf_add_AT_any_value_uleb()\fP
1510
+ instead].
1511
+
1512
+ .H 3 "dwarf_add_AT_dataref()"
1513
+ .DS
1514
+ \f(CWDwarf_P_Attribute dwarf_add_AT_dataref(
1515
+ Dwarf_P_Debug dbg,
1516
+ Dwarf_P_Die ownerdie,
1517
+ Dwarf_Half attr,
1518
+ Dwarf_Unsigned pc_value,
1519
+ Dwarf_Unsigned sym_index,
1520
+ Dwarf_Error *error) \fP
1521
+ .DE
1522
+ This is very similar to \f(CWdwarf_add_AT_targ_address_b() \fP
1523
+ but results in a different FORM (results in DW_FORM_data4
1524
+ or DW_FORM_data8).
1525
+
1526
+ Useful for adding relocatable addresses in location lists.
1527
+
1528
+ \f(CWsym_index() \fP is guaranteed to
1529
+ be large enough that it can contain a pointer to
1530
+ arbitrary data (so the caller can pass in a real elf
1531
+ symbol index, an arbitrary number, or a pointer
1532
+ to arbitrary data).
1533
+ The ability to pass in a pointer through \f(CWsym_index() \fP
1534
+ is only usable with
1535
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.
1536
+
1537
+ The \f(CWpc_value\fP
1538
+ is put into the section stream output and
1539
+ the \f(CWsym_index\fP is applied to the relocation
1540
+ information.
1541
+
1542
+ Do not use this function for \f(CWDW_AT_high_pc\fP, use
1543
+ \f(CWdwarf_add_AT_unsigned_const()\fP
1544
+ or \f(CWdwarf_add_AT_any_value_uleb()\fP
1545
+ [ if the value to be recorded is
1546
+ an offset of \f(CWDW_AT_low_pc\fP]
1547
+ or \f(CWdwarf_add_AT_targ_address_b()\fP [ if the value
1548
+ to be recorded is an address].
1549
+
1550
+ .H 3 "dwarf_add_AT_ref_address()"
1551
+ .DS
1552
+ \f(CWDwarf_P_Attribute dwarf_add_AT_ref_address(
1553
+ Dwarf_P_Debug dbg,
1554
+ Dwarf_P_Die ownerdie,
1555
+ Dwarf_Half attr,
1556
+ Dwarf_Unsigned pc_value,
1557
+ Dwarf_Unsigned sym_index,
1558
+ Dwarf_Error *error) \fP
1559
+ .DE
1560
+
1561
+ This is very similar to \f(CWdwarf_add_AT_targ_address_b() \fP
1562
+ but results in a different FORM (results in \f(CWDW_FORM_ref_addr\fP
1563
+ being generated).
1564
+
1565
+ Useful for \f(CWDW_AT_type\fP and \f(CWDW_AT_import\fP attributes.
1566
+
1567
+ \f(CWsym_index() \fP is guaranteed to
1568
+ be large enough that it can contain a pointer to
1569
+ arbitrary data (so the caller can pass in a real elf
1570
+ symbol index, an arbitrary number, or a pointer
1571
+ to arbitrary data).
1572
+ The ability to pass in a pointer through \f(CWsym_index() \fP
1573
+ is only usable with
1574
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.
1575
+
1576
+ The \f(CWpc_value\fP
1577
+ is put into the section stream output and
1578
+ the \f(CWsym_index\fP is applied to the relocation
1579
+ information.
1580
+
1581
+ Do not use this function for \f(CWDW_AT_high_pc\fP.
1582
+
1583
+
1584
+ .H 3 "dwarf_add_AT_unsigned_const()"
1585
+ .DS
1586
+ \f(CWDwarf_P_Attribute dwarf_add_AT_unsigned_const(
1587
+ Dwarf_P_Debug dbg,
1588
+ Dwarf_P_Die ownerdie,
1589
+ Dwarf_Half attr,
1590
+ Dwarf_Unsigned value,
1591
+ Dwarf_Error *error) \fP
1592
+ .DE
1593
+ The function \f(CWdwarf_add_AT_unsigned_const() \fP adds an attribute
1594
+ with a \f(CWDwarf_Unsigned\fP value belonging to the "constant" class,
1595
+ to the \f(CWDIE\fP specified by \f(CWownerdie\fP. The object that
1596
+ the \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The attribute
1597
+ is specified by \f(CWattr\fP, and its value is specified by \f(CWvalue\fP.
1598
+
1599
+ The FORM of the output will be one of the \f(CWDW_FORM_data<n>\fP forms.
1600
+
1601
+ It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
1602
+ on success, and \f(CWDW_DLV_BADADDR\fP on error.
1603
+
1604
+ .H 3 "dwarf_add_AT_signed_const()"
1605
+ .DS
1606
+ \f(CWDwarf_P_Attribute dwarf_add_AT_signed_const(
1607
+ Dwarf_P_Debug dbg,
1608
+ Dwarf_P_Die ownerdie,
1609
+ Dwarf_Half attr,
1610
+ Dwarf_Signed value,
1611
+ Dwarf_Error *error) \fP
1612
+ .DE
1613
+ The function \f(CWdwarf_add_AT_signed_const() \fP adds an attribute
1614
+ with a \f(CWDwarf_Signed\fP value belonging to the "constant" class,
1615
+ to the \f(CWDIE\fP specified by \f(CWownerdie\fP. The object that
1616
+ the \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The attribute
1617
+ is specified by \f(CWattr\fP, and its value is specified by \f(CWvalue\fP.
1618
+
1619
+ It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
1620
+ on success, and \f(CWDW_DLV_BADADDR\fP on error.
1621
+
1622
+ .H 3 "dwarf_add_AT_reference()"
1623
+ .DS
1624
+ \f(CWDwarf_P_Attribute dwarf_add_AT_reference(
1625
+ Dwarf_P_Debug dbg,
1626
+ Dwarf_P_Die ownerdie,
1627
+ Dwarf_Half attr,
1628
+ Dwarf_P_Die otherdie,
1629
+ Dwarf_Error *error)\fP
1630
+ .DE
1631
+ The function \f(CWdwarf_add_AT_reference()\fP adds an attribute
1632
+ with a value that is a reference to another \f(CWDIE\fP in the
1633
+ same compilation-unit to the \f(CWDIE\fP specified by \f(CWownerdie\fP.
1634
+ The object that the \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP.
1635
+ The attribute is specified by \f(CWattr\fP, and the other \f(CWDIE\fP
1636
+ being referred to is specified by \f(CWotherdie\fP.
1637
+
1638
+ The FORM of the output will be one of the \f(CWDW_FORM_data<n>\fP forms.
1639
+
1640
+ This cannot generate DW_FORM_ref_addr references to
1641
+ \f(CWDIE\fPs in other compilation units.
1642
+
1643
+ It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
1644
+ on success, and \f(CWDW_DLV_BADADDR\fP on error.
1645
+
1646
+ .H 3 "dwarf_add_AT_reference_b()"
1647
+ .DS
1648
+ \f(CWDwarf_P_Attribute dwarf_add_AT_reference_b(
1649
+ Dwarf_P_Debug dbg,
1650
+ Dwarf_Half attr,
1651
+ Dwarf_P_Die ownerdie,
1652
+ Dwarf_P_Die otherdie,
1653
+ Dwarf_Error *error)\fP
1654
+ .DE
1655
+ The function \f(CWdwarf_add_AT_reference_b()\fP
1656
+ is the same as \f(CWdwarf_add_AT_reference()\fP
1657
+ except that \f(CWdwarf_add_AT_reference_b()\fP
1658
+ accepts a NULL \f(CWotherdie\fP with the assumption
1659
+ that \f(CWdwarf_fixup_AT_reference_die()\fP
1660
+ will be called by user code
1661
+ to fill in the missing \f(CWotherdie\fP
1662
+ before the DIEs are transformed to disk form.
1663
+
1664
+ .H 3 "dwarf_fixup_AT_reference_die()"
1665
+ .DS
1666
+ \f(CWint dwarf_fixup_AT_reference_die(
1667
+ Dwarf_Half attrnum,
1668
+ Dwarf_P_Die ownerdie,
1669
+ Dwarf_P_Die otherdie,
1670
+ Dwarf_Error *error)\fP
1671
+ .DE
1672
+ The function \f(CWdwarf_fixup_AT_reference_die()\fP
1673
+ is provided to set the NULL \f(CWotherdie\fP
1674
+ that \f(CWdwarf_add_AT_reference_b()\fP allows
1675
+ to the reference target DIE.
1676
+ This must be done before transforming to disk form.
1677
+ \f(CWattrnum()\fP should be the
1678
+ attribute number of the attribute of \fCWownerdie\fP which is
1679
+ to be updated. For example, if a local forward reference
1680
+ was in a \fCWDW_AT_sibling\fP attribute in ownerdie, pass
1681
+ the value \fCWDW_AT_sibling\fP as attrnum.
1682
+ .P
1683
+ Since no attribute number can appear more than once on a
1684
+ given DIE
1685
+ the \f(CWattrnum()\fP suffices to uniquely identify which
1686
+ attribute of \fCWownerdie\fP to update
1687
+ .P
1688
+ It returns either \f(CWDW_DLV_OK\fP (on success)
1689
+ or \f(CWDW_DLV_ERROR\fP (on error).
1690
+ Calling this on an attribute where \f(CWotherdie\fP
1691
+ was already set is an error.
1692
+
1693
+
1694
+ .H 3 "dwarf_add_AT_flag()"
1695
+ .DS
1696
+ \f(CWDwarf_P_Attribute dwarf_add_AT_flag(
1697
+ Dwarf_P_Debug dbg,
1698
+ Dwarf_P_Die ownerdie,
1699
+ Dwarf_Half attr,
1700
+ Dwarf_Small flag,
1701
+ Dwarf_Error *error)\fP
1702
+ .DE
1703
+ The function \f(CWdwarf_add_AT_flag()\fP adds an attribute with
1704
+ a \f(CWDwarf_Small\fP value belonging to the "flag" class, to the
1705
+ \f(CWDIE\fP specified by \f(CWownerdie\fP. The object that the
1706
+ \f(CWDIE\fP belongs to is specified by \f(CWdbg\fP. The attribute
1707
+ is specified by \f(CWattr\fP, and its value is specified by \f(CWflag\fP.
1708
+
1709
+ It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
1710
+ on success, and \f(CWDW_DLV_BADADDR\fP on error.
1711
+
1712
+ .H 3 "dwarf_add_AT_string()"
1713
+ .DS
1714
+ \f(CWDwarf_P_Attribute dwarf_add_AT_string(
1715
+ Dwarf_P_Debug dbg,
1716
+ Dwarf_P_Die ownerdie,
1717
+ Dwarf_Half attr,
1718
+ char *string,
1719
+ Dwarf_Error *error)\fP
1720
+ .DE
1721
+ The function \f(CWdwarf_add_AT_string()\fP adds an attribute with a
1722
+ value that is a character string to the \f(CWDIE\fP specified by
1723
+ \f(CWownerdie\fP. The object that the \f(CWDIE\fP belongs to is
1724
+ specified by \f(CWdbg\fP. The attribute is specified by \f(CWattr\fP,
1725
+ and its value is pointed to by \f(CWstring\fP.
1726
+
1727
+ It returns the \f(CWDwarf_P_Attribute\fP descriptor for the attribute
1728
+ on success, and \f(CWDW_DLV_BADADDR\fP on error.
1729
+
1730
+ .H 2 "Expression Creation"
1731
+ The following functions are used to convert location expressions into
1732
+ blocks so that attributes with values that are location expressions
1733
+ can store their values as a \f(CWDW_FORM_blockn\fP value. This is for
1734
+ both .debug_info and .debug_loc expression blocks.
1735
+
1736
+ To create an expression, first call \f(CWdwarf_new_expr()\fP to get
1737
+ a \f(CWDwarf_P_Expr\fP descriptor that can be used to build up the
1738
+ block containing the location expression. Then insert the parts of
1739
+ the expression in prefix order (exactly the order they would be
1740
+ interpreted in in an expression interpreter). The bytes of the
1741
+ expression are then built-up as specified by the user.
1742
+
1743
+ .H 3 "dwarf_new_expr()"
1744
+ .DS
1745
+ \f(CWDwarf_Expr dwarf_new_expr(
1746
+ Dwarf_P_Debug dbg,
1747
+ Dwarf_Error *error)\fP
1748
+ .DE
1749
+ The function \f(CWdwarf_new_expr()\fP creates a new expression area
1750
+ in which a location expression stream can be created. It returns
1751
+ a \f(CWDwarf_P_Expr\fP descriptor that can be used to add operators
1752
+ to build up a location expression. It returns \f(CWNULL\fP on error.
1753
+
1754
+ .H 3 "dwarf_add_expr_gen()"
1755
+ .DS
1756
+ \f(CWDwarf_Unsigned dwarf_add_expr_gen(
1757
+ Dwarf_P_Expr expr,
1758
+ Dwarf_Small opcode,
1759
+ Dwarf_Unsigned val1,
1760
+ Dwarf_Unsigned val2,
1761
+ Dwarf_Error *error)\fP
1762
+ .DE
1763
+ The function \f(CWdwarf_add_expr_gen()\fP takes an operator specified
1764
+ by \f(CWopcode\fP, along with up to 2 operands specified by \f(CWval1\fP,
1765
+ and \f(CWval2\fP, converts it into the \f(CWDwarf\fP representation and
1766
+ appends the bytes to the byte stream being assembled for the location
1767
+ expression represented by \f(CWexpr\fP. The first operand, if present,
1768
+ to \f(CWopcode\fP is in \f(CWval1\fP, and the second operand, if present,
1769
+ is in \f(CWval2\fP. Both the operands may actually be signed or unsigned
1770
+ depending on \f(CWopcode\fP. It returns the number of bytes in the byte
1771
+ stream for \f(CWexpr\fP currently generated, i.e. after the addition of
1772
+ \f(CWopcode\fP. It returns \f(CWDW_DLV_NOCOUNT\fP on error.
1773
+
1774
+ The function \f(CWdwarf_add_expr_gen()\fP works for all opcodes except
1775
+ those that have a target address as an operand. This is because it does
1776
+ not set up a relocation record that is needed when target addresses are
1777
+ involved.
1778
+
1779
+ .H 3 "dwarf_add_expr_addr()"
1780
+ .DS
1781
+ \f(CWDwarf_Unsigned dwarf_add_expr_addr(
1782
+ Dwarf_P_Expr expr,
1783
+ Dwarf_Unsigned address,
1784
+ Dwarf_Signed sym_index,
1785
+ Dwarf_Error *error)\fP
1786
+ .DE
1787
+ The function \f(CWdwarf_add_expr_addr()\fP is used to add the
1788
+ \f(CWDW_OP_addr\fP opcode to the location expression represented
1789
+ by the given \f(CWDwarf_P_Expr\fP descriptor, \f(CWexpr\fP. The
1790
+ value of the relocatable address is given by \f(CWaddress\fP.
1791
+ The symbol to be used for relocation is given by \f(CWsym_index\fP,
1792
+ which is the index of the symbol in the Elf symbol table. It returns
1793
+ the number of bytes in the byte stream for \f(CWexpr\fP currently
1794
+ generated, i.e. after the addition of the \f(CWDW_OP_addr\fP operator.
1795
+ It returns \f(CWDW_DLV_NOCOUNT\fP on error.
1796
+
1797
+ .H 3 "dwarf_add_expr_addr_b()"
1798
+ .DS
1799
+ \f(CWDwarf_Unsigned dwarf_add_expr_addr_b(
1800
+ Dwarf_P_Expr expr,
1801
+ Dwarf_Unsigned address,
1802
+ Dwarf_Unsigned sym_index,
1803
+ Dwarf_Error *error)\fP
1804
+ .DE
1805
+ The function \f(CWdwarf_add_expr_addr_f()\fP is
1806
+ identical to \f(CWdwarf_add_expr_addr()\fP
1807
+ except that \f(CWsym_index() \fP is guaranteed to
1808
+ be large enough that it can contain a pointer to
1809
+ arbitrary data (so the caller can pass in a real elf
1810
+ symbol index, an arbitrary number, or a pointer
1811
+ to arbitrary data).
1812
+ The ability to pass in a pointer through \f(CWsym_index() \fP
1813
+ is only usable with
1814
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.
1815
+
1816
+
1817
+
1818
+ .H 3 "dwarf_expr_current_offset()"
1819
+ .DS
1820
+ \f(CWDwarf_Unsigned dwarf_expr_current_offset(
1821
+ Dwarf_P_Expr expr,
1822
+ Dwarf_Error *error)\fP
1823
+ .DE
1824
+ The function \f(CWdwarf_expr_current_offset()\fP returns the number
1825
+ of bytes currently in the byte stream for the location expression
1826
+ represented by the given \fCW(Dwarf_P_Expr\fP descriptor, \f(CWexpr\fP.
1827
+ It returns \f(CWDW_DLV_NOCOUNT\fP on error.
1828
+
1829
+ .H 3 "dwarf_expr_into_block()"
1830
+ .DS
1831
+ \f(CWDwarf_Addr dwarf_expr_into_block(
1832
+ Dwarf_P_Expr expr,
1833
+ Dwarf_Unsigned *length,
1834
+ Dwarf_Error *error)\fP
1835
+ .DE
1836
+ The function \f(CWdwarf_expr_into_block()\fP returns the address
1837
+ of the start of the byte stream generated for the location expression
1838
+ represented by the given \f(CWDwarf_P_Expr\fP descriptor, \f(CWexpr\fP.
1839
+ The length of the byte stream is returned in the location pointed to
1840
+ by \f(CWlength\fP. It returns \f(CWDW_DLV_BADADDR\fP on error.
1841
+
1842
+ .H 2 "Line Number Operations"
1843
+ These are operations on the .debug_line section.
1844
+ They provide
1845
+ information about instructions in the program and the source
1846
+ lines the instruction come from.
1847
+ Typically, code is generated
1848
+ in contiguous blocks, which may then be relocated as contiguous
1849
+ blocks.
1850
+ To make the provision of relocation information more
1851
+ efficient, the information is recorded in such a manner that only
1852
+ the address of the start of the block needs to be relocated.
1853
+ This is done by providing the address of the first instruction
1854
+ in a block using the function \f(CWdwarf_lne_set_address()\fP.
1855
+ Information about the instructions in the block are then added
1856
+ using the function \f(CWdwarf_add_line_entry()\fP, which specifies
1857
+ offsets from the address of the first instruction.
1858
+ The end of
1859
+ a contiguous block is indicated by calling the function
1860
+ \f(CWdwarf_lne_end_sequence()\fP.
1861
+ .P
1862
+ Line number operations do not support
1863
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.
1864
+
1865
+ .H 3 "dwarf_add_line_entry_b()"
1866
+ .DS
1867
+ \f(CWDwarf_Unsigned dwarf_add_line_entry_b(
1868
+ Dwarf_P_Debug dbg,
1869
+ Dwarf_Unsigned file_index,
1870
+ Dwarf_Addr code_offset,
1871
+ Dwarf_Unsigned lineno,
1872
+ Dwarf_Signed column_number,
1873
+ Dwarf_Bool is_source_stmt_begin,
1874
+ Dwarf_Bool is_basic_block_begin,
1875
+ Dwarf_Bool is_epilogue_begin,
1876
+ Dwarf_Bool is_prologue_end,
1877
+ Dwarf_Unsigned isa,
1878
+ Dwarf_Unsigned discriminator,
1879
+ Dwarf_Error *error)\fP
1880
+ .DE
1881
+ The function \f(CWdwarf_add_line_entry()\fP adds an entry to the
1882
+ section containing information about source lines.
1883
+ It specifies
1884
+ in \f(CWcode_offset\fP, the address of this line.
1885
+ The function subtracts \f(CWcode_offset\fP from the value given
1886
+ as the address of a previous line call to compute an offset,
1887
+ and the offset is what is recorded in the line instructions
1888
+ so no relocation will be needed on the line instruction generated.
1889
+ .P
1890
+ The source file that gave rise
1891
+ to the instruction is specified by \f(CWfile_index\fP, the source
1892
+ line number is specified by \f(CWlineno\fP, and the source column
1893
+ number is specified by \f(CWcolumn_number\fP
1894
+ (column numbers begin at 1)
1895
+ (if the source column is unknown, specify 0).
1896
+ \f(CWfile_index\fP
1897
+ is the index of the source file in a list of source files which is
1898
+ built up using the function \f(CWdwarf_add_file_decl()\fP.
1899
+
1900
+ \f(CWis_source_stmt_begin\fP is a boolean flag that is true only if
1901
+ the instruction at \f(CWcode_address\fP is the first instruction in
1902
+ the sequence generated for the source line at \f(CWlineno\fP. Similarly,
1903
+ \f(CWis_basic_block_begin\fP is a boolean flag that is true only if
1904
+ the instruction at \f(CWcode_address\fP is the first instruction of
1905
+ a basic block.
1906
+
1907
+ \f(CWis_epilogue_begin\fP is a boolean flag that is true only if
1908
+ the instruction at \f(CWcode_address\fP is the first instruction in
1909
+ the sequence generated for the function epilogue code.
1910
+
1911
+ Similarly, \f(CWis_prolgue_end\fP is a boolean flag that is true only if
1912
+ the instruction at \f(CWcode_address\fP is the last instruction of
1913
+ the seqence generated for the function prologue.
1914
+
1915
+ \f(CWisa\fP should be zero unless the code
1916
+ at \f(CWcode_address\fP is generated in a non-standard isa.
1917
+ The values assigned to non-standard isas are defined by the compiler
1918
+ implementation.
1919
+
1920
+ \f(CWdiscriminator\fP should be zero unless the line table
1921
+ needs to distinguish among multiple blocks
1922
+ associated with the same source file, line, and column.
1923
+ The values assigned to \f(CWdiscriminator\fP are defined by the compiler
1924
+ implementation.
1925
+
1926
+ It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error.
1927
+
1928
+ This function is defined as of December 2011.
1929
+
1930
+ .H 3 "dwarf_add_line_entry()"
1931
+ .DS
1932
+ \f(CWDwarf_Unsigned dwarf_add_line_entry(
1933
+ Dwarf_P_Debug dbg,
1934
+ Dwarf_Unsigned file_index,
1935
+ Dwarf_Addr code_offset,
1936
+ Dwarf_Unsigned lineno,
1937
+ Dwarf_Signed column_number,
1938
+ Dwarf_Bool is_source_stmt_begin,
1939
+ Dwarf_Bool is_basic_block_begin,
1940
+ Dwarf_Error *error)\fP
1941
+ .DE
1942
+ This function is the same as \f(CWdwarf_add_line_entry_b()\fP
1943
+ except this older version is missing the new
1944
+ DWARF3/4 line table fields.
1945
+
1946
+ .H 3 "dwarf_lne_set_address()"
1947
+ .DS
1948
+ \f(CWDwarf_Unsigned dwarf_lne_set_address(
1949
+ Dwarf_P_Debug dbg,
1950
+ Dwarf_Addr offs,
1951
+ Dwarf_Unsigned symidx,
1952
+ Dwarf_Error *error)\fP
1953
+ .DE
1954
+ The function \f(CWdwarf_lne_set_address()\fP sets the target address
1955
+ at which a contiguous block of instructions begin. Information about
1956
+ the instructions in the block is added to .debug_line using calls to
1957
+ \f(CWdwarfdwarf_add_line_entry()\fP which specifies the offset of each
1958
+ instruction in the block relative to the start of the block. This is
1959
+ done so that a single relocation record can be used to obtain the final
1960
+ target address of every instruction in the block.
1961
+
1962
+ The relocatable address of the start of the block of instructions is
1963
+ specified by \f(CWoffs\fP. The symbol used to relocate the address
1964
+ is given by \f(CWsymidx\fP, which is normally the index of the symbol in the
1965
+ Elf symbol table.
1966
+
1967
+ It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error.
1968
+
1969
+ .H 3 "dwarf_lne_end_sequence()"
1970
+ .DS
1971
+ \f(CWDwarf_Unsigned dwarf_lne_end_sequence(
1972
+ Dwarf_P_Debug dbg,
1973
+ Dwarf_Addr address;
1974
+ Dwarf_Error *error)\fP
1975
+ .DE
1976
+ The function \f(CWdwarf_lne_end_sequence()\fP indicates the end of a
1977
+ contiguous block of instructions.
1978
+ \f(CWaddress()\fP
1979
+ should be just higher than the end of the last address in the
1980
+ sequence of instructions.
1981
+ Before the next
1982
+ block of instructions (if any) a call to \f(CWdwarf_lne_set_address()\fP will
1983
+ have to be made to set the address of the start of the target address
1984
+ of the block, followed by calls to \f(CWdwarf_add_line_entry()\fP for
1985
+ each of the instructions in the block.
1986
+
1987
+ It returns \f(CW0\fP on success, and \f(CWDW_DLV_NOCOUNT\fP on error.
1988
+
1989
+ .H 3 "dwarf_add_directory_decl()"
1990
+ .DS
1991
+ \f(CWDwarf_Unsigned dwarf_add_directory_decl(
1992
+ Dwarf_P_Debug dbg,
1993
+ char *name,
1994
+ Dwarf_Error *error)\fP
1995
+ .DE
1996
+ The function \f(CWdwarf_add_directory_decl()\fP adds the string
1997
+ specified by \f(CWname\fP to the list of include directories in
1998
+ the statement program prologue of the .debug_line section.
1999
+ The
2000
+ string should therefore name a directory from which source files
2001
+ have been used to create the present object.
2002
+
2003
+ It returns the index of the string just added, in the list of include
2004
+ directories for the object.
2005
+ This index is then used to refer to this
2006
+ string. The first successful call of this function
2007
+ returns one, not zero, to be consistent with the directory indices
2008
+ that \f(CWdwarf_add_file_decl()\fP (below) expects..
2009
+
2010
+ \f(CWdwarf_add_directory_decl()\fP
2011
+ returns \f(CWDW_DLV_NOCOUNT\fP on error.
2012
+
2013
+ .H 3 "dwarf_add_file_decl()"
2014
+ .DS
2015
+ \f(CWDwarf_Unsigned dwarf_add_file_decl(
2016
+ Dwarf_P_Debug dbg,
2017
+ char *name,
2018
+ Dwarf_Unsigned dir_idx,
2019
+ Dwarf_Unsigned time_mod,
2020
+ Dwarf_Unsigned length,
2021
+ Dwarf_Error *error)\fP
2022
+ .DE
2023
+ The function \f(CWdwarf_add_file_decl()\fP adds the name of a source
2024
+ file that contributed to the present object.
2025
+ The name of the file is
2026
+ specified by \f(CWname\fP (which must not be the empty string
2027
+ or a null pointer, it must point to
2028
+ a string with length greater than 0).
2029
+
2030
+ In case the name is not a fully-qualified
2031
+ pathname, it is
2032
+ considered prefixed with the name of the directory specified by
2033
+ \f(CWdir_idx\fP (which does not mean the \f(CWname\fP
2034
+ is changed or physically prefixed by
2035
+ this producer function, we simply describe the meaning here).
2036
+ \f(CWdir_idx\fP is the index of the directory to be
2037
+ prefixed in the list builtup using \f(CWdwarf_add_directory_decl()\fP.
2038
+ As specified by the DWARF spec, a \f(CWdir_idx\fP of zero will be
2039
+ interpreted as meaning the directory of the compilation and
2040
+ another index must refer to a valid directory as
2041
+ FIXME
2042
+
2043
+
2044
+ \f(CWtime_mod\fP gives the time at which the file was last modified,
2045
+ and \f(CWlength\fP gives the length of the file in bytes.
2046
+
2047
+ It returns the index of the source file in the list built up so far
2048
+ using this function, on success. This index can then be used to
2049
+ refer to this source file in calls to \f(CWdwarf_add_line_entry()\fP.
2050
+ On error, it returns \f(CWDW_DLV_NOCOUNT\fP.
2051
+
2052
+ .H 2 "Fast Access (aranges) Operations"
2053
+ These functions operate on the .debug_aranges section.
2054
+
2055
+ .H 3 "dwarf_add_arange()"
2056
+ .DS
2057
+ \f(CWDwarf_Unsigned dwarf_add_arange(
2058
+ Dwarf_P_Debug dbg,
2059
+ Dwarf_Addr begin_address,
2060
+ Dwarf_Unsigned length,
2061
+ Dwarf_Signed symbol_index,
2062
+ Dwarf_Error *error)\fP
2063
+ .DE
2064
+ The function \f(CWdwarf_add_arange()\fP adds another address range
2065
+ to be added to the section
2066
+ containing address range information, .debug_aranges.
2067
+ The relocatable start address of the range is
2068
+ specified by \f(CWbegin_address\fP, and the length of the address
2069
+ range is specified by \f(CWlength\fP.
2070
+ The relocatable symbol to be
2071
+ used to relocate the start of the address range is specified by
2072
+ \f(CWsymbol_index\fP, which is normally
2073
+ the index of the symbol in the Elf
2074
+ symbol table.
2075
+
2076
+ It returns a non-zero value on success, and \f(CW0\fP on error.
2077
+
2078
+ .H 3 "dwarf_add_arange_b()"
2079
+ .DS
2080
+ \f(CWDwarf_Unsigned dwarf_add_arange_b(
2081
+ Dwarf_P_Debug dbg,
2082
+ Dwarf_Addr begin_address,
2083
+ Dwarf_Unsigned length,
2084
+ Dwarf_Unsigned symbol_index,
2085
+ Dwarf_Unsigned end_symbol_index,
2086
+ Dwarf_Addr offset_from_end_symbol,
2087
+ Dwarf_Error *error)\fP
2088
+ .DE
2089
+ The function \f(CWdwarf_add_arange_b()\fP adds another address range
2090
+ to be added to the section containing
2091
+ address range information, .debug_aranges.
2092
+
2093
+ If
2094
+ \f(CWend_symbol_index is not zero\fP
2095
+ we are using two symbols to create a length
2096
+ (must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful)
2097
+ .sp
2098
+ .in +2
2099
+ \f(CWbegin_address\fP
2100
+ is the offset from the symbol specified by
2101
+ \f(CWsymbol_index\fP .
2102
+ \f(CWoffset_from_end_symbol\fP
2103
+ is the offset from the symbol specified by
2104
+ \f(CWend_symbol_index\fP.
2105
+ \f(CWlength\fP is ignored.
2106
+ This begin-end pair will be show up in the
2107
+ relocation array returned by
2108
+ \f(CWdwarf_get_relocation_info() \fP
2109
+ as a
2110
+ \f(CWdwarf_drt_first_of_length_pair\fP
2111
+ and
2112
+ \f(CWdwarf_drt_second_of_length_pair\fP
2113
+ pair of relocation records.
2114
+ The consuming application will turn that pair into
2115
+ something conceptually identical to
2116
+ .sp
2117
+ .nf
2118
+ .in +4
2119
+ .word end_symbol + offset_from_end - \\
2120
+ ( start_symbol + begin_address)
2121
+ .in -4
2122
+ .fi
2123
+ .sp
2124
+ The reason offsets are allowed on the begin and end symbols
2125
+ is to allow the caller to re-use existing labels
2126
+ when the labels are available
2127
+ and the corresponding offset is known
2128
+ (economizing on the number of labels in use).
2129
+ The 'offset_from_end - begin_address'
2130
+ will actually be in the binary stream, not the relocation
2131
+ record, so the app processing the relocation array
2132
+ must read that stream value into (for example)
2133
+ net_offset and actually emit something like
2134
+ .sp
2135
+ .nf
2136
+ .in +4
2137
+ .word end_symbol - start_symbol + net_offset
2138
+ .in -4
2139
+ .fi
2140
+ .sp
2141
+ .in -2
2142
+
2143
+ If
2144
+ \f(CWend_symbol_index\fP is zero
2145
+ we must be given a length
2146
+ (either
2147
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
2148
+ or
2149
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
2150
+ ):
2151
+ .sp
2152
+ .in +2
2153
+ The relocatable start address of the range is
2154
+ specified by \f(CWbegin_address\fP, and the length of the address
2155
+ range is specified by \f(CWlength\fP.
2156
+ The relocatable symbol to be
2157
+ used to relocate the start of the address range is specified by
2158
+ \f(CWsymbol_index\fP, which is normally
2159
+ the index of the symbol in the Elf
2160
+ symbol table.
2161
+ The
2162
+ \f(CWoffset_from_end_symbol\fP
2163
+ is ignored.
2164
+ .in -2
2165
+
2166
+
2167
+ It returns a non-zero value on success, and \f(CW0\fP on error.
2168
+
2169
+
2170
+ .H 2 "Fast Access (pubnames) Operations"
2171
+ These functions operate on the .debug_pubnames section.
2172
+ .sp
2173
+ .H 3 "dwarf_add_pubname()"
2174
+ .DS
2175
+ \f(CWDwarf_Unsigned dwarf_add_pubname(
2176
+ Dwarf_P_Debug dbg,
2177
+ Dwarf_P_Die die,
2178
+ char *pubname_name,
2179
+ Dwarf_Error *error)\fP
2180
+ .DE
2181
+ The function \f(CWdwarf_add_pubname()\fP adds the pubname specified
2182
+ by \f(CWpubname_name\fP to the section containing pubnames, i.e.
2183
+ .debug_pubnames. The \f(CWDIE\fP that represents the function
2184
+ being named is specified by \f(CWdie\fP.
2185
+
2186
+ It returns a non-zero value on success, and \f(CW0\fP on error.
2187
+
2188
+ .H 2 "Fast Access (weak names) Operations"
2189
+ These functions operate on the .debug_weaknames section.
2190
+
2191
+ .H 3 "dwarf_add_weakname()"
2192
+ .DS
2193
+ \f(CWDwarf_Unsigned dwarf_add_weakname(
2194
+ Dwarf_P_Debug dbg,
2195
+ Dwarf_P_Die die,
2196
+ char *weak_name,
2197
+ Dwarf_Error *error)\fP
2198
+ .DE
2199
+ The function \f(CWdwarf_add_weakname()\fP adds the weak name specified
2200
+ by \f(CWweak_name\fP to the section containing weak names, i.e.
2201
+ .debug_weaknames. The \f(CWDIE\fP that represents the function
2202
+ being named is specified by \f(CWdie\fP.
2203
+
2204
+ It returns a non-zero value on success, and \f(CW0\fP on error.
2205
+
2206
+ .H 2 "Static Function Names Operations"
2207
+ The .debug_funcnames section contains the names of static function
2208
+ names defined in the object, and also the offsets of the \f(CWDIE\fPs
2209
+ that represent the definitions of the functions in the .debug_info
2210
+ section.
2211
+
2212
+ .H 3 "dwarf_add_funcname()"
2213
+ .DS
2214
+ \f(CWDwarf_Unsigned dwarf_add_funcname(
2215
+ Dwarf_P_Debug dbg,
2216
+ Dwarf_P_Die die,
2217
+ char *func_name,
2218
+ Dwarf_Error *error)\fP
2219
+ .DE
2220
+ The function \f(CWdwarf_add_funcname()\fP adds the name of a static
2221
+ function specified by \f(CWfunc_name\fP to the section containing the
2222
+ names of static functions defined in the object represented by \f(CWdbg\fP.
2223
+ The \f(CWDIE\fP that represents the definition of the function is
2224
+ specified by \f(CWdie\fP.
2225
+
2226
+ It returns a non-zero value on success, and \f(CW0\fP on error.
2227
+
2228
+ .H 2 "File-scope User-defined Type Names Operations"
2229
+ The .debug_typenames section contains the names of file-scope
2230
+ user-defined types in the given object, and also the offsets
2231
+ of the \f(CWDIE\fPs that represent the definitions of the types
2232
+ in the .debug_info section.
2233
+
2234
+ .H 3 "dwarf_add_typename()"
2235
+ .DS
2236
+ \f(CWDwarf_Unsigned dwarf_add_typename(
2237
+ Dwarf_P_Debug dbg,
2238
+ Dwarf_P_Die die,
2239
+ char *type_name,
2240
+ Dwarf_Error *error)\fP
2241
+ .DE
2242
+ The function \f(CWdwarf_add_typename()\fP adds the name of a file-scope
2243
+ user-defined type specified by \f(CWtype_name\fP to the section that
2244
+ contains the names of file-scope user-defined type. The object that
2245
+ this section belongs to is specified by \f(CWdbg\fP. The \f(CWDIE\fP
2246
+ that represents the definition of the type is specified by \f(CWdie\fP.
2247
+
2248
+ It returns a non-zero value on success, and \f(CW0\fP on error.
2249
+
2250
+ .H 2 "File-scope Static Variable Names Operations"
2251
+ The .debug_varnames section contains the names of file-scope static
2252
+ variables in the given object, and also the offsets of the \f(CWDIE\fPs
2253
+ that represent the definition of the variables in the .debug_info
2254
+ section.
2255
+
2256
+ .H 3 "dwarf_add_varname()"
2257
+ .DS
2258
+ \f(CWDwarf_Unsigned dwarf_add_varname(
2259
+ Dwarf_P_Debug dbg,
2260
+ Dwarf_P_Die die,
2261
+ char *var_name,
2262
+ Dwarf_Error *error)\fP
2263
+ .DE
2264
+ The function \f(CWdwarf_add_varname()\fP adds the name of a file-scope
2265
+ static variable specified by \f(CWvar_name\fP to the section that
2266
+ contains the names of file-scope static variables defined by the
2267
+ object represented by \f(CWdbg\fP. The \f(CWDIE\fP that represents
2268
+ the definition of the static variable is specified by \f(CWdie\fP.
2269
+
2270
+ It returns a non-zero value on success, and \f(CW0\fP on error.
2271
+
2272
+ .H 2 "Macro Information Creation"
2273
+ All strings passed in by the caller are copied by these
2274
+ functions, so the space in which the caller provides the strings
2275
+ may be ephemeral (on the stack, or immediately reused or whatever)
2276
+ without this causing any difficulty.
2277
+
2278
+ .H 3 "dwarf_def_macro()"
2279
+ .DS
2280
+ \f(CWint dwarf_def_macro(Dwarf_P_Debug dbg,
2281
+ Dwarf_Unsigned lineno,
2282
+ char *name
2283
+ char *value,
2284
+ Dwarf_Error *error);\fP
2285
+ .DE
2286
+ Adds a macro definition.
2287
+ The \f(CWname\fP argument should include the parentheses
2288
+ and parameter names if this is a function-like macro.
2289
+ Neither string should contain extraneous whitespace.
2290
+ \f(CWdwarf_def_macro()\fP adds the mandated space after the
2291
+ name and before the value in the
2292
+ output DWARF section(but does not change the
2293
+ strings pointed to by the arguments).
2294
+ If this is a definition before any files are read,
2295
+ \f(CWlineno\fP should be 0.
2296
+ Returns \f(CWDW_DLV_ERROR\fP
2297
+ and sets \f(CWerror\fP
2298
+ if there is an error.
2299
+ Returns \f(CWDW_DLV_OK\fP if the call was successful.
2300
+
2301
+
2302
+ .H 3 "dwarf_undef_macro()"
2303
+ .DS
2304
+ \f(CWint dwarf_undef_macro(Dwarf_P_Debug dbg,
2305
+ Dwarf_Unsigned lineno,
2306
+ char *name,
2307
+ Dwarf_Error *error);\fP
2308
+ .DE
2309
+ Adds a macro un-definition note.
2310
+ If this is a definition before any files are read,
2311
+ \f(CWlineno\fP should be 0.
2312
+ Returns \f(CWDW_DLV_ERROR\fP
2313
+ and sets \f(CWerror\fP
2314
+ if there is an error.
2315
+ Returns \f(CWDW_DLV_OK\fP if the call was successful.
2316
+
2317
+
2318
+ .H 3 "dwarf_start_macro_file()"
2319
+ .DS
2320
+ \f(CWint dwarf_start_macro_file(Dwarf_P_Debug dbg,
2321
+ Dwarf_Unsigned lineno,
2322
+ Dwarf_Unsigned fileindex,
2323
+ Dwarf_Error *error);\fP
2324
+ .DE
2325
+ \f(CWfileindex\fP is an index in the .debug_line header:
2326
+ the index of
2327
+ the file name.
2328
+ See the function \f(CWdwarf_add_file_decl()\fP.
2329
+ The \f(CWlineno\fP should be 0 if this file is
2330
+ the file of the compilation unit source itself
2331
+ (which, of course, is not a #include in any
2332
+ file).
2333
+ Returns \f(CWDW_DLV_ERROR\fP
2334
+ and sets \f(CWerror\fP
2335
+ if there is an error.
2336
+ Returns \f(CWDW_DLV_OK\fP if the call was successful.
2337
+
2338
+
2339
+ .H 3 "dwarf_end_macro_file()"
2340
+ .DS
2341
+ \f(CWint dwarf_end_macro_file(Dwarf_P_Debug dbg,
2342
+ Dwarf_Error *error);\fP
2343
+ .DE
2344
+ Returns \f(CWDW_DLV_ERROR\fP
2345
+ and sets \f(CWerror\fP
2346
+ if there is an error.
2347
+ Returns \f(CWDW_DLV_OK\fP if the call was successful.
2348
+
2349
+ .H 3 "dwarf_vendor_ext()"
2350
+ .DS
2351
+ \f(CWint dwarf_vendor_ext(Dwarf_P_Debug dbg,
2352
+ Dwarf_Unsigned constant,
2353
+ char * string,
2354
+ Dwarf_Error* error); \fP
2355
+ .DE
2356
+ The meaning of the \f(CWconstant\fP and the\f(CWstring\fP
2357
+ in the macro info section
2358
+ are undefined by DWARF itself, but the string must be
2359
+ an ordinary null terminated string.
2360
+ This call is not an extension to DWARF.
2361
+ It simply enables storing
2362
+ macro information as specified in the DWARF document.
2363
+ Returns \f(CWDW_DLV_ERROR\fP
2364
+ and sets \f(CWerror\fP
2365
+ if there is an error.
2366
+ Returns \f(CWDW_DLV_OK\fP if the call was successful.
2367
+
2368
+
2369
+ .H 2 "Low Level (.debug_frame) operations"
2370
+ These functions operate on the .debug_frame section. Refer to
2371
+ \f(CWlibdwarf.h\fP for the register names and register assignment
2372
+ mapping. Both of these are necessarily machine dependent.
2373
+
2374
+ .H 3 "dwarf_new_fde()"
2375
+ .DS
2376
+ \f(CWDwarf_P_Fde dwarf_new_fde(
2377
+ Dwarf_P_Debug dbg,
2378
+ Dwarf_Error *error)\fP
2379
+ .DE
2380
+ The function \f(CWdwarf_new_fde()\fP returns a new \f(CWDwarf_P_Fde\fP
2381
+ descriptor that should be used to build a complete \f(CWFDE\fP.
2382
+ Subsequent calls to routines that build up the \f(CWFDE\fP should use
2383
+ the same \f(CWDwarf_P_Fde\fP descriptor.
2384
+
2385
+ It returns a valid \f(CWDwarf_P_Fde\fP descriptor on success, and
2386
+ \f(CWDW_DLV_BADADDR\fP on error.
2387
+
2388
+ .H 3 "dwarf_add_frame_cie()"
2389
+ .DS
2390
+ \f(CWDwarf_Unsigned dwarf_add_frame_cie(
2391
+ Dwarf_P_Debug dbg,
2392
+ char *augmenter,
2393
+ Dwarf_Small code_align,
2394
+ Dwarf_Small data_align,
2395
+ Dwarf_Small ret_addr_reg,
2396
+ Dwarf_Ptr init_bytes,
2397
+ Dwarf_Unsigned init_bytes_len,
2398
+ Dwarf_Error *error);\fP
2399
+ .DE
2400
+ The function
2401
+ \f(CWdwarf_add_frame_cie()\fP
2402
+ creates a \f(CWCIE\fP,
2403
+ and returns an index to it, that should be used to refer to this
2404
+ \f(CWCIE\fP.
2405
+ \f(CWCIE\fPs are used by \f(CWFDE\fPs to setup
2406
+ initial values for frames.
2407
+ The augmentation string for the \f(CWCIE\fP
2408
+ is specified by \f(CWaugmenter\fP.
2409
+ The code alignment factor,
2410
+ data alignment factor, and the return address register for the
2411
+ \f(CWCIE\fP are specified by \f(CWcode_align\fP, \f(CWdata_align\fP,
2412
+ and \f(CWret_addr_reg\fP respectively.
2413
+ \f(CWinit_bytes\fP points
2414
+ to the bytes that represent the instructions for the \f(CWCIE\fP
2415
+ being created, and \f(CWinit_bytes_len\fP specifies the number
2416
+ of bytes of instructions.
2417
+
2418
+ There is no convenient way to generate the \f(CWinit_bytes\fP
2419
+ stream.
2420
+ One just
2421
+ has to calculate it by hand or separately
2422
+ generate something with the
2423
+ correct sequence and use dwarfdump -v and readelf (or objdump)
2424
+ and some
2425
+ kind of hex dumper to see the bytes.
2426
+ This is a serious inconvenience!
2427
+
2428
+ It returns an index to the \f(CWCIE\fP just created on success.
2429
+ On error it returns \f(CWDW_DLV_NOCOUNT\fP.
2430
+
2431
+ .H 3 "dwarf_add_frame_fde()"
2432
+ .DS
2433
+ \f(CWDwarf_Unsigned dwarf_add_frame_fde(
2434
+ Dwarf_P_Debug dbg,
2435
+ Dwarf_P_Fde fde,
2436
+ Dwarf_P_Die die,
2437
+ Dwarf_Unsigned cie,
2438
+ Dwarf_Addr virt_addr,
2439
+ Dwarf_Unsigned code_len,
2440
+ Dwarf_Unsigned sym_idx,
2441
+ Dwarf_Error* error)\fP
2442
+ .DE
2443
+ The function \f(CWdwarf_add_frame_fde()\fP adds the \f(CWFDE\fP
2444
+ specified by \f(CWfde\fP to the list of \f(CWFDE\fPs for the
2445
+ object represented by the given \f(CWdbg\fP.
2446
+ \f(CWdie\fP specifies
2447
+ the \f(CWDIE\fP that represents the function whose frame information
2448
+ is specified by the given \f(CWfde\fP.
2449
+ \f(CWcie\fP specifies the
2450
+ index of the \f(CWCIE\fP that should be used to setup the initial
2451
+ conditions for the given frame.
2452
+
2453
+ If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
2454
+ needed in .debug_info pass in 0 as the \f(CWdie\fP argument.
2455
+
2456
+ It returns an index to the given \f(CWfde\fP.
2457
+
2458
+
2459
+ .H 3 "dwarf_add_frame_fde_b()"
2460
+ .DS
2461
+ \f(CWDwarf_Unsigned dwarf_add_frame_fde_b(
2462
+ Dwarf_P_Debug dbg,
2463
+ Dwarf_P_Fde fde,
2464
+ Dwarf_P_Die die,
2465
+ Dwarf_Unsigned cie,
2466
+ Dwarf_Addr virt_addr,
2467
+ Dwarf_Unsigned code_len,
2468
+ Dwarf_Unsigned sym_idx,
2469
+ Dwarf_Unsigned sym_idx_of_end,
2470
+ Dwarf_Addr offset_from_end_sym,
2471
+ Dwarf_Error* error)\fP
2472
+ .DE
2473
+ This function is like
2474
+ \f(CWdwarf_add_frame_fde()\fP
2475
+ except that
2476
+ \f(CWdwarf_add_frame_fde_b()\fP
2477
+ has new arguments to allow use
2478
+ with
2479
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP.
2480
+
2481
+ The function \f(CWdwarf_add_frame_fde_b()\fP
2482
+ adds the
2483
+ \f(CWFDE\fP
2484
+ specified by \f(CWfde\fP to the list of \f(CWFDE\fPs for the
2485
+ object represented by the given \f(CWdbg\fP.
2486
+
2487
+ \f(CWdie\fP specifies
2488
+ the \f(CWDIE\fP that represents the function whose frame information
2489
+ is specified by the given \f(CWfde\fP.
2490
+ If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
2491
+ needed in .debug_info pass in 0 as the \f(CWdie\fP argument.
2492
+
2493
+ \f(CWcie\fP specifies the
2494
+ index of the \f(CWCIE\fP that should be used to setup the initial
2495
+ conditions for the given frame.
2496
+ \f(CWvirt_addr\fP represents the
2497
+ relocatable address at which the code for the given function begins,
2498
+ and \f(CWsym_idx\fP gives the index of the relocatable symbol to
2499
+ be used to relocate this address (\f(CWvirt_addr\fP that is).
2500
+ \f(CWcode_len\fP specifies the size in bytes of the machine instructions
2501
+ for the given function.
2502
+
2503
+ If \f(CWsym_idx_of_end\fP is zero
2504
+ (may be
2505
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
2506
+ or
2507
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
2508
+ ):
2509
+ .sp
2510
+ .in +2
2511
+ \f(CWvirt_addr\fP represents the
2512
+ relocatable address at which the code for the given function begins,
2513
+ and \f(CWsym_idx\fP gives the index of the relocatable symbol to
2514
+ be used to relocate this address (\f(CWvirt_addr\fP that is).
2515
+ \f(CWcode_len\fP
2516
+ specifies the size in bytes of the machine instructions
2517
+ for the given function.
2518
+ \f(CWsym_idx_of_end\fP
2519
+ and
2520
+ \f(CWoffset_from_end_sym\fP
2521
+ are unused.
2522
+ .in -2
2523
+ .sp
2524
+
2525
+
2526
+ If \f(CWsym_idx_of_end\fP is non-zero
2527
+ (must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful):
2528
+ .sp
2529
+ .in +2
2530
+ \f(CWvirt_addr\fP
2531
+ is the offset from the symbol specified by
2532
+ \f(CWsym_idx\fP .
2533
+ \f(CWoffset_from_end_sym\fP
2534
+ is the offset from the symbol specified by
2535
+ \f(CWsym_idx_of_end\fP.
2536
+ \f(CWcode_len\fP is ignored.
2537
+ This begin-end pair will be show up in the
2538
+ relocation array returned by
2539
+ \f(CWdwarf_get_relocation_info() \fP
2540
+ as a
2541
+ \f(CWdwarf_drt_first_of_length_pair\fP
2542
+ and
2543
+ \f(CWdwarf_drt_second_of_length_pair\fP
2544
+ pair of relocation records.
2545
+ The consuming application will turn that pair into
2546
+ something conceptually identical to
2547
+ .sp
2548
+ .nf
2549
+ .in +4
2550
+ .word end_symbol + begin - \\
2551
+ ( start_symbol + offset_from_end)
2552
+ .in -4
2553
+ .fi
2554
+ .sp
2555
+ The reason offsets are allowed on the begin and end symbols
2556
+ is to allow the caller to re-use existing labels
2557
+ when the labels are available
2558
+ and the corresponding offset is known
2559
+ (economizing on the number of labels in use).
2560
+ The 'offset_from_end - begin_address'
2561
+ will actually be in the binary stream, not the relocation
2562
+ record, so the app processing the relocation array
2563
+ must read that stream value into (for example)
2564
+ net_offset and actually emit something like
2565
+ .sp
2566
+ .nf
2567
+ .in +4
2568
+ .word end_symbol - start_symbol + net_offset
2569
+ .in -4
2570
+ .fi
2571
+ .sp
2572
+ .in -2
2573
+
2574
+ It returns an index to the given \f(CWfde\fP.
2575
+
2576
+ On error, it returns \f(CWDW_DLV_NOCOUNT\fP.
2577
+
2578
+ .H 3 "dwarf_add_frame_info_b()"
2579
+ .DS
2580
+ \f(CWDwarf_Unsigned dwarf_add_frame_info_b(
2581
+ Dwarf_P_Debug dbg,
2582
+ Dwarf_P_Fde fde,
2583
+ Dwarf_P_Die die,
2584
+ Dwarf_Unsigned cie,
2585
+ Dwarf_Addr virt_addr,
2586
+ Dwarf_Unsigned code_len,
2587
+ Dwarf_Unsigned sym_idx,
2588
+ Dwarf_Unsigned end_symbol_index,
2589
+ Dwarf_Addr offset_from_end_symbol,
2590
+ Dwarf_Signed offset_into_exception_tables,
2591
+ Dwarf_Unsigned exception_table_symbol,
2592
+ Dwarf_Error* error)\fP
2593
+ .DE
2594
+ The function \f(CWdwarf_add_frame_fde()\fP adds the \f(CWFDE\fP
2595
+ specified by \f(CWfde\fP to the list of \f(CWFDE\fPs for the
2596
+ object represented by the given \f(CWdbg\fP.
2597
+
2598
+ This function refers to MIPS/IRIX specific exception tables
2599
+ and is not a function other targets need.
2600
+
2601
+ \f(CWdie\fP specifies
2602
+ the \f(CWDIE\fP that represents the function whose frame information
2603
+ is specified by the given \f(CWfde\fP.
2604
+ If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
2605
+ needed in .debug_info pass in 0 as the \f(CWdie\fP argument.
2606
+
2607
+ \f(CWcie\fP specifies the
2608
+ index of the \f(CWCIE\fP that should be used to setup the initial
2609
+ conditions for the given frame.
2610
+
2611
+ \f(CWoffset_into_exception_tables\fP specifies the
2612
+ MIPS/IRIX specific
2613
+ offset into \f(CW.MIPS.eh_region\fP elf section where the exception tables
2614
+ for this function begins.
2615
+ \f(CWexception_table_symbol\fP is also MIPS/IRIX
2616
+ specific and it specifies the index of
2617
+ the relocatable symbol to be used to relocate this offset.
2618
+
2619
+
2620
+ If
2621
+ \f(CWend_symbol_index is not zero\fP
2622
+ we are using two symbols to create a length
2623
+ (must be \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP to be useful)
2624
+ .sp
2625
+ .in +2
2626
+ \f(CWvirt_addr\fP
2627
+ is the offset from the symbol specified by
2628
+ \f(CWsym_idx\fP .
2629
+ \f(CWoffset_from_end_symbol\fP
2630
+ is the offset from the symbol specified by
2631
+ \f(CWend_symbol_index\fP.
2632
+ \f(CWcode_len\fP is ignored.
2633
+ This begin-end pair will be show up in the
2634
+ relocation array returned by
2635
+ \f(CWdwarf_get_relocation_info() \fP
2636
+ as a
2637
+ \f(CWdwarf_drt_first_of_length_pair\fP
2638
+ and
2639
+ \f(CWdwarf_drt_second_of_length_pair\fP
2640
+ pair of relocation records.
2641
+ The consuming application will turn that pair into
2642
+ something conceptually identical to
2643
+ .sp
2644
+ .nf
2645
+ .in +4
2646
+ .word end_symbol + offset_from_end_symbol - \\
2647
+ ( start_symbol + virt_addr)
2648
+ .in -4
2649
+ .fi
2650
+ .sp
2651
+ The reason offsets are allowed on the begin and end symbols
2652
+ is to allow the caller to re-use existing labels
2653
+ when the labels are available
2654
+ and the corresponding offset is known
2655
+ (economizing on the number of labels in use).
2656
+ The 'offset_from_end - begin_address'
2657
+ will actually be in the binary stream, not the relocation
2658
+ record, so the app processing the relocation array
2659
+ must read that stream value into (for example)
2660
+ net_offset and actually emit something like
2661
+ .sp
2662
+ .nf
2663
+ .in +4
2664
+ .word end_symbol - start_symbol + net_offset
2665
+ .in -4
2666
+ .fi
2667
+ .sp
2668
+ .in -2
2669
+
2670
+ If
2671
+ \f(CWend_symbol_index\fP is zero
2672
+ we must be given a code_len value
2673
+ (either
2674
+ \f(CWDW_DLC_STREAM_RELOCATIONS\fP
2675
+ or
2676
+ \f(CWDW_DLC_SYMBOLIC_RELOCATIONS\fP
2677
+ ):
2678
+ .sp
2679
+ .in +2
2680
+ The relocatable start address of the range is
2681
+ specified by \f(CWvirt_addr\fP, and the length of the address
2682
+ range is specified by \f(CWcode_len\fP.
2683
+ The relocatable symbol to be
2684
+ used to relocate the start of the address range is specified by
2685
+ \f(CWsymbol_index\fP, which is normally
2686
+ the index of the symbol in the Elf
2687
+ symbol table.
2688
+ The
2689
+ \f(CWoffset_from_end_symbol\fP
2690
+ is ignored.
2691
+ .in -2
2692
+
2693
+
2694
+ It returns an index to the given \f(CWfde\fP.
2695
+
2696
+ On error, it returns \f(CWDW_DLV_NOCOUNT\fP.
2697
+
2698
+
2699
+ .H 3 "dwarf_add_frame_info()"
2700
+
2701
+ .DS
2702
+ \f(CWDwarf_Unsigned dwarf_add_frame_info(
2703
+ Dwarf_P_Debug dbg,
2704
+ Dwarf_P_Fde fde,
2705
+ Dwarf_P_Die die,
2706
+ Dwarf_Unsigned cie,
2707
+ Dwarf_Addr virt_addr,
2708
+ Dwarf_Unsigned code_len,
2709
+ Dwarf_Unsigned sym_idx,
2710
+ Dwarf_Signed offset_into_exception_tables,
2711
+ Dwarf_Unsigned exception_table_symbol,
2712
+ Dwarf_Error* error)\fP
2713
+ .DE
2714
+ The function \f(CWdwarf_add_frame_fde()\fP adds the \f(CWFDE\fP
2715
+ specified by \f(CWfde\fP to the list of \f(CWFDE\fPs for the
2716
+ object represented by the given \f(CWdbg\fP.
2717
+
2718
+ \f(CWdie\fP specifies
2719
+ the \f(CWDIE\fP that represents the function whose frame information
2720
+ is specified by the given \f(CWfde\fP.
2721
+ If the MIPS/IRIX specific DW_AT_MIPS_fde attribute is not
2722
+ needed in .debug_info pass in 0 as the \f(CWdie\fP argument.
2723
+
2724
+ \f(CWcie\fP specifies the
2725
+ index of the \f(CWCIE\fP that should be used to setup the initial
2726
+ conditions for the given frame. \f(CWvirt_addr\fP represents the
2727
+ relocatable address at which the code for the given function begins,
2728
+ and \f(CWsym_idx\fP gives the index of the relocatable symbol to
2729
+ be used to relocate this address (\f(CWvirt_addr\fP that is).
2730
+ \f(CWcode_len\fP specifies the size in bytes of the machine instructions
2731
+ for the given function.
2732
+
2733
+ \f(CWoffset_into_exception_tables\fP specifies the
2734
+ offset into \f(CW.MIPS.eh_region\fP elf section where the exception tables
2735
+ for this function begins.
2736
+ \f(CWexception_table_symbol\fP gives the index of
2737
+ the relocatable symbol to be used to relocate this offset.
2738
+ These arguments are MIPS/IRIX specific, pass in 0 for
2739
+ other targets.
2740
+
2741
+ It returns an index to the given \f(CWfde\fP.
2742
+
2743
+ .H 3 "dwarf_fde_cfa_offset()"
2744
+ .DS
2745
+ \f(CWDwarf_P_Fde dwarf_fde_cfa_offset(
2746
+ Dwarf_P_Fde fde,
2747
+ Dwarf_Unsigned reg,
2748
+ Dwarf_Signed offset,
2749
+ Dwarf_Error *error)\fP
2750
+ .DE
2751
+ The function \f(CWdwarf_fde_cfa_offset()\fP appends a \f(CWDW_CFA_offset\fP
2752
+ operation to the \f(CWFDE\fP, specified by \f(CWfde\fP, being constructed.
2753
+ The first operand of the \f(CWDW_CFA_offset\fP operation is specified by
2754
+ \f(CWreg\P. The register specified should not exceed 6 bits. The second
2755
+ operand of the \f(CWDW_CFA_offset\fP operation is specified by \f(CWoffset\fP.
2756
+
2757
+ It returns the given \f(CWfde\fP on success.
2758
+
2759
+ It returns \f(CWDW_DLV_BADADDR\fP on error.
2760
+
2761
+ .H 3 "dwarf_add_fde_inst()"
2762
+ .DS
2763
+ \f(CWDwarf_P_Fde dwarf_add_fde_inst(
2764
+ Dwarf_P_Fde fde,
2765
+ Dwarf_Small op,
2766
+ Dwarf_Unsigned val1,
2767
+ Dwarf_Unsigned val2,
2768
+ Dwarf_Error *error)\fP
2769
+ .DE
2770
+ The function \f(CWdwarf_add_fde_inst()\fP adds the operation specified
2771
+ by \f(CWop\fP to the \f(CWFDE\fP specified by \f(CWfde\fP. Up to two
2772
+ operands can be specified in \f(CWval1\fP, and \f(CWval2\fP. Based on
2773
+ the operand specified \f(CWLibdwarf\fP decides how many operands are
2774
+ meaningful for the operand. It also converts the operands to the
2775
+ appropriate datatypes (they are passed to \f(CWdwarf_add_fde_inst\fP
2776
+ as \f(CWDwarf_Unsigned\fP).
2777
+
2778
+ It returns the given \f(CWfde\fP on success, and \f(CWDW_DLV_BADADDR\fP
2779
+ on error.
2780
+
2781
+ .H 3 "dwarf_insert_fde_inst_bytes()"
2782
+ .DS
2783
+ \f(CWint dwarf_insert_fde_inst_bytes(
2784
+ Dwarf_P_Debug dbg,
2785
+ Dwarf_P_Fde fde,
2786
+ Dwarf_Unsigned len,
2787
+ Dwarf_Ptr ibytes,
2788
+ Dwarf_Error *error)\fP
2789
+ .DE
2790
+ The function \f(CWdwarf_insert_fde_inst_bytes()\fP inserts
2791
+ the byte array (pointed at by \f(CWibytes\fP and of length \f(CWlen\fP)
2792
+ of frame instructions into the fde \f(CWfde\fP.
2793
+ It is incompatible with \f(CWdwarf_add_fde_inst()\fP, do not use
2794
+ both functions on any given Dwarf_P_Debug.
2795
+ At present it may only be called once on a given \f(CWfde\fP.
2796
+ The \f(CWlen\fP bytes \f(CWibytes\fP may be constructed in any way, but
2797
+ the assumption is they were copied from an object file
2798
+ such as is returned by the libdwarf consumer function
2799
+ \f(CWdwarf_get_fde_instr_bytes()\fP.
2800
+
2801
+ It returns \f(CWDW_DLV_OK\fP on success, and \f(CWDW_DLV_ERROR\fP
2802
+ on error.
2803
+
2804
+
2805
+ .S
2806
+ .TC 1 1 4
2807
+ .CS