forked from AdaCore/gnatcoverage
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disa_ppc.ads
104 lines (86 loc) · 4.2 KB
/
disa_ppc.ads
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
------------------------------------------------------------------------------
-- --
-- GNATcoverage --
-- --
-- Copyright (C) 2008-2021, AdaCore --
-- --
-- GNATcoverage is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 3, or (at your option) any later --
-- version. This software is distributed in the hope that it will be useful --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
-- PowerPC disassembler
with Binary_Files; use Binary_Files;
private with Dis_Opcodes;
with Disa_Symbolize; use Disa_Symbolize;
with Disassemblers; use Disassemblers;
with Highlighting;
with Traces; use Traces;
with Ada.Finalization;
package Disa_Ppc is
function Extract_APU_Info
(Filename : String;
Is_Big_Endian : Boolean;
APU_Info_Section : Binary_Content)
return Traces.Machine_Type;
-- The PowerPC ABI defines an ELF section ".PPC.EMB.apuinfo" section to
-- provide information to properly interpret opcodes. This attempts to
-- extract a specific machine type out of it. Filename must be the name of
-- the executable this section comes from; it is used to emit diagnostics.
type PPC_Disassembler is
new Ada.Finalization.Limited_Controlled and Disassembler with private;
overriding function Get_Insn_Length
(Self : PPC_Disassembler;
Insn_Bin : Binary_Content) return Positive;
-- Return the length of the instruction at the beginning of Insn_Bin
overriding procedure Disassemble_Insn
(Self : PPC_Disassembler;
Insn_Bin : Binary_Content;
Pc : Pc_Type;
Buffer : in out Highlighting.Buffer_Type;
Insn_Len : out Natural;
Sym : Symbolizer'Class);
-- Disassemble instruction at ADDR, and put the result in LINE/LINE_POS.
-- LINE_POS is the index of the next character to be written (ie line
-- length if Line'First = 1).
overriding procedure Get_Insn_Properties
(Self : PPC_Disassembler;
Insn_Bin : Binary_Content;
Pc : Pc_Type;
Branch : out Branch_Kind;
Flag_Indir : out Boolean;
Flag_Cond : out Boolean;
Branch_Dest : out Dest;
FT_Dest : out Dest);
-- Determine whether the given instruction, located at PC, is a branch
-- instruction of some kind (indicated by Branch).
-- For a branch, indicate whether it is indirect (Flag_Indir) and whether
-- it is conditional (Flag_Cond), and determine its destination (Dest).
overriding function Is_Padding
(Self : PPC_Disassembler;
Insn_Bin : Binary_Content;
Pc : Pc_Type) return Boolean;
-- See disassemblers.ads
overriding procedure Initialize
(Object : in out PPC_Disassembler);
-- Override of controlled object primitive
overriding procedure Finalize
(Object : in out PPC_Disassembler);
-- Override of controlled object primitive
type E500_Disassembler is new PPC_Disassembler with private;
overriding procedure Initialize
(Object : in out E500_Disassembler);
-- Override of controlled object primitive
private
type PPC_Disassembler is
new Ada.Finalization.Limited_Controlled and Disassembler with record
Handle : Dis_Opcodes.Disassemble_Handle;
end record;
type E500_Disassembler is new PPC_Disassembler with null record;
end Disa_Ppc;