pro_forms.c revision 07dc1947c362e187fb955d283b692f8769dd5def
/*
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
Portions Copyright 2007-2010 David Anderson. 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:
*/
#include "config.h"
#include "libdwarfdefs.h"
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include "pro_incl.h"
#include "pro_expr.h"
#ifndef R_MIPS_NONE
#define R_MIPS_NONE 0
#endif
/* Indicates no relocation needed. */
#define NO_ELF_SYM_INDEX 0
/* adds an attribute to a die */
/*
This function adds an attribute whose value is
a target address to the given die. The attribute
is given the name provided by attr. The address
is given in pc_value.
*/
static Dwarf_P_Attribute
Dwarf_Error * error);
/* old interface */
{
return
attr,
}
/* New interface, replacing dwarf_add_AT_targ_address.
Essentially just makes sym_index a Dwarf_Unsigned
so for symbolic relocations it can be a full address.
*/
Dwarf_Error * error)
{
switch (attr) {
case DW_AT_low_pc:
case DW_AT_high_pc:
/* added to support location lists */
/* no way to check that this is a loclist-style address though */
case DW_AT_location:
case DW_AT_string_length:
case DW_AT_return_addr:
case DW_AT_frame_base:
case DW_AT_segment:
case DW_AT_static_link:
case DW_AT_use_location:
case DW_AT_const_value: /* Gcc can generate this as address. */
case DW_AT_entry_pc:
break;
default:
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
break;
}
}
Dwarf_Error * error)
{
switch (attr) {
case DW_AT_type:
case DW_AT_import:
break;
default:
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
break;
}
}
/* Make sure attribute types are checked before entering here. */
static Dwarf_P_Attribute
Dwarf_Error * error)
{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* attribute types have already been checked */
/* switch (attr) { ... } */
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
if (sym_index != NO_ELF_SYM_INDEX)
else
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
(const void *) &pc_value,
sizeof(pc_value), upointer_size);
/* add attribute to the die */
return new_attr;
}
/*
* Functions to compress and uncompress data from normal
* arrays of integral types into arrays of LEB128 numbers.
* Extend these functions as needed to handle wider input
* variety. Return values should be freed with _dwarf_p_dealloc
* after they aren't needed any more.
*/
/* return value points to an array of LEB number */
void *
void* input_block,
)
{
char * output_block = 0;
char encode_buffer[ENCODE_SPACE_NEEDED];
int i = 0;
char * ptr = 0;
int remain = 0;
int result = 0;
return((void *)DW_DLV_BADADDR);
}
if (unit_is_signed == false ||
unit_length_in_bits != 32 ||
input_block == NULL ||
input_length_in_units == 0 ||
return ((void *) DW_DLV_BADADDR);
}
/* At this point we assume the format is: signed 32 bit */
/* first compress everything to find the total size. */
for (i=0; i<input_length_in_units; i++) {
int unit_encoded_size;
encode_buffer,sizeof(encode_buffer));
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
}
}
/* then alloc */
output_block = (void *)
if (output_block == NULL) {
return((void*)DW_DLV_BADADDR);
}
/* then compress again and copy into new buffer */
ptr = output_block;
for (i=0; i<input_length_in_units; i++) {
int unit_encoded_size;
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
}
ptr += unit_encoded_size;
}
if (remain != 0) {
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
}
return (void*) output_block;
}
void
{
}
/* This is very similar to targ_address but results in a different FORM */
/* dbg->de_ar_data_attribute_form is data4 or data8
and dwarf4 changes the definition for such on DW_AT_high_pc.
DWARF 3: the FORM here has no defined meaning for dwarf3.
DWARF 4: the FORM here means that for DW_AT_high_pc the value
is not a high address but is instead an offset
from a (separate) DW_AT_low_pc.
The intent for DWARF4 is that this is not a relocated
address at all. Instead a simple offset.
But this should NOT be called for a simple non-relocated offset.
So do not call this with an attr of DW_AT_high_pc.
Use dwarf_add_AT_unsigned_const() (for example) instead of
dwarf_add_AT_dataref when the value is a simple offset .
*/
Dwarf_Error * error)
{
/* TODO: Add checking here */
error);
}
)
{
int result;
char encode_buffer[ENCODE_SPACE_NEEDED];
int len_size;
char * attrdata;
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
}
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
}
/* I don't mess with block1, block2, block4, not worth the effort */
/* So, encode the length into LEB128 */
encode_buffer,sizeof(encode_buffer));
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
}
/* Allocate the new attribute */
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
}
/* Fill in the attribute */
/* free the block we got earlier */
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
}
/* write length and data to attribute data buffer */
/* add attribute to the die */
return new_attr;
}
/*
This function adds attributes whose value
is an unsigned constant. It determines the
size of the value field from the value of
the constant.
*/
{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
switch (attr) {
case DW_AT_ordering:
case DW_AT_byte_size:
case DW_AT_bit_offset:
case DW_AT_bit_size:
case DW_AT_inline:
case DW_AT_language:
case DW_AT_visibility:
case DW_AT_virtuality:
case DW_AT_accessibility:
case DW_AT_address_class:
case DW_AT_calling_convention:
case DW_AT_encoding:
case DW_AT_identifier_case:
break;
case DW_AT_decl_column:
case DW_AT_decl_file:
case DW_AT_decl_line:
case DW_AT_const_value:
case DW_AT_start_scope:
case DW_AT_stride_size:
case DW_AT_count:
case DW_AT_associated:
case DW_AT_allocated:
case DW_AT_upper_bound:
case DW_AT_lower_bound:
case DW_AT_call_file:
case DW_AT_call_line:
break;
default: {
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
break;
}
}
/*
Compute the number of bytes needed to hold constant. */
size = 1;
size = 2;
size = 4;
} else {
size = 8;
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}
/*
This function adds attributes whose value
is an signed constant. It determines the
size of the value field from the value of
the constant.
*/
{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
switch (attr) {
case DW_AT_lower_bound:
case DW_AT_upper_bound:
case DW_AT_const_value:
case DW_AT_bit_offset:
case DW_AT_bit_size:
case DW_AT_byte_size:
case DW_AT_count:
case DW_AT_byte_stride:
case DW_AT_bit_stride:
case DW_AT_allocated:
case DW_AT_associated:
break;
default:{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
}
break;
}
/*
Compute the number of bytes needed to hold constant. */
size = 1;
size = 2;
size = 4;
} else {
size = 8;
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}
/*
This function adds attributes whose value
is a location expression.
*/
{
char encode_buffer[ENCODE_SPACE_NEEDED];
int res;
char *len_str = 0;
int len_size;
int block_size;
char *block_dest_ptr;
int do_len_as_int = 0;
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
switch (attr) {
case DW_AT_location:
case DW_AT_string_length:
case DW_AT_const_value:
case DW_AT_use_location:
case DW_AT_return_addr:
case DW_AT_frame_base:
case DW_AT_static_link:
case DW_AT_lower_bound:
case DW_AT_upper_bound:
case DW_AT_count:
case DW_AT_associated:
case DW_AT_allocated:
case DW_AT_data_location:
case DW_AT_byte_stride:
case DW_AT_bit_stride:
case DW_AT_byte_size:
case DW_AT_bit_size:
break;
default:
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
break;
}
/*
Compute the number of bytes needed to hold constant. */
if (block_size <= UCHAR_MAX) {
len_size = 1;
do_len_as_int = 1;
} else if (block_size <= USHRT_MAX) {
len_size = 2;
do_len_as_int = 1;
} else if (block_size <= UINT_MAX) {
len_size = 4;
do_len_as_int = 1;
} else {
sizeof(encode_buffer));
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
len_str = (char *) encode_buffer;
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
} else {
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
if (do_len_as_int) {
sizeof(block_size), len_size);
} else {
/* Is uleb number form, DW_FORM_block. See above. */
}
/* add attribute to the die */
return new_attr;
}
/*
This function adds attributes of reference class.
The references here are local CU references,
not DW_FORM_ref_addr.
The offset field is 4 bytes for 32-bit objects,
and 8-bytes for 64-bit objects. Otherdie is the
that is referenced by ownerdie.
For reference attributes, the ar_data and ar_nbytes
are not needed. Instead, the ar_ref_die points to
the other die, and its di_offset value is used as
the reference value.
*/
{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
switch (attr) {
case DW_AT_specification:
case DW_AT_discr:
case DW_AT_common_reference:
case DW_AT_import:
case DW_AT_containing_type:
case DW_AT_default_value:
case DW_AT_abstract_origin:
case DW_AT_friend:
case DW_AT_priority:
case DW_AT_type:
case DW_AT_lower_bound:
case DW_AT_upper_bound:
case DW_AT_count:
case DW_AT_associated:
case DW_AT_allocated:
case DW_AT_bit_offset:
case DW_AT_bit_size:
case DW_AT_byte_size:
case DW_AT_sibling:
case DW_AT_bit_stride:
case DW_AT_byte_stride:
case DW_AT_namelist_item:
break;
default:
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
break;
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}
/*
This function adds attributes of the flag class.
*/
{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
#if 0
switch (attr) {
case DW_AT_is_optional:
case DW_AT_artificial:
case DW_AT_declaration:
case DW_AT_external:
case DW_AT_prototyped:
case DW_AT_variable_parameter:
break;
default:
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
break;
}
#endif
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}
/*
This function adds values of attributes
belonging to the string class.
*/
{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
switch (attr) {
case DW_AT_name:
case DW_AT_comp_dir:
case DW_AT_const_value:
case DW_AT_producer:
break;
default:
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
break;
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}
{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}
{
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}
Dwarf_Error * error)
{
int leb_size;
char encode_buffer[ENCODE_SPACE_NEEDED];
int res;
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
sizeof(encode_buffer));
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}
Dwarf_Error * error)
{
int leb_size;
char encode_buffer[ENCODE_SPACE_NEEDED];
int res;
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
sizeof(encode_buffer));
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
}
/* add attribute to the die */
return new_attr;
}