rdwarf 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.travis.yml +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +28 -0
- data/README.md +39 -0
- data/Rakefile +8 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/ext/rdwarf/depend +5 -0
- data/ext/rdwarf/extconf.rb +29 -0
- data/ext/rdwarf/libdwarf/CHANGES +102 -0
- data/ext/rdwarf/libdwarf/CODINGSTYLE +71 -0
- data/ext/rdwarf/libdwarf/COPYING +28 -0
- data/ext/rdwarf/libdwarf/ChangeLog +619 -0
- data/ext/rdwarf/libdwarf/ChangeLog2006 +835 -0
- data/ext/rdwarf/libdwarf/ChangeLog2007 +217 -0
- data/ext/rdwarf/libdwarf/ChangeLog2008 +263 -0
- data/ext/rdwarf/libdwarf/ChangeLog2009 +348 -0
- data/ext/rdwarf/libdwarf/ChangeLog2010 +175 -0
- data/ext/rdwarf/libdwarf/ChangeLog2011 +297 -0
- data/ext/rdwarf/libdwarf/ChangeLog2012 +131 -0
- data/ext/rdwarf/libdwarf/ChangeLog2013 +238 -0
- data/ext/rdwarf/libdwarf/ChangeLog2014 +399 -0
- data/ext/rdwarf/libdwarf/LGPL.txt +504 -0
- data/ext/rdwarf/libdwarf/LIBDWARFCOPYRIGHT +40 -0
- data/ext/rdwarf/libdwarf/Makefile.in +220 -0
- data/ext/rdwarf/libdwarf/NEWS +535 -0
- data/ext/rdwarf/libdwarf/README +235 -0
- data/ext/rdwarf/libdwarf/checkexamples.c +1179 -0
- data/ext/rdwarf/libdwarf/cmplrs/dwarf_addr_finder.h +55 -0
- data/ext/rdwarf/libdwarf/common.c +62 -0
- data/ext/rdwarf/libdwarf/common.h +38 -0
- data/ext/rdwarf/libdwarf/config.h.in +146 -0
- data/ext/rdwarf/libdwarf/configure +5581 -0
- data/ext/rdwarf/libdwarf/configure.in +167 -0
- data/ext/rdwarf/libdwarf/dw-linetableheader.txt +39 -0
- data/ext/rdwarf/libdwarf/dwarf.h +1342 -0
- data/ext/rdwarf/libdwarf/dwarf_abbrev.c +291 -0
- data/ext/rdwarf/libdwarf/dwarf_abbrev.h +45 -0
- data/ext/rdwarf/libdwarf/dwarf_addr_finder.c +676 -0
- data/ext/rdwarf/libdwarf/dwarf_alloc.c +685 -0
- data/ext/rdwarf/libdwarf/dwarf_alloc.h +38 -0
- data/ext/rdwarf/libdwarf/dwarf_arange.c +595 -0
- data/ext/rdwarf/libdwarf/dwarf_arange.h +62 -0
- data/ext/rdwarf/libdwarf/dwarf_base_types.h +157 -0
- data/ext/rdwarf/libdwarf/dwarf_die_deliv.c +1802 -0
- data/ext/rdwarf/libdwarf/dwarf_die_deliv.h +46 -0
- data/ext/rdwarf/libdwarf/dwarf_elf_access.c +1348 -0
- data/ext/rdwarf/libdwarf/dwarf_elf_access.h +46 -0
- data/ext/rdwarf/libdwarf/dwarf_error.c +492 -0
- data/ext/rdwarf/libdwarf/dwarf_error.h +53 -0
- data/ext/rdwarf/libdwarf/dwarf_form.c +1302 -0
- data/ext/rdwarf/libdwarf/dwarf_frame.c +2454 -0
- data/ext/rdwarf/libdwarf/dwarf_frame.h +418 -0
- data/ext/rdwarf/libdwarf/dwarf_frame2.c +1533 -0
- data/ext/rdwarf/libdwarf/dwarf_frame3.c +282 -0
- data/ext/rdwarf/libdwarf/dwarf_funcs.c +123 -0
- data/ext/rdwarf/libdwarf/dwarf_funcs.h +33 -0
- data/ext/rdwarf/libdwarf/dwarf_gdbindex.c +520 -0
- data/ext/rdwarf/libdwarf/dwarf_gdbindex.h +97 -0
- data/ext/rdwarf/libdwarf/dwarf_global.c +612 -0
- data/ext/rdwarf/libdwarf/dwarf_global.h +117 -0
- data/ext/rdwarf/libdwarf/dwarf_harmless.c +228 -0
- data/ext/rdwarf/libdwarf/dwarf_harmless.h +31 -0
- data/ext/rdwarf/libdwarf/dwarf_incl.h +61 -0
- data/ext/rdwarf/libdwarf/dwarf_init_finish.c +1263 -0
- data/ext/rdwarf/libdwarf/dwarf_leb.c +159 -0
- data/ext/rdwarf/libdwarf/dwarf_line.c +1822 -0
- data/ext/rdwarf/libdwarf/dwarf_line.h +446 -0
- data/ext/rdwarf/libdwarf/dwarf_line2.c +98 -0
- data/ext/rdwarf/libdwarf/dwarf_line_table_reader_common.c +1583 -0
- data/ext/rdwarf/libdwarf/dwarf_loc.c +1525 -0
- data/ext/rdwarf/libdwarf/dwarf_loc.h +149 -0
- data/ext/rdwarf/libdwarf/dwarf_loc2.c +833 -0
- data/ext/rdwarf/libdwarf/dwarf_macro.c +479 -0
- data/ext/rdwarf/libdwarf/dwarf_macro.h +35 -0
- data/ext/rdwarf/libdwarf/dwarf_opaque.h +778 -0
- data/ext/rdwarf/libdwarf/dwarf_original_elf_init.c +219 -0
- data/ext/rdwarf/libdwarf/dwarf_print_lines.c +631 -0
- data/ext/rdwarf/libdwarf/dwarf_pubtypes.c +132 -0
- data/ext/rdwarf/libdwarf/dwarf_query.c +1594 -0
- data/ext/rdwarf/libdwarf/dwarf_ranges.c +194 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_arm.h +308 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_mips.h +117 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_ppc.h +242 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_ppc64.h +272 -0
- data/ext/rdwarf/libdwarf/dwarf_reloc_x86_64.h +127 -0
- data/ext/rdwarf/libdwarf/dwarf_sort_line.c +665 -0
- data/ext/rdwarf/libdwarf/dwarf_string.c +82 -0
- data/ext/rdwarf/libdwarf/dwarf_stubs.c +38 -0
- data/ext/rdwarf/libdwarf/dwarf_tied.c +423 -0
- data/ext/rdwarf/libdwarf/dwarf_tsearch.h +125 -0
- data/ext/rdwarf/libdwarf/dwarf_tsearchhash.c +675 -0
- data/ext/rdwarf/libdwarf/dwarf_types.c +121 -0
- data/ext/rdwarf/libdwarf/dwarf_types.h +32 -0
- data/ext/rdwarf/libdwarf/dwarf_util.c +913 -0
- data/ext/rdwarf/libdwarf/dwarf_util.h +324 -0
- data/ext/rdwarf/libdwarf/dwarf_vars.c +125 -0
- data/ext/rdwarf/libdwarf/dwarf_vars.h +29 -0
- data/ext/rdwarf/libdwarf/dwarf_weaks.c +123 -0
- data/ext/rdwarf/libdwarf/dwarf_weaks.h +29 -0
- data/ext/rdwarf/libdwarf/dwarf_xu_index.c +579 -0
- data/ext/rdwarf/libdwarf/dwarf_xu_index.h +68 -0
- data/ext/rdwarf/libdwarf/dwgetopt.c +181 -0
- data/ext/rdwarf/libdwarf/dwgetopt.h +51 -0
- data/ext/rdwarf/libdwarf/gennames.c +531 -0
- data/ext/rdwarf/libdwarf/install.sh +119 -0
- data/ext/rdwarf/libdwarf/libdwarf.h.in +3746 -0
- data/ext/rdwarf/libdwarf/libdwarf2.1.mm +9805 -0
- data/ext/rdwarf/libdwarf/libdwarf2.1.pdf +0 -0
- data/ext/rdwarf/libdwarf/libdwarf2p.1.mm +2807 -0
- data/ext/rdwarf/libdwarf/libdwarf2p.1.pdf +0 -0
- data/ext/rdwarf/libdwarf/libdwarfdefs.h +81 -0
- data/ext/rdwarf/libdwarf/malloc_check.c +327 -0
- data/ext/rdwarf/libdwarf/malloc_check.h +52 -0
- data/ext/rdwarf/libdwarf/mips_extensions.mm +1266 -0
- data/ext/rdwarf/libdwarf/mips_extensions.pdf +0 -0
- data/ext/rdwarf/libdwarf/pro_alloc.c +179 -0
- data/ext/rdwarf/libdwarf/pro_alloc.h +33 -0
- data/ext/rdwarf/libdwarf/pro_arange.c +310 -0
- data/ext/rdwarf/libdwarf/pro_arange.h +51 -0
- data/ext/rdwarf/libdwarf/pro_die.c +431 -0
- data/ext/rdwarf/libdwarf/pro_die.h +59 -0
- data/ext/rdwarf/libdwarf/pro_encode_nm.c +108 -0
- data/ext/rdwarf/libdwarf/pro_encode_nm.h +39 -0
- data/ext/rdwarf/libdwarf/pro_error.c +96 -0
- data/ext/rdwarf/libdwarf/pro_error.h +43 -0
- data/ext/rdwarf/libdwarf/pro_expr.c +575 -0
- data/ext/rdwarf/libdwarf/pro_expr.h +36 -0
- data/ext/rdwarf/libdwarf/pro_finish.c +45 -0
- data/ext/rdwarf/libdwarf/pro_forms.c +1271 -0
- data/ext/rdwarf/libdwarf/pro_frame.c +572 -0
- data/ext/rdwarf/libdwarf/pro_frame.h +120 -0
- data/ext/rdwarf/libdwarf/pro_funcs.c +50 -0
- data/ext/rdwarf/libdwarf/pro_incl.h +91 -0
- data/ext/rdwarf/libdwarf/pro_init.c +327 -0
- data/ext/rdwarf/libdwarf/pro_line.c +373 -0
- data/ext/rdwarf/libdwarf/pro_line.h +112 -0
- data/ext/rdwarf/libdwarf/pro_macinfo.c +457 -0
- data/ext/rdwarf/libdwarf/pro_macinfo.h +31 -0
- data/ext/rdwarf/libdwarf/pro_opaque.h +513 -0
- data/ext/rdwarf/libdwarf/pro_pubnames.c +60 -0
- data/ext/rdwarf/libdwarf/pro_reloc.c +253 -0
- data/ext/rdwarf/libdwarf/pro_reloc.h +38 -0
- data/ext/rdwarf/libdwarf/pro_reloc_stream.c +256 -0
- data/ext/rdwarf/libdwarf/pro_reloc_stream.h +52 -0
- data/ext/rdwarf/libdwarf/pro_reloc_symbolic.c +245 -0
- data/ext/rdwarf/libdwarf/pro_reloc_symbolic.h +45 -0
- data/ext/rdwarf/libdwarf/pro_section.c +2233 -0
- data/ext/rdwarf/libdwarf/pro_section.h +100 -0
- data/ext/rdwarf/libdwarf/pro_types.c +274 -0
- data/ext/rdwarf/libdwarf/pro_types.h +34 -0
- data/ext/rdwarf/libdwarf/pro_util.h +38 -0
- data/ext/rdwarf/libdwarf/pro_vars.c +52 -0
- data/ext/rdwarf/libdwarf/pro_weaks.c +51 -0
- data/ext/rdwarf/rdwarf.c +765 -0
- data/ext/rdwarf/rdwarf.h +52 -0
- data/ext/rdwarf/rdwarf_names_gen.rb +109 -0
- data/lib/rdwarf.rb +181 -0
- data/lib/rdwarf/version.rb +3 -0
- data/rdwarf.gemspec +30 -0
- metadata +251 -0
@@ -0,0 +1,36 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
4
|
+
|
5
|
+
This program is free software; you can redistribute it and/or modify it
|
6
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
7
|
+
as published by the Free Software Foundation.
|
8
|
+
|
9
|
+
This program is distributed in the hope that it would be useful, but
|
10
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
12
|
+
|
13
|
+
Further, this software is distributed without any warranty that it is
|
14
|
+
free of the rightful claim of any third person regarding infringement
|
15
|
+
or the like. Any license provided herein, whether implied or
|
16
|
+
otherwise, applies only to this software file. Patent licenses, if
|
17
|
+
any, provided herein do not apply to combinations of this program with
|
18
|
+
other software, or any other product whatsoever.
|
19
|
+
|
20
|
+
You should have received a copy of the GNU Lesser General Public
|
21
|
+
License along with this program; if not, write the Free Software
|
22
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
23
|
+
USA.
|
24
|
+
|
25
|
+
*/
|
26
|
+
|
27
|
+
|
28
|
+
#define MAXIMUM_LOC_EXPR_LENGTH 20
|
29
|
+
|
30
|
+
struct Dwarf_P_Expr_s {
|
31
|
+
Dwarf_Small ex_byte_stream[MAXIMUM_LOC_EXPR_LENGTH];
|
32
|
+
Dwarf_P_Debug ex_dbg;
|
33
|
+
Dwarf_Unsigned ex_next_byte_offset;
|
34
|
+
Dwarf_Unsigned ex_reloc_sym_index;
|
35
|
+
Dwarf_Unsigned ex_reloc_offset;
|
36
|
+
};
|
@@ -0,0 +1,45 @@
|
|
1
|
+
/*
|
2
|
+
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
4
|
+
Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
|
5
|
+
Portions Copyright 2011 David Anderson. All rights reserved.
|
6
|
+
|
7
|
+
This program is free software; you can redistribute it and/or modify it
|
8
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
9
|
+
as published by the Free Software Foundation.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it would be useful, but
|
12
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
|
15
|
+
Further, this software is distributed without any warranty that it is
|
16
|
+
free of the rightful claim of any third person regarding infringement
|
17
|
+
or the like. Any license provided herein, whether implied or
|
18
|
+
otherwise, applies only to this software file. Patent licenses, if
|
19
|
+
any, provided herein do not apply to combinations of this program with
|
20
|
+
other software, or any other product whatsoever.
|
21
|
+
|
22
|
+
You should have received a copy of the GNU Lesser General Public
|
23
|
+
License along with this program; if not, write the Free Software
|
24
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
25
|
+
USA.
|
26
|
+
|
27
|
+
*/
|
28
|
+
|
29
|
+
#include "config.h"
|
30
|
+
#include "libdwarfdefs.h"
|
31
|
+
#include "pro_incl.h"
|
32
|
+
|
33
|
+
/* This routine deallocates all memory, and does some
|
34
|
+
finishing up */
|
35
|
+
/*ARGSUSED*/ Dwarf_Unsigned
|
36
|
+
dwarf_producer_finish(Dwarf_P_Debug dbg, Dwarf_Error * error)
|
37
|
+
{
|
38
|
+
if (dbg->de_version_magic_number != PRO_VERSION_MAGIC) {
|
39
|
+
DWARF_P_DBG_ERROR(dbg, DW_DLE_IA, DW_DLV_NOCOUNT);
|
40
|
+
}
|
41
|
+
|
42
|
+
/* this frees all blocks, then frees dbg. */
|
43
|
+
_dwarf_p_dealloc_all(dbg);
|
44
|
+
return 0;
|
45
|
+
}
|
@@ -0,0 +1,1271 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
3
|
+
Portions Copyright 2002-2010 Sun Microsystems, Inc. All rights reserved.
|
4
|
+
Portions Copyright 2007-2013 David Anderson. All rights reserved.
|
5
|
+
Portions Copyright 2012 SN Systems Ltd. All rights reserved.
|
6
|
+
|
7
|
+
This program is free software; you can redistribute it and/or modify it
|
8
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
9
|
+
as published by the Free Software Foundation.
|
10
|
+
|
11
|
+
This program is distributed in the hope that it would be useful, but
|
12
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
14
|
+
|
15
|
+
Further, this software is distributed without any warranty that it is
|
16
|
+
free of the rightful claim of any third person regarding infringement
|
17
|
+
or the like. Any license provided herein, whether implied or
|
18
|
+
otherwise, applies only to this software file. Patent licenses, if
|
19
|
+
any, provided herein do not apply to combinations of this program with
|
20
|
+
other software, or any other product whatsoever.
|
21
|
+
|
22
|
+
You should have received a copy of the GNU Lesser General Public
|
23
|
+
License along with this program; if not, write the Free Software
|
24
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
25
|
+
USA.
|
26
|
+
|
27
|
+
*/
|
28
|
+
|
29
|
+
#include "config.h"
|
30
|
+
#include "libdwarfdefs.h"
|
31
|
+
#include <stdio.h>
|
32
|
+
#include <string.h>
|
33
|
+
#include <limits.h>
|
34
|
+
#include "pro_incl.h"
|
35
|
+
#include "pro_expr.h"
|
36
|
+
|
37
|
+
#ifndef R_MIPS_NONE
|
38
|
+
#define R_MIPS_NONE 0
|
39
|
+
#endif
|
40
|
+
|
41
|
+
|
42
|
+
/* Indicates no relocation needed. */
|
43
|
+
#define NO_ELF_SYM_INDEX 0
|
44
|
+
|
45
|
+
|
46
|
+
/* Adds an attribute to a die */
|
47
|
+
extern void _dwarf_pro_add_at_to_die(Dwarf_P_Die die,
|
48
|
+
Dwarf_P_Attribute attr);
|
49
|
+
|
50
|
+
/* This function adds an attribute whose value is
|
51
|
+
a target address to the given die. The attribute
|
52
|
+
is given the name provided by attr. The address
|
53
|
+
is given in pc_value. */
|
54
|
+
|
55
|
+
static Dwarf_P_Attribute
|
56
|
+
local_add_AT_address(Dwarf_P_Debug dbg,
|
57
|
+
Dwarf_P_Die ownerdie,
|
58
|
+
Dwarf_Half attr,
|
59
|
+
Dwarf_Signed form,
|
60
|
+
Dwarf_Unsigned pc_value,
|
61
|
+
Dwarf_Unsigned sym_index,
|
62
|
+
Dwarf_Error * error);
|
63
|
+
|
64
|
+
/* old interface */
|
65
|
+
Dwarf_P_Attribute
|
66
|
+
dwarf_add_AT_targ_address(Dwarf_P_Debug dbg,
|
67
|
+
Dwarf_P_Die ownerdie,
|
68
|
+
Dwarf_Half attr,
|
69
|
+
Dwarf_Unsigned pc_value,
|
70
|
+
Dwarf_Signed sym_index, Dwarf_Error * error)
|
71
|
+
{
|
72
|
+
return
|
73
|
+
dwarf_add_AT_targ_address_b(dbg,
|
74
|
+
ownerdie,
|
75
|
+
attr,
|
76
|
+
pc_value,
|
77
|
+
(Dwarf_Unsigned) sym_index, error);
|
78
|
+
}
|
79
|
+
|
80
|
+
/* New interface, replacing dwarf_add_AT_targ_address.
|
81
|
+
Essentially just makes sym_index a Dwarf_Unsigned
|
82
|
+
so for symbolic relocations it can be a full address. */
|
83
|
+
Dwarf_P_Attribute
|
84
|
+
dwarf_add_AT_targ_address_b(Dwarf_P_Debug dbg,
|
85
|
+
Dwarf_P_Die ownerdie,
|
86
|
+
Dwarf_Half attr,
|
87
|
+
Dwarf_Unsigned pc_value,
|
88
|
+
Dwarf_Unsigned sym_index,
|
89
|
+
Dwarf_Error * error)
|
90
|
+
{
|
91
|
+
switch (attr) {
|
92
|
+
case DW_AT_low_pc:
|
93
|
+
case DW_AT_high_pc:
|
94
|
+
|
95
|
+
/* added to support location lists */
|
96
|
+
/* no way to check that this is a loclist-style address though */
|
97
|
+
case DW_AT_location:
|
98
|
+
case DW_AT_string_length:
|
99
|
+
case DW_AT_return_addr:
|
100
|
+
case DW_AT_frame_base:
|
101
|
+
case DW_AT_segment:
|
102
|
+
case DW_AT_static_link:
|
103
|
+
case DW_AT_use_location:
|
104
|
+
case DW_AT_vtable_elem_location:
|
105
|
+
case DW_AT_const_value: /* Gcc can generate this as address. */
|
106
|
+
case DW_AT_entry_pc:
|
107
|
+
break;
|
108
|
+
default:
|
109
|
+
if (attr < DW_AT_lo_user || attr > DW_AT_hi_user ) {
|
110
|
+
_dwarf_p_error(dbg, error, DW_DLE_INPUT_ATTR_BAD);
|
111
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
112
|
+
}
|
113
|
+
break;
|
114
|
+
}
|
115
|
+
|
116
|
+
return local_add_AT_address(dbg, ownerdie, attr, DW_FORM_addr,
|
117
|
+
pc_value, sym_index, error);
|
118
|
+
}
|
119
|
+
|
120
|
+
Dwarf_P_Attribute
|
121
|
+
dwarf_add_AT_ref_address(Dwarf_P_Debug dbg,
|
122
|
+
Dwarf_P_Die ownerdie,
|
123
|
+
Dwarf_Half attr,
|
124
|
+
Dwarf_Unsigned pc_value,
|
125
|
+
Dwarf_Unsigned sym_index,
|
126
|
+
Dwarf_Error * error)
|
127
|
+
{
|
128
|
+
switch (attr) {
|
129
|
+
case DW_AT_type:
|
130
|
+
case DW_AT_import:
|
131
|
+
break;
|
132
|
+
|
133
|
+
default:
|
134
|
+
if (attr < DW_AT_lo_user || attr > DW_AT_hi_user ) {
|
135
|
+
_dwarf_p_error(dbg, error, DW_DLE_INPUT_ATTR_BAD);
|
136
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
137
|
+
}
|
138
|
+
break;
|
139
|
+
}
|
140
|
+
|
141
|
+
/* FIXME: For DWARF3 and later this call is problematic as
|
142
|
+
DW_FORM_ref_addr is really an offset in
|
143
|
+
.debug_info , not an address. */
|
144
|
+
return local_add_AT_address(dbg, ownerdie, attr, DW_FORM_ref_addr,
|
145
|
+
pc_value, sym_index, error);
|
146
|
+
}
|
147
|
+
|
148
|
+
|
149
|
+
/* Make sure attribute types are checked before entering here. */
|
150
|
+
static Dwarf_P_Attribute
|
151
|
+
local_add_AT_address(Dwarf_P_Debug dbg,
|
152
|
+
Dwarf_P_Die ownerdie,
|
153
|
+
Dwarf_Half attr,
|
154
|
+
Dwarf_Signed form,
|
155
|
+
Dwarf_Unsigned pc_value,
|
156
|
+
Dwarf_Unsigned sym_index,
|
157
|
+
Dwarf_Error * error)
|
158
|
+
{
|
159
|
+
Dwarf_P_Attribute new_attr;
|
160
|
+
int upointer_size = 0;
|
161
|
+
|
162
|
+
if (dbg == NULL) {
|
163
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
164
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
165
|
+
}
|
166
|
+
upointer_size = dbg->de_pointer_size;
|
167
|
+
|
168
|
+
if (ownerdie == NULL) {
|
169
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
170
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
171
|
+
}
|
172
|
+
|
173
|
+
/* attribute types have already been checked */
|
174
|
+
/* switch (attr) { ... } */
|
175
|
+
|
176
|
+
new_attr = (Dwarf_P_Attribute)
|
177
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
178
|
+
if (new_attr == NULL) {
|
179
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
180
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
181
|
+
}
|
182
|
+
|
183
|
+
new_attr->ar_attribute = attr;
|
184
|
+
new_attr->ar_attribute_form = form;
|
185
|
+
new_attr->ar_nbytes = upointer_size;
|
186
|
+
new_attr->ar_rel_symidx = sym_index;
|
187
|
+
new_attr->ar_reloc_len = upointer_size;
|
188
|
+
new_attr->ar_next = 0;
|
189
|
+
if (sym_index != NO_ELF_SYM_INDEX) {
|
190
|
+
new_attr->ar_rel_type = dbg->de_ptr_reloc;
|
191
|
+
} else {
|
192
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
193
|
+
}
|
194
|
+
|
195
|
+
new_attr->ar_data = (char *)
|
196
|
+
_dwarf_p_get_alloc(dbg, upointer_size);
|
197
|
+
if (new_attr->ar_data == NULL) {
|
198
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
199
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
200
|
+
}
|
201
|
+
WRITE_UNALIGNED(dbg, new_attr->ar_data,
|
202
|
+
(const void *) &pc_value,
|
203
|
+
sizeof(pc_value), upointer_size);
|
204
|
+
|
205
|
+
/* add attribute to the die */
|
206
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
207
|
+
return new_attr;
|
208
|
+
}
|
209
|
+
|
210
|
+
/* Functions to compress and uncompress data from normal
|
211
|
+
arrays of integral types into arrays of LEB128 numbers.
|
212
|
+
Extend these functions as needed to handle wider input
|
213
|
+
variety. Return values should be freed with _dwarf_p_dealloc
|
214
|
+
after they aren't needed any more. */
|
215
|
+
|
216
|
+
/* return value points to an array of LEB number */
|
217
|
+
|
218
|
+
void *
|
219
|
+
dwarf_compress_integer_block(
|
220
|
+
Dwarf_P_Debug dbg,
|
221
|
+
Dwarf_Bool unit_is_signed,
|
222
|
+
Dwarf_Small unit_length_in_bits,
|
223
|
+
void* input_block,
|
224
|
+
Dwarf_Unsigned input_length_in_units,
|
225
|
+
Dwarf_Unsigned* output_length_in_bytes_ptr,
|
226
|
+
Dwarf_Error* error
|
227
|
+
)
|
228
|
+
{
|
229
|
+
Dwarf_Unsigned output_length_in_bytes = 0;
|
230
|
+
char * output_block = 0;
|
231
|
+
char encode_buffer[ENCODE_SPACE_NEEDED];
|
232
|
+
unsigned u = 0;
|
233
|
+
char * ptr = 0;
|
234
|
+
int remain = 0;
|
235
|
+
int result = 0;
|
236
|
+
|
237
|
+
if (dbg == NULL) {
|
238
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
239
|
+
return((void *)DW_DLV_BADADDR);
|
240
|
+
}
|
241
|
+
|
242
|
+
if (unit_is_signed == false ||
|
243
|
+
unit_length_in_bits != 32 ||
|
244
|
+
input_block == NULL ||
|
245
|
+
input_length_in_units == 0 ||
|
246
|
+
output_length_in_bytes_ptr == NULL) {
|
247
|
+
_dwarf_p_error(NULL, error, DW_DLE_BADBITC);
|
248
|
+
return ((void *) DW_DLV_BADADDR);
|
249
|
+
}
|
250
|
+
|
251
|
+
/* At this point we assume the format is: signed 32 bit */
|
252
|
+
|
253
|
+
/* First compress everything to find the total size. */
|
254
|
+
|
255
|
+
output_length_in_bytes = 0;
|
256
|
+
for (u=0; u<input_length_in_units; u++) {
|
257
|
+
int unit_encoded_size;
|
258
|
+
Dwarf_sfixed unit; /* this is fixed at signed-32-bits */
|
259
|
+
|
260
|
+
unit = ((Dwarf_sfixed*)input_block)[u];
|
261
|
+
|
262
|
+
result = _dwarf_pro_encode_signed_leb128_nm(unit, &unit_encoded_size,
|
263
|
+
encode_buffer,sizeof(encode_buffer));
|
264
|
+
if (result != DW_DLV_OK) {
|
265
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
266
|
+
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
|
267
|
+
}
|
268
|
+
output_length_in_bytes += unit_encoded_size;
|
269
|
+
}
|
270
|
+
|
271
|
+
|
272
|
+
/* Then alloc */
|
273
|
+
|
274
|
+
output_block = (void *)
|
275
|
+
_dwarf_p_get_alloc(dbg, output_length_in_bytes);
|
276
|
+
if (output_block == NULL) {
|
277
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
278
|
+
return((void*)DW_DLV_BADADDR);
|
279
|
+
}
|
280
|
+
|
281
|
+
/* Then compress again and copy into new buffer */
|
282
|
+
|
283
|
+
ptr = output_block;
|
284
|
+
remain = output_length_in_bytes;
|
285
|
+
for (u=0; u<input_length_in_units; u++) {
|
286
|
+
int unit_encoded_size;
|
287
|
+
Dwarf_sfixed unit; /* this is fixed at signed-32-bits */
|
288
|
+
|
289
|
+
unit = ((Dwarf_sfixed*)input_block)[u];
|
290
|
+
|
291
|
+
result = _dwarf_pro_encode_signed_leb128_nm(unit, &unit_encoded_size,
|
292
|
+
ptr, remain);
|
293
|
+
if (result != DW_DLV_OK) {
|
294
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
295
|
+
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
|
296
|
+
}
|
297
|
+
remain -= unit_encoded_size;
|
298
|
+
ptr += unit_encoded_size;
|
299
|
+
}
|
300
|
+
|
301
|
+
if (remain != 0) {
|
302
|
+
_dwarf_p_dealloc(dbg, (unsigned char *)output_block);
|
303
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
304
|
+
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
|
305
|
+
}
|
306
|
+
|
307
|
+
*output_length_in_bytes_ptr = output_length_in_bytes;
|
308
|
+
return (void*) output_block;
|
309
|
+
|
310
|
+
}
|
311
|
+
|
312
|
+
void
|
313
|
+
dwarf_dealloc_compressed_block(Dwarf_P_Debug dbg, void * space)
|
314
|
+
{
|
315
|
+
_dwarf_p_dealloc(dbg, space);
|
316
|
+
}
|
317
|
+
|
318
|
+
/* This is very similar to targ_address but results in a different FORM */
|
319
|
+
/* dbg->de_ar_data_attribute_form is data4 or data8
|
320
|
+
and dwarf4 changes the definition for such on DW_AT_high_pc.
|
321
|
+
DWARF 3: the FORM here has no defined meaning for dwarf3.
|
322
|
+
DWARF 4: the FORM here means that for DW_AT_high_pc the value
|
323
|
+
is not a high address but is instead an offset
|
324
|
+
from a (separate) DW_AT_low_pc.
|
325
|
+
The intent for DWARF4 is that this is not a relocated
|
326
|
+
address at all. Instead a simple offset.
|
327
|
+
But this should NOT be called for a simple non-relocated offset.
|
328
|
+
So do not call this with an attr of DW_AT_high_pc.
|
329
|
+
Use dwarf_add_AT_unsigned_const() (for example) instead of
|
330
|
+
dwarf_add_AT_dataref when the value is a simple offset . */
|
331
|
+
Dwarf_P_Attribute
|
332
|
+
dwarf_add_AT_dataref(
|
333
|
+
Dwarf_P_Debug dbg,
|
334
|
+
Dwarf_P_Die ownerdie,
|
335
|
+
Dwarf_Half attr,
|
336
|
+
Dwarf_Unsigned pc_value,
|
337
|
+
Dwarf_Unsigned sym_index,
|
338
|
+
Dwarf_Error * error)
|
339
|
+
{
|
340
|
+
/* TODO: Add checking here */
|
341
|
+
return local_add_AT_address(dbg, ownerdie, attr,
|
342
|
+
dbg->de_ar_data_attribute_form,
|
343
|
+
pc_value,
|
344
|
+
sym_index,
|
345
|
+
error);
|
346
|
+
}
|
347
|
+
|
348
|
+
|
349
|
+
|
350
|
+
Dwarf_P_Attribute
|
351
|
+
dwarf_add_AT_block(
|
352
|
+
Dwarf_P_Debug dbg,
|
353
|
+
Dwarf_P_Die ownerdie,
|
354
|
+
Dwarf_Half attr,
|
355
|
+
Dwarf_Small *block_data,
|
356
|
+
Dwarf_Unsigned block_size,
|
357
|
+
Dwarf_Error *error
|
358
|
+
)
|
359
|
+
{
|
360
|
+
Dwarf_P_Attribute new_attr = 0;
|
361
|
+
int result = 0;
|
362
|
+
char encode_buffer[ENCODE_SPACE_NEEDED];
|
363
|
+
int len_size = 0;
|
364
|
+
char * attrdata = 0;
|
365
|
+
|
366
|
+
if (dbg == NULL) {
|
367
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
368
|
+
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
|
369
|
+
}
|
370
|
+
|
371
|
+
if (ownerdie == NULL) {
|
372
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
373
|
+
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
|
374
|
+
}
|
375
|
+
|
376
|
+
/* I don't mess with block1, block2, block4, not worth the effort */
|
377
|
+
|
378
|
+
/* So, encode the length into LEB128 */
|
379
|
+
result = _dwarf_pro_encode_leb128_nm(block_size, &len_size,
|
380
|
+
encode_buffer,sizeof(encode_buffer));
|
381
|
+
if (result != DW_DLV_OK) {
|
382
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
383
|
+
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
|
384
|
+
}
|
385
|
+
|
386
|
+
/* Allocate the new attribute */
|
387
|
+
new_attr = (Dwarf_P_Attribute)
|
388
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
389
|
+
if (new_attr == NULL) {
|
390
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
391
|
+
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
|
392
|
+
}
|
393
|
+
|
394
|
+
/* Fill in the attribute */
|
395
|
+
new_attr->ar_attribute = attr;
|
396
|
+
new_attr->ar_attribute_form = DW_FORM_block;
|
397
|
+
new_attr->ar_nbytes = len_size + block_size;
|
398
|
+
new_attr->ar_next = 0;
|
399
|
+
|
400
|
+
new_attr->ar_data = attrdata = (char *)
|
401
|
+
_dwarf_p_get_alloc(dbg, len_size + block_size);
|
402
|
+
if (new_attr->ar_data == NULL) {
|
403
|
+
/* free the block we got earlier */
|
404
|
+
_dwarf_p_dealloc(dbg, (unsigned char *) new_attr);
|
405
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
406
|
+
return((Dwarf_P_Attribute)DW_DLV_BADADDR);
|
407
|
+
}
|
408
|
+
|
409
|
+
/* write length and data to attribute data buffer */
|
410
|
+
memcpy(attrdata, encode_buffer, len_size);
|
411
|
+
attrdata += len_size;
|
412
|
+
memcpy(attrdata, block_data, block_size);
|
413
|
+
|
414
|
+
/* add attribute to the die */
|
415
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
416
|
+
|
417
|
+
return new_attr;
|
418
|
+
}
|
419
|
+
|
420
|
+
|
421
|
+
/*
|
422
|
+
This function adds attributes whose value
|
423
|
+
is an unsigned constant. It determines the
|
424
|
+
size of the value field from the value of
|
425
|
+
the constant.
|
426
|
+
*/
|
427
|
+
Dwarf_P_Attribute
|
428
|
+
dwarf_add_AT_unsigned_const(Dwarf_P_Debug dbg,
|
429
|
+
Dwarf_P_Die ownerdie,
|
430
|
+
Dwarf_Half attr,
|
431
|
+
Dwarf_Unsigned value, Dwarf_Error * error)
|
432
|
+
{
|
433
|
+
Dwarf_P_Attribute new_attr = 0;
|
434
|
+
Dwarf_Half attr_form = 0;
|
435
|
+
Dwarf_Small size = 0;
|
436
|
+
|
437
|
+
if (dbg == NULL) {
|
438
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
439
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
440
|
+
}
|
441
|
+
|
442
|
+
if (ownerdie == NULL) {
|
443
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
444
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
445
|
+
}
|
446
|
+
|
447
|
+
switch (attr) {
|
448
|
+
case DW_AT_ordering:
|
449
|
+
case DW_AT_byte_size:
|
450
|
+
case DW_AT_bit_offset:
|
451
|
+
case DW_AT_bit_size:
|
452
|
+
case DW_AT_inline:
|
453
|
+
case DW_AT_language:
|
454
|
+
case DW_AT_visibility:
|
455
|
+
case DW_AT_virtuality:
|
456
|
+
case DW_AT_accessibility:
|
457
|
+
case DW_AT_address_class:
|
458
|
+
case DW_AT_calling_convention:
|
459
|
+
case DW_AT_encoding:
|
460
|
+
case DW_AT_identifier_case:
|
461
|
+
case DW_AT_MIPS_loop_unroll_factor:
|
462
|
+
case DW_AT_MIPS_software_pipeline_depth:
|
463
|
+
break;
|
464
|
+
|
465
|
+
case DW_AT_decl_column:
|
466
|
+
case DW_AT_decl_file:
|
467
|
+
case DW_AT_decl_line:
|
468
|
+
case DW_AT_const_value:
|
469
|
+
case DW_AT_start_scope:
|
470
|
+
case DW_AT_stride_size: /* DW_AT_bit_stride is DWARF3 name */
|
471
|
+
case DW_AT_count:
|
472
|
+
case DW_AT_associated:
|
473
|
+
case DW_AT_allocated:
|
474
|
+
case DW_AT_upper_bound:
|
475
|
+
case DW_AT_lower_bound:
|
476
|
+
case DW_AT_call_file:
|
477
|
+
case DW_AT_call_line:
|
478
|
+
break;
|
479
|
+
|
480
|
+
default:
|
481
|
+
if (attr < DW_AT_lo_user || attr > DW_AT_hi_user ) {
|
482
|
+
_dwarf_p_error(dbg, error, DW_DLE_INPUT_ATTR_BAD);
|
483
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
484
|
+
}
|
485
|
+
break;
|
486
|
+
}
|
487
|
+
|
488
|
+
/* Compute the number of bytes needed to hold constant. */
|
489
|
+
if (value <= UCHAR_MAX) {
|
490
|
+
attr_form = DW_FORM_data1;
|
491
|
+
size = 1;
|
492
|
+
} else if (value <= USHRT_MAX) {
|
493
|
+
attr_form = DW_FORM_data2;
|
494
|
+
size = 2;
|
495
|
+
} else if (value <= UINT_MAX) {
|
496
|
+
attr_form = DW_FORM_data4;
|
497
|
+
size = 4;
|
498
|
+
} else {
|
499
|
+
attr_form = DW_FORM_data8;
|
500
|
+
size = 8;
|
501
|
+
}
|
502
|
+
|
503
|
+
new_attr = (Dwarf_P_Attribute)
|
504
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
505
|
+
if (new_attr == NULL) {
|
506
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
507
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
508
|
+
}
|
509
|
+
|
510
|
+
new_attr->ar_attribute = attr;
|
511
|
+
new_attr->ar_attribute_form = attr_form;
|
512
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
513
|
+
new_attr->ar_reloc_len = 0; /* irrelevant: unused with R_MIPS_NONE */
|
514
|
+
new_attr->ar_nbytes = size;
|
515
|
+
new_attr->ar_next = 0;
|
516
|
+
|
517
|
+
new_attr->ar_data = (char *)
|
518
|
+
_dwarf_p_get_alloc(dbg, size);
|
519
|
+
if (new_attr->ar_data == NULL) {
|
520
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
521
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
522
|
+
}
|
523
|
+
WRITE_UNALIGNED(dbg, new_attr->ar_data,
|
524
|
+
(const void *) &value, sizeof(value), size);
|
525
|
+
|
526
|
+
/* add attribute to the die */
|
527
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
528
|
+
return new_attr;
|
529
|
+
}
|
530
|
+
|
531
|
+
|
532
|
+
/* This function adds attributes whose value
|
533
|
+
is an signed constant. It determines the
|
534
|
+
size of the value field from the value of
|
535
|
+
the constant. */
|
536
|
+
Dwarf_P_Attribute
|
537
|
+
dwarf_add_AT_signed_const(Dwarf_P_Debug dbg,
|
538
|
+
Dwarf_P_Die ownerdie,
|
539
|
+
Dwarf_Half attr,
|
540
|
+
Dwarf_Signed value, Dwarf_Error * error)
|
541
|
+
{
|
542
|
+
Dwarf_P_Attribute new_attr = 0;
|
543
|
+
Dwarf_Half attr_form = 0;
|
544
|
+
Dwarf_Small size = 0;
|
545
|
+
|
546
|
+
if (dbg == NULL) {
|
547
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
548
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
549
|
+
}
|
550
|
+
|
551
|
+
if (ownerdie == NULL) {
|
552
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
553
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
554
|
+
}
|
555
|
+
|
556
|
+
switch (attr) {
|
557
|
+
case DW_AT_lower_bound:
|
558
|
+
case DW_AT_upper_bound:
|
559
|
+
case DW_AT_const_value:
|
560
|
+
case DW_AT_bit_offset:
|
561
|
+
case DW_AT_bit_size:
|
562
|
+
case DW_AT_byte_size:
|
563
|
+
case DW_AT_count:
|
564
|
+
case DW_AT_byte_stride:
|
565
|
+
case DW_AT_bit_stride:
|
566
|
+
case DW_AT_allocated:
|
567
|
+
case DW_AT_associated:
|
568
|
+
break;
|
569
|
+
|
570
|
+
default:
|
571
|
+
if (attr < DW_AT_lo_user || attr > DW_AT_hi_user ) {
|
572
|
+
_dwarf_p_error(dbg, error, DW_DLE_INPUT_ATTR_BAD);
|
573
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
574
|
+
}
|
575
|
+
break;
|
576
|
+
}
|
577
|
+
|
578
|
+
/* Compute the number of bytes needed to hold constant. */
|
579
|
+
if (value >= SCHAR_MIN && value <= SCHAR_MAX) {
|
580
|
+
attr_form = DW_FORM_data1;
|
581
|
+
size = 1;
|
582
|
+
} else if (value >= SHRT_MIN && value <= SHRT_MAX) {
|
583
|
+
attr_form = DW_FORM_data2;
|
584
|
+
size = 2;
|
585
|
+
} else if (value >= INT_MIN && value <= INT_MAX) {
|
586
|
+
attr_form = DW_FORM_data4;
|
587
|
+
size = 4;
|
588
|
+
} else {
|
589
|
+
attr_form = DW_FORM_data8;
|
590
|
+
size = 8;
|
591
|
+
}
|
592
|
+
|
593
|
+
new_attr = (Dwarf_P_Attribute)
|
594
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
595
|
+
if (new_attr == NULL) {
|
596
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
597
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
598
|
+
}
|
599
|
+
|
600
|
+
new_attr->ar_attribute = attr;
|
601
|
+
new_attr->ar_attribute_form = attr_form;
|
602
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
603
|
+
new_attr->ar_reloc_len = 0; /* irrelevant: unused with R_MIPS_NONE */
|
604
|
+
new_attr->ar_nbytes = size;
|
605
|
+
new_attr->ar_next = 0;
|
606
|
+
|
607
|
+
new_attr->ar_data = (char *)
|
608
|
+
_dwarf_p_get_alloc(dbg, size);
|
609
|
+
if (new_attr->ar_data == NULL) {
|
610
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
611
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
612
|
+
}
|
613
|
+
WRITE_UNALIGNED(dbg, new_attr->ar_data,
|
614
|
+
(const void *) &value, sizeof(value), size);
|
615
|
+
|
616
|
+
/* add attribute to the die */
|
617
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
618
|
+
return new_attr;
|
619
|
+
}
|
620
|
+
|
621
|
+
|
622
|
+
/* This function adds attributes whose value
|
623
|
+
is a location expression. */
|
624
|
+
Dwarf_P_Attribute
|
625
|
+
dwarf_add_AT_location_expr(Dwarf_P_Debug dbg,
|
626
|
+
Dwarf_P_Die ownerdie,
|
627
|
+
Dwarf_Half attr,
|
628
|
+
Dwarf_P_Expr loc_expr, Dwarf_Error * error)
|
629
|
+
{
|
630
|
+
char encode_buffer[ENCODE_SPACE_NEEDED];
|
631
|
+
int res = 0;
|
632
|
+
Dwarf_P_Attribute new_attr = 0;
|
633
|
+
Dwarf_Half attr_form = 0;
|
634
|
+
char *len_str = 0;
|
635
|
+
int len_size = 0;
|
636
|
+
unsigned block_size = 0;
|
637
|
+
char *block_dest_ptr = 0;
|
638
|
+
int do_len_as_int = 0;
|
639
|
+
|
640
|
+
if (dbg == NULL) {
|
641
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
642
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
643
|
+
}
|
644
|
+
|
645
|
+
if (ownerdie == NULL) {
|
646
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
647
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
648
|
+
}
|
649
|
+
|
650
|
+
if (loc_expr == NULL) {
|
651
|
+
_dwarf_p_error(dbg, error, DW_DLE_EXPR_NULL);
|
652
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
653
|
+
}
|
654
|
+
|
655
|
+
if (loc_expr->ex_dbg != dbg) {
|
656
|
+
_dwarf_p_error(dbg, error, DW_DLE_LOC_EXPR_BAD);
|
657
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
658
|
+
}
|
659
|
+
block_size = loc_expr->ex_next_byte_offset;
|
660
|
+
|
661
|
+
switch (attr) {
|
662
|
+
case DW_AT_location:
|
663
|
+
case DW_AT_string_length:
|
664
|
+
case DW_AT_const_value:
|
665
|
+
case DW_AT_use_location:
|
666
|
+
case DW_AT_return_addr:
|
667
|
+
case DW_AT_data_member_location:
|
668
|
+
case DW_AT_frame_base:
|
669
|
+
case DW_AT_static_link:
|
670
|
+
case DW_AT_vtable_elem_location:
|
671
|
+
case DW_AT_lower_bound:
|
672
|
+
case DW_AT_upper_bound:
|
673
|
+
case DW_AT_count:
|
674
|
+
case DW_AT_associated:
|
675
|
+
case DW_AT_allocated:
|
676
|
+
case DW_AT_data_location:
|
677
|
+
case DW_AT_byte_stride:
|
678
|
+
case DW_AT_bit_stride:
|
679
|
+
case DW_AT_byte_size:
|
680
|
+
case DW_AT_bit_size:
|
681
|
+
break;
|
682
|
+
|
683
|
+
default:
|
684
|
+
if (attr < DW_AT_lo_user || attr > DW_AT_hi_user ) {
|
685
|
+
_dwarf_p_error(dbg, error, DW_DLE_INPUT_ATTR_BAD);
|
686
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
687
|
+
}
|
688
|
+
break;
|
689
|
+
}
|
690
|
+
|
691
|
+
/* Compute the number of bytes needed to hold constant. */
|
692
|
+
if (block_size <= UCHAR_MAX) {
|
693
|
+
attr_form = DW_FORM_block1;
|
694
|
+
len_size = 1;
|
695
|
+
do_len_as_int = 1;
|
696
|
+
} else if (block_size <= USHRT_MAX) {
|
697
|
+
attr_form = DW_FORM_block2;
|
698
|
+
len_size = 2;
|
699
|
+
do_len_as_int = 1;
|
700
|
+
} else if (block_size <= UINT_MAX) {
|
701
|
+
attr_form = DW_FORM_block4;
|
702
|
+
len_size = 4;
|
703
|
+
do_len_as_int = 1;
|
704
|
+
} else {
|
705
|
+
attr_form = DW_FORM_block;
|
706
|
+
res = _dwarf_pro_encode_leb128_nm(block_size, &len_size,
|
707
|
+
encode_buffer,
|
708
|
+
sizeof(encode_buffer));
|
709
|
+
if (res != DW_DLV_OK) {
|
710
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
711
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
712
|
+
}
|
713
|
+
len_str = (char *) encode_buffer;
|
714
|
+
}
|
715
|
+
|
716
|
+
new_attr = (Dwarf_P_Attribute)
|
717
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
718
|
+
if (new_attr == NULL) {
|
719
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
720
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
721
|
+
}
|
722
|
+
|
723
|
+
new_attr->ar_attribute = attr;
|
724
|
+
new_attr->ar_attribute_form = attr_form;
|
725
|
+
new_attr->ar_reloc_len = dbg->de_pointer_size;
|
726
|
+
if (loc_expr->ex_reloc_sym_index != NO_ELF_SYM_INDEX) {
|
727
|
+
new_attr->ar_rel_type = dbg->de_ptr_reloc;
|
728
|
+
} else {
|
729
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
730
|
+
}
|
731
|
+
new_attr->ar_rel_symidx = loc_expr->ex_reloc_sym_index;
|
732
|
+
new_attr->ar_rel_offset =
|
733
|
+
(Dwarf_Word) loc_expr->ex_reloc_offset + len_size;
|
734
|
+
|
735
|
+
new_attr->ar_nbytes = block_size + len_size;
|
736
|
+
|
737
|
+
new_attr->ar_next = 0;
|
738
|
+
new_attr->ar_data = block_dest_ptr =
|
739
|
+
(char *) _dwarf_p_get_alloc(dbg, block_size + len_size);
|
740
|
+
if (new_attr->ar_data == NULL) {
|
741
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
742
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
743
|
+
}
|
744
|
+
|
745
|
+
if (do_len_as_int) {
|
746
|
+
WRITE_UNALIGNED(dbg, block_dest_ptr, (const void *) &block_size,
|
747
|
+
sizeof(block_size), len_size);
|
748
|
+
} else {
|
749
|
+
/* Is uleb number form, DW_FORM_block. See above. */
|
750
|
+
memcpy(block_dest_ptr, len_str, len_size);
|
751
|
+
}
|
752
|
+
block_dest_ptr += len_size;
|
753
|
+
memcpy(block_dest_ptr, &(loc_expr->ex_byte_stream[0]), block_size);
|
754
|
+
|
755
|
+
/* add attribute to the die */
|
756
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
757
|
+
return new_attr;
|
758
|
+
}
|
759
|
+
|
760
|
+
|
761
|
+
/* This function adds attributes of reference class.
|
762
|
+
The references here are local CU references,
|
763
|
+
not DW_FORM_ref_addr.
|
764
|
+
The offset field is 4 bytes for 32-bit objects,
|
765
|
+
and 8-bytes for 64-bit objects. Otherdie is the
|
766
|
+
that is referenced by ownerdie.
|
767
|
+
|
768
|
+
For reference attributes, the ar_data and ar_nbytes
|
769
|
+
are not needed. Instead, the ar_ref_die points to
|
770
|
+
the other die, and its di_offset value is used as
|
771
|
+
the reference value. */
|
772
|
+
|
773
|
+
static Dwarf_P_Attribute
|
774
|
+
_dwarf_add_AT_reference_internal(Dwarf_P_Debug dbg,
|
775
|
+
Dwarf_P_Die ownerdie,
|
776
|
+
Dwarf_Half attr,
|
777
|
+
Dwarf_P_Die otherdie,
|
778
|
+
int check_otherdie,
|
779
|
+
Dwarf_Error * error)
|
780
|
+
{
|
781
|
+
Dwarf_P_Attribute new_attr = 0;
|
782
|
+
|
783
|
+
if (dbg == NULL) {
|
784
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
785
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
786
|
+
}
|
787
|
+
|
788
|
+
if (ownerdie == NULL) {
|
789
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
790
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
791
|
+
}
|
792
|
+
|
793
|
+
if (check_otherdie && (otherdie == NULL)) {
|
794
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
795
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
796
|
+
}
|
797
|
+
|
798
|
+
switch (attr) {
|
799
|
+
case DW_AT_count:
|
800
|
+
case DW_AT_sibling:
|
801
|
+
case DW_AT_byte_size:
|
802
|
+
case DW_AT_bit_offset:
|
803
|
+
case DW_AT_bit_size:
|
804
|
+
case DW_AT_discr:
|
805
|
+
case DW_AT_import:
|
806
|
+
case DW_AT_common_reference:
|
807
|
+
case DW_AT_containing_type:
|
808
|
+
case DW_AT_default_value:
|
809
|
+
case DW_AT_lower_bound:
|
810
|
+
case DW_AT_bit_stride: /* Early name is DW_AT_stride_size */
|
811
|
+
case DW_AT_upper_bound:
|
812
|
+
case DW_AT_abstract_origin:
|
813
|
+
case DW_AT_base_types:
|
814
|
+
case DW_AT_friend:
|
815
|
+
case DW_AT_namelist_item:
|
816
|
+
case DW_AT_priority:
|
817
|
+
case DW_AT_specification:
|
818
|
+
case DW_AT_type:
|
819
|
+
case DW_AT_allocated:
|
820
|
+
case DW_AT_associated:
|
821
|
+
case DW_AT_byte_stride:
|
822
|
+
case DW_AT_extension:
|
823
|
+
case DW_AT_trampoline:
|
824
|
+
case DW_AT_small:
|
825
|
+
case DW_AT_object_pointer:
|
826
|
+
case DW_AT_signature:
|
827
|
+
break;
|
828
|
+
|
829
|
+
default:
|
830
|
+
if (attr < DW_AT_lo_user || attr > DW_AT_hi_user ) {
|
831
|
+
_dwarf_p_error(dbg, error, DW_DLE_INPUT_ATTR_BAD);
|
832
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
833
|
+
}
|
834
|
+
break;
|
835
|
+
}
|
836
|
+
|
837
|
+
new_attr = (Dwarf_P_Attribute)
|
838
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
839
|
+
if (new_attr == NULL) {
|
840
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
841
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
842
|
+
}
|
843
|
+
|
844
|
+
new_attr->ar_attribute = attr;
|
845
|
+
new_attr->ar_attribute_form = dbg->de_ar_ref_attr_form;
|
846
|
+
new_attr->ar_nbytes = dbg->de_offset_size;
|
847
|
+
new_attr->ar_reloc_len = dbg->de_offset_size;
|
848
|
+
new_attr->ar_ref_die = otherdie;
|
849
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
850
|
+
new_attr->ar_next = 0;
|
851
|
+
|
852
|
+
/* Add attribute to the die */
|
853
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
854
|
+
return new_attr;
|
855
|
+
}
|
856
|
+
Dwarf_P_Attribute
|
857
|
+
dwarf_add_AT_reference(Dwarf_P_Debug dbg,
|
858
|
+
Dwarf_P_Die ownerdie,
|
859
|
+
Dwarf_Half attr,
|
860
|
+
Dwarf_P_Die otherdie, Dwarf_Error * error)
|
861
|
+
{
|
862
|
+
return _dwarf_add_AT_reference_internal(dbg,
|
863
|
+
ownerdie,
|
864
|
+
attr,
|
865
|
+
otherdie,
|
866
|
+
/* check otherdie */ 1,
|
867
|
+
error);
|
868
|
+
}
|
869
|
+
|
870
|
+
/* Allowing the target die to be identified later.
|
871
|
+
*/
|
872
|
+
Dwarf_P_Attribute
|
873
|
+
dwarf_add_AT_reference_b(Dwarf_P_Debug dbg,
|
874
|
+
Dwarf_P_Die ownerdie,
|
875
|
+
Dwarf_Half attr,
|
876
|
+
Dwarf_P_Die otherdie,
|
877
|
+
Dwarf_Error * error)
|
878
|
+
{
|
879
|
+
return _dwarf_add_AT_reference_internal(dbg,
|
880
|
+
ownerdie,
|
881
|
+
attr,
|
882
|
+
otherdie,
|
883
|
+
/* check otherdie */ 0,
|
884
|
+
error);
|
885
|
+
}
|
886
|
+
|
887
|
+
|
888
|
+
|
889
|
+
|
890
|
+
int
|
891
|
+
dwarf_fixup_AT_reference_die(Dwarf_P_Debug dbg,
|
892
|
+
Dwarf_Half attrnum,
|
893
|
+
Dwarf_P_Die sourcedie,
|
894
|
+
Dwarf_P_Die targetdie,
|
895
|
+
Dwarf_Error *error)
|
896
|
+
{
|
897
|
+
Dwarf_P_Attribute a = 0;
|
898
|
+
Dwarf_P_Attribute cur = 0;
|
899
|
+
if (dbg == NULL) {
|
900
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
901
|
+
return DW_DLV_ERROR;
|
902
|
+
}
|
903
|
+
for(cur = sourcedie->di_attrs; cur; cur = cur->ar_next) {
|
904
|
+
if (attrnum == cur->ar_attribute) {
|
905
|
+
a = cur;
|
906
|
+
break;
|
907
|
+
}
|
908
|
+
}
|
909
|
+
if(!a) {
|
910
|
+
_dwarf_p_error(dbg, error, DW_DLE_AT_FIXUP_NULL);
|
911
|
+
return DW_DLV_ERROR;
|
912
|
+
}
|
913
|
+
if(a->ar_ref_die) {
|
914
|
+
_dwarf_p_error(dbg, error, DW_DLE_AT_FIXUP_DUP);
|
915
|
+
return DW_DLV_ERROR;
|
916
|
+
}
|
917
|
+
a->ar_ref_die = targetdie;
|
918
|
+
return DW_DLV_OK;
|
919
|
+
}
|
920
|
+
|
921
|
+
|
922
|
+
/* This function adds attributes of the flag class. */
|
923
|
+
Dwarf_P_Attribute
|
924
|
+
dwarf_add_AT_flag(Dwarf_P_Debug dbg,
|
925
|
+
Dwarf_P_Die ownerdie,
|
926
|
+
Dwarf_Half attr,
|
927
|
+
Dwarf_Small flag, Dwarf_Error * error)
|
928
|
+
{
|
929
|
+
Dwarf_P_Attribute new_attr = 0;
|
930
|
+
|
931
|
+
if (dbg == NULL) {
|
932
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
933
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
934
|
+
}
|
935
|
+
|
936
|
+
if (ownerdie == NULL) {
|
937
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
938
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
939
|
+
}
|
940
|
+
|
941
|
+
new_attr = (Dwarf_P_Attribute)
|
942
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
943
|
+
if (new_attr == NULL) {
|
944
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
945
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
946
|
+
}
|
947
|
+
|
948
|
+
new_attr->ar_attribute = attr;
|
949
|
+
new_attr->ar_attribute_form = DW_FORM_flag;
|
950
|
+
new_attr->ar_nbytes = 1;
|
951
|
+
new_attr->ar_reloc_len = 0; /* not used */
|
952
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
953
|
+
new_attr->ar_next = 0;
|
954
|
+
|
955
|
+
new_attr->ar_data = (char *)
|
956
|
+
_dwarf_p_get_alloc(dbg, 1);
|
957
|
+
if (new_attr->ar_data == NULL) {
|
958
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
959
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
960
|
+
}
|
961
|
+
memcpy(new_attr->ar_data, &flag, 1);
|
962
|
+
|
963
|
+
/* Add attribute to the die */
|
964
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
965
|
+
return new_attr;
|
966
|
+
}
|
967
|
+
|
968
|
+
|
969
|
+
/* This function adds values of attributes
|
970
|
+
belonging to the string class. */
|
971
|
+
Dwarf_P_Attribute
|
972
|
+
dwarf_add_AT_string(Dwarf_P_Debug dbg,
|
973
|
+
Dwarf_P_Die ownerdie,
|
974
|
+
Dwarf_Half attr, char *string, Dwarf_Error * error)
|
975
|
+
{
|
976
|
+
Dwarf_P_Attribute new_attr;
|
977
|
+
|
978
|
+
if (dbg == NULL) {
|
979
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
980
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
981
|
+
}
|
982
|
+
|
983
|
+
if (ownerdie == NULL) {
|
984
|
+
_dwarf_p_error(dbg, error, DW_DLE_DIE_NULL);
|
985
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
986
|
+
}
|
987
|
+
|
988
|
+
new_attr = (Dwarf_P_Attribute)
|
989
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Attribute_s));
|
990
|
+
if (new_attr == NULL) {
|
991
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
992
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
993
|
+
}
|
994
|
+
|
995
|
+
switch (attr) {
|
996
|
+
case DW_AT_name:
|
997
|
+
case DW_AT_comp_dir:
|
998
|
+
case DW_AT_const_value:
|
999
|
+
case DW_AT_producer:
|
1000
|
+
break;
|
1001
|
+
|
1002
|
+
default:
|
1003
|
+
if (attr < DW_AT_lo_user || attr > DW_AT_hi_user ) {
|
1004
|
+
_dwarf_p_error(dbg, error, DW_DLE_INPUT_ATTR_BAD);
|
1005
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1006
|
+
}
|
1007
|
+
break;
|
1008
|
+
}
|
1009
|
+
|
1010
|
+
new_attr->ar_attribute = attr;
|
1011
|
+
new_attr->ar_attribute_form = DW_FORM_string;
|
1012
|
+
new_attr->ar_nbytes = strlen(string) + 1;
|
1013
|
+
new_attr->ar_next = 0;
|
1014
|
+
|
1015
|
+
new_attr->ar_data =
|
1016
|
+
(char *) _dwarf_p_get_alloc(dbg, strlen(string)+1);
|
1017
|
+
if (new_attr->ar_data == NULL) {
|
1018
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
1019
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1020
|
+
}
|
1021
|
+
|
1022
|
+
strcpy(new_attr->ar_data, string);
|
1023
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
1024
|
+
new_attr->ar_reloc_len = 0; /* unused for R_MIPS_NONE */
|
1025
|
+
|
1026
|
+
/* add attribute to the die */
|
1027
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
1028
|
+
return new_attr;
|
1029
|
+
}
|
1030
|
+
|
1031
|
+
|
1032
|
+
Dwarf_P_Attribute
|
1033
|
+
dwarf_add_AT_const_value_string(Dwarf_P_Die ownerdie,
|
1034
|
+
char *string_value, Dwarf_Error * error)
|
1035
|
+
{
|
1036
|
+
Dwarf_P_Attribute new_attr;
|
1037
|
+
|
1038
|
+
if (ownerdie == NULL) {
|
1039
|
+
_dwarf_p_error(NULL, error, DW_DLE_DIE_NULL);
|
1040
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1041
|
+
}
|
1042
|
+
|
1043
|
+
new_attr = (Dwarf_P_Attribute)
|
1044
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg, sizeof(struct Dwarf_P_Attribute_s));
|
1045
|
+
if (new_attr == NULL) {
|
1046
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1047
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
new_attr->ar_attribute = DW_AT_const_value;
|
1051
|
+
new_attr->ar_attribute_form = DW_FORM_string;
|
1052
|
+
new_attr->ar_nbytes = strlen(string_value) + 1;
|
1053
|
+
new_attr->ar_next = 0;
|
1054
|
+
|
1055
|
+
new_attr->ar_data =
|
1056
|
+
(char *) _dwarf_p_get_alloc(ownerdie->di_dbg, strlen(string_value)+1);
|
1057
|
+
if (new_attr->ar_data == NULL) {
|
1058
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1059
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1060
|
+
}
|
1061
|
+
|
1062
|
+
strcpy(new_attr->ar_data, string_value);
|
1063
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
1064
|
+
new_attr->ar_reloc_len = 0; /* unused for R_MIPS_NONE */
|
1065
|
+
|
1066
|
+
/* add attribute to the die */
|
1067
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
1068
|
+
return new_attr;
|
1069
|
+
}
|
1070
|
+
|
1071
|
+
Dwarf_P_Attribute
|
1072
|
+
dwarf_add_AT_with_ref_sig8(Dwarf_P_Die ownerdie,
|
1073
|
+
Dwarf_Half attrnum,
|
1074
|
+
const Dwarf_Sig8 *sig8_in,
|
1075
|
+
Dwarf_Error * error)
|
1076
|
+
{
|
1077
|
+
Dwarf_P_Attribute new_attr = 0;
|
1078
|
+
if (ownerdie == NULL) {
|
1079
|
+
_dwarf_p_error(NULL, error, DW_DLE_DIE_NULL);
|
1080
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1081
|
+
}
|
1082
|
+
|
1083
|
+
new_attr = (Dwarf_P_Attribute)
|
1084
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg, sizeof(struct Dwarf_P_Attribute_s));
|
1085
|
+
if (new_attr == NULL) {
|
1086
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1087
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1088
|
+
}
|
1089
|
+
new_attr->ar_attribute = attrnum;
|
1090
|
+
new_attr->ar_attribute_form = DW_FORM_ref_sig8;
|
1091
|
+
new_attr->ar_nbytes = sizeof (Dwarf_Sig8);
|
1092
|
+
new_attr->ar_next = 0;
|
1093
|
+
|
1094
|
+
new_attr->ar_data =
|
1095
|
+
(char *) _dwarf_p_get_alloc(ownerdie->di_dbg, sizeof(Dwarf_Sig8));
|
1096
|
+
if (new_attr->ar_data == NULL) {
|
1097
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1098
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1099
|
+
}
|
1100
|
+
memcpy(new_attr->ar_data,sig8_in,sizeof(Dwarf_Sig8));
|
1101
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
1102
|
+
new_attr->ar_reloc_len = 0; /* unused for R_MIPS_NONE */
|
1103
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
1104
|
+
return new_attr;
|
1105
|
+
}
|
1106
|
+
|
1107
|
+
|
1108
|
+
|
1109
|
+
Dwarf_P_Attribute
|
1110
|
+
dwarf_add_AT_producer(Dwarf_P_Die ownerdie,
|
1111
|
+
char *producer_string, Dwarf_Error * error)
|
1112
|
+
{
|
1113
|
+
Dwarf_P_Attribute new_attr;
|
1114
|
+
|
1115
|
+
if (ownerdie == NULL) {
|
1116
|
+
_dwarf_p_error(NULL, error, DW_DLE_DIE_NULL);
|
1117
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1118
|
+
}
|
1119
|
+
|
1120
|
+
new_attr = (Dwarf_P_Attribute)
|
1121
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg, sizeof(struct Dwarf_P_Attribute_s));
|
1122
|
+
if (new_attr == NULL) {
|
1123
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1124
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1125
|
+
}
|
1126
|
+
|
1127
|
+
new_attr->ar_attribute = DW_AT_producer;
|
1128
|
+
new_attr->ar_attribute_form = DW_FORM_string;
|
1129
|
+
new_attr->ar_nbytes = strlen(producer_string) + 1;
|
1130
|
+
new_attr->ar_next = 0;
|
1131
|
+
|
1132
|
+
new_attr->ar_data =
|
1133
|
+
(char *) _dwarf_p_get_alloc(ownerdie->di_dbg, strlen(producer_string)+1);
|
1134
|
+
if (new_attr->ar_data == NULL) {
|
1135
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1136
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
strcpy(new_attr->ar_data, producer_string);
|
1140
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
1141
|
+
new_attr->ar_reloc_len = 0; /* unused for R_MIPS_NONE */
|
1142
|
+
|
1143
|
+
/* add attribute to the die */
|
1144
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
1145
|
+
return new_attr;
|
1146
|
+
}
|
1147
|
+
|
1148
|
+
|
1149
|
+
Dwarf_P_Attribute
|
1150
|
+
dwarf_add_AT_const_value_signedint(Dwarf_P_Die ownerdie,
|
1151
|
+
Dwarf_Signed signed_value,
|
1152
|
+
Dwarf_Error * error)
|
1153
|
+
{
|
1154
|
+
return dwarf_add_AT_any_value_sleb(
|
1155
|
+
ownerdie,DW_AT_const_value,
|
1156
|
+
signed_value,
|
1157
|
+
error);
|
1158
|
+
}
|
1159
|
+
|
1160
|
+
Dwarf_P_Attribute
|
1161
|
+
dwarf_add_AT_any_value_sleb(Dwarf_P_Die ownerdie,
|
1162
|
+
Dwarf_Half attrnum,
|
1163
|
+
Dwarf_Signed signed_value,
|
1164
|
+
Dwarf_Error * error)
|
1165
|
+
{
|
1166
|
+
Dwarf_P_Attribute new_attr = 0;
|
1167
|
+
int leb_size = 0;
|
1168
|
+
char encode_buffer[ENCODE_SPACE_NEEDED];
|
1169
|
+
int res = 0;
|
1170
|
+
|
1171
|
+
if (ownerdie == NULL) {
|
1172
|
+
_dwarf_p_error(NULL, error, DW_DLE_DIE_NULL);
|
1173
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1174
|
+
}
|
1175
|
+
|
1176
|
+
new_attr = (Dwarf_P_Attribute)
|
1177
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg, sizeof(struct Dwarf_P_Attribute_s));
|
1178
|
+
if (new_attr == NULL) {
|
1179
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1180
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1181
|
+
}
|
1182
|
+
|
1183
|
+
new_attr->ar_attribute = attrnum;
|
1184
|
+
new_attr->ar_attribute_form = DW_FORM_sdata;
|
1185
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
1186
|
+
new_attr->ar_reloc_len = 0; /* unused for R_MIPS_NONE */
|
1187
|
+
new_attr->ar_next = 0;
|
1188
|
+
|
1189
|
+
res = _dwarf_pro_encode_signed_leb128_nm(signed_value, &leb_size,
|
1190
|
+
encode_buffer,
|
1191
|
+
sizeof(encode_buffer));
|
1192
|
+
if (res != DW_DLV_OK) {
|
1193
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1194
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1195
|
+
}
|
1196
|
+
new_attr->ar_data = (char *)
|
1197
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg, leb_size);
|
1198
|
+
if (new_attr->ar_data == NULL) {
|
1199
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1200
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1201
|
+
}
|
1202
|
+
memcpy(new_attr->ar_data, encode_buffer, leb_size);
|
1203
|
+
new_attr->ar_nbytes = leb_size;
|
1204
|
+
|
1205
|
+
/* add attribute to the die */
|
1206
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
1207
|
+
return new_attr;
|
1208
|
+
}
|
1209
|
+
|
1210
|
+
/* AT_const_value, uleb */
|
1211
|
+
Dwarf_P_Attribute
|
1212
|
+
dwarf_add_AT_const_value_unsignedint(Dwarf_P_Die ownerdie,
|
1213
|
+
Dwarf_Unsigned unsigned_value,
|
1214
|
+
Dwarf_Error * error)
|
1215
|
+
{
|
1216
|
+
return dwarf_add_AT_any_value_uleb(
|
1217
|
+
ownerdie,DW_AT_const_value,
|
1218
|
+
unsigned_value,
|
1219
|
+
error);
|
1220
|
+
}
|
1221
|
+
|
1222
|
+
|
1223
|
+
Dwarf_P_Attribute
|
1224
|
+
dwarf_add_AT_any_value_uleb(Dwarf_P_Die ownerdie,
|
1225
|
+
Dwarf_Half attrnum,
|
1226
|
+
Dwarf_Unsigned unsigned_value,
|
1227
|
+
Dwarf_Error * error)
|
1228
|
+
{
|
1229
|
+
Dwarf_P_Attribute new_attr;
|
1230
|
+
int leb_size;
|
1231
|
+
char encode_buffer[ENCODE_SPACE_NEEDED];
|
1232
|
+
int res;
|
1233
|
+
|
1234
|
+
if (ownerdie == NULL) {
|
1235
|
+
_dwarf_p_error(NULL, error, DW_DLE_DIE_NULL);
|
1236
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1237
|
+
}
|
1238
|
+
|
1239
|
+
new_attr = (Dwarf_P_Attribute)
|
1240
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg, sizeof(struct Dwarf_P_Attribute_s));
|
1241
|
+
if (new_attr == NULL) {
|
1242
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1243
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1244
|
+
}
|
1245
|
+
|
1246
|
+
new_attr->ar_attribute = attrnum;
|
1247
|
+
new_attr->ar_attribute_form = DW_FORM_udata;
|
1248
|
+
new_attr->ar_rel_type = R_MIPS_NONE;
|
1249
|
+
new_attr->ar_reloc_len = 0; /* unused for R_MIPS_NONE */
|
1250
|
+
new_attr->ar_next = 0;
|
1251
|
+
|
1252
|
+
res = _dwarf_pro_encode_leb128_nm(unsigned_value, &leb_size,
|
1253
|
+
encode_buffer,
|
1254
|
+
sizeof(encode_buffer));
|
1255
|
+
if (res != DW_DLV_OK) {
|
1256
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1257
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1258
|
+
}
|
1259
|
+
new_attr->ar_data = (char *)
|
1260
|
+
_dwarf_p_get_alloc(ownerdie->di_dbg, leb_size);
|
1261
|
+
if (new_attr->ar_data == NULL) {
|
1262
|
+
_dwarf_p_error(NULL, error, DW_DLE_ALLOC_FAIL);
|
1263
|
+
return ((Dwarf_P_Attribute) DW_DLV_BADADDR);
|
1264
|
+
}
|
1265
|
+
memcpy(new_attr->ar_data, encode_buffer, leb_size);
|
1266
|
+
new_attr->ar_nbytes = leb_size;
|
1267
|
+
|
1268
|
+
/* add attribute to the die */
|
1269
|
+
_dwarf_pro_add_at_to_die(ownerdie, new_attr);
|
1270
|
+
return new_attr;
|
1271
|
+
}
|