pypcode
PyPCode integration
get_arch_from_string(target_id)
Find the architecture for an arch based on the target identification
Parameters:
Name | Type | Description | Default |
---|---|---|---|
target_id |
str
|
Identifier of the architecture |
required |
Raises:
Type | Description |
---|---|
PypcodeError
|
if the architecture is not found |
Returns:
Type | Description |
---|---|
ArchLanguage
|
The appropriate ArchLang |
Source code in quokka/backends/pypcode.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
|
get_pypcode_context(arch, endian=Endianness.LITTLE_ENDIAN)
Convert an arch from Quokka to Pypcode
For the moment, only the arch described in quokka.analysis are supported. This method is a bit slow because enum are generated by pypcode on the fly but should be executed only once.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arch |
Type[QuokkaArch]
|
Quokka program architecture |
required |
endian |
Type[Endianness]
|
Architecture endianness |
LITTLE_ENDIAN
|
Raises:
Type | Description |
---|---|
PypcodeError
|
if the conversion for arch is not found |
Returns:
Type | Description |
---|---|
Context
|
A pypcode.Context instance |
Source code in quokka/backends/pypcode.py
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 |
|
pypcode_decode_block(block)
Decode a block at once.
This method decode a block of instructions using Pypcode context all at once. This is faster than multiple calls to the decode at the instruction level.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
block |
Block
|
Block to decode |
required |
Returns:
Type | Description |
---|---|
List[PcodeOp]
|
A list of pcode operations |
Source code in quokka/backends/pypcode.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
|
pypcode_decode_instruction(inst)
Decode an instruction using Pypcode
This will return the list of Pcode operations done for the instruction. Note that a (binary) instruction is expected to have several pcode instructions associated. When decoding a single instruction IMARK instructions are excluded!
Parameters:
Name | Type | Description | Default |
---|---|---|---|
inst |
Instruction
|
Instruction to translate |
required |
Raises:
Type | Description |
---|---|
PypcodeError
|
if the decoding fails |
Returns:
Type | Description |
---|---|
Sequence[PcodeOp]
|
A sequence of PcodeOp |
Source code in quokka/backends/pypcode.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 |
|
update_pypcode_context(program, is_thumb)
Return an appropriate pypcode context for the decoding
For ARM architecture, if the block starts with a Thumb instruction, we must use a different pypcode Context.
We use the boolean is_thumb
directly to allow caching of the call here because it
is costly to generate the context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
program |
Program
|
Program to consider |
required |
is_thumb |
bool
|
Is the instruction a thumb one? |
required |
Returns:
Type | Description |
---|---|
Context
|
The correct pypcode context |
Source code in quokka/backends/pypcode.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
|