1 .\" $NetBSD: dwarf_producer_init.3,v 1.2 2014/03/09 16:58:04 christos Exp $
3 .\" Copyright (c) 2011 Kai Wang
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" Id: dwarf_producer_init.3 2074 2011-10-27 03:34:33Z jkoshy
31 .Dt DWARF_PRODUCER_INIT 3
33 .Nm dwarf_producer_init
34 .Nm dwarf_producer_init_b
35 .Nd allocate a DWARF producer descriptor
41 .Fo dwarf_producer_init
42 .Fa "Dwarf_Unsigned flags"
43 .Fa "Dwarf_Callback_Func func"
44 .Fa "Dwarf_Handler errhand"
45 .Fa "Dwarf_Ptr errarg"
46 .Fa "Dwarf_Error *err"
49 .Fo dwarf_producer_init_b
50 .Fa "Dwarf_Unsigned flags"
51 .Fa "Dwarf_Callback_Func_b func"
52 .Fa "Dwarf_Handler errhand"
53 .Fa "Dwarf_Ptr errarg"
54 .Fa "Dwarf_Error *error"
57 These functions allocate and return a
59 descriptor representing a DWARF producer instance.
63 should contain the adddress of a function to be called in case of an
67 the default error handling scheme is used, see
72 will be passed to the error handler function when it is invoked.
76 references a memory location that would hold a
78 descriptor in case of an error.
82 specifies additional characteristics of the DWARF producer instance.
83 The following flags are recognized:
85 .Bl -tag -width "Dv DW_DLC_ISA_MIPS"
86 .It Dv DW_DLC_ISA_IA64
88 The target instruction set architecture is IA64.
89 This flag is deprecated.
90 Application code should use the
91 .Xr dwarf_producer_set_isa 3
92 function to specify target instruction set architecture.
93 .It Dv DW_DLC_ISA_MIPS
95 The target instruction set architecture is MIPS.
96 This flag is deprecated.
97 Application code should use the
98 .Xr dwarf_producer_set_isa 3
99 function to specify target instruction set architecture.
100 .It Dv DW_DLC_SIZE_32
102 The target address size is 32-bit.
103 .It Dv DW_DLC_SIZE_64
104 The target address size is 64-bit.
105 .It Dv DW_DLC_STREAM_RELOCATIONS
107 Generate stream relocations.
108 .It Dv DW_DLC_SYMBOLIC_RELOCATIONS
109 Generate symbolic relocations.
110 .It Dv DW_DLC_TARGET_BIGENDIAN
111 The target is big endian.
112 .It Dv DW_DLC_TARGET_LITTLEENDIAN
113 The target is little endian.
116 Permit writing of DWARF information.
119 The following flags are mutually exclusive.
125 .Dv DW_DLC_ISA_MIPS .
133 .Dv DW_DLC_STREAM_RELOCATIONS
135 .Dv DW_DLC_SYMBOLIC_RELOCATIONS .
138 .Dv DW_DLC_TARGET_BIGENDIAN
140 .Dv DW_DLC_TARGET_LITTLEENDIAN .
142 If neither of the flags
143 .Dv DW_DLC_TARGET_BIGENDIAN
145 .Dv DW_DLC_TARGET_LITTLEENDIAN
146 is set, the target's endianness is assumed to be the same as the host's
151 should point to an application-provided callback function of type
152 .Vt Dwarf_Callback_Func_b .
154 .Vt Dwarf_Callback_Func_b
155 is defined in the header file
158 .Bd -literal -offset indent
159 typedef int (*Dwarf_Callback_Func_b)(char *name, int size,
160 Dwarf_Unsigned type, Dwarf_Unsigned flags, Dwarf_Unsigned link,
161 Dwarf_Unsigned info, Dwarf_Unsigned *index, int *error);
164 This function is called by the
166 once for each section in the object file that the library needs to
168 The arguments to this callback function specify the values in the ELF
169 section header for the section being created:
171 .Bl -tag -width indent -compact -offset indent
173 The name of the section being created.
177 value in the section header.
181 value in the section header.
185 value in the section header.
189 value in the section header.
193 value in the section header.
196 On success, the callback function should return the section index
197 value of the created section, and set the location pointed to by
200 to the symbol table index of the symbol that associated with the newly
202 This symbol table index will be used in relocation entries
203 referring to the created section.
205 In case of failure, the callback function should return -1 and set the
206 location pointed to by argument
208 to an application-defined error code.
209 This application returned error code is currently ignored by the
213 .Fn dwarf_producer_init
216 .Fn dwarf_producer_init
217 is identical to function
218 .Fn dwarf_producer_init_b
219 except that the callback function it expects can not properly handle
220 arbitrary section symbol index values.
221 .Ss Memory Management
224 instance returned by these functions should be freed using the
226 .Fn dwarf_producer_finish .
228 On success, these functions return the created DWARF producer
230 In case of an error, they return
235 These functions can fail with:
236 .Bl -tag -width ".Bq Er DW_DLE_NO_ENTRY"
237 .It Bq Er DW_DLE_ARGUMENT
241 .It Bq Er DW_DLE_ARGUMENT
244 was not set in argument
246 .It Bq Er DW_DLE_ARGUMENT
251 were both set in argument
253 .It Bq Er DW_DLE_ARGUMENT
258 were both set in argument
260 .It Bq Er DW_DLE_ARGUMENT
262 .Dv DW_DLC_TARGET_BIGENDIAN
264 .Dv DW_DLC_TARGET_LITTLEENDIAN
265 were both set in argument
267 .It Bq Er DW_DLE_ARGUMENT
269 .Dv DW_DLC_STREAM_RELOCATIONS
271 .Dv DW_DLC_SYMBOLIC_RELOCATIONS
272 were both set in argument
274 .It Bq Er DW_DLE_MEMORY
275 An out of memory condition was encountered.
280 instance for a MIPS32 big endian object, use:
281 .Bd -literal -offset indent
283 Dwarf_Unsigned flags;
286 /* ... assume cb_func points to the callback function ... */
288 flags = DW_DLC_WRITE | DW_DLC_SIZE_32 | DW_DLC_ISA_MIPS |
289 DW_DLC_STREAM_RELOCATIONS | DW_DLC_TARGET_BIGENDIAN;
290 if ((dbg = dwarf_producer_init(flags, cb_func, NULL, NULL, &de)) ==
292 warnx("dwarf_producer_init failed: %s", dwarf_errmsg(-1));
297 .Xr dwarf_producer_finish 3 ,
298 .Xr dwarf_producer_set_isa 3 ,
299 .Xr dwarf_transform_to_disk_form 3