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 {
/**
* @param constant: Constant value
* @return: Constant value without prefix
* @param constant: Value which may have a 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) {
return constant.replaceFirst("^(const:)", "");
public static String removePrefix(String constant) {
return constant.replaceFirst("^([a-zA-Z]*:)", "");
}
......
......@@ -162,7 +162,7 @@ public class ParseCspecContent {
*/
public static ResourceFile getLdefFile() {
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();
}
if(processorDef.startsWith("PowerPC")) {
......
......@@ -31,7 +31,7 @@ public class TermCreator {
*/
public static Term<Program> createProgramTerm() {
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));
}
......@@ -195,10 +195,10 @@ public class TermCreator {
var.setName(HelperFunctions.renameVirtualRegister(node.getAddress().toString()));
var.setIsVirtual(true);
} else if (node.isConstant()) {
var.setValue(HelperFunctions.removeConstantPrefix(node.getAddress().toString()));
var.setValue(HelperFunctions.removePrefix(node.getAddress().toString()));
var.setIsVirtual(false);
} else if (node.isAddress()) {
var.setAddress(node.getAddress().toString());
var.setAddress(HelperFunctions.removePrefix(node.getAddress().toString()));
var.setIsVirtual(false);
} else if (node.isFree()) {
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