xref: /netbsd-src/external/bsd/elftoolchain/dist/libdwarf/dwarf_formref.3 (revision 5ac3bc719ce6e70593039505b491894133237d12)
1*5ac3bc71Schristos.\"	$NetBSD: dwarf_formref.3,v 1.6 2024/03/03 17:37:31 christos Exp $
2e81373b4Schristos.\"
39dd9d0cfSchristos.\" Copyright (c) 2010 Joseph Koshy
49dd9d0cfSchristos.\" All rights reserved.
59dd9d0cfSchristos.\"
69dd9d0cfSchristos.\" Redistribution and use in source and binary forms, with or without
79dd9d0cfSchristos.\" modification, are permitted provided that the following conditions
89dd9d0cfSchristos.\" are met:
99dd9d0cfSchristos.\" 1. Redistributions of source code must retain the above copyright
109dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer.
119dd9d0cfSchristos.\" 2. Redistributions in binary form must reproduce the above copyright
129dd9d0cfSchristos.\"    notice, this list of conditions and the following disclaimer in the
139dd9d0cfSchristos.\"    documentation and/or other materials provided with the distribution.
149dd9d0cfSchristos.\"
159dd9d0cfSchristos.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
169dd9d0cfSchristos.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
179dd9d0cfSchristos.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
189dd9d0cfSchristos.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
199dd9d0cfSchristos.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
209dd9d0cfSchristos.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
219dd9d0cfSchristos.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
229dd9d0cfSchristos.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
239dd9d0cfSchristos.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
249dd9d0cfSchristos.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
259dd9d0cfSchristos.\" SUCH DAMAGE.
269dd9d0cfSchristos.\"
27cdbf1fe1Sjkoshy.\" Id: dwarf_formref.3 3962 2022-03-12 15:56:10Z jkoshy
289dd9d0cfSchristos.\"
299dd9d0cfSchristos.Dd June 21, 2010
309dd9d0cfSchristos.Dt DWARF_FORMREF 3
31604b0842Sjkoshy.Os
329dd9d0cfSchristos.Sh NAME
339dd9d0cfSchristos.Nm dwarf_formref ,
349dd9d0cfSchristos.Nm dwarf_global_formref
359dd9d0cfSchristos.Nd retrieve offsets for REFERENCE class attributes
369dd9d0cfSchristos.Sh LIBRARY
379dd9d0cfSchristos.Lb libdwarf
389dd9d0cfSchristos.Sh SYNOPSIS
399dd9d0cfSchristos.In libdwarf.h
409dd9d0cfSchristos.Ft int
419dd9d0cfSchristos.Fo dwarf_formref
429dd9d0cfSchristos.Fa "Dwarf_Attribute attr"
439dd9d0cfSchristos.Fa "Dwarf_Off *retoffset"
449dd9d0cfSchristos.Fa "Dwarf_Error *err"
459dd9d0cfSchristos.Fc
469dd9d0cfSchristos.Ft int
479dd9d0cfSchristos.Fo dwarf_global_formref
489dd9d0cfSchristos.Fa "Dwarf_Attribute attr"
499dd9d0cfSchristos.Fa "Dwarf_Off *retoffset"
509dd9d0cfSchristos.Fa "Dwarf_Error *err"
519dd9d0cfSchristos.Fc
529dd9d0cfSchristos.Sh DESCRIPTION
539dd9d0cfSchristosThese functions return the offsets associated with a DWARF attribute
549dd9d0cfSchristosdescriptor.
559dd9d0cfSchristos.Pp
569dd9d0cfSchristosFunction
579dd9d0cfSchristos.Fn dwarf_formref
589dd9d0cfSchristosreturns the compilation unit relative offset of the descriptor
599dd9d0cfSchristosreferenced by argument
60cdbf1fe1Sjkoshy.Fa attr
619dd9d0cfSchristosin the location pointed to by argument
62cdbf1fe1Sjkoshy.Fa retoffset .
639dd9d0cfSchristosArgument
64cdbf1fe1Sjkoshy.Fa attr
659dd9d0cfSchristosmust be a reference that is local to a compilation unit.
669dd9d0cfSchristosPermitted forms for argument
67cdbf1fe1Sjkoshy.Fa attr
689dd9d0cfSchristosare
699dd9d0cfSchristos.Dv DW_FORM_ref1 ,
709dd9d0cfSchristos.Dv DW_FORM_ref2 ,
719dd9d0cfSchristos.Dv DW_FORM_ref4 ,
729dd9d0cfSchristos.Dv DW_FORM_ref8
739dd9d0cfSchristosand
749dd9d0cfSchristos.Dv DW_FORM_ref_udata .
759dd9d0cfSchristos.Pp
769dd9d0cfSchristosFunction
779dd9d0cfSchristos.Fn dwarf_global_formref
789dd9d0cfSchristosreturns the section-relative offset of the descriptor referenced by
799dd9d0cfSchristosargument
80cdbf1fe1Sjkoshy.Fa attr
819dd9d0cfSchristosin the location pointed to by argument
82cdbf1fe1Sjkoshy.Fa retoffset .
839dd9d0cfSchristosArgument
84cdbf1fe1Sjkoshy.Fa attr
859dd9d0cfSchristosshould be a legal
869dd9d0cfSchristos.Sy REFERENCE
879dd9d0cfSchristosclass form.
889dd9d0cfSchristosPermitted forms for argument
89cdbf1fe1Sjkoshy.Fa attr
909dd9d0cfSchristosare:
919dd9d0cfSchristos.Dv DW_FORM_ref_addr ,
929dd9d0cfSchristos.Dv DW_FORM_ref_udata ,
939dd9d0cfSchristos.Dv DW_FORM_ref1 ,
949dd9d0cfSchristos.Dv DW_FORM_ref2 ,
959dd9d0cfSchristos.Dv DW_FORM_ref4 ,
969dd9d0cfSchristos.Dv DW_FORM_ref8
979dd9d0cfSchristosand
989dd9d0cfSchristos.Dv DW_FORM_sec_offset .
999dd9d0cfSchristosThe returned offset is relative to the start of the
1009dd9d0cfSchristos.Dq .debug_info
1019dd9d0cfSchristosELF section.
1029dd9d0cfSchristos.Pp
1039dd9d0cfSchristosIf argument
104cdbf1fe1Sjkoshy.Fa err
105cdbf1fe1Sjkoshyis not
106cdbf1fe1Sjkoshy.Dv NULL ,
107cdbf1fe1Sjkoshyit will be used to return an error descriptor in case of an error.
1089dd9d0cfSchristos.Sh RETURN VALUES
1099dd9d0cfSchristosThese functions return
1109dd9d0cfSchristos.Dv DW_DLV_OK
1119dd9d0cfSchristoson success.
1129dd9d0cfSchristosIn case of an error, these functions return
1139dd9d0cfSchristos.Dv DW_DLV_ERROR
1149dd9d0cfSchristosand sets argument
115cdbf1fe1Sjkoshy.Fa err .
1169dd9d0cfSchristos.Sh ERRORS
1179dd9d0cfSchristosThese functions may fail with the following errors:
1189dd9d0cfSchristos.Bl -tag -width ".Bq Er DW_DLE_ATTR_FORM_BAD"
1199dd9d0cfSchristos.It Bq Er DW_DLE_ARGUMENT
1209dd9d0cfSchristosEither of arguments
121cdbf1fe1Sjkoshy.Fa attr
1229dd9d0cfSchristosor
123cdbf1fe1Sjkoshy.Fa retoffset
124cdbf1fe1Sjkoshywas
125cdbf1fe1Sjkoshy.Dv NULL .
1269dd9d0cfSchristos.It Bq Er DW_DLE_ATTR_FORM_BAD
1279dd9d0cfSchristosThe attribute referenced by argument
128cdbf1fe1Sjkoshy.Fa attr
1299dd9d0cfSchristoswas not of a permitted kind.
1309dd9d0cfSchristos.El
1319dd9d0cfSchristos.Sh SEE ALSO
1329dd9d0cfSchristos.Xr dwarf 3 ,
1339dd9d0cfSchristos.Xr dwarf_attr 3 ,
1349dd9d0cfSchristos.Xr dwarf_formblock 3 ,
1359dd9d0cfSchristos.Xr dwarf_formflag 3 ,
1369dd9d0cfSchristos.Xr dwarf_formsdata 3 ,
1379dd9d0cfSchristos.Xr dwarf_formsig8 3 ,
1389dd9d0cfSchristos.Xr dwarf_formstring 3 ,
1399dd9d0cfSchristos.Xr dwarf_formudata 3 ,
1409dd9d0cfSchristos.Xr dwarf_hasattr 3
141