Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2021-09-03 08:32:55 -04:00
commit c11c12a74f
2 changed files with 10 additions and 9 deletions

View File

@ -23,11 +23,11 @@ public class RegisterManager {
private List<Register> registers;
private Map<String, Register> registerNameMap = new HashMap<String, Register>(); // include aliases and case-variations
private List<String> registerNames; // alphabetical sorted list, excludes aliases
private List<Register> contextRegisters;
private Register contextBaseRegister;
private Map<RegisterSizeKey, Register> sizeMap = new HashMap<RegisterSizeKey, Register>();
private Map<Address, List<Register>> registerAddressMap =
new HashMap<Address, List<Register>>();
@ -124,6 +124,11 @@ public class RegisterManager {
populateSizeMapLittleEndian(reg);
}
}
// if there is no context register, force a default one
if (contextBaseRegister == null) {
contextBaseRegister =
new Register("DEFAULT_CONTEXT", "DEFAULT_CONTEXT", Address.NO_ADDRESS, 4, true, 0);
}
// handle the register size 0 case;
Collections.reverse(registerListSortedBySize);
for (Register register : registerListSortedBySize) {
@ -275,7 +280,8 @@ public class RegisterManager {
*/
private static int compareVectorRegisters(Register reg1, Register reg2) {
if (!(reg1.isVectorRegister() && reg2.isVectorRegister())) {
throw new IllegalArgumentException("compareVectorRegisters can only be applied to vector registers!");
throw new IllegalArgumentException(
"compareVectorRegisters can only be applied to vector registers!");
}
//want registers sorted in descending order of size
int sizeComp = Integer.compare(reg2.getBitLength(), reg1.getBitLength());

View File

@ -18,13 +18,12 @@ package ghidra.program.util;
import java.util.Arrays;
import java.util.List;
import ghidra.program.model.address.Address;
import ghidra.program.model.lang.*;
import ghidra.program.model.listing.DefaultProgramContext;
import ghidra.program.model.listing.ProgramContext;
abstract public class AbstractProgramContext implements ProgramContext, DefaultProgramContext {
protected Language language;
protected Register baseContextRegister;
@ -116,10 +115,6 @@ abstract public class AbstractProgramContext implements ProgramContext, DefaultP
protected void init(Language lang) {
this.language = lang;
baseContextRegister = lang.getContextBaseRegister();
if (baseContextRegister == null) {
baseContextRegister =
new Register("DEFAULT_CONTEXT", "DEFAULT_CONTEXT", Address.NO_ADDRESS, 4, true, 0);
}
defaultDisassemblyContext = new RegisterValue(baseContextRegister);
nonFlowingContextRegisterMask = baseContextRegister.getBaseMask().clone();