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,127 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (C) 2007-2012 David Anderson. All Rights Reserved.
|
3
|
+
Portions Copyright (C) 2012 SN Systems Ltd. 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
|
+
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 License along
|
21
|
+
with this program; if not, write the Free Software Foundation, Inc., 51
|
22
|
+
Franklin Street - Fifth Floor, Boston MA 02110-1301, USA.
|
23
|
+
*/
|
24
|
+
/* The address of the Free Software Foundation is
|
25
|
+
Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
|
26
|
+
Boston, MA 02110-1301, USA.
|
27
|
+
*/
|
28
|
+
|
29
|
+
#ifndef DWARF_RELOC_X86_64_H
|
30
|
+
#define DWARF_RELOC_X86_64_H
|
31
|
+
|
32
|
+
/* Definitions for X86_64 */
|
33
|
+
#define DWARF_RELOC_X86_64
|
34
|
+
|
35
|
+
/* Include the definitions only in the case of Windows */
|
36
|
+
#ifdef WIN32
|
37
|
+
/* Relocation types for AMD x86-64 architecture */
|
38
|
+
#define R_X86_64_NONE 0 /* No reloc */
|
39
|
+
#define R_X86_64_64 1 /* Direct 64 bit */
|
40
|
+
#define R_X86_64_PC32 2 /* PC relative 32 bit signed */
|
41
|
+
#define R_X86_64_GOT32 3 /* 32 bit GOT entry */
|
42
|
+
#define R_X86_64_PLT32 4 /* 32 bit PLT address */
|
43
|
+
#define R_X86_64_COPY 5 /* Copy symbol at runtime */
|
44
|
+
#define R_X86_64_GLOB_DAT 6 /* Create GOT entry */
|
45
|
+
#define R_X86_64_JUMP_SLOT 7 /* Create PLT entry */
|
46
|
+
#define R_X86_64_RELATIVE 8 /* Adjust by program base */
|
47
|
+
#define R_X86_64_GOTPCREL 9 /* 32 bit signed pc relative offset to GOT */
|
48
|
+
#define R_X86_64_32 10 /* Direct 32 bit zero extended */
|
49
|
+
#define R_X86_64_32S 11 /* Direct 32 bit sign extended */
|
50
|
+
#define R_X86_64_16 12 /* Direct 16 bit zero extended */
|
51
|
+
#define R_X86_64_PC16 13 /* 16 bit sign extended pc relative */
|
52
|
+
#define R_X86_64_8 14 /* Direct 8 bit sign extended */
|
53
|
+
#define R_X86_64_PC8 15 /* 8 bit sign extended pc relative */
|
54
|
+
#define R_X86_64_DTPMOD64 16 /* ID of module containing symbol */
|
55
|
+
#define R_X86_64_DTPOFF64 17 /* Offset in module's TLS block */
|
56
|
+
#define R_X86_64_TPOFF64 18 /* Offset in initial TLS block */
|
57
|
+
#define R_X86_64_TLSGD 19 /* 32 bit signed PC relative offset
|
58
|
+
to two GOT entries for GD symbol */
|
59
|
+
#define R_X86_64_TLSLD 20 /* 32 bit signed PC relative offset
|
60
|
+
to two GOT entries for LD symbol */
|
61
|
+
#define R_X86_64_DTPOFF32 21 /* Offset in TLS block */
|
62
|
+
#define R_X86_64_GOTTPOFF 22 /* 32 bit signed PC relative offset
|
63
|
+
to GOT entry for IE symbol */
|
64
|
+
#define R_X86_64_TPOFF32 23 /* Offset in initial TLS block */
|
65
|
+
#define R_X86_64_PC64 24 /* PC relative 64 bit */
|
66
|
+
#define R_X86_64_GOTOFF64 25 /* 64 bit offset to GOT */
|
67
|
+
#define R_X86_64_GOTPC32 26 /* 32 bit signed pc relative offset to GOT */
|
68
|
+
#define R_X86_64_GOT64 27 /* 64-bit GOT entry offset */
|
69
|
+
#define R_X86_64_GOTPCREL64 28 /* 64-bit PC relative offset to GOT entry */
|
70
|
+
#define R_X86_64_GOTPC64 29 /* 64-bit PC relative offset to GOT */
|
71
|
+
#define R_X86_64_GOTPLT64 30 /* like GOT64, says PLT entry needed */
|
72
|
+
#define R_X86_64_PLTOFF64 31 /* 64-bit GOT relative offset to PLT entry */
|
73
|
+
#define R_X86_64_SIZE32 32 /* Size of symbol plus 32-bit addend */
|
74
|
+
#define R_X86_64_SIZE64 33 /* Size of symbol plus 64-bit addend */
|
75
|
+
#define R_X86_64_GOTPC32_TLSDESC 34 /* GOT offset for TLS descriptor */
|
76
|
+
#define R_X86_64_TLSDESC_CALL 35 /* Marker for call through TLS descriptor */
|
77
|
+
#define R_X86_64_TLSDESC 36 /* TLS descriptor */
|
78
|
+
#define R_X86_64_IRELATIVE 37 /* Adjust indirectly by program base */
|
79
|
+
#define R_X86_64_RELATIVE64 38 /* 64bit adjust by program base */
|
80
|
+
|
81
|
+
/* Keep this the last entry. */
|
82
|
+
#define R_X86_64_NUM 39
|
83
|
+
#endif /* WIN32 */
|
84
|
+
|
85
|
+
/* Relocation types for X86_64 */
|
86
|
+
static const char *reloc_type_names_X86_64[] = {
|
87
|
+
"R_X86_64_NONE", /* 00 */
|
88
|
+
"R_X86_64_64", /* 01 */
|
89
|
+
"R_X86_64_PC32", /* 02 */
|
90
|
+
"R_X86_64_GOT32", /* 03 */
|
91
|
+
"R_X86_64_PLT32", /* 04 */
|
92
|
+
"R_X86_64_COPY", /* 05 */
|
93
|
+
"R_X86_64_GLOB_DAT", /* 06 */
|
94
|
+
"R_X86_64_JUMP_SLOT", /* 07 */
|
95
|
+
"R_X86_64_RELATIVE", /* 08 */
|
96
|
+
"R_X86_64_GOTPCREL", /* 09 */
|
97
|
+
"R_X86_64_32", /* 10 */
|
98
|
+
"R_X86_64_32S", /* 11 */
|
99
|
+
"R_X86_64_16", /* 12 */
|
100
|
+
"R_X86_64_PC16", /* 13 */
|
101
|
+
"R_X86_64_8", /* 14 */
|
102
|
+
"R_X86_64_PC8", /* 15 */
|
103
|
+
"R_X86_64_DTPMOD64", /* 16 */
|
104
|
+
"R_X86_64_DTPOFF64", /* 17 */
|
105
|
+
"R_X86_64_TPOFF64", /* 18 */
|
106
|
+
"R_X86_64_TLSGD", /* 19 */
|
107
|
+
"R_X86_64_TLSLD", /* 20 */
|
108
|
+
"R_X86_64_DTPOFF32", /* 21 */
|
109
|
+
"R_X86_64_GOTTPOFF", /* 22 */
|
110
|
+
"R_X86_64_TPOFF32", /* 23 */
|
111
|
+
"R_X86_64_PC64", /* 24 */
|
112
|
+
"R_X86_64_GOTOFF64", /* 25 */
|
113
|
+
"R_X86_64_GOTPC32", /* 26 */
|
114
|
+
"R_X86_64_GOT64", /* 27 */
|
115
|
+
"R_X86_64_GOTPCREL64", /* 28 */
|
116
|
+
"R_X86_64_GOTPC64", /* 29 */
|
117
|
+
"R_X86_64_GOTPLT64", /* 30 */
|
118
|
+
"R_X86_64_PLTOFF64", /* 31 */
|
119
|
+
"R_X86_64_SIZE32", /* 32 */
|
120
|
+
"R_X86_64_SIZE64", /* 33 */
|
121
|
+
"R_X86_64_GOTPC32_TLSDESC", /* 34 */
|
122
|
+
"R_X86_64_TLSDESC_CALL", /* 35 */
|
123
|
+
"R_X86_64_TLSDESC", /* 36 */
|
124
|
+
"R_X86_64_IRELATIVE", /* 37 */
|
125
|
+
"R_X86_64_RELATIVE64", /* 38 */
|
126
|
+
};
|
127
|
+
#endif /* DWARF_RELOC_X86_64_H */
|
@@ -0,0 +1,665 @@
|
|
1
|
+
/*
|
2
|
+
Copyright (C) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
|
3
|
+
Portions Copyright (C) 2007-2011 David Anderson. 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
|
+
/* This file was designed for SGI IRIX compiler use.
|
28
|
+
The static linker can rearrange the order of functions
|
29
|
+
in the layout in memory
|
30
|
+
and provided each has the right form
|
31
|
+
this will (when called by the SGI IRIX
|
32
|
+
static linker) rearrange the table so the line table
|
33
|
+
is arranged in the same order as the memory layout. */
|
34
|
+
|
35
|
+
#include "config.h"
|
36
|
+
#ifdef __sgi /* SGI IRIX ONLY */
|
37
|
+
#include "dwarf_incl.h"
|
38
|
+
#include <stdio.h>
|
39
|
+
#include <stdlib.h>
|
40
|
+
#include "dwarf_line.h"
|
41
|
+
#ifdef HAVE_ALLOCA_H
|
42
|
+
#include <alloca.h>
|
43
|
+
#endif
|
44
|
+
#ifdef HAVE_STRING_H
|
45
|
+
#include <string.h>
|
46
|
+
#endif
|
47
|
+
|
48
|
+
#define MINIMUM_POSSIBLE_PROLOG_LEN 10 /* 10 is based on */
|
49
|
+
/* the definition of the DWARF2/3 line table prolog. The value
|
50
|
+
here should be >8 (accounting for a 64 bit read) and <= the
|
51
|
+
length of a legal DWARF2/3 line prolog, which is at least 10
|
52
|
+
bytes long (but can be longer). What this constant helps
|
53
|
+
avoid is reading past the end of a malloc'd buffer in
|
54
|
+
_dwarf_update_line_sec(). */
|
55
|
+
|
56
|
+
static int
|
57
|
+
_dwarf_update_line_sec(Dwarf_Small * line_ptr,
|
58
|
+
unsigned long remaining_bytes,
|
59
|
+
int *any_change,
|
60
|
+
int length_size,
|
61
|
+
int *err_code, Dwarf_Small ** new_line_ptr);
|
62
|
+
|
63
|
+
/* Used to construct
|
64
|
+
a linked list of so we can sort and reorder the line info. */
|
65
|
+
struct a_line_area {
|
66
|
+
Dwarf_Addr ala_address; /* from DW_LNE_set_address */
|
67
|
+
Dwarf_Unsigned ala_offset; /* byte offset in buffer */
|
68
|
+
Dwarf_Unsigned ala_length; /* byte length in buffer */
|
69
|
+
long ala_entry_num; /* to guarantee stable sort */
|
70
|
+
struct a_line_area *ala_next;
|
71
|
+
};
|
72
|
+
|
73
|
+
|
74
|
+
/* Written to support the SGI IRIX static linker.
|
75
|
+
It helps SGI IRIX ld
|
76
|
+
rearrange lines in .debug_line in a .o created with a text
|
77
|
+
section per function. The SGI IRIX linker option is:
|
78
|
+
-OPT:procedure_reorder=ON
|
79
|
+
where ld-cord (cord(1)ing by ld,
|
80
|
+
not by cord(1)) may have changed the function order.
|
81
|
+
|
82
|
+
Returns
|
83
|
+
DW_DLV_OK if nothing went wrong.
|
84
|
+
DW_DLV_ERROR if could not do anything due to
|
85
|
+
error. the original buffer is unchanged.
|
86
|
+
|
87
|
+
is_64_bit must be passed in by caller and tells
|
88
|
+
if this is a 32 or 64bit pointer object section
|
89
|
+
being processed.
|
90
|
+
|
91
|
+
err_code must be a non-null pointer to integer.
|
92
|
+
If DW_DLV_ERROR is returned that integer is set
|
93
|
+
to a dwarf error code so the caller may
|
94
|
+
print it for diagnostic purposes.
|
95
|
+
|
96
|
+
*any_change is set here
|
97
|
+
set 0 if no sorting (movement) done.
|
98
|
+
set 1 if some sorting (movement) done.
|
99
|
+
on all returns. On error return sets to 0.
|
100
|
+
|
101
|
+
The _dwarf name form is now obsolete,
|
102
|
+
the dwarf_ name for is preferred.
|
103
|
+
Both names supported. */
|
104
|
+
int
|
105
|
+
_dwarf_ld_sort_lines(void *orig_buffer,
|
106
|
+
unsigned long buffer_len,
|
107
|
+
int is_64_bit, int *any_change, int *err_code)
|
108
|
+
{
|
109
|
+
return dwarf_ld_sort_lines(orig_buffer,buffer_len,
|
110
|
+
is_64_bit,any_change,err_code);
|
111
|
+
}
|
112
|
+
int
|
113
|
+
dwarf_ld_sort_lines(void *orig_buffer,
|
114
|
+
unsigned long buffer_len,
|
115
|
+
int is_64_bit, int *any_change, int *err_code)
|
116
|
+
{
|
117
|
+
|
118
|
+
int length_size = 4;
|
119
|
+
Dwarf_Small *orig_line_ptr; /* our local copy of the user's input
|
120
|
+
buffer */
|
121
|
+
Dwarf_Small *line_ptr; /* starts at orig_line_ptr, gets
|
122
|
+
incremented thru to end of our copy
|
123
|
+
of the input buffer */
|
124
|
+
Dwarf_Small *new_line_ptr; /* output of _dwarf_update_line_sec(),
|
125
|
+
used to update line_ptr as we pass
|
126
|
+
thru compilation units in a .o
|
127
|
+
.debug_line */
|
128
|
+
|
129
|
+
unsigned long remaining_bytes = buffer_len; /* total length of
|
130
|
+
original area left to be processed. Changes as we pass
|
131
|
+
thru compilation units in a .o .debug_line */
|
132
|
+
|
133
|
+
int sec_res;
|
134
|
+
int lany_change = 0;
|
135
|
+
int did_change = 0;
|
136
|
+
|
137
|
+
if (is_64_bit)
|
138
|
+
length_size = 8;
|
139
|
+
|
140
|
+
*any_change = 0;
|
141
|
+
line_ptr = malloc(buffer_len);
|
142
|
+
if (!line_ptr) {
|
143
|
+
*err_code = DW_DLE_ALLOC_FAIL;
|
144
|
+
return DW_DLV_ERROR;
|
145
|
+
}
|
146
|
+
orig_line_ptr = line_ptr;
|
147
|
+
memcpy(line_ptr, orig_buffer, buffer_len);
|
148
|
+
|
149
|
+
|
150
|
+
/* We must iterate thru each of a set of prologues and line data.
|
151
|
+
We process each set in turn. If all pass, we update the
|
152
|
+
passed-in buffer. */
|
153
|
+
sec_res = DW_DLV_OK;
|
154
|
+
|
155
|
+
for (sec_res = _dwarf_update_line_sec(line_ptr,
|
156
|
+
remaining_bytes, &lany_change, length_size, err_code, &new_line_ptr);
|
157
|
+
(sec_res == DW_DLV_OK) && (remaining_bytes > 0);
|
158
|
+
sec_res = _dwarf_update_line_sec(line_ptr,
|
159
|
+
remaining_bytes, &lany_change, length_size,
|
160
|
+
err_code, &new_line_ptr)) {
|
161
|
+
long bytes_used = new_line_ptr - line_ptr;
|
162
|
+
|
163
|
+
line_ptr = new_line_ptr;
|
164
|
+
remaining_bytes -= bytes_used;
|
165
|
+
if (lany_change) {
|
166
|
+
did_change = 1;
|
167
|
+
}
|
168
|
+
if (remaining_bytes > 0) {
|
169
|
+
continue;
|
170
|
+
}
|
171
|
+
break;
|
172
|
+
}
|
173
|
+
if (sec_res == DW_DLV_ERROR) {
|
174
|
+
free(orig_line_ptr);
|
175
|
+
return sec_res;
|
176
|
+
}
|
177
|
+
|
178
|
+
|
179
|
+
/* all passed */
|
180
|
+
if (did_change) {
|
181
|
+
/* So update the passed in buffer orig_buffer is caller's input
|
182
|
+
area. orig_line_ptr is our modified copy of input area. */
|
183
|
+
memcpy(orig_buffer, orig_line_ptr, buffer_len);
|
184
|
+
*any_change = 1;
|
185
|
+
}
|
186
|
+
free(orig_line_ptr);
|
187
|
+
|
188
|
+
return sec_res;
|
189
|
+
}
|
190
|
+
|
191
|
+
|
192
|
+
/* By setting ala_entry_num we guarantee a stable sort,
|
193
|
+
no duplicates
|
194
|
+
Sorting in address order.
|
195
|
+
*/
|
196
|
+
static int
|
197
|
+
cmpr(const void *lin, const void *rin)
|
198
|
+
{
|
199
|
+
const struct a_line_area *l = lin;
|
200
|
+
const struct a_line_area *r = rin;
|
201
|
+
|
202
|
+
if (l->ala_address < r->ala_address) {
|
203
|
+
return -1;
|
204
|
+
}
|
205
|
+
if (l->ala_address > r->ala_address) {
|
206
|
+
return 1;
|
207
|
+
}
|
208
|
+
if (l->ala_entry_num < r->ala_entry_num) {
|
209
|
+
return -1;
|
210
|
+
}
|
211
|
+
if (l->ala_entry_num > r->ala_entry_num) {
|
212
|
+
return 1;
|
213
|
+
}
|
214
|
+
return 0; /* should never happen. */
|
215
|
+
}
|
216
|
+
|
217
|
+
/* The list of line area records is no longer needed.
|
218
|
+
Free the data allocated. */
|
219
|
+
static void
|
220
|
+
free_area_data(struct a_line_area *arp)
|
221
|
+
{
|
222
|
+
while (arp) {
|
223
|
+
struct a_line_area *next = arp->ala_next;
|
224
|
+
free(arp);
|
225
|
+
arp = next;
|
226
|
+
}
|
227
|
+
}
|
228
|
+
|
229
|
+
/* On entry:
|
230
|
+
line_ptr must point to first
|
231
|
+
byte of a line group for one (original) .o
|
232
|
+
|
233
|
+
remaining_bytes is the size of the area pointed to
|
234
|
+
by line_ptr: may be larger than the
|
235
|
+
current original compilation unit .
|
236
|
+
|
237
|
+
length size is 4 for 32bit pointers, 8 for 64bit pointers
|
238
|
+
in the data pointed to.
|
239
|
+
|
240
|
+
|
241
|
+
On return:
|
242
|
+
return DW_DLV_OK if all ok. (ignore
|
243
|
+
*err_code in this case)
|
244
|
+
|
245
|
+
return DW_DLV_ERROR and set *err_code if an error.
|
246
|
+
|
247
|
+
If some line data was moved around, set *any_change to 1.
|
248
|
+
If error or no movement, set *any_change to 0;
|
249
|
+
|
250
|
+
Set *new_line_ptr to one-byte-past the end of the
|
251
|
+
current original compilation unit (not necessary
|
252
|
+
if returning DW_DLV_ERROR, but not harmful).
|
253
|
+
|
254
|
+
This copies the entire array to a malloc area, then
|
255
|
+
mallocs pieces of it (another malloc) for sorting a CU entries
|
256
|
+
and copying back. Then at end the whole new thing copied in.
|
257
|
+
The result is that on error, the input is not touched.
|
258
|
+
|
259
|
+
An alternative would be to just update a piece at a time
|
260
|
+
and on error stop updating but leave what was done, done.
|
261
|
+
This alternative would save some temporary malloc space. */
|
262
|
+
static int
|
263
|
+
_dwarf_update_line_sec(Dwarf_Small * line_ptr,
|
264
|
+
unsigned long remaining_bytes,
|
265
|
+
int *any_change,
|
266
|
+
int length_size,
|
267
|
+
int *err_code, Dwarf_Small ** new_line_ptr)
|
268
|
+
{
|
269
|
+
/* This points to the last byte of the .debug_line portion for the
|
270
|
+
current cu. */
|
271
|
+
Dwarf_Small *line_ptr_end = 0;
|
272
|
+
|
273
|
+
/* This points to the end of the statement program prologue for the
|
274
|
+
current cu, and serves to check that the prologue was correctly
|
275
|
+
decoded. */
|
276
|
+
|
277
|
+
Dwarf_Small *orig_line_ptr = 0;
|
278
|
+
|
279
|
+
/* These are the fields of the statement program header. */
|
280
|
+
struct Dwarf_Debug_s dbg_data;
|
281
|
+
Dwarf_Debug dbg = &dbg_data;
|
282
|
+
|
283
|
+
/* These are the state machine state variables. */
|
284
|
+
Dwarf_Addr address = 0;
|
285
|
+
Dwarf_Word line = 1;
|
286
|
+
Dwarf_Bool is_stmt = false;
|
287
|
+
|
288
|
+
/* Dwarf_Bool prologue_end; Dwarf_Bool epilogue_begin; */
|
289
|
+
Dwarf_Small isa = 0;
|
290
|
+
|
291
|
+
|
292
|
+
struct a_line_area *area_base = 0;
|
293
|
+
struct a_line_area *area_current = 0;
|
294
|
+
long area_count = 0;
|
295
|
+
|
296
|
+
Dwarf_Addr last_address = 0;
|
297
|
+
int need_to_sort = 0;
|
298
|
+
|
299
|
+
/* This is the current opcode read from the statement program. */
|
300
|
+
Dwarf_Small opcode = 0;
|
301
|
+
|
302
|
+
|
303
|
+
/* These variables are used to decode leb128 numbers. Leb128_num
|
304
|
+
holds the decoded number, and leb128_length is its length in
|
305
|
+
bytes. */
|
306
|
+
Dwarf_Word leb128_num = 0;
|
307
|
+
Dwarf_Sword advance_line = 0;
|
308
|
+
|
309
|
+
/* This is the operand of the latest fixed_advance_pc extended
|
310
|
+
opcode. */
|
311
|
+
Dwarf_Half fixed_advance_pc = 0;
|
312
|
+
|
313
|
+
/* This is the length of an extended opcode instr. */
|
314
|
+
Dwarf_Word instr_length = 0;
|
315
|
+
Dwarf_Small ext_opcode = 0;
|
316
|
+
struct Line_Table_Prefix_s prefix;
|
317
|
+
|
318
|
+
|
319
|
+
|
320
|
+
memset(dbg, 0, sizeof(struct Dwarf_Debug_s));
|
321
|
+
dbg->de_copy_word = memcpy;
|
322
|
+
/* Following is a straightforward decoding of the statement program
|
323
|
+
prologue information. */
|
324
|
+
*any_change = 0;
|
325
|
+
|
326
|
+
|
327
|
+
orig_line_ptr = line_ptr;
|
328
|
+
if (remaining_bytes < MINIMUM_POSSIBLE_PROLOG_LEN) {
|
329
|
+
/* We are at the end. Remaining should be zero bytes, padding.
|
330
|
+
This is really just 'end of CU buffer' not an error. The is
|
331
|
+
no 'entry' left so report there is none. We don't want to
|
332
|
+
READ_UNALIGNED the total_length below and then belatedly
|
333
|
+
discover that we read off the end already. */
|
334
|
+
return (DW_DLV_NO_ENTRY);
|
335
|
+
}
|
336
|
+
|
337
|
+
dwarf_init_line_table_prefix(&prefix);
|
338
|
+
{
|
339
|
+
Dwarf_Small *line_ptr_out = 0;
|
340
|
+
Dwarf_Error error;
|
341
|
+
int dres = _dwarf_read_line_table_prefix(dbg,
|
342
|
+
NULL, /* context*/
|
343
|
+
line_ptr,
|
344
|
+
remaining_bytes,
|
345
|
+
&line_ptr_out,
|
346
|
+
&prefix,
|
347
|
+
NULL, NULL,&error,
|
348
|
+
NULL);
|
349
|
+
|
350
|
+
if (dres == DW_DLV_ERROR) {
|
351
|
+
dwarf_free_line_table_prefix(&prefix);
|
352
|
+
*err_code = dwarf_errno(error);
|
353
|
+
dwarf_dealloc(dbg, error, DW_DLA_ERROR);
|
354
|
+
free_area_data(area_base);
|
355
|
+
return dres;
|
356
|
+
}
|
357
|
+
if (dres == DW_DLV_NO_ENTRY) {
|
358
|
+
dwarf_free_line_table_prefix(&prefix);
|
359
|
+
return dres;
|
360
|
+
}
|
361
|
+
line_ptr_end = prefix.pf_line_ptr_end;
|
362
|
+
line_ptr = line_ptr_out;
|
363
|
+
}
|
364
|
+
|
365
|
+
/* Initialize the state machine. */
|
366
|
+
/* file = 1; */
|
367
|
+
/* column = 0; */
|
368
|
+
is_stmt = prefix.pf_default_is_stmt;
|
369
|
+
/* basic_block = false; */
|
370
|
+
/* end_sequence = false; */
|
371
|
+
/* prologue_end = false; */
|
372
|
+
/* epilogue_begin = false; */
|
373
|
+
isa = 0;
|
374
|
+
|
375
|
+
|
376
|
+
/* Start of statement program. */
|
377
|
+
while (line_ptr < line_ptr_end) {
|
378
|
+
int type;
|
379
|
+
Dwarf_Small *stmt_prog_entry_start = line_ptr;
|
380
|
+
|
381
|
+
opcode = *(Dwarf_Small *) line_ptr;
|
382
|
+
line_ptr++;
|
383
|
+
/* 'type' is the output */
|
384
|
+
WHAT_IS_OPCODE(type, opcode, prefix.pf_opcode_base,
|
385
|
+
prefix.pf_opcode_length_table, line_ptr,
|
386
|
+
prefix.pf_std_op_count);
|
387
|
+
|
388
|
+
if (type == LOP_DISCARD) {
|
389
|
+
int oc;
|
390
|
+
int opcnt = prefix.pf_opcode_length_table[opcode];
|
391
|
+
|
392
|
+
for (oc = 0; oc < opcnt; oc++) {
|
393
|
+
/* Read and discard operands we don't
|
394
|
+
understand.
|
395
|
+
arbitrary choice of unsigned read.
|
396
|
+
signed read would work as well. */
|
397
|
+
/* utmp2 set but not used here */
|
398
|
+
Dwarf_Unsigned utmp2;
|
399
|
+
|
400
|
+
DECODE_LEB128_UWORD(line_ptr, utmp2);
|
401
|
+
}
|
402
|
+
|
403
|
+
} else if (type == LOP_SPECIAL) {
|
404
|
+
opcode = opcode - prefix.pf_opcode_base;
|
405
|
+
address = address + prefix.pf_minimum_instruction_length *
|
406
|
+
(opcode / prefix.pf_line_range);
|
407
|
+
line =
|
408
|
+
line + prefix.pf_line_base +
|
409
|
+
opcode % prefix.pf_line_range;
|
410
|
+
|
411
|
+
/* basic_block = false; */
|
412
|
+
} else if (type == LOP_STANDARD) {
|
413
|
+
switch (opcode) {
|
414
|
+
case DW_LNS_copy:{
|
415
|
+
/* basic_block = false; */
|
416
|
+
break;
|
417
|
+
}
|
418
|
+
|
419
|
+
case DW_LNS_advance_pc:{
|
420
|
+
Dwarf_Unsigned utmp2;
|
421
|
+
|
422
|
+
DECODE_LEB128_UWORD(line_ptr, utmp2);
|
423
|
+
leb128_num = (Dwarf_Word) utmp2;
|
424
|
+
address = address +
|
425
|
+
prefix.pf_minimum_instruction_length * leb128_num;
|
426
|
+
break;
|
427
|
+
}
|
428
|
+
|
429
|
+
case DW_LNS_advance_line:{
|
430
|
+
Dwarf_Signed stmp;
|
431
|
+
|
432
|
+
DECODE_LEB128_SWORD(line_ptr, stmp);
|
433
|
+
advance_line = (Dwarf_Sword) stmp;
|
434
|
+
line = line + advance_line;
|
435
|
+
break;
|
436
|
+
}
|
437
|
+
|
438
|
+
case DW_LNS_set_file:{
|
439
|
+
/* utmp2 set but not used here. */
|
440
|
+
Dwarf_Unsigned utmp2;
|
441
|
+
|
442
|
+
DECODE_LEB128_UWORD(line_ptr, utmp2);
|
443
|
+
/* file = (Dwarf_Word)utmp2; */
|
444
|
+
break;
|
445
|
+
}
|
446
|
+
|
447
|
+
case DW_LNS_set_column:{
|
448
|
+
/* utmp2 set but not used here. */
|
449
|
+
Dwarf_Unsigned utmp2;
|
450
|
+
|
451
|
+
DECODE_LEB128_UWORD(line_ptr, utmp2);
|
452
|
+
/* column = (Dwarf_Word)utmp2; */
|
453
|
+
break;
|
454
|
+
}
|
455
|
+
|
456
|
+
case DW_LNS_negate_stmt:{
|
457
|
+
is_stmt = !is_stmt;
|
458
|
+
break;
|
459
|
+
}
|
460
|
+
|
461
|
+
case DW_LNS_set_basic_block:{
|
462
|
+
/* basic_block = true; */
|
463
|
+
break;
|
464
|
+
}
|
465
|
+
|
466
|
+
case DW_LNS_const_add_pc:{
|
467
|
+
opcode = MAX_LINE_OP_CODE - prefix.pf_opcode_base;
|
468
|
+
address = address +
|
469
|
+
prefix.pf_minimum_instruction_length *
|
470
|
+
(opcode / prefix. pf_line_range);
|
471
|
+
break;
|
472
|
+
}
|
473
|
+
|
474
|
+
case DW_LNS_fixed_advance_pc:{
|
475
|
+
|
476
|
+
READ_UNALIGNED(dbg, fixed_advance_pc, Dwarf_Half,
|
477
|
+
line_ptr, sizeof(Dwarf_Half));
|
478
|
+
line_ptr += sizeof(Dwarf_Half);
|
479
|
+
address = address + fixed_advance_pc;
|
480
|
+
break;
|
481
|
+
}
|
482
|
+
/* New in DWARF3 */
|
483
|
+
case DW_LNS_set_prologue_end:{
|
484
|
+
/* prologue_end = true; */
|
485
|
+
break;
|
486
|
+
|
487
|
+
|
488
|
+
}
|
489
|
+
/* New in DWARF3 */
|
490
|
+
case DW_LNS_set_epilogue_begin:{
|
491
|
+
/* epilogue_begin = true; */
|
492
|
+
break;
|
493
|
+
}
|
494
|
+
|
495
|
+
/* New in DWARF3 */
|
496
|
+
case DW_LNS_set_isa:{
|
497
|
+
Dwarf_Unsigned utmp2;
|
498
|
+
|
499
|
+
DECODE_LEB128_UWORD(line_ptr, utmp2);
|
500
|
+
isa = utmp2;
|
501
|
+
if (isa != utmp2) {
|
502
|
+
/* The value of the isa did not fit in our
|
503
|
+
local so we record it wrong. declare an
|
504
|
+
error. */
|
505
|
+
dwarf_free_line_table_prefix(&prefix);
|
506
|
+
*err_code = DW_DLE_LINE_NUM_OPERANDS_BAD;
|
507
|
+
free_area_data(area_base);
|
508
|
+
return (DW_DLV_ERROR);
|
509
|
+
}
|
510
|
+
break;
|
511
|
+
}
|
512
|
+
}
|
513
|
+
} else if (type == LOP_EXTENDED) {
|
514
|
+
Dwarf_Unsigned utmp3 = 0;
|
515
|
+
|
516
|
+
DECODE_LEB128_UWORD(line_ptr, utmp3);
|
517
|
+
instr_length = (Dwarf_Word) utmp3;
|
518
|
+
ext_opcode = *(Dwarf_Small *) line_ptr;
|
519
|
+
line_ptr++;
|
520
|
+
switch (ext_opcode) {
|
521
|
+
|
522
|
+
case DW_LNE_end_sequence:{
|
523
|
+
/* end_sequence = true; */
|
524
|
+
|
525
|
+
address = 0;
|
526
|
+
/* file = 1; */
|
527
|
+
line = 1;
|
528
|
+
/* column = 0; */
|
529
|
+
is_stmt = prefix.pf_default_is_stmt;
|
530
|
+
/* basic_block = false; */
|
531
|
+
/* end_sequence = false; */
|
532
|
+
/* prologue_end = false; */
|
533
|
+
/* epilogue_begin = false; */
|
534
|
+
}
|
535
|
+
break;
|
536
|
+
case DW_LNE_set_address:{
|
537
|
+
struct a_line_area *area = 0;
|
538
|
+
|
539
|
+
READ_UNALIGNED(dbg, address, Dwarf_Addr,
|
540
|
+
line_ptr, length_size);
|
541
|
+
/* Here we need to remember the offset into the
|
542
|
+
buffer and check to see if address went
|
543
|
+
down. */
|
544
|
+
if (address < last_address) {
|
545
|
+
need_to_sort = 1;
|
546
|
+
}
|
547
|
+
last_address = address;
|
548
|
+
|
549
|
+
area = malloc(sizeof(struct a_line_area));
|
550
|
+
area->ala_address = address;
|
551
|
+
area->ala_offset = stmt_prog_entry_start -
|
552
|
+
orig_line_ptr;
|
553
|
+
area->ala_entry_num = area_count;
|
554
|
+
area->ala_next = 0;
|
555
|
+
area->ala_length = 0;
|
556
|
+
if (area_current) {
|
557
|
+
area_current->ala_next = area;
|
558
|
+
area_current->ala_length =
|
559
|
+
area->ala_offset -
|
560
|
+
area_current->ala_offset;
|
561
|
+
}
|
562
|
+
++area_count;
|
563
|
+
area_current = area;
|
564
|
+
if (area_base == 0) {
|
565
|
+
area_base = area;
|
566
|
+
}
|
567
|
+
|
568
|
+
line_ptr += length_size;
|
569
|
+
}
|
570
|
+
break;
|
571
|
+
|
572
|
+
case DW_LNE_define_file:{
|
573
|
+
break;
|
574
|
+
}
|
575
|
+
|
576
|
+
default:{
|
577
|
+
Dwarf_Unsigned remaining_bytes2 = instr_length -1;
|
578
|
+
line_ptr += remaining_bytes2;
|
579
|
+
break;
|
580
|
+
}
|
581
|
+
}
|
582
|
+
|
583
|
+
}
|
584
|
+
}
|
585
|
+
|
586
|
+
|
587
|
+
*new_line_ptr = line_ptr;
|
588
|
+
if (!need_to_sort) {
|
589
|
+
dwarf_free_line_table_prefix(&prefix);
|
590
|
+
free_area_data(area_base);
|
591
|
+
return (DW_DLV_OK);
|
592
|
+
}
|
593
|
+
|
594
|
+
/* So now we have something to sort. First, finish off the last
|
595
|
+
area record: */
|
596
|
+
area_current->ala_length = (line_ptr - orig_line_ptr)
|
597
|
+
-area_current->ala_offset;
|
598
|
+
|
599
|
+
/* Build and sort a simple array of sections. Forcing a stable sort
|
600
|
+
by comparing on sequence number. We will use the sorted list to
|
601
|
+
move sections of this part of the line table. Each 'section'
|
602
|
+
starting with a DW_LNE_set_address opcode, on the assumption
|
603
|
+
that such only get out of order where there was an ld-cord
|
604
|
+
function rearrangement and that it is meaningful to restart the
|
605
|
+
line info there. */
|
606
|
+
{
|
607
|
+
struct a_line_area *ala_array;
|
608
|
+
struct a_line_area *local;
|
609
|
+
long start_len;
|
610
|
+
Dwarf_Small *new_area;
|
611
|
+
long i;
|
612
|
+
|
613
|
+
ala_array = malloc(area_count * sizeof(struct a_line_area));
|
614
|
+
if (!ala_array) {
|
615
|
+
dwarf_free_line_table_prefix(&prefix);
|
616
|
+
*err_code = DW_DLE_ALLOC_FAIL;
|
617
|
+
free_area_data(area_base);
|
618
|
+
return DW_DLV_ERROR;
|
619
|
+
}
|
620
|
+
|
621
|
+
for (local = area_base, i = 0; local;
|
622
|
+
local = local->ala_next, ++i) {
|
623
|
+
|
624
|
+
ala_array[i] = *local;
|
625
|
+
}
|
626
|
+
free_area_data(area_base);
|
627
|
+
/* Zero the stale pointers so we don't use them accidentally. */
|
628
|
+
area_base = 0;
|
629
|
+
area_current = 0;
|
630
|
+
|
631
|
+
qsort(ala_array, area_count, sizeof(struct a_line_area), cmpr);
|
632
|
+
|
633
|
+
/* Now we must rearrange the pieces of the line table. */
|
634
|
+
|
635
|
+
start_len =
|
636
|
+
(prefix.pf_line_prologue_start +
|
637
|
+
prefix.pf_prologue_length) - orig_line_ptr;
|
638
|
+
new_area = malloc(remaining_bytes);
|
639
|
+
if (!new_area) {
|
640
|
+
free(ala_array);
|
641
|
+
*err_code = DW_DLE_ALLOC_FAIL;
|
642
|
+
dwarf_free_line_table_prefix(&prefix);
|
643
|
+
return DW_DLV_ERROR;
|
644
|
+
}
|
645
|
+
memcpy(new_area, orig_line_ptr, start_len);
|
646
|
+
line_ptr = new_area + start_len;
|
647
|
+
for (i = 0; i < area_count; ++i) {
|
648
|
+
memcpy(line_ptr, orig_line_ptr +
|
649
|
+
ala_array[i].ala_offset, ala_array[i].ala_length);
|
650
|
+
line_ptr += ala_array[i].ala_length;
|
651
|
+
}
|
652
|
+
|
653
|
+
memcpy(orig_line_ptr, new_area, remaining_bytes);
|
654
|
+
|
655
|
+
free(new_area);
|
656
|
+
free(ala_array);
|
657
|
+
ala_array = 0;
|
658
|
+
new_area = 0;
|
659
|
+
}
|
660
|
+
|
661
|
+
*any_change = 1;
|
662
|
+
dwarf_free_line_table_prefix(&prefix);
|
663
|
+
return (DW_DLV_OK);
|
664
|
+
}
|
665
|
+
#endif /* __sgi */
|