rdwarf 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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,59 @@
|
|
|
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
|
+
|
|
29
|
+
|
|
30
|
+
/*
|
|
31
|
+
This struct holds the abbreviation table, before they are written
|
|
32
|
+
on disk. Holds a linked list of abbreviations, each consisting of
|
|
33
|
+
a bitmap for attributes and a bitmap for forms
|
|
34
|
+
*/
|
|
35
|
+
typedef struct Dwarf_P_Abbrev_s *Dwarf_P_Abbrev;
|
|
36
|
+
|
|
37
|
+
struct Dwarf_P_Abbrev_s {
|
|
38
|
+
Dwarf_Unsigned abb_idx; /* index of abbreviation */
|
|
39
|
+
Dwarf_Tag abb_tag; /* tag of die */
|
|
40
|
+
Dwarf_Ubyte abb_children; /* if children are present */
|
|
41
|
+
Dwarf_ufixed *abb_attrs; /* holds names of attrs */
|
|
42
|
+
Dwarf_ufixed *abb_forms; /* forms of attributes */
|
|
43
|
+
int abb_n_attr; /* num of attrs = # of forms */
|
|
44
|
+
Dwarf_P_Abbrev abb_next;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/* used in pro_section.c */
|
|
48
|
+
|
|
49
|
+
int _dwarf_pro_add_AT_fde(Dwarf_P_Debug dbg, Dwarf_P_Die die,
|
|
50
|
+
Dwarf_Unsigned offset, Dwarf_Error * error);
|
|
51
|
+
|
|
52
|
+
int _dwarf_pro_add_AT_stmt_list(Dwarf_P_Debug dbg,
|
|
53
|
+
Dwarf_P_Die first_die,
|
|
54
|
+
Dwarf_Error * error);
|
|
55
|
+
|
|
56
|
+
int _dwarf_pro_add_AT_macro_info(Dwarf_P_Debug dbg,
|
|
57
|
+
Dwarf_P_Die first_die,
|
|
58
|
+
Dwarf_Unsigned offset,
|
|
59
|
+
Dwarf_Error * error);
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2000,2004 Silicon Graphics, Inc. All Rights Reserved.
|
|
4
|
+
Portions Copyright 2011 David Anderson. All Rights Reserved.
|
|
5
|
+
|
|
6
|
+
This program is free software; you can redistribute it and/or modify it
|
|
7
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
|
8
|
+
as published by the Free Software Foundation.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it would be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
|
|
14
|
+
Further, this software is distributed without any warranty that it is
|
|
15
|
+
free of the rightful claim of any third person regarding infringement
|
|
16
|
+
or the like. Any license provided herein, whether implied or
|
|
17
|
+
otherwise, applies only to this software file. Patent licenses, if
|
|
18
|
+
any, provided herein do not apply to combinations of this program with
|
|
19
|
+
other software, or any other product whatsoever.
|
|
20
|
+
|
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
|
22
|
+
License along with this program; if not, write the Free Software
|
|
23
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
|
24
|
+
USA.
|
|
25
|
+
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#include "config.h"
|
|
29
|
+
#include "libdwarfdefs.h"
|
|
30
|
+
#include <string.h>
|
|
31
|
+
#include "pro_incl.h"
|
|
32
|
+
|
|
33
|
+
#define MORE_BYTES 0x80
|
|
34
|
+
#define DATA_MASK 0x7f
|
|
35
|
+
#define DIGIT_WIDTH 7
|
|
36
|
+
#define SIGN_BIT 0x40
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/* Encode val as a leb128. This encodes it as an unsigned
|
|
40
|
+
number. */
|
|
41
|
+
/* Return DW_DLV_ERROR or DW_DLV_OK.
|
|
42
|
+
space to write leb number is provided by caller, with caller
|
|
43
|
+
passing length.
|
|
44
|
+
number of bytes used returned thru nbytes arg */
|
|
45
|
+
int
|
|
46
|
+
_dwarf_pro_encode_leb128_nm(Dwarf_Unsigned val, int *nbytes,
|
|
47
|
+
char *space, int splen)
|
|
48
|
+
{
|
|
49
|
+
char *a;
|
|
50
|
+
char *end = space + splen;
|
|
51
|
+
|
|
52
|
+
a = space;
|
|
53
|
+
do {
|
|
54
|
+
unsigned char uc;
|
|
55
|
+
|
|
56
|
+
if (a >= end) {
|
|
57
|
+
return DW_DLV_ERROR;
|
|
58
|
+
}
|
|
59
|
+
uc = val & DATA_MASK;
|
|
60
|
+
val >>= DIGIT_WIDTH;
|
|
61
|
+
if (val != 0) {
|
|
62
|
+
uc |= MORE_BYTES;
|
|
63
|
+
}
|
|
64
|
+
*a = uc;
|
|
65
|
+
a++;
|
|
66
|
+
} while (val);
|
|
67
|
+
*nbytes = a - space;
|
|
68
|
+
return DW_DLV_OK;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* return DW_DLV_ERROR or DW_DLV_OK.
|
|
72
|
+
** space to write leb number is provided by caller, with caller
|
|
73
|
+
** passing length.
|
|
74
|
+
** number of bytes used returned thru nbytes arg
|
|
75
|
+
** encodes a signed number.
|
|
76
|
+
*/
|
|
77
|
+
int
|
|
78
|
+
_dwarf_pro_encode_signed_leb128_nm(Dwarf_Signed value, int *nbytes,
|
|
79
|
+
char *space, int splen)
|
|
80
|
+
{
|
|
81
|
+
char *str;
|
|
82
|
+
Dwarf_Signed sign = -(value < 0);
|
|
83
|
+
int more = 1;
|
|
84
|
+
char *end = space + splen;
|
|
85
|
+
|
|
86
|
+
str = space;
|
|
87
|
+
|
|
88
|
+
do {
|
|
89
|
+
unsigned char byte = value & DATA_MASK;
|
|
90
|
+
|
|
91
|
+
value >>= DIGIT_WIDTH;
|
|
92
|
+
|
|
93
|
+
if (str >= end) {
|
|
94
|
+
return DW_DLV_ERROR;
|
|
95
|
+
}
|
|
96
|
+
/* Remaining chunks would just contain the sign bit, and this chunk
|
|
97
|
+
has already captured at least one sign bit. */
|
|
98
|
+
if (value == sign && ((byte & SIGN_BIT) == (sign & SIGN_BIT))) {
|
|
99
|
+
more = 0;
|
|
100
|
+
} else {
|
|
101
|
+
byte |= MORE_BYTES;
|
|
102
|
+
}
|
|
103
|
+
*str = byte;
|
|
104
|
+
str++;
|
|
105
|
+
} while (more);
|
|
106
|
+
*nbytes = str - space;
|
|
107
|
+
return DW_DLV_OK;
|
|
108
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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
|
+
|
|
29
|
+
/* Bytes needed to encode a number.
|
|
30
|
+
Not a tight bound, just a reasonable bound.
|
|
31
|
+
*/
|
|
32
|
+
#define ENCODE_SPACE_NEEDED (2*sizeof(Dwarf_Unsigned))
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
int _dwarf_pro_encode_leb128_nm(Dwarf_Unsigned val, int *nbytes,
|
|
36
|
+
char *space, int splen);
|
|
37
|
+
|
|
38
|
+
int _dwarf_pro_encode_signed_leb128_nm(Dwarf_Signed value, int *nbytes,
|
|
39
|
+
char *space, int splen);
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/*
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2000,2002,2004 Silicon Graphics, Inc. All Rights Reserved.
|
|
4
|
+
Portions Copyright 2011 David Anderson. All Rights Reserved.
|
|
5
|
+
|
|
6
|
+
This program is free software; you can redistribute it and/or modify it
|
|
7
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
|
8
|
+
as published by the Free Software Foundation.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it would be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
|
|
14
|
+
Further, this software is distributed without any warranty that it is
|
|
15
|
+
free of the rightful claim of any third person regarding infringement
|
|
16
|
+
or the like. Any license provided herein, whether implied or
|
|
17
|
+
otherwise, applies only to this software file. Patent licenses, if
|
|
18
|
+
any, provided herein do not apply to combinations of this program with
|
|
19
|
+
other software, or any other product whatsoever.
|
|
20
|
+
|
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
|
22
|
+
License along with this program; if not, write the Free Software
|
|
23
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
|
24
|
+
USA.
|
|
25
|
+
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#include "config.h"
|
|
29
|
+
#include "libdwarfdefs.h"
|
|
30
|
+
#ifdef HAVE_ELF_H
|
|
31
|
+
#include <elf.h>
|
|
32
|
+
#endif
|
|
33
|
+
|
|
34
|
+
#include <stdio.h>
|
|
35
|
+
#include <sys/stat.h>
|
|
36
|
+
#include <sys/types.h>
|
|
37
|
+
#include <stdlib.h>
|
|
38
|
+
#include "pro_incl.h"
|
|
39
|
+
|
|
40
|
+
extern char *_dwarf_errmsgs[];
|
|
41
|
+
|
|
42
|
+
/*
|
|
43
|
+
This function performs error handling as described in the
|
|
44
|
+
libdwarf consumer document section 3. Dbg is the Dwarf_P_debug
|
|
45
|
+
structure being processed. Error is a pointer to the pointer
|
|
46
|
+
to the error descriptor that will be returned. Errval is an
|
|
47
|
+
error code listed in dwarf_error.h.
|
|
48
|
+
|
|
49
|
+
The error number may be retrieved from the Dwarf_Error
|
|
50
|
+
by calling dwarf_errno().
|
|
51
|
+
The error string implied by the error number may be retrieved
|
|
52
|
+
from the Dwarf_Error by calling dwarf_errmsg().
|
|
53
|
+
*/
|
|
54
|
+
void
|
|
55
|
+
_dwarf_p_error(Dwarf_P_Debug dbg,
|
|
56
|
+
Dwarf_Error * error, Dwarf_Word errval)
|
|
57
|
+
{
|
|
58
|
+
Dwarf_Error errptr;
|
|
59
|
+
|
|
60
|
+
if (errval > DW_DLE_LAST) {
|
|
61
|
+
/* We do not expect to ever see such an error number,
|
|
62
|
+
DW_DLE_LO_USER is not used. */
|
|
63
|
+
/* The 'standard' typedef for Dwarf_Word is "unsigned long". */
|
|
64
|
+
fprintf(stderr,"ERROR VALUE: %lu - %s\n",
|
|
65
|
+
(unsigned long) errval, "this error value is unknown to libdwarf.");
|
|
66
|
+
}
|
|
67
|
+
/* Allow NULL dbg on entry, since sometimes that can happen and we
|
|
68
|
+
want to report the upper-level error, not this one. */
|
|
69
|
+
if (error != NULL) {
|
|
70
|
+
errptr = (Dwarf_Error)
|
|
71
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_Error_s));
|
|
72
|
+
if (errptr == NULL) {
|
|
73
|
+
fprintf(stderr,
|
|
74
|
+
"Could not allocate Dwarf_Error structure\n");
|
|
75
|
+
abort();
|
|
76
|
+
}
|
|
77
|
+
errptr->er_errval = (Dwarf_Sword) errval;
|
|
78
|
+
*error = errptr;
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (dbg != NULL && dbg->de_errhand != NULL) {
|
|
83
|
+
errptr = (Dwarf_Error)
|
|
84
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_Error_s));
|
|
85
|
+
if (errptr == NULL) {
|
|
86
|
+
fprintf(stderr,
|
|
87
|
+
"Could not allocate Dwarf_Error structure\n");
|
|
88
|
+
abort();
|
|
89
|
+
}
|
|
90
|
+
errptr->er_errval = (Dwarf_Sword) errval;
|
|
91
|
+
dbg->de_errhand(errptr, dbg->de_errarg);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
abort();
|
|
96
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
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
|
+
|
|
29
|
+
|
|
30
|
+
/* Handle error passing in the name of the Dwarf_P_Debug
|
|
31
|
+
User must supply {} around the macro.
|
|
32
|
+
Putting the {} here leads to macro uses that don't look like C.
|
|
33
|
+
The error argument to dwarf_error is hard coded here as 'error'
|
|
34
|
+
*/
|
|
35
|
+
#define DWARF_P_DBG_ERROR(dbg,errval,retval) \
|
|
36
|
+
_dwarf_p_error(dbg,error,errval); return(retval);
|
|
37
|
+
|
|
38
|
+
struct Dwarf_Error_s {
|
|
39
|
+
Dwarf_Sword er_errval;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
void _dwarf_p_error(Dwarf_P_Debug dbg, Dwarf_Error * error,
|
|
43
|
+
Dwarf_Word errval);
|
|
@@ -0,0 +1,575 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright (C) 2000,2004,2006 Silicon Graphics, Inc. All Rights Reserved.
|
|
3
|
+
Portions Copyright 2007-2010 Sun Microsystems, Inc. All rights reserved.
|
|
4
|
+
Portions Copyright 2011 David Anderson. All rights reserved.
|
|
5
|
+
|
|
6
|
+
This program is free software; you can redistribute it and/or modify it
|
|
7
|
+
under the terms of version 2.1 of the GNU Lesser General Public License
|
|
8
|
+
as published by the Free Software Foundation.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it would be useful, but
|
|
11
|
+
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
13
|
+
|
|
14
|
+
Further, this software is distributed without any warranty that it is
|
|
15
|
+
free of the rightful claim of any third person regarding infringement
|
|
16
|
+
or the like. Any license provided herein, whether implied or
|
|
17
|
+
otherwise, applies only to this software file. Patent licenses, if
|
|
18
|
+
any, provided herein do not apply to combinations of this program with
|
|
19
|
+
other software, or any other product whatsoever.
|
|
20
|
+
|
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
|
22
|
+
License along with this program; if not, write the Free Software
|
|
23
|
+
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston MA 02110-1301,
|
|
24
|
+
USA.
|
|
25
|
+
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
#include "config.h"
|
|
29
|
+
#include "libdwarfdefs.h"
|
|
30
|
+
#include <stdio.h>
|
|
31
|
+
#include <string.h>
|
|
32
|
+
#include "pro_incl.h"
|
|
33
|
+
#include "pro_expr.h"
|
|
34
|
+
|
|
35
|
+
/*
|
|
36
|
+
This function creates a new expression
|
|
37
|
+
struct that can be used to build up a
|
|
38
|
+
location expression.
|
|
39
|
+
*/
|
|
40
|
+
Dwarf_P_Expr
|
|
41
|
+
dwarf_new_expr(Dwarf_P_Debug dbg, Dwarf_Error * error)
|
|
42
|
+
{
|
|
43
|
+
Dwarf_P_Expr ret_expr;
|
|
44
|
+
|
|
45
|
+
if (dbg == NULL) {
|
|
46
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
|
47
|
+
return (NULL);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
ret_expr = (Dwarf_P_Expr)
|
|
51
|
+
_dwarf_p_get_alloc(dbg, sizeof(struct Dwarf_P_Expr_s));
|
|
52
|
+
if (ret_expr == NULL) {
|
|
53
|
+
_dwarf_p_error(dbg, error, DW_DLE_ALLOC_FAIL);
|
|
54
|
+
return (NULL);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
ret_expr->ex_dbg = dbg;
|
|
58
|
+
|
|
59
|
+
return (ret_expr);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
Dwarf_Unsigned
|
|
64
|
+
dwarf_add_expr_gen(Dwarf_P_Expr expr,
|
|
65
|
+
Dwarf_Small opcode,
|
|
66
|
+
Dwarf_Unsigned val1,
|
|
67
|
+
Dwarf_Unsigned val2, Dwarf_Error * error)
|
|
68
|
+
{
|
|
69
|
+
/* 2* since used to concatenate 2 leb's below */
|
|
70
|
+
char encode_buffer[2 * ENCODE_SPACE_NEEDED];
|
|
71
|
+
|
|
72
|
+
char encode_buffer2[ENCODE_SPACE_NEEDED];
|
|
73
|
+
int res = 0;
|
|
74
|
+
Dwarf_P_Debug dbg = 0;
|
|
75
|
+
|
|
76
|
+
/* Give the buffer where the operands are first going to be
|
|
77
|
+
assembled the largest alignment. */
|
|
78
|
+
Dwarf_Unsigned operand_buffer[10];
|
|
79
|
+
|
|
80
|
+
/* Size of the byte stream buffer that needs to be memcpy-ed. */
|
|
81
|
+
int operand_size = 0;
|
|
82
|
+
|
|
83
|
+
/* Points to the byte stream for the first operand, and finally to
|
|
84
|
+
the buffer that is memcp-ed into the Dwarf_P_Expr_s struct. */
|
|
85
|
+
Dwarf_Small *operand = 0;
|
|
86
|
+
|
|
87
|
+
/* Size of the byte stream for second operand. */
|
|
88
|
+
int operand2_size = 0;
|
|
89
|
+
|
|
90
|
+
/* Points to next byte to be written in Dwarf_P_Expr_s struct. */
|
|
91
|
+
Dwarf_Small *next_byte_ptr = 0;
|
|
92
|
+
|
|
93
|
+
/* Offset past the last byte written into Dwarf_P_Expr_s. */
|
|
94
|
+
int next_byte_offset = 0;
|
|
95
|
+
|
|
96
|
+
/* ***** BEGIN CODE ***** */
|
|
97
|
+
|
|
98
|
+
if (expr == NULL) {
|
|
99
|
+
_dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL);
|
|
100
|
+
return (DW_DLV_NOCOUNT);
|
|
101
|
+
}
|
|
102
|
+
dbg = expr->ex_dbg;
|
|
103
|
+
|
|
104
|
+
if (expr->ex_dbg == NULL) {
|
|
105
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
|
106
|
+
return (DW_DLV_NOCOUNT);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
operand = NULL;
|
|
110
|
+
operand_size = 0;
|
|
111
|
+
|
|
112
|
+
switch (opcode) {
|
|
113
|
+
case DW_OP_reg0:
|
|
114
|
+
case DW_OP_reg1:
|
|
115
|
+
case DW_OP_reg2:
|
|
116
|
+
case DW_OP_reg3:
|
|
117
|
+
case DW_OP_reg4:
|
|
118
|
+
case DW_OP_reg5:
|
|
119
|
+
case DW_OP_reg6:
|
|
120
|
+
case DW_OP_reg7:
|
|
121
|
+
case DW_OP_reg8:
|
|
122
|
+
case DW_OP_reg9:
|
|
123
|
+
case DW_OP_reg10:
|
|
124
|
+
case DW_OP_reg11:
|
|
125
|
+
case DW_OP_reg12:
|
|
126
|
+
case DW_OP_reg13:
|
|
127
|
+
case DW_OP_reg14:
|
|
128
|
+
case DW_OP_reg15:
|
|
129
|
+
case DW_OP_reg16:
|
|
130
|
+
case DW_OP_reg17:
|
|
131
|
+
case DW_OP_reg18:
|
|
132
|
+
case DW_OP_reg19:
|
|
133
|
+
case DW_OP_reg20:
|
|
134
|
+
case DW_OP_reg21:
|
|
135
|
+
case DW_OP_reg22:
|
|
136
|
+
case DW_OP_reg23:
|
|
137
|
+
case DW_OP_reg24:
|
|
138
|
+
case DW_OP_reg25:
|
|
139
|
+
case DW_OP_reg26:
|
|
140
|
+
case DW_OP_reg27:
|
|
141
|
+
case DW_OP_reg28:
|
|
142
|
+
case DW_OP_reg29:
|
|
143
|
+
case DW_OP_reg30:
|
|
144
|
+
case DW_OP_reg31:
|
|
145
|
+
break;
|
|
146
|
+
|
|
147
|
+
case DW_OP_breg0:
|
|
148
|
+
case DW_OP_breg1:
|
|
149
|
+
case DW_OP_breg2:
|
|
150
|
+
case DW_OP_breg3:
|
|
151
|
+
case DW_OP_breg4:
|
|
152
|
+
case DW_OP_breg5:
|
|
153
|
+
case DW_OP_breg6:
|
|
154
|
+
case DW_OP_breg7:
|
|
155
|
+
case DW_OP_breg8:
|
|
156
|
+
case DW_OP_breg9:
|
|
157
|
+
case DW_OP_breg10:
|
|
158
|
+
case DW_OP_breg11:
|
|
159
|
+
case DW_OP_breg12:
|
|
160
|
+
case DW_OP_breg13:
|
|
161
|
+
case DW_OP_breg14:
|
|
162
|
+
case DW_OP_breg15:
|
|
163
|
+
case DW_OP_breg16:
|
|
164
|
+
case DW_OP_breg17:
|
|
165
|
+
case DW_OP_breg18:
|
|
166
|
+
case DW_OP_breg19:
|
|
167
|
+
case DW_OP_breg20:
|
|
168
|
+
case DW_OP_breg21:
|
|
169
|
+
case DW_OP_breg22:
|
|
170
|
+
case DW_OP_breg23:
|
|
171
|
+
case DW_OP_breg24:
|
|
172
|
+
case DW_OP_breg25:
|
|
173
|
+
case DW_OP_breg26:
|
|
174
|
+
case DW_OP_breg27:
|
|
175
|
+
case DW_OP_breg28:
|
|
176
|
+
case DW_OP_breg29:
|
|
177
|
+
case DW_OP_breg30:
|
|
178
|
+
case DW_OP_breg31:
|
|
179
|
+
res = _dwarf_pro_encode_signed_leb128_nm(val1,
|
|
180
|
+
&operand_size, encode_buffer, sizeof(encode_buffer));
|
|
181
|
+
if (res != DW_DLV_OK) {
|
|
182
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
183
|
+
return (DW_DLV_NOCOUNT);
|
|
184
|
+
}
|
|
185
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
186
|
+
break;
|
|
187
|
+
|
|
188
|
+
case DW_OP_regx:
|
|
189
|
+
res = _dwarf_pro_encode_leb128_nm(val1, &operand_size,
|
|
190
|
+
encode_buffer, sizeof(encode_buffer));
|
|
191
|
+
if (res != DW_DLV_OK) {
|
|
192
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
193
|
+
return (DW_DLV_NOCOUNT);
|
|
194
|
+
}
|
|
195
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
196
|
+
break;
|
|
197
|
+
|
|
198
|
+
case DW_OP_lit0:
|
|
199
|
+
case DW_OP_lit1:
|
|
200
|
+
case DW_OP_lit2:
|
|
201
|
+
case DW_OP_lit3:
|
|
202
|
+
case DW_OP_lit4:
|
|
203
|
+
case DW_OP_lit5:
|
|
204
|
+
case DW_OP_lit6:
|
|
205
|
+
case DW_OP_lit7:
|
|
206
|
+
case DW_OP_lit8:
|
|
207
|
+
case DW_OP_lit9:
|
|
208
|
+
case DW_OP_lit10:
|
|
209
|
+
case DW_OP_lit11:
|
|
210
|
+
case DW_OP_lit12:
|
|
211
|
+
case DW_OP_lit13:
|
|
212
|
+
case DW_OP_lit14:
|
|
213
|
+
case DW_OP_lit15:
|
|
214
|
+
case DW_OP_lit16:
|
|
215
|
+
case DW_OP_lit17:
|
|
216
|
+
case DW_OP_lit18:
|
|
217
|
+
case DW_OP_lit19:
|
|
218
|
+
case DW_OP_lit20:
|
|
219
|
+
case DW_OP_lit21:
|
|
220
|
+
case DW_OP_lit22:
|
|
221
|
+
case DW_OP_lit23:
|
|
222
|
+
case DW_OP_lit24:
|
|
223
|
+
case DW_OP_lit25:
|
|
224
|
+
case DW_OP_lit26:
|
|
225
|
+
case DW_OP_lit27:
|
|
226
|
+
case DW_OP_lit28:
|
|
227
|
+
case DW_OP_lit29:
|
|
228
|
+
case DW_OP_lit30:
|
|
229
|
+
case DW_OP_lit31:
|
|
230
|
+
break;
|
|
231
|
+
|
|
232
|
+
case DW_OP_addr:
|
|
233
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_BAD_EXPR_OPCODE);
|
|
234
|
+
return (DW_DLV_NOCOUNT);
|
|
235
|
+
|
|
236
|
+
case DW_OP_const1u:
|
|
237
|
+
case DW_OP_const1s:
|
|
238
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
239
|
+
WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 1);
|
|
240
|
+
operand_size = 1;
|
|
241
|
+
break;
|
|
242
|
+
|
|
243
|
+
case DW_OP_const2u:
|
|
244
|
+
case DW_OP_const2s:
|
|
245
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
246
|
+
WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 2);
|
|
247
|
+
operand_size = 2;
|
|
248
|
+
break;
|
|
249
|
+
|
|
250
|
+
case DW_OP_const4u:
|
|
251
|
+
case DW_OP_const4s:
|
|
252
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
253
|
+
WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 4);
|
|
254
|
+
operand_size = 4;
|
|
255
|
+
break;
|
|
256
|
+
|
|
257
|
+
case DW_OP_const8u:
|
|
258
|
+
case DW_OP_const8s:
|
|
259
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
260
|
+
WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 8);
|
|
261
|
+
operand_size = 8;
|
|
262
|
+
break;
|
|
263
|
+
|
|
264
|
+
case DW_OP_constu:
|
|
265
|
+
res = _dwarf_pro_encode_leb128_nm(val1,
|
|
266
|
+
&operand_size, encode_buffer, sizeof(encode_buffer));
|
|
267
|
+
if (res != DW_DLV_OK) {
|
|
268
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
269
|
+
return (DW_DLV_NOCOUNT);
|
|
270
|
+
}
|
|
271
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
272
|
+
break;
|
|
273
|
+
|
|
274
|
+
case DW_OP_consts:
|
|
275
|
+
res = _dwarf_pro_encode_signed_leb128_nm(val1,
|
|
276
|
+
&operand_size,
|
|
277
|
+
encode_buffer,
|
|
278
|
+
sizeof(encode_buffer));
|
|
279
|
+
if (res != DW_DLV_OK) {
|
|
280
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
281
|
+
return (DW_DLV_NOCOUNT);
|
|
282
|
+
}
|
|
283
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
284
|
+
break;
|
|
285
|
+
|
|
286
|
+
case DW_OP_fbreg:
|
|
287
|
+
res = _dwarf_pro_encode_signed_leb128_nm(val1,
|
|
288
|
+
&operand_size,
|
|
289
|
+
encode_buffer,
|
|
290
|
+
sizeof(encode_buffer));
|
|
291
|
+
if (res != DW_DLV_OK) {
|
|
292
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
293
|
+
return (DW_DLV_NOCOUNT);
|
|
294
|
+
}
|
|
295
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
296
|
+
break;
|
|
297
|
+
|
|
298
|
+
case DW_OP_bregx:
|
|
299
|
+
res = _dwarf_pro_encode_leb128_nm(val1, &operand_size,
|
|
300
|
+
encode_buffer,
|
|
301
|
+
sizeof(encode_buffer));
|
|
302
|
+
if (res != DW_DLV_OK) {
|
|
303
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
304
|
+
return (DW_DLV_NOCOUNT);
|
|
305
|
+
}
|
|
306
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
307
|
+
/* put this one directly into 'operand' at tail of prev value */
|
|
308
|
+
res = _dwarf_pro_encode_signed_leb128_nm(val2, &operand2_size,
|
|
309
|
+
((char *) operand) +
|
|
310
|
+
operand_size,
|
|
311
|
+
sizeof(encode_buffer2));
|
|
312
|
+
if (res != DW_DLV_OK) {
|
|
313
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
314
|
+
return (DW_DLV_NOCOUNT);
|
|
315
|
+
}
|
|
316
|
+
operand_size += operand2_size;
|
|
317
|
+
|
|
318
|
+
case DW_OP_dup:
|
|
319
|
+
case DW_OP_drop:
|
|
320
|
+
break;
|
|
321
|
+
|
|
322
|
+
case DW_OP_pick:
|
|
323
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
324
|
+
WRITE_UNALIGNED(dbg, operand, (const void *) &val1,
|
|
325
|
+
sizeof(val1), 1);
|
|
326
|
+
operand_size = 1;
|
|
327
|
+
break;
|
|
328
|
+
|
|
329
|
+
case DW_OP_over:
|
|
330
|
+
case DW_OP_swap:
|
|
331
|
+
case DW_OP_rot:
|
|
332
|
+
case DW_OP_deref:
|
|
333
|
+
case DW_OP_xderef:
|
|
334
|
+
break;
|
|
335
|
+
|
|
336
|
+
case DW_OP_deref_size:
|
|
337
|
+
case DW_OP_xderef_size:
|
|
338
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
339
|
+
WRITE_UNALIGNED(dbg, operand, (const void *) &val1,
|
|
340
|
+
sizeof(val1), 1);
|
|
341
|
+
operand_size = 1;
|
|
342
|
+
break;
|
|
343
|
+
|
|
344
|
+
case DW_OP_abs:
|
|
345
|
+
case DW_OP_and:
|
|
346
|
+
case DW_OP_div:
|
|
347
|
+
case DW_OP_minus:
|
|
348
|
+
case DW_OP_mod:
|
|
349
|
+
case DW_OP_mul:
|
|
350
|
+
case DW_OP_neg:
|
|
351
|
+
case DW_OP_not:
|
|
352
|
+
case DW_OP_or:
|
|
353
|
+
case DW_OP_plus:
|
|
354
|
+
break;
|
|
355
|
+
|
|
356
|
+
case DW_OP_plus_uconst:
|
|
357
|
+
res = _dwarf_pro_encode_leb128_nm(val1, &operand_size,
|
|
358
|
+
encode_buffer,
|
|
359
|
+
sizeof(encode_buffer));
|
|
360
|
+
if (res != DW_DLV_OK) {
|
|
361
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
362
|
+
return (DW_DLV_NOCOUNT);
|
|
363
|
+
}
|
|
364
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
365
|
+
break;
|
|
366
|
+
|
|
367
|
+
case DW_OP_shl:
|
|
368
|
+
case DW_OP_shr:
|
|
369
|
+
case DW_OP_shra:
|
|
370
|
+
case DW_OP_xor:
|
|
371
|
+
break;
|
|
372
|
+
|
|
373
|
+
case DW_OP_le:
|
|
374
|
+
case DW_OP_ge:
|
|
375
|
+
case DW_OP_eq:
|
|
376
|
+
case DW_OP_lt:
|
|
377
|
+
case DW_OP_gt:
|
|
378
|
+
case DW_OP_ne:
|
|
379
|
+
break;
|
|
380
|
+
|
|
381
|
+
case DW_OP_skip:
|
|
382
|
+
case DW_OP_bra:
|
|
383
|
+
/* FIX: unhandled! OP_bra, OP_skip! */
|
|
384
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_BAD_EXPR_OPCODE);
|
|
385
|
+
return (DW_DLV_NOCOUNT);
|
|
386
|
+
|
|
387
|
+
case DW_OP_piece:
|
|
388
|
+
res = _dwarf_pro_encode_leb128_nm(val1, &operand_size,
|
|
389
|
+
encode_buffer,
|
|
390
|
+
sizeof(encode_buffer));
|
|
391
|
+
if (res != DW_DLV_OK) {
|
|
392
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
393
|
+
return (DW_DLV_NOCOUNT);
|
|
394
|
+
}
|
|
395
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
396
|
+
break;
|
|
397
|
+
|
|
398
|
+
case DW_OP_nop:
|
|
399
|
+
break;
|
|
400
|
+
case DW_OP_push_object_address: /* DWARF3 */
|
|
401
|
+
break;
|
|
402
|
+
case DW_OP_call2: /* DWARF3 */
|
|
403
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
404
|
+
WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 2);
|
|
405
|
+
operand_size = 2;
|
|
406
|
+
break;
|
|
407
|
+
|
|
408
|
+
case DW_OP_call4: /* DWARF3 */
|
|
409
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
410
|
+
WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1), 4);
|
|
411
|
+
operand_size = 4;
|
|
412
|
+
break;
|
|
413
|
+
|
|
414
|
+
case DW_OP_call_ref: /* DWARF3 */
|
|
415
|
+
operand = (Dwarf_Small *) & operand_buffer[0];
|
|
416
|
+
WRITE_UNALIGNED(dbg, operand, &val1, sizeof(val1),
|
|
417
|
+
dbg->de_offset_size);
|
|
418
|
+
operand_size = dbg->de_offset_size;
|
|
419
|
+
break;
|
|
420
|
+
case DW_OP_form_tls_address: /* DWARF3f */
|
|
421
|
+
break;
|
|
422
|
+
case DW_OP_call_frame_cfa: /* DWARF3f */
|
|
423
|
+
break;
|
|
424
|
+
case DW_OP_bit_piece: /* DWARF3f */
|
|
425
|
+
res = _dwarf_pro_encode_leb128_nm(val1, &operand_size,
|
|
426
|
+
encode_buffer,
|
|
427
|
+
sizeof(encode_buffer));
|
|
428
|
+
if (res != DW_DLV_OK) {
|
|
429
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
430
|
+
return (DW_DLV_NOCOUNT);
|
|
431
|
+
}
|
|
432
|
+
operand = (Dwarf_Small *) encode_buffer;
|
|
433
|
+
/* put this one directly into 'operand' at tail of prev value */
|
|
434
|
+
res = _dwarf_pro_encode_leb128_nm(val2, &operand2_size,
|
|
435
|
+
((char *) operand) +
|
|
436
|
+
operand_size,
|
|
437
|
+
sizeof(encode_buffer2));
|
|
438
|
+
if (res != DW_DLV_OK) {
|
|
439
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
440
|
+
return (DW_DLV_NOCOUNT);
|
|
441
|
+
}
|
|
442
|
+
operand_size += operand2_size;
|
|
443
|
+
|
|
444
|
+
|
|
445
|
+
default:
|
|
446
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_BAD_EXPR_OPCODE);
|
|
447
|
+
return (DW_DLV_NOCOUNT);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
next_byte_offset = expr->ex_next_byte_offset + operand_size + 1;
|
|
451
|
+
|
|
452
|
+
if (next_byte_offset > MAXIMUM_LOC_EXPR_LENGTH) {
|
|
453
|
+
_dwarf_p_error(expr->ex_dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
454
|
+
return (DW_DLV_NOCOUNT);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
next_byte_ptr =
|
|
458
|
+
&(expr->ex_byte_stream[0]) + expr->ex_next_byte_offset;
|
|
459
|
+
|
|
460
|
+
*next_byte_ptr = opcode;
|
|
461
|
+
next_byte_ptr++;
|
|
462
|
+
memcpy(next_byte_ptr, operand, operand_size);
|
|
463
|
+
|
|
464
|
+
expr->ex_next_byte_offset = next_byte_offset;
|
|
465
|
+
return (next_byte_offset);
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
Dwarf_Unsigned
|
|
469
|
+
dwarf_add_expr_addr_b(Dwarf_P_Expr expr,
|
|
470
|
+
Dwarf_Unsigned addr,
|
|
471
|
+
Dwarf_Unsigned sym_index, Dwarf_Error * error)
|
|
472
|
+
{
|
|
473
|
+
Dwarf_P_Debug dbg;
|
|
474
|
+
Dwarf_Small *next_byte_ptr;
|
|
475
|
+
Dwarf_Unsigned next_byte_offset;
|
|
476
|
+
int upointer_size;
|
|
477
|
+
|
|
478
|
+
if (expr == NULL) {
|
|
479
|
+
_dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL);
|
|
480
|
+
return (DW_DLV_NOCOUNT);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
dbg = expr->ex_dbg;
|
|
484
|
+
if (dbg == NULL) {
|
|
485
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
|
486
|
+
return (DW_DLV_NOCOUNT);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
upointer_size = dbg->de_pointer_size;
|
|
490
|
+
next_byte_offset = expr->ex_next_byte_offset + upointer_size + 1;
|
|
491
|
+
if (next_byte_offset > MAXIMUM_LOC_EXPR_LENGTH) {
|
|
492
|
+
_dwarf_p_error(dbg, error, DW_DLE_EXPR_LENGTH_BAD);
|
|
493
|
+
return (DW_DLV_NOCOUNT);
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
next_byte_ptr =
|
|
497
|
+
&(expr->ex_byte_stream[0]) + expr->ex_next_byte_offset;
|
|
498
|
+
|
|
499
|
+
*next_byte_ptr = DW_OP_addr;
|
|
500
|
+
next_byte_ptr++;
|
|
501
|
+
WRITE_UNALIGNED(dbg, next_byte_ptr, (const void *) &addr,
|
|
502
|
+
sizeof(addr), upointer_size);
|
|
503
|
+
|
|
504
|
+
if (expr->ex_reloc_offset != 0) {
|
|
505
|
+
_dwarf_p_error(dbg, error, DW_DLE_MULTIPLE_RELOC_IN_EXPR);
|
|
506
|
+
return (DW_DLV_NOCOUNT);
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
expr->ex_reloc_sym_index = sym_index;
|
|
510
|
+
expr->ex_reloc_offset = expr->ex_next_byte_offset + 1;
|
|
511
|
+
|
|
512
|
+
expr->ex_next_byte_offset = next_byte_offset;
|
|
513
|
+
return (next_byte_offset);
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
Dwarf_Unsigned
|
|
517
|
+
dwarf_add_expr_addr(Dwarf_P_Expr expr,
|
|
518
|
+
Dwarf_Unsigned addr,
|
|
519
|
+
Dwarf_Signed sym_index, Dwarf_Error * error)
|
|
520
|
+
{
|
|
521
|
+
return
|
|
522
|
+
dwarf_add_expr_addr_b(expr, addr, (Dwarf_Unsigned) sym_index,
|
|
523
|
+
error);
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
|
|
527
|
+
Dwarf_Unsigned
|
|
528
|
+
dwarf_expr_current_offset(Dwarf_P_Expr expr, Dwarf_Error * error)
|
|
529
|
+
{
|
|
530
|
+
if (expr == NULL) {
|
|
531
|
+
_dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL);
|
|
532
|
+
return (DW_DLV_NOCOUNT);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
if (expr->ex_dbg == NULL) {
|
|
536
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
|
537
|
+
return (DW_DLV_NOCOUNT);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
return (expr->ex_next_byte_offset);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
void
|
|
544
|
+
dwarf_expr_reset(Dwarf_P_Expr expr, Dwarf_Error * error)
|
|
545
|
+
{
|
|
546
|
+
if (expr == NULL) {
|
|
547
|
+
_dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL);
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
expr->ex_next_byte_offset=0;
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
|
|
554
|
+
Dwarf_Addr
|
|
555
|
+
dwarf_expr_into_block(Dwarf_P_Expr expr,
|
|
556
|
+
Dwarf_Unsigned * length, Dwarf_Error * error)
|
|
557
|
+
{
|
|
558
|
+
if (expr == NULL) {
|
|
559
|
+
_dwarf_p_error(NULL, error, DW_DLE_EXPR_NULL);
|
|
560
|
+
return (DW_DLV_BADADDR);
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
if (expr->ex_dbg == NULL) {
|
|
564
|
+
_dwarf_p_error(NULL, error, DW_DLE_DBG_NULL);
|
|
565
|
+
return (DW_DLV_BADADDR);
|
|
566
|
+
}
|
|
567
|
+
|
|
568
|
+
if (length != NULL)
|
|
569
|
+
*length = expr->ex_next_byte_offset;
|
|
570
|
+
/* The following cast from pointer to integer is ok as long as
|
|
571
|
+
Dwarf_Addr is at least as large as a pointer. Which is a
|
|
572
|
+
requirement of libdwarf so must be satisfied (some compilers
|
|
573
|
+
emit a warning about the following line). */
|
|
574
|
+
return ((Dwarf_Addr) & (expr->ex_byte_stream[0]));
|
|
575
|
+
}
|