1*5ac3bc71Schristos.\" $NetBSD: dwarf_add_frame_fde.3,v 1.6 2024/03/03 17:37:30 christos Exp $ 2e81373b4Schristos.\" 39dd9d0cfSchristos.\" Copyright (c) 2011 Kai Wang 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_add_frame_fde.3 3961 2022-03-12 15:13:22Z jkoshy 289dd9d0cfSchristos.\" 299dd9d0cfSchristos.Dd September 26, 2011 309dd9d0cfSchristos.Dt DWARF_ADD_FRAME_FDE 3 31604b0842Sjkoshy.Os 329dd9d0cfSchristos.Sh NAME 339dd9d0cfSchristos.Nm dwarf_add_frame_fde 349dd9d0cfSchristos.Nd add a call frame descriptor to a DWARF producer instance 359dd9d0cfSchristos.Sh LIBRARY 369dd9d0cfSchristos.Lb libdwarf 379dd9d0cfSchristos.Sh SYNOPSIS 389dd9d0cfSchristos.In libdwarf.h 399dd9d0cfSchristos.Ft "Dwarf_Unsigned" 409dd9d0cfSchristos.Fo dwarf_add_frame_fde 419dd9d0cfSchristos.Fa "Dwarf_P_Debug dbg" 429dd9d0cfSchristos.Fa "Dwarf_P_Fde fde" 439dd9d0cfSchristos.Fa "Dwarf_P_Die die" 449dd9d0cfSchristos.Fa "Dwarf_Unsigned cie" 459dd9d0cfSchristos.Fa "Dwarf_Addr virt_addr" 469dd9d0cfSchristos.Fa "Dwarf_Unsigned code_len" 479dd9d0cfSchristos.Fa "Dwarf_Unsigned symbol_index" 489dd9d0cfSchristos.Fa "Dwarf_Error *err" 499dd9d0cfSchristos.Fc 509dd9d0cfSchristos.Ft "Dwarf_Unsigned" 519dd9d0cfSchristos.Fo dwarf_add_frame_fde_b 529dd9d0cfSchristos.Fa "Dwarf_P_Debug dbg" 539dd9d0cfSchristos.Fa "Dwarf_P_Fde fde" 549dd9d0cfSchristos.Fa "Dwarf_P_Die die" 559dd9d0cfSchristos.Fa "Dwarf_Unsigned cie" 569dd9d0cfSchristos.Fa "Dwarf_Addr virt_addr" 579dd9d0cfSchristos.Fa "Dwarf_Unsigned code_len" 589dd9d0cfSchristos.Fa "Dwarf_Unsigned symbol_index" 599dd9d0cfSchristos.Fa "Dwarf_Unsigned end_symbol_index" 609dd9d0cfSchristos.Fa "Dwarf_Addr offset_from_end_sym" 619dd9d0cfSchristos.Fa "Dwarf_Error *err" 629dd9d0cfSchristos.Fc 639dd9d0cfSchristos.Sh DESCRIPTION 649dd9d0cfSchristosFunction 659dd9d0cfSchristos.Fn dwarf_add_frame_fde_b 669dd9d0cfSchristosadds the call frame descriptor referenced by argument 67cdbf1fe1Sjkoshy.Fa fde 689dd9d0cfSchristosto a producer instance. 699dd9d0cfSchristos.Pp 709dd9d0cfSchristosArgument 71cdbf1fe1Sjkoshy.Fa dbg 729dd9d0cfSchristosshould reference a DWARF producer instance allocated using 739dd9d0cfSchristos.Xr dwarf_producer_init 3 749dd9d0cfSchristosor 759dd9d0cfSchristos.Xr dwarf_producer_init_b 3 . 769dd9d0cfSchristos.Pp 779dd9d0cfSchristosArgument 78cdbf1fe1Sjkoshy.Fa fde 799dd9d0cfSchristosshould reference a frame descriptor allocated using 809dd9d0cfSchristos.Xr dwarf_new_fde 3 . 819dd9d0cfSchristos.Pp 829dd9d0cfSchristosArgument 83cdbf1fe1Sjkoshy.Fa die 849dd9d0cfSchristosis ignored by this implementation of the 859dd9d0cfSchristos.Lb libdwarf . 869dd9d0cfSchristos.Pp 879dd9d0cfSchristosArgument 88cdbf1fe1Sjkoshy.Fa cie 899dd9d0cfSchristosspecifies the index of call frame common information entry for 909dd9d0cfSchristosthe frame descriptor. 919dd9d0cfSchristosValid indices are those returned by the function 929dd9d0cfSchristos.Xr dwarf_add_frame_cie 3 . 939dd9d0cfSchristos.Pp 949dd9d0cfSchristosArgument 95cdbf1fe1Sjkoshy.Fa symbol_index 969dd9d0cfSchristosspecifies the ELF symbol index of the first symbol to be used for 979dd9d0cfSchristosrelocation. 989dd9d0cfSchristos.Pp 999dd9d0cfSchristosThe meaning of the arguments 100cdbf1fe1Sjkoshy.Fa virt_addr , 101cdbf1fe1Sjkoshy.Fa code_len 1029dd9d0cfSchristosand 103cdbf1fe1Sjkoshy.Fa offset_from_end_sym 1049dd9d0cfSchristosdepend on the value of argument 105cdbf1fe1Sjkoshy.Fa end_symbol_index : 1069dd9d0cfSchristos.Bl -bullet 1079dd9d0cfSchristos.It 1089dd9d0cfSchristosIf the argument 109cdbf1fe1Sjkoshy.Fa end_symbol_index 1109dd9d0cfSchristosis zero, the argument 111cdbf1fe1Sjkoshy.Fa virt_addr 1129dd9d0cfSchristosspecifies the relocatable address of the start of the function 1139dd9d0cfSchristosassociated with the frame descriptor, the argument 114cdbf1fe1Sjkoshy.Fa code_len 1159dd9d0cfSchristosspecifies the size in bytes of the machine instructions for this 1169dd9d0cfSchristosfunction, the argument 117cdbf1fe1Sjkoshy.Fa symbol_index 1189dd9d0cfSchristosspecifies the ELF symbol to be used for relocating the address in 1199dd9d0cfSchristosargument 120cdbf1fe1Sjkoshy.Fa virt_addr , 1219dd9d0cfSchristosand the argument 122cdbf1fe1Sjkoshy.Fa offset_from_end_symbol 1239dd9d0cfSchristosis ignored. 1249dd9d0cfSchristos.It 1259dd9d0cfSchristosIf the argument 126cdbf1fe1Sjkoshy.Fa end_symbol_index 1279dd9d0cfSchristosis non-zero, it specifies the ELF symbol index of the second symbol to 1289dd9d0cfSchristosbe used for relocation. 1299dd9d0cfSchristosIn this case, the argument 130cdbf1fe1Sjkoshy.Fa virt_addr 1319dd9d0cfSchristosspecifies an offset from the relocatable symbol specified by argument 132cdbf1fe1Sjkoshy.Fa symbol_index , 1339dd9d0cfSchristosthe argument 134cdbf1fe1Sjkoshy.Fa offset_from_end_symbol 1359dd9d0cfSchristosshould specify an offset from the symbol named by the argument 136cdbf1fe1Sjkoshy.Fa end_symbol_index , 1379dd9d0cfSchristosand the argument 138cdbf1fe1Sjkoshy.Fa code_len 1399dd9d0cfSchristoswill be ignored. 1409dd9d0cfSchristosThe 1419dd9d0cfSchristos.Dv DW_DLC_SYMBOLIC_RELOCATIONS 1429dd9d0cfSchristosflag should also have been set on the DWARF producer instance. 1439dd9d0cfSchristos.Pp 1449dd9d0cfSchristosApplication code can retrieve the relocation entries for the symbol 1459dd9d0cfSchristospair by calling function 1469dd9d0cfSchristos.Xr dwarf_get_relocation_info 3 . 1479dd9d0cfSchristosThe relocation entry for the first symbol will have type 1489dd9d0cfSchristos.Dv dwarf_drt_first_of_length_pair 1499dd9d0cfSchristosand the relocation entry for the second symbol will have type 1509dd9d0cfSchristos.Dv dwarf_drt_second_of_length_pair . 1519dd9d0cfSchristos.El 1529dd9d0cfSchristos.Pp 1539dd9d0cfSchristosIf argument 154cdbf1fe1Sjkoshy.Fa err 155cdbf1fe1Sjkoshyis not 156cdbf1fe1Sjkoshy.Dv NULL , 157cdbf1fe1Sjkoshyit will be used to store error information in case of an error. 1589dd9d0cfSchristos.Pp 1599dd9d0cfSchristosFunction 1609dd9d0cfSchristos.Fn dwarf_add_frame_fde 1619dd9d0cfSchristosis similar to function 1629dd9d0cfSchristos.Fn dwarf_add_frame_fde_b 1639dd9d0cfSchristosexcept that it supports only one relocation symbol. 1649dd9d0cfSchristos.Sh RETURN VALUES 1659dd9d0cfSchristosOn success, these functions return the index value for 1669dd9d0cfSchristosthe added frame descriptor. 1679dd9d0cfSchristosIn case of an error, these functions return 1689dd9d0cfSchristos.Dv DW_DLV_NOCOUNT 1699dd9d0cfSchristosand set the argument 170cdbf1fe1Sjkoshy.Fa err . 1719dd9d0cfSchristos.Sh ERRORS 1729dd9d0cfSchristosThese functions can fail with: 1739dd9d0cfSchristos.Bl -tag -width ".Bq Er DW_DLE_ARGUMENT" 1749dd9d0cfSchristos.It Bq Er DW_DLE_ARGUMENT 1759dd9d0cfSchristosOne of the arguments 176cdbf1fe1Sjkoshy.Fa dbg 1779dd9d0cfSchristosor 178cdbf1fe1Sjkoshy.Fa fde 179cdbf1fe1Sjkoshywas 180cdbf1fe1Sjkoshy.Dv NULL . 1819dd9d0cfSchristos.It Bq Er DW_DLE_ARGUMENT 1829dd9d0cfSchristosThe frame descriptor referenced by argument 183cdbf1fe1Sjkoshy.Fa fde 1849dd9d0cfSchristosdid not belong to the producer instance referenced by argument 185cdbf1fe1Sjkoshy.Fa dbg . 1869dd9d0cfSchristos.It Bq Er DW_DLE_ARGUMENT 1879dd9d0cfSchristosThe common information entry index specified by argument 188cdbf1fe1Sjkoshy.Fa cie 1899dd9d0cfSchristoswas invalid. 1909dd9d0cfSchristos.It Bq Er DW_DLE_ARGUMENT 1919dd9d0cfSchristosArgument 192cdbf1fe1Sjkoshy.Fa end_symbol_index 1939dd9d0cfSchristoswas non-zero, but the flag 1949dd9d0cfSchristos.Dv DW_DLC_SYMBOLIC_RELOCATIONS 1959dd9d0cfSchristoswas not set on the producer instance. 1969dd9d0cfSchristos.El 1979dd9d0cfSchristos.Sh SEE ALSO 1989dd9d0cfSchristos.Xr dwarf 3 , 1999dd9d0cfSchristos.Xr dwarf_add_fde_inst 3 , 2009dd9d0cfSchristos.Xr dwarf_add_frame_cie 3 , 2019dd9d0cfSchristos.Xr dwarf_fde_cfa_offset 3 , 2029dd9d0cfSchristos.Xr dwarf_get_relocation_info 3 , 2039dd9d0cfSchristos.Xr dwarf_new_fde 3 , 2049dd9d0cfSchristos.Xr dwarf_producer_init 3 , 2059dd9d0cfSchristos.Xr dwarf_producer_init_b 3 206