/*
Copyright (C) 2000,2004,2006 Silicon Graphics, Inc. All Rights Reserved.
Portions Copyright (C) 2007-2010 David Anderson. All Rights Reserved.
Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
under the terms of version 2.1 of the GNU Lesser General Public License
as published by the Free Software Foundation.
This program is distributed in the hope that it would be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Further, this software is distributed without any warranty that it is
free of the rightful claim of any third person regarding infringement
or the like. Any license provided herein, whether implied or
otherwise, applies only to this software file. Patent licenses, if
any, provided herein do not apply to combinations of this program with
other software, or any other product whatsoever.
You should have received a copy of the GNU Lesser General Public
License along with this program; if not, write the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
USA.
Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
Mountain View, CA 94043, or:
For further information regarding this notice, see:
*/
/*
SGI has moved from the Crittenden Lane address.
*/
#include "config.h"
#include "libdwarfdefs.h"
#include <stdio.h>
#include <string.h>
#ifdef HAVE_ELFACCESS_H
#include <elfaccess.h>
#endif
#include "pro_incl.h"
#include "pro_section.h"
#include "pro_line.h"
#include "pro_frame.h"
#include "pro_die.h"
#include "pro_macinfo.h"
#include "pro_types.h"
#ifndef SHF_MIPS_NOSTRIP
/* if this is not defined, we probably don't need it: just use 0 */
#define SHF_MIPS_NOSTRIP 0
#endif
#ifndef R_MIPS_NONE
#define R_MIPS_NONE 0
#endif
#ifndef TRUE
#endif
#ifndef FALSE
#define FALSE 0
#endif
/* must match up with pro_section.h defines of DEBUG_INFO etc
and sectnames (below). REL_SEC_PREFIX is either ".rel" or ".rela"
see pro_incl.h
*/
char *_dwarf_rel_section_names[] = {
REL_SEC_PREFIX ".debug_info",
REL_SEC_PREFIX ".debug_line",
REL_SEC_PREFIX ".debug_frame",
REL_SEC_PREFIX ".debug_aranges",
REL_SEC_PREFIX ".debug_pubnames",
REL_SEC_PREFIX ".debug_str",
REL_SEC_PREFIX ".debug_macinfo",
REL_SEC_PREFIX ".debug_loc"
};
/* names of sections. Ensure that it matches the defines
in pro_section.h, in the same order
Must match also _dwarf_rel_section_names above
*/
char *_dwarf_sectnames[] = {
".debug_info",
".debug_line",
".debug_abbrev",
".debug_frame",
".debug_aranges",
".debug_pubnames",
".debug_str",
".debug_funcnames", /* sgi extension */
".debug_typenames", /* sgi extension */
".debug_varnames", /* sgi extension */
".debug_weaknames", /* sgi extension */
".debug_macinfo",
".debug_loc"
};
1, /* DW_LNS_advance_pc */
1, /* DW_LNS_advance_line */
1, /* DW_LNS_set_file */
1, /* DW_LNS_set_column */
0, /* DW_LNS_negate_stmt */
0, /* DW_LNS_set_basic_block */
0, /* DW_LNS_const_add_pc */
1, /* DW_LNS_fixed_advance_pc */
};
/* struct to hold relocation entries. Its mantained as a linked
list of relocation structs, and will then be written at as a
whole into the relocation section. Whether its 32 bit or
64 bit will be obtained from Dwarf_Debug pointer.
*/
struct Dwarf_P_Rel_s {
void *dr_rel_datap;
};
struct Dwarf_P_Rel_Head_s {
};
Dwarf_Error * error);
Dwarf_Error * error);
Dwarf_Error * error);
static int _dwarf_pro_match_attr
/* these macros used as return value for below functions */
/* BEGIN_LEN_SIZE is the size of the 'length' field in total.
Which may be 4,8, or 12 bytes!
4 is standard DWARF2.
8 is non-standard MIPS-IRIX 64-bit.
12 is standard DWARF3 for 64 bit offsets.
Used in various routines: local variable names
must match the names here.
*/
/*
Return TRUE if we need the section, FALSE otherwise
If any of the 'line-data-related' calls were made
including file or directory entries,
produce .debug_line .
*/
static int
{
return FALSE;
}
return TRUE;
}
/*
Convert debug information to a format such that
it can be written on disk.
Called exactly once per execution.
*/
{
/*
Section data in written out in a number of buffers. Each
_generate_*() function returns a cumulative count of buffers for
all the sections. get_section_bytes() returns pointers to these
buffers one at a time. */
int nbufs = 0;
int sect = 0;
int err = 0;
}
/* Create dwarf section headers */
long flags = 0;
switch (sect) {
case DEBUG_INFO:
continue;
break;
case DEBUG_LINE:
continue;
}
break;
case DEBUG_ABBREV:
continue;
break;
case DEBUG_FRAME:
continue;
break;
case DEBUG_ARANGES:
continue;
break;
case DEBUG_PUBNAMES:
continue;
break;
case DEBUG_STR:
continue;
break;
case DEBUG_FUNCNAMES:
continue;
break;
case DEBUG_TYPENAMES:
continue;
break;
case DEBUG_VARNAMES:
continue;
break;
case DEBUG_WEAKNAMES:
continue;
break;
case DEBUG_MACINFO:
continue;
break;
case DEBUG_LOC:
/* not handled yet */
continue;
default:
/* logic error: missing a case */
}
{
int new_base_elf_sect;
if (dbg->de_callback_func_b) {
/* rec size */ 1,
} else {
int name_idx = 0;
SHN_UNDEF, 0,
}
if (new_base_elf_sect == -1) {
}
}
}
nbufs = 0;
/*
Changing the order in which the sections are generated may cause
problems because of relocations. */
if (nbufs < 0) {
}
}
if (dbg->de_frame_cies) {
if (nbufs < 0) {
}
}
if (dbg->de_first_macinfo) {
if (nbufs < 0) {
}
}
if (nbufs < 0) {
}
}
if (nbufs < 0) {
}
}
error);
if (nbufs < 0) {
}
}
error);
if (nbufs < 0) {
}
}
error);
if (nbufs < 0) {
}
}
error);
if (nbufs < 0) {
}
}
if (nbufs < 0) {
}
}
{
int res = 0;
}
}
return nbufs;
}
/*---------------------------------------------------------------
Generate debug_line section
---------------------------------------------------------------*/
static int
{
/* all data named cur* are used to loop thru linked lists */
int sum_bytes = 0;
int prolog_size = 0;
int elfsectno = 0;
section start */
/* temps for memcpy */
int res = 0;
sum_bytes = 0;
/* include directories */
while (curdir) {
}
prolog_size++; /* last null following last directory
entry. */
/* file entries */
while (curentry) {
prolog_size +=
}
prolog_size++; /* last null byte */
uwordb_size + /* header length */
/* length of table specifying # of opnds */
prolog_size += sizeof(std_opcode_len);
/* copy over the data */
/* total_length */
du = 0;
if (extension_size) {
sizeof(x), extension_size);
data += extension_size;
}
data += uwordb_size;
sizeof(dh), sizeof(Dwarf_Half));
data += sizeof(Dwarf_Half);
/* header length */
{
data += uwordb_size;
}
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
db = LINE_RANGE;
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
db = OPCODE_BASE;
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sizeof(std_opcode_len), sizeof(std_opcode_len));
data += sizeof(std_opcode_len);
/* copy over include directories */
while (curdir) {
}
data++;
/* copy file entries */
while (curentry) {
/* copies of leb numbers, no endian issues */
}
*data = '\0';
data++;
sum_bytes += prolog_size;
prevline = (Dwarf_P_Line)
}
/* generate opcodes for line numbers */
while (curline) {
int nbytes;
char *arg;
int opc;
generated, if special opcode or end
sequence */
number, so the size should not be a
problem. ? */
no_lns_copy = 0;
case DW_LNE_end_sequence:
/* Advance pc to end of text section. */
if (addr_adv > 0) {
res =
sizeof(buff1));
}
sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
/* leb, no endianness issue */
}
/* first null byte */
db = 0;
error);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sum_bytes += sizeof(Dwarf_Ubyte);
/* write length of extended opcode */
inst_bytes = sizeof(Dwarf_Ubyte);
res =
}
data += str_nbytes;
sum_bytes += str_nbytes;
/* write extended opcode */
error);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sum_bytes += sizeof(Dwarf_Ubyte);
/* reset value to original values */
no_lns_copy = 1;
/* this is set only for end_sequence, so that a
dw_lns_copy is not generated */
break;
case DW_LNE_set_address:
/* first null byte */
db = 0;
error);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sum_bytes += sizeof(Dwarf_Ubyte);
/* write length of extended opcode */
res =
}
/* leb number, no endian issue */
data += str_nbytes;
sum_bytes += str_nbytes;
/* write extended opcode */
sizeof(Dwarf_Ubyte), error);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sum_bytes += sizeof(Dwarf_Ubyte);
/* reloc for address */
sum_bytes, /* r_offset */
}
/* write offset (address) */
data += upointer_size;
no_lns_copy = 1;
break;
}
} else {
res =
sizeof(buff1));
}
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
}
&nbytes,
}
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
}
error);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sum_bytes += sizeof(Dwarf_Ubyte);
}
if (curline->dpl_basic_block == true &&
prevline->dpl_basic_block == false) {
error);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sum_bytes += sizeof(Dwarf_Ubyte);
}
if ((addr_adv % MIN_INST_LENGTH) != 0) {
}
no_lns_copy = 1;
error);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sum_bytes += sizeof(Dwarf_Ubyte);
prevline->dpl_basic_block = false;
} else {
if (addr_adv > 0) {
res =
sizeof(buff1));
}
(const void *) &db,
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
prevline->dpl_basic_block = false;
}
if (line_adv != 0) {
&nbytes,
sizeof
(buff1));
}
sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
prevline->dpl_basic_block = false;
}
}
} /* ends else for opc != 0 */
if (no_lns_copy == 0) { /* if not a special or dw_lne_end_seq
generate a matrix line */
db = DW_LNS_copy;
(const void *) &db,
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sum_bytes += sizeof(Dwarf_Ubyte);
prevline->dpl_basic_block = false;
}
}
/* write total length field */
{
}
return (int) dbg->de_n_debug_sect;
}
/*---------------------------------------------------------------
Generate debug_frame section
---------------------------------------------------------------*/
static int
{
int elfsectno = 0;
int i = 0;
unsigned char *data = 0;
unsigned long cie_length = 0;
int cie_no = 0;
for relocation info */
cie_length = 0;
cur_off = 0;
cie_offs = (long *)
}
/* Generate cie number as we go along. This writes
all CIEs first before any FDEs, which is rather
different from the order a compiler might like (which
might be each CIE followed by its FDEs then the next CIE, and
so on). */
cie_no = 1;
while (curcie) {
char *code_al = 0;
int c_bytes = 0;
char *data_al = 0;
int d_bytes = 0;
int res = 0;
char *augmentation = 0;
char *augmented_al = 0;
long augmented_fields_length = 0;
int a_bytes = 0;
&c_bytes,
}
/* Before April 1999, the following was using an unsigned
encode. That worked ok even though the decoder used the
correct signed leb read, but doing the encode correctly
(according to the dwarf spec) saves space in the output file
and is completely compatible.
Note the actual stored amount on MIPS was 10 bytes (!) to
store the value -4. (hex)fc ffffffff ffffffff 01 The
libdwarf consumer consumed all 10 bytes too!
old version res =
_dwarf_pro_encode_leb128_nm(curcie->cie_data_align,
below is corrected signed version. */
&d_bytes,
}
/* get the correct offset */
if (firsttime) {
firsttime = 0;
} else {
(long) cie_length + BEGIN_LEN_SIZE;
}
cie_no++;
sizeof(buff3));
}
sizeof(Dwarf_Ubyte) + /* cie version */
c_bytes + /* code alignment factor */
d_bytes + /* data alignment factor */
sizeof(Dwarf_Ubyte) + /* return reg address */
a_bytes + /* augmentation length */
} else {
sizeof(Dwarf_Ubyte) + /* cie version */
reg
address
*/
}
cie_length += pad;
if (extension_size) {
(const void *) &x,
sizeof(x), extension_size);
data += extension_size;
}
du = cie_length;
/* total length of cie */
data += uwordb_size;
/* cie-id is a special value. */
data += uwordb_size;
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
}
for (i = 0; i < pad; i++) {
*data = DW_CFA_nop;
data++;
}
}
/* calculate current offset */
/* write out fde's */
while (curfde) {
long fde_length = 0;
int pad = 0;
int oet_length = 0;
int afl_length = 0;
int res = 0;
int v0_augmentation = 0;
#if 0
unsigned char *fde_start_point = 0;
#endif
/* Find the CIE associated with this fde. */
not 0. */
index++;
}
}
v0_augmentation = 1;
oet_length = sizeof(Dwarf_sfixed);
/* encode the length of augmented fields. */
sizeof(afl_buff));
}
pointer
*/
upointer_size + /* initial loc */
upointer_size + /* address range */
afl_length + /* augmented field length */
oet_length; /* exception_table offset */
} else {
pointer
*/
upointer_size + /* initial loc */
upointer_size; /* address range */
}
Using fde offset, generate DW_AT_MIPS_fde attribute for the
die corresponding to this fde. */
error) < 0) {
return -1;
}
}
/* store relocation for cie pointer */
BEGIN_LEN_SIZE /* r_offset */,
}
/* store relocation information for initial location */
upointer_size /* r_offset */,
}
/* Store the relocation information for the
offset_into_exception_info field, if the offset is valid (0
is a valid offset). */
if (v0_augmentation &&
curfde->fde_offset_into_exception_tables >= 0) {
/* r_offset, where in cie this
field starts */
sizeof(Dwarf_sfixed));
}
}
/* adjust for padding */
fde_length += pad;
/* write out fde */
error);
#if 0
#endif
du = fde_length;
{
if (extension_size) {
(const void *) &x,
sizeof(x), extension_size);
data += extension_size;
}
/* length */
(const void *) &du,
data += uwordb_size;
/* offset to cie */
(const void *) &du,
data += uwordb_size;
(const void *) &du,
data += upointer_size;
if (dbg->de_reloc_pair &&
curfde->fde_end_symbol != 0 &&
curfde->fde_addr_range == 0) {
/* symbolic reloc, need reloc for length What if we
really know the length? If so, should use the other
part of 'if'. */
/* DEBUG_ARANGES, */
*/
{
return (0);
}
}
/* arrange pre-calc so assem text can do .word end -
begin + val (gets val from stream) */
(const void *) &val,
sizeof(val), upointer_size);
data += upointer_size;
} else {
(const void *) &du,
data += upointer_size;
}
}
if (v0_augmentation) {
/* write the encoded augmented field length. */
data += afl_length;
/* write the offset_into_exception_tables field. */
dsw =
sizeof(dsw), sizeof(Dwarf_sfixed));
data += sizeof(Dwarf_sfixed);
}
} else {
while (curinst) {
sizeof(db), sizeof(Dwarf_Ubyte));
data += sizeof(Dwarf_Ubyte);
#if 0
if (curinst->dfp_sym_index) {
/* r_offset = */
return (0);
}
}
#endif
}
}
/* padding */
for (i = 0; i < pad; i++) {
*data = DW_CFA_nop;
data++;
}
}
return (int) dbg->de_n_debug_sect;
}
/*
These functions remember all the markers we see along
with the right offset in the .debug_info section so that
we can dump them all back to the user with the section info.
*/
static int
unsigned count)
{
if (count > 0) {
dbg->de_marker_n_alloc = 0;
return -1;
}
}
return 0;
}
static int
{
unsigned n = dbg->de_marker_n_used++;
return 0;
}
return -1;
}
Dwarf_Error * error)
{
}
}
return DW_DLV_OK;
}
/* These functions provide the offsets of DW_FORM_string
attributes in the section section_index. These information
will enable a producer app that is generating assembly
text output to easily emit those attributes in ascii form
without having to decode the byte stream.
*/
static int
unsigned count)
{
if (count > 0) {
sizeof(struct Dwarf_P_String_Attr_s)
* sect_sa->sect_sa_n_alloc);
sect_sa->sect_sa_n_alloc = 0;
return -1;
}
}
return 0;
}
static int
{
unsigned n = sect_sa->sect_sa_n_used++;
return 0;
}
return -1;
}
int
int *drd_buffer_version,
{
int i;
unsigned int count = 0;
for (i = 0; i < NUM_DEBUG_SECTIONS; ++i) {
++count;
}
}
return DW_DLV_OK;
}
int
{
int i;
for (i = next; i < NUM_DEBUG_SECTIONS; ++i) {
if (sect_sa->sect_sa_n_used > 0) {
return DW_DLV_OK;
}
}
return DW_DLV_NO_ENTRY;
}
/*---------------------------------------------------------------
Generate debug_info and debug_abbrev sections
---------------------------------------------------------------*/
static int
{
int elfsectno_of_debug_info = 0;
int abbrevsectno = 0;
unsigned char *data = 0;
int cu_header_size = 0;
int n_abbrevs = 0;
int res = 0;
unsigned marker_count = 0;
unsigned string_attr_count = 0;
unsigned string_attr_offset = 0;
/* write cu header */
stamp
*/
uwordb_size + /* offset into abbrev table */
sizeof(Dwarf_Ubyte); /* size of target address */
error);
if (extension_size) {
data += extension_size;
}
du = 0; /* length of debug_info, not counting
this field itself (unknown at this
point). */
data += uwordb_size;
change */
sizeof(version), sizeof(Dwarf_Half));
data += sizeof(Dwarf_Half);
du = 0; /* offset into abbrev table, not yet
known. */
data += uwordb_size;
sizeof(db), 1);
/* We have filled the chunk we got with GET_CHUNK. At this point we
no longer dare use "data" or "start_info_sec" as a pointer any
longer except to refer to that first small chunk for the cu
header. */
/* create AT_macro_info if appropriate */
return -1;
}
/* create AT_stmt_list attribute if necessary */
return -1;
/*
Relocation for abbrev offset in cu header store relocation
record in linked list */
sizeof(Dwarf_Half),
/* r_offset */
}
/* pass 0: only top level dies, add at_sibling attribute to those
dies with children */
if (first_child->di_child)
}
/* pass 1: create abbrev info, get die offsets, calc relocations */
marker_count = 0;
string_attr_count = 0;
int nbytes = 0;
char *space = 0;
int res = 0;
int i = 0;
marker_count++;
}
if (abbrev_head == NULL) {
n_abbrevs = 1;
} else {
/* check if its a new abbreviation, if yes, add to tail */
n_abbrevs++;
}
}
&nbytes,
}
}
/* Resorting the attributes!! */
for (i = 0; i < (int)curabbrev->abb_n_attr; i++) {
/* The following should always find an attribute! */
{
}
if (!ca) {
}
/* Remove the attribute from the old list. */
} else {
}
/* Add the attribute to the new list. */
if (new_first_attr == NULL) {
} else {
new_last_attr = ca;
}
}
while (curattr) {
switch (curattr->ar_attribute) {
case DW_AT_stmt_list:
break;
case DW_AT_MIPS_fde:
break;
case DW_AT_macro_info:
break;
default:
break;
}
*/
}
}
}
}
/* depth first search */
else {
die_off++; /* since we are writing a null die at
the end of each sibling chain */
}
}
} /* end while (curdie != NULL) */
if (res == -1) {
}
if (res == -1) {
}
/* Pass 2: Write out the die information Here 'data' is a
temporary, one block for each GET_CHUNK. 'data' is overused. */
if (res == -1) {
}
}
/* index to abbreviation table */
/* Attribute values - need to fill in all form attributes */
while (curattr) {
switch (curattr->ar_attribute_form) {
case DW_FORM_ref1:
{
(unsigned) 0xff) {
}
(const void *) &db,
sizeof(db), sizeof(Dwarf_Ubyte));
break;
}
case DW_FORM_ref2:
{
(unsigned) 0xffff) {
}
(const void *) &dh,
sizeof(dh), sizeof(Dwarf_Half));
break;
}
case DW_FORM_ref_addr:
{
/* curattr->ar_ref_die == NULL!
*
* ref_addr doesn't take a CU-offset.
* This is different than other refs.
* This value will be set by the user of the
* producer library using a relocation.
* No need to set a value here.
*/
#if 0
{
/* ref to offset of die */
(const void *) &du,
sizeof(du), uwordb_size);
}
#endif
break;
}
case DW_FORM_ref4:
{
(unsigned) 0xffffffff) {
}
(const void *) &dw,
sizeof(dw), sizeof(Dwarf_ufixed));
break;
}
case DW_FORM_ref8:
(const void *) &du,
sizeof(du), sizeof(Dwarf_Unsigned));
break;
case DW_FORM_ref_udata:
{ /* unsigned leb128 offset */
int nbytes;
res =
sizeof(buff1));
}
break;
}
default:
break;
}
}
}
/* depth first search */
else {
*data = '\0';
}
}
} /* end while (curdir != NULL) */
/* Write out debug_info size */
/* Dont include length field or extension bytes */
data = 0; /* Emphasise not usable now */
/* Write out debug_abbrev section */
while (curabbrev) {
char *val;
int nbytes;
int idx;
int res;
}
}
sizeof(db), sizeof(Dwarf_Ubyte));
/* add attributes and forms */
&nbytes,
}
&nbytes,
}
}
for last
entry, see
dwarf2 sec
7.5.3 */
*data = 0;
data++;
*data = 0;
}
for end of
cu, see
dwarf2 sec
7.5.3 */
*data = 0;
return (int) dbg->de_n_debug_sect;
}
/*---------------------------------------------------------------------
Get a buffer of section data.
section_idx is the elf-section number that this data applies to.
length shows length of returned data
----------------------------------------------------------------------*/
/*ARGSUSED*/ /* pretend all args used */
{
}
if (dbg->de_debug_sects == 0) {
/* no more data !! */
return NULL;
}
/* no data ever entered !! */
return NULL;
}
/* We may want to call the section stuff more than once: see
dwarf_reset_section_bytes() do not do: dbg->de_n_debug_sect--; */
return buf;
}
/*
No errors possible.
*/
void
{
/* No need to reset; commented out decrement. dbg->de_n_debug_sect
= ???; */
dbg->de_reloc_next_to_return = 0;
dbg->de_sect_sa_next_to_return = 0;
}
/*
Storage handler. Gets either a new chunk of memory, or
a pointer in existing memory, from the linked list attached
to dbg at de_debug_sects, depending on size of nbytes
Assume dbg not null, checked in top level routine
Returns a pointer to the allocated buffer space for the
lib to fill in, predincrements next-to-use count so the
space requested is already counted 'used'
when this returns (ie, reserved).
*/
{
/* By using MAGIC_SECT_NO we allow the following MAGIC_SECT_NO must
not match any legit section number. test to have just two
clauses (no NULL pointer test) See dwarf_producer_init(). */
) {
/* Either the elf section has changed or there is not enough
space in the current section.
Create a new Dwarf_P_Section_Data_s for the chunk. and have
space 'on the end' for the buffer itself so we just do one
malloc (not two).
*/
if (nbytes < CHUNK_SIZE)
space = CHUNK_SIZE;
sizeof(struct Dwarf_P_Section_Data_s)
+ space);
return (NULL);
/* _dwarf_p_get_alloc zeroes the space... */
sizeof(struct Dwarf_P_Section_Data_s);
of space for caller to fill
in */
/* Now link on the end of the list, and mark this one as the
current one */
/* the only entry is the special one for 'no entry' so
delete that phony one while adding this initial real
one. */
} else {
}
dbg->de_n_debug_sect++;
}
/* There is enough space in the current buffer */
{
return space_for_caller;
}
}
/*------------------------------------------------------------
Given address advance and line advance, it gives
either special opcode, or a number < 0
------------------------------------------------------------*/
static int
{
int opc;
return OPC_INCS_ZERO;
opc =
if (opc > 255)
return OPC_OUT_OF_RANGE;
return opc;
} else
return LINE_OUT_OF_RANGE;
}
/*-----------------------------------------------------------------------
Handles abbreviations. It takes a die, searches through
current list of abbreviations for matching one. If it
finds one, it returns a pointer to it, and if it doesnt,
it returns a new one. Upto the user of this function to
link it up to the abbreviation head. If its a new one,
abb_idx has 0.
-----------------------------------------------------------------------*/
static Dwarf_P_Abbrev
{
int res1;
int nattrs;
int match;
while (curabbrev) {
/* There is a chance of a match. */
(int) curabbrev->
if (res1 == 0)
match = 0;
}
if (match == 1)
return curabbrev;
}
}
/* no match, create new abbreviation */
forms = (Dwarf_ufixed *)
return NULL;
attrs = (Dwarf_ufixed *)
return NULL;
}
nattrs = 0;
while (curattr) {
nattrs++;
}
return NULL;
else
return curabbrev;
}
/*------------------------------------------------------------------
Tries to see if given attribute and form combination
exists in the given abbreviation
-------------------------------------------------------------------*/
static int
{
int i;
int found = 0;
for (i = 0; i < no_attr; i++) {
found = 1;
break;
}
}
return found;
}