-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support for PPC VLE as a sub-isa. Patchmaker support, plus automated …
…tests. Ghidra analysis and unpackers support.
- Loading branch information
Paul Noalhyt
committed
Jun 26, 2023
1 parent
7bdeeef
commit b3c1af4
Showing
17 changed files
with
390 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
disassemblers/ofrak_ghidra/ofrak_ghidra/ghidra_scripts/PreAnalyzePPCVLE.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import ghidra.app.script.GhidraScript; | ||
import ghidra.program.model.mem.*; | ||
import ghidra.program.model.lang.*; | ||
import ghidra.program.model.pcode.*; | ||
import ghidra.program.model.util.*; | ||
import ghidra.program.model.reloc.*; | ||
import ghidra.program.model.data.*; | ||
import ghidra.program.model.block.*; | ||
import ghidra.program.model.symbol.*; | ||
import ghidra.program.model.scalar.*; | ||
import ghidra.program.model.listing.*; | ||
import ghidra.program.model.address.*; | ||
|
||
import java.math.BigInteger; | ||
|
||
public class PreAnalyzePPCVLE extends GhidraScript { | ||
|
||
@Override | ||
public void run() throws Exception { | ||
try { | ||
// Set the language to PPC VLE | ||
Language language = (Language) getLanguage(new LanguageID("PowerPC:BE:64:VLE-32addr")); | ||
Program p = currentProgram; | ||
p.setLanguage(language, language.getDefaultCompilerSpec().getCompilerSpecID(), false, monitor); | ||
ProgramContext programContext = p.getProgramContext(); | ||
// Set the vle bit (Ghidra has a "vle" register for that, but on real devices, the VLE | ||
// bit is defined per memory page, as a page attribute bit) so that instructions are | ||
// decoded correctly. | ||
for (Register register : programContext.getContextRegisters()) { | ||
if (register.getName().equals("vle")){ | ||
RegisterValue newValue = new RegisterValue(programContext.getBaseContextRegister()); | ||
BigInteger value = BigInteger.ONE; | ||
newValue = setRegisterValue(newValue, register, value); | ||
programContext.setDefaultDisassemblyContext(newValue); | ||
println("Set the vle bit."); | ||
} | ||
} | ||
} catch(Exception e) { | ||
println(e.toString()); | ||
e.printStackTrace(System.out); | ||
throw e; | ||
} | ||
} | ||
|
||
private RegisterValue setRegisterValue(RegisterValue registerValue, Register register, | ||
BigInteger value) { | ||
RegisterValue newValue = new RegisterValue(register, value); | ||
return registerValue.combineValues(newValue); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
ofrak_patch_maker/ofrak_patch_maker_test/example_2/bom1.vle.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.global _main1 | ||
_main1: | ||
add 1, 1, 2 | ||
add 1, 1, 2 | ||
add 1, 1, 2 | ||
add 1, 1, 2 | ||
add 1, 1, 2 |
7 changes: 7 additions & 0 deletions
7
ofrak_patch_maker/ofrak_patch_maker_test/example_2/bom2.vle.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.global _main2 | ||
_main2: | ||
add 2, 2, 3 | ||
add 2, 2, 3 | ||
add 2, 2, 3 | ||
add 2, 2, 3 | ||
add 2, 2, 3 |
7 changes: 7 additions & 0 deletions
7
ofrak_patch_maker/ofrak_patch_maker_test/example_2/bom3.vle.S
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
.global _main3 | ||
_main3: | ||
add 3, 3, 4 | ||
add 3, 3, 4 | ||
add 3, 3, 4 | ||
add 3, 3, 4 | ||
add 3, 3, 4 |
2 changes: 2 additions & 0 deletions
2
ofrak_patch_maker/ofrak_patch_maker_test/test_alignment/patch_vle.as
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.align 1 | ||
se_mflr 0 |
Oops, something went wrong.