Unverified Commit 19eac24e by Enkelmann Committed by GitHub

fix some (but not all) AVR8 issues (#286)

parent c0a33fc9
...@@ -94,13 +94,13 @@ public final class HelperFunctions { ...@@ -94,13 +94,13 @@ public final class HelperFunctions {
/** /**
* @param constant: Constant value * @param constant: Value which may have a prefix
* @return: Constant value without prefix * @return: Value without prefix
* *
* Removes the consts prefix from the constant. * Removes prefixes like "const:" and "mem:" from the constant.
*/ */
public static String removeConstantPrefix(String constant) { public static String removePrefix(String constant) {
return constant.replaceFirst("^(const:)", ""); return constant.replaceFirst("^([a-zA-Z]*:)", "");
} }
......
...@@ -162,7 +162,7 @@ public class ParseCspecContent { ...@@ -162,7 +162,7 @@ public class ParseCspecContent {
*/ */
public static ResourceFile getLdefFile() { public static ResourceFile getLdefFile() {
String processorDef = String.format("%s.ldefs", program.getLanguage().getLanguageDescription().getProcessor().toString()); String processorDef = String.format("%s.ldefs", program.getLanguage().getLanguageDescription().getProcessor().toString());
if(processorDef.startsWith("MIPS")) { if(processorDef.startsWith("MIPS") || processorDef.startsWith("AVR")) {
processorDef = processorDef.toLowerCase(); processorDef = processorDef.toLowerCase();
} }
if(processorDef.startsWith("PowerPC")) { if(processorDef.startsWith("PowerPC")) {
......
...@@ -31,7 +31,7 @@ public class TermCreator { ...@@ -31,7 +31,7 @@ public class TermCreator {
*/ */
public static Term<Program> createProgramTerm() { public static Term<Program> createProgramTerm() {
Tid progTid = new Tid(String.format("prog_%s", HelperFunctions.ghidraProgram.getMinAddress().toString()), HelperFunctions.ghidraProgram.getMinAddress().toString()); Tid progTid = new Tid(String.format("prog_%s", HelperFunctions.ghidraProgram.getMinAddress().toString()), HelperFunctions.ghidraProgram.getMinAddress().toString());
String imageBase = HelperFunctions.ghidraProgram.getImageBase().toString(); String imageBase = HelperFunctions.removePrefix(HelperFunctions.ghidraProgram.getImageBase().toString());
return new Term<Program>(progTid, new Program(new ArrayList<Term<Sub>>(), HelperFunctions.addEntryPoints(symTab), imageBase)); return new Term<Program>(progTid, new Program(new ArrayList<Term<Sub>>(), HelperFunctions.addEntryPoints(symTab), imageBase));
} }
...@@ -195,10 +195,10 @@ public class TermCreator { ...@@ -195,10 +195,10 @@ public class TermCreator {
var.setName(HelperFunctions.renameVirtualRegister(node.getAddress().toString())); var.setName(HelperFunctions.renameVirtualRegister(node.getAddress().toString()));
var.setIsVirtual(true); var.setIsVirtual(true);
} else if (node.isConstant()) { } else if (node.isConstant()) {
var.setValue(HelperFunctions.removeConstantPrefix(node.getAddress().toString())); var.setValue(HelperFunctions.removePrefix(node.getAddress().toString()));
var.setIsVirtual(false); var.setIsVirtual(false);
} else if (node.isAddress()) { } else if (node.isAddress()) {
var.setAddress(node.getAddress().toString()); var.setAddress(HelperFunctions.removePrefix(node.getAddress().toString()));
var.setIsVirtual(false); var.setIsVirtual(false);
} else if (node.isFree()) { } else if (node.isFree()) {
var.setAddress(HelperFunctions.removeStackPrefix(node.getAddress().toString())); var.setAddress(HelperFunctions.removeStackPrefix(node.getAddress().toString()));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment