Program specific, user-defined, cspec extensions

Documentation for spec extensions

Handle extensions with parse errors
Export button for spec extensions
Pop-up dialog for parse errors in user-defined specification extensions
GP-653 corrected some minor issues and established new ProgramDB version
make incremental initialization constructor for AddressSized private
Make AddressSized fields private
More adjustments to AddressSized
Review fixes for BasicCompilerSpec
Take restoreXml out of DataOrganization interface
Remove restoreXml from BitFieldPacking interface
More review fixes
Prevent callotherfixup extension with non-existent target
Suggested export name
More documentation for SpecExtension
Support for undo/redo with spec extensions
Documentation for ConstructTpl
Split out ProgramCompilerSpec and other changes for review
Changes after next round of reviews
This commit is contained in:
caheckman 2021-02-02 13:07:54 -05:00 committed by ghidra1
parent 27fbe7278d
commit a5d4ca3cab
108 changed files with 7997 additions and 1997 deletions

View file

@ -28,10 +28,12 @@ import ghidra.app.util.importer.MessageLog;
import ghidra.file.analyzers.FileFormatAnalyzer;
import ghidra.file.formats.android.dex.format.*;
import ghidra.file.formats.android.dex.util.DexUtil;
import ghidra.program.database.ProgramCompilerSpec;
import ghidra.program.model.address.Address;
import ghidra.program.model.address.AddressSetView;
import ghidra.program.model.data.*;
import ghidra.program.model.lang.*;
import ghidra.program.model.lang.Language;
import ghidra.program.model.lang.Register;
import ghidra.program.model.listing.*;
import ghidra.program.model.listing.Function.FunctionUpdateType;
import ghidra.program.model.mem.Memory;
@ -65,7 +67,7 @@ public class DexHeaderFormatAnalyzer extends FileFormatAnalyzer {
createInitialFragments(program, header, monitor);
BasicCompilerSpec.enableJavaLanguageDecompilation(program);
ProgramCompilerSpec.enableJavaLanguageDecompilation(program);
createNamespaces(program, header, monitor, log);
processMap(program, header, monitor, log);
processStrings(program, header, monitor, log);
@ -172,11 +174,9 @@ public class DexHeaderFormatAnalyzer extends FileFormatAnalyzer {
return;
}
for (int i = 0; i < methods.size(); ++i) {
for (EncodedMethod encodedMethod : methods) {
monitor.checkCanceled();
EncodedMethod encodedMethod = methods.get(i);
MethodIDItem methodID = header.getMethods().get(encodedMethod.getMethodIndex());
String methodName = DexUtil.convertToString(header, methodID.getNameIndex());
@ -213,8 +213,8 @@ public class DexHeaderFormatAnalyzer extends FileFormatAnalyzer {
Namespace classNameSpace, MessageLog log) {
program.getSymbolTable().addExternalEntryPoint(methodAddress);
try {
return program.getSymbolTable().createLabel(methodAddress, methodName, classNameSpace,
SourceType.ANALYSIS);
return program.getSymbolTable()
.createLabel(methodAddress, methodName, classNameSpace, SourceType.ANALYSIS);
}
catch (InvalidInputException e) {
log.appendException(e);
@ -240,8 +240,8 @@ public class DexHeaderFormatAnalyzer extends FileFormatAnalyzer {
commentBuilder.append("Method Debug Info Offset: 0x" +
Integer.toHexString(codeItem.getDebugInfoOffset()) + "\n");
}
commentBuilder.append(
"Method ID Offset: 0x" + Long.toHexString(methodID.getFileOffset()) + "\n");
commentBuilder
.append("Method ID Offset: 0x" + Long.toHexString(methodID.getFileOffset()) + "\n");
setPlateComment(program, methodAddress, commentBuilder.toString());
}
@ -522,11 +522,9 @@ public class DexHeaderFormatAnalyzer extends FileFormatAnalyzer {
private void processEncodedMethods(Program program, DexHeader header, ClassDefItem item,
List<EncodedMethod> methods, TaskMonitor monitor) throws Exception {
for (int i = 0; i < methods.size(); ++i) {
for (EncodedMethod method : methods) {
monitor.checkCanceled();
EncodedMethod method = methods.get(i);
MethodIDItem methodID = header.getMethods().get(method.getMethodIndex());
StringBuilder builder = new StringBuilder();
@ -662,7 +660,8 @@ public class DexHeaderFormatAnalyzer extends FileFormatAnalyzer {
methodAddress.add(setItemDataType.getLength()));
processAnnotationSetItem(program, setItem, monitor, log);
}
for (ParameterAnnotation parameter : annotationsDirectoryItem.getParameterAnnotations()) {
for (ParameterAnnotation parameter : annotationsDirectoryItem
.getParameterAnnotations()) {
monitor.checkCanceled();
Address parameterAddress = toAddr(program, parameter.getAnnotationsOffset());
AnnotationSetReferenceList annotationSetReferenceList =
@ -767,9 +766,9 @@ public class DexHeaderFormatAnalyzer extends FileFormatAnalyzer {
classNameSpace, log);
if (methodSymbol != null) {
String externalName = methodSymbol.getName(true);
program.getReferenceManager().addExternalReference(methodIndexAddress,
"EXTERNAL.dex", externalName, null, SourceType.ANALYSIS, 0,
RefType.DATA);
program.getReferenceManager()
.addExternalReference(methodIndexAddress, "EXTERNAL.dex",
externalName, null, SourceType.ANALYSIS, 0, RefType.DATA);
}
}
}