Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cwe_checker
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fact-depend
cwe_checker
Commits
44a194f7
Unverified
Commit
44a194f7
authored
Apr 27, 2021
by
Melvin Klimke
Committed by
GitHub
Apr 27, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Fixed issue #169 (#171)
parent
41088680
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
4 deletions
+12
-4
PcodeExtractor.java
src/ghidra/p_code_extractor/PcodeExtractor.java
+5
-0
JumpProcessing.java
src/ghidra/p_code_extractor/internal/JumpProcessing.java
+2
-3
TermCreator.java
src/ghidra/p_code_extractor/internal/TermCreator.java
+5
-1
No files found.
src/ghidra/p_code_extractor/PcodeExtractor.java
View file @
44a194f7
...
@@ -214,11 +214,16 @@ public class PcodeExtractor extends GhidraScript {
...
@@ -214,11 +214,16 @@ public class PcodeExtractor extends GhidraScript {
*/
*/
protected
Boolean
iteratePcode
()
{
protected
Boolean
iteratePcode
()
{
int
numberOfPcodeOps
=
PcodeBlockData
.
ops
.
length
;
int
numberOfPcodeOps
=
PcodeBlockData
.
ops
.
length
;
int
previousPcodeIndex
=
0
;
Boolean
intraInstructionJumpOccured
=
false
;
Boolean
intraInstructionJumpOccured
=
false
;
PcodeBlockData
.
pcodeIndex
=
0
;
PcodeBlockData
.
pcodeIndex
=
0
;
for
(
PcodeOp
op
:
PcodeBlockData
.
ops
)
{
for
(
PcodeOp
op
:
PcodeBlockData
.
ops
)
{
PcodeBlockData
.
pcodeOp
=
op
;
PcodeBlockData
.
pcodeOp
=
op
;
String
mnemonic
=
PcodeBlockData
.
pcodeOp
.
getMnemonic
();
String
mnemonic
=
PcodeBlockData
.
pcodeOp
.
getMnemonic
();
if
(
previousPcodeIndex
<
PcodeBlockData
.
pcodeIndex
-
1
)
{
numberOfPcodeOps
++;
}
previousPcodeIndex
=
PcodeBlockData
.
pcodeIndex
;
if
(
JumpProcessing
.
jumps
.
contains
(
mnemonic
)
||
PcodeBlockData
.
pcodeOp
.
getOpcode
()
==
PcodeOp
.
UNIMPLEMENTED
)
{
if
(
JumpProcessing
.
jumps
.
contains
(
mnemonic
)
||
PcodeBlockData
.
pcodeOp
.
getOpcode
()
==
PcodeOp
.
UNIMPLEMENTED
)
{
intraInstructionJumpOccured
=
JumpProcessing
.
processJump
(
mnemonic
,
numberOfPcodeOps
);
intraInstructionJumpOccured
=
JumpProcessing
.
processJump
(
mnemonic
,
numberOfPcodeOps
);
}
else
{
}
else
{
...
...
src/ghidra/p_code_extractor/internal/JumpProcessing.java
View file @
44a194f7
...
@@ -45,7 +45,7 @@ public final class JumpProcessing {
...
@@ -45,7 +45,7 @@ public final class JumpProcessing {
return
processJumpInPcodeBlock
(
mnemonic
,
numberOfPcodeOps
,
currentBlock
);
return
processJumpInPcodeBlock
(
mnemonic
,
numberOfPcodeOps
,
currentBlock
);
}
}
processJumpAtEndOfPcodeBlocks
(
mnemonic
,
numberOfPcodeOps
,
currentBlock
);
processJumpAtEndOfPcodeBlocks
(
mnemonic
,
currentBlock
);
return
false
;
return
false
;
}
}
...
@@ -53,13 +53,12 @@ public final class JumpProcessing {
...
@@ -53,13 +53,12 @@ public final class JumpProcessing {
/**
/**
*
*
* @param mnemonic: pcode mnemonic
* @param mnemonic: pcode mnemonic
* @param numberOfPcodeOps: number of pcode instruction in pcode block
* @param currentBlock: current block term
* @param currentBlock: current block term
*
*
* Process jumps at the end of pcode blocks
* Process jumps at the end of pcode blocks
* If it is a return block, the call return address is changed to the current block
* If it is a return block, the call return address is changed to the current block
*/
*/
private
static
void
processJumpAtEndOfPcodeBlocks
(
String
mnemonic
,
int
numberOfPcodeOps
,
Term
<
Blk
>
currentBlock
)
{
private
static
void
processJumpAtEndOfPcodeBlocks
(
String
mnemonic
,
Term
<
Blk
>
currentBlock
)
{
// Case 1: jump at the end of pcode group but not end of ghidra generated block. Create a block for the next assembly instruction.
// Case 1: jump at the end of pcode group but not end of ghidra generated block. Create a block for the next assembly instruction.
if
(
PcodeBlockData
.
instructionIndex
<
PcodeBlockData
.
numberOfInstructionsInBlock
-
1
&&
PcodeBlockData
.
instruction
.
getDelaySlotDepth
()
==
0
)
{
if
(
PcodeBlockData
.
instructionIndex
<
PcodeBlockData
.
numberOfInstructionsInBlock
-
1
&&
PcodeBlockData
.
instruction
.
getDelaySlotDepth
()
==
0
)
{
PcodeBlockData
.
blocks
.
add
(
TermCreator
.
createBlkTerm
(
PcodeBlockData
.
instruction
.
getFallThrough
().
toString
(),
null
));
PcodeBlockData
.
blocks
.
add
(
TermCreator
.
createBlkTerm
(
PcodeBlockData
.
instruction
.
getFallThrough
().
toString
(),
null
));
...
...
src/ghidra/p_code_extractor/internal/TermCreator.java
View file @
44a194f7
...
@@ -348,7 +348,11 @@ public class TermCreator {
...
@@ -348,7 +348,11 @@ public class TermCreator {
callString
=
"unimplemented"
;
callString
=
"unimplemented"
;
call
=
new
Call
(
null
,
createLabel
(
PcodeBlockData
.
instruction
.
getFallThrough
()),
callString
);
call
=
new
Call
(
null
,
createLabel
(
PcodeBlockData
.
instruction
.
getFallThrough
()),
callString
);
}
else
{
}
else
{
call
=
new
Call
(
createLabel
(
null
),
createLabel
(
PcodeBlockData
.
instruction
.
getFallThrough
()));
if
(
PcodeBlockData
.
instruction
.
getFallThrough
()
==
null
)
{
call
=
new
Call
(
createLabel
(
null
));
}
else
{
call
=
new
Call
(
createLabel
(
null
),
createLabel
(
PcodeBlockData
.
instruction
.
getFallThrough
()));
}
}
}
return
call
;
return
call
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment