Skip to content

Commit

Permalink
Update to Ghidra 10.4, close #33, #34
Browse files Browse the repository at this point in the history
  • Loading branch information
kotcrab committed Oct 22, 2023
1 parent e4885e9 commit 747b88f
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ghidra: [ '10.3', '10.3.1', '10.3.2', '10.3.3' ]
ghidra: [ '10.4' ]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ghidra: [ '10.3', '10.3.1', '10.3.2', '10.3.3' ]
ghidra: [ '10.4' ]
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### Version 17
- Updated to Ghidra 10.4

#### Version 16
- Updated to Ghidra 10.3
- [#25](https://github.com/kotcrab/ghidra-allegrex/issues/25) - added support for type A relocations only present in program headers
Expand Down
25 changes: 20 additions & 5 deletions src/main/kotlin/allegrex/MipsInstructionStasher.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import allegrex.MipsInstructionStasher.LinkedCuRestorePolicy.RestoreLast
import ghidra.program.model.address.Address
import ghidra.program.model.lang.InstructionPrototype
import ghidra.program.model.lang.ProgramProcessorContext
import ghidra.program.model.listing.FlowOverride
import ghidra.program.model.listing.Program
import ghidra.program.model.mem.DumbMemBufferImpl
import ghidra.program.model.symbol.Reference
Expand Down Expand Up @@ -56,15 +57,23 @@ private class CodeUnitCtx(
val minAddress: Address,
val maxAddress: Address,
val prototype: InstructionPrototype,
val referencesFrom: Array<Reference>
val referencesFrom: Array<Reference>,
val flowOverride: FlowOverride,
val fallthroughOverride: Address?,
val lengthOverride: Int
) {
companion object {
fun fromProgram(program: Program, address: Address): CodeUnitCtx? {
val instruction = program.listing.getInstructionContaining(address) ?: return null
return CodeUnitCtx(
program,
instruction.minAddress, instruction.maxAddress,
instruction.prototype, instruction.referencesFrom
program = program,
minAddress = instruction.minAddress,
maxAddress = instruction.maxAddress,
prototype = instruction.prototype,
referencesFrom = instruction.referencesFrom,
flowOverride = instruction.flowOverride,
fallthroughOverride = if (instruction.isFallThroughOverridden) instruction.fallThrough else null,
lengthOverride = if (instruction.isLengthOverridden) instruction.length else 0
)
}
}
Expand All @@ -76,7 +85,13 @@ private class CodeUnitCtx(
fun restore() {
val buf = DumbMemBufferImpl(program.memory, minAddress)
val context = ProgramProcessorContext(program.programContext, minAddress)
program.listing.createInstruction(minAddress, prototype, buf, context)
val instruction = program.listing.createInstruction(minAddress, prototype, buf, context, lengthOverride)
if (flowOverride != FlowOverride.NONE) {
instruction.flowOverride = flowOverride
}
if (fallthroughOverride != null) {
instruction.fallThrough = fallthroughOverride
}
for (reference in referencesFrom) {
if (reference.source != SourceType.DEFAULT) {
program.referenceManager.addReference(reference)
Expand Down

0 comments on commit 747b88f

Please sign in to comment.