15c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles)/* Get specific attribute of abbreviation. 25267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) Copyright (C) 2003, 2004, 2005 Red Hat, Inc. 35c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) This file is part of Red Hat elfutils. 45c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Written by Ulrich Drepper <drepper@redhat.com>, 2003. 55c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 65c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Red Hat elfutils is free software; you can redistribute it and/or modify 75267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) it under the terms of the GNU General Public License as published by the 85c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Free Software Foundation; version 2 of the License. 95267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 105c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Red Hat elfutils is distributed in the hope that it will be useful, but 115c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) WITHOUT ANY WARRANTY; without even the implied warranty of 125c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 135267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) General Public License for more details. 145c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 155c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) You should have received a copy of the GNU General Public License along 165267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) with Red Hat elfutils; if not, write to the Free Software Foundation, 175c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA. 185c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) 195c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) In addition, as a special exception, Red Hat, Inc. gives You the 205c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) additional right to link the code of Red Hat elfutils with code licensed 215c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) under any Open Source Initiative certified open source license 225c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) (http://www.opensource.org/licenses/index.php) which requires the 235c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) distribution of source code with any binary distribution and to 245c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) distribute linked combinations of the two. Non-GPL Code permitted under 255c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) this exception must only link to the code of Red Hat elfutils through 265267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) those well defined interfaces identified in the file named EXCEPTION 275267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) found in the source code files (the "Approved Interfaces"). The files 285c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) of Non-GPL Code may instantiate templates or use macros or inline 295267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) functions from the Approved Interfaces without causing the resulting 305c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) work to be covered by the GNU General Public License. Only Red Hat, 3151b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) Inc. may make changes or additions to the list of Approved Interfaces. 325c87bf8b86a7c82ef50fb7a89697d8e02e2553beTorne (Richard Coles) Red Hat's grant of this exception is conditioned upon your not adding 335267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) any new exceptions. If you wish to add a new Approved Interface or 345267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) exception, please contact Red Hat. You must obey the GNU General Public 355267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) License in all respects for all of the Red Hat elfutils code and other 365267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) code used in conjunction with Red Hat elfutils except the Non-GPL Code 375267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) covered by this exception. If you modify this file, you may extend this 385267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) exception to your version of the file, but you are not obligated to do 395267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) so. If you do not wish to provide this exception without modification, 405267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) you must delete this exception statement from your version and license 415267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) this file solely under the GPL without exception. 425267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 435267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) Red Hat elfutils is an included package of the Open Invention Network. 445267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) An included package of the Open Invention Network is a package for which 455267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) Open Invention Network licensees cross-license their patents. No patent 465267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) license is granted, either expressly or impliedly, by designation as an 475267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) included package. Should you wish to participate in the Open Invention 485267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) Network licensing program, please visit www.openinventionnetwork.com 4951b2906e11752df6c18351cf520e30522d3b53a1Torne (Richard Coles) <http://www.openinventionnetwork.com>. */ 505267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles) 515267f701546148b83dfbe1d151cb184385bb5c22Torne (Richard Coles)#ifdef HAVE_CONFIG_H 52# include <config.h> 53#endif 54 55#include <assert.h> 56#include <dwarf.h> 57#include "libdwP.h" 58 59 60int 61dwarf_getabbrevattr (abbrev, idx, namep, formp, offsetp) 62 Dwarf_Abbrev *abbrev; 63 size_t idx; 64 unsigned int *namep; 65 unsigned int *formp; 66 Dwarf_Off *offsetp; 67{ 68 if (abbrev == NULL) 69 return -1; 70 71 size_t cnt = 0; 72 const unsigned char *attrp = abbrev->attrp; 73 const unsigned char *start_attrp; 74 unsigned int name; 75 unsigned int form; 76 77 do 78 { 79 start_attrp = attrp; 80 81 /* Attribute code and form are encoded as ULEB128 values. */ 82 get_uleb128 (name, attrp); 83 get_uleb128 (form, attrp); 84 85 /* If both values are zero the index is out of range. */ 86 if (name == 0 && form == 0) 87 return -1; 88 } 89 while (cnt++ < idx); 90 91 /* Store the result if requested. */ 92 if (namep != NULL) 93 *namep = name; 94 if (formp != NULL) 95 *formp = form; 96 if (offsetp != NULL) 97 *offsetp = (start_attrp - abbrev->attrp) + abbrev->offset; 98 99 return 0; 100} 101