dwarf_pro_arange.c revision 260697
198944Sobrien/*- 298944Sobrien * Copyright (c) 2010 Kai Wang 3130803Smarcel * All rights reserved. 4130803Smarcel * 598944Sobrien * Redistribution and use in source and binary forms, with or without 698944Sobrien * modification, are permitted provided that the following conditions 798944Sobrien * are met: 898944Sobrien * 1. Redistributions of source code must retain the above copyright 998944Sobrien * notice, this list of conditions and the following disclaimer. 1098944Sobrien * 2. Redistributions in binary form must reproduce the above copyright 1198944Sobrien * notice, this list of conditions and the following disclaimer in the 1298944Sobrien * documentation and/or other materials provided with the distribution. 1398944Sobrien * 1498944Sobrien * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1598944Sobrien * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1698944Sobrien * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1798944Sobrien * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1898944Sobrien * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 1998944Sobrien * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2098944Sobrien * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2198944Sobrien * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2298944Sobrien * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2398944Sobrien * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2498944Sobrien * SUCH DAMAGE. 2598944Sobrien */ 2698944Sobrien 2798944Sobrien#include "_libdwarf.h" 28130803Smarcel 2998944SobrienELFTC_VCSID("$Id: dwarf_pro_arange.c 2074 2011-10-27 03:34:33Z jkoshy $"); 3098944Sobrien 3198944SobrienDwarf_Unsigned 3298944Sobriendwarf_add_arange(Dwarf_P_Debug dbg, Dwarf_Addr start, Dwarf_Unsigned length, 33130803Smarcel Dwarf_Signed symbol_index, Dwarf_Error *error) 3498944Sobrien{ 3598944Sobrien 3698944Sobrien return (dwarf_add_arange_b(dbg, start, length, symbol_index, 0, 0, 3798944Sobrien error)); 3898944Sobrien} 3998944Sobrien 4098944SobrienDwarf_Unsigned 4198944Sobriendwarf_add_arange_b(Dwarf_P_Debug dbg, Dwarf_Addr start, Dwarf_Unsigned length, 4298944Sobrien Dwarf_Unsigned symbol_index, Dwarf_Unsigned end_symbol_index, 4398944Sobrien Dwarf_Addr offset_from_end_symbol, Dwarf_Error *error) 4498944Sobrien{ 45130803Smarcel Dwarf_ArangeSet as; 4698944Sobrien Dwarf_Arange ar; 4798944Sobrien 4898944Sobrien if (dbg == NULL) { 4998944Sobrien DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 5098944Sobrien return (0); 5198944Sobrien } 5298944Sobrien as = dbg->dbgp_as; 5398944Sobrien 5498944Sobrien if (end_symbol_index > 0 && 5598944Sobrien (dbg->dbgp_flags & DW_DLC_SYMBOLIC_RELOCATIONS) == 0) { 5698944Sobrien DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 5798944Sobrien return (0); 5898944Sobrien } 5998944Sobrien 6098944Sobrien if ((ar = calloc(1, sizeof(struct _Dwarf_Arange))) == NULL) { 6198944Sobrien DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); 6298944Sobrien return (0); 63130803Smarcel } 6498944Sobrien ar->ar_as = as; 6598944Sobrien ar->ar_address = start; 6698944Sobrien ar->ar_range = length; 6798944Sobrien ar->ar_symndx = symbol_index; 6898944Sobrien ar->ar_esymndx = end_symbol_index; 6998944Sobrien ar->ar_eoff = offset_from_end_symbol; 7098944Sobrien STAILQ_INSERT_TAIL(&as->as_arlist, ar, ar_next); 7198944Sobrien 7298944Sobrien return (1); 7398944Sobrien} 7498944Sobrien