Merge remote-tracking branch 'origin/Ghidra_11.1'

This commit is contained in:
Ryan Kurtz 2024-06-03 06:25:17 -04:00
commit 8d8649ab5a
4 changed files with 25 additions and 71 deletions

View File

@ -407,24 +407,6 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
return FileSystemService.getInstance().getByteProvider(libFsrl, true, monitor);
}
/**
* Checks whether or not the given library should be loaded.
* <p>
* It may be appropriate to not load a specific library after examining its bytes.
*
* @param libraryName The name of the library
* @param libraryFsrl The library {@link FSRL}
* @param provider The library bytes
* @param desiredLoadSpec The desired {@link LoadSpec}
* @param log The log
* @return True if the given library should be loaded; otherwise, false
* @throws IOException If an IO-related error occurred
*/
protected boolean shouldLoadLibrary(String libraryName, FSRL libraryFsrl,
ByteProvider provider, LoadSpec desiredLoadSpec, MessageLog log) throws IOException {
return true;
}
/**
* Performs optional follow-on actions after an the given library has been loaded
*
@ -513,7 +495,6 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
// options turned off (if shouldSearchAllPaths() is overridden to return true).
// In this case, we still want to process those libraries, but we
// do not want to save them, so they can be released.
boolean found = false;
boolean loaded = false;
if (!customSearchPaths.isEmpty()) {
log.appendMsg("Searching %d custom path%s for library %s...".formatted(
@ -523,7 +504,6 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
provider, customSearchPaths, libraryDestFolderPath, unprocessed, depth,
desiredLoadSpec, options, log, consumer, monitor);
if (loadedLibrary != null) {
found = true;
loaded = true;
loadedPrograms.add(loadedLibrary);
}
@ -536,7 +516,6 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
provider, localSearchPaths, libraryDestFolderPath, unprocessed, depth,
desiredLoadSpec, options, log, consumer, monitor);
if (loadedLibrary != null) {
found = true;
if (loadLocalLibraries) {
loaded = true;
loadedPrograms.add(loadedLibrary);
@ -554,7 +533,6 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
provider, systemSearchPaths, libraryDestFolderPath, unprocessed, depth,
desiredLoadSpec, options, log, consumer, monitor);
if (loadedLibrary != null) {
found = true;
if (loadSystemLibraries) {
loaded = true;
loadedPrograms.add(loadedLibrary);
@ -564,9 +542,6 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
}
}
}
if (!found) {
log.appendMsg("Library not found.");
}
else {
if (loaded) {
log.appendMsg("Saving library to: " +
@ -641,6 +616,11 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
try {
List<FSRL> candidateLibraryFsrls =
findLibrary(getCheckedPath(libraryName), fsSearchPaths, log, monitor);
if (candidateLibraryFsrls.isEmpty()) {
log.appendMsg("Library not found.");
return null;
}
for (FSRL candidateLibraryFsrl : candidateLibraryFsrls) {
monitor.checkCancelled();
List<String> newLibraryList = new ArrayList<>();
@ -831,9 +811,6 @@ public abstract class AbstractLibrarySupportLoader extends AbstractProgramLoader
try (ByteProvider provider =
createLibraryByteProvider(libraryFsrl, desiredLoadSpec, log, monitor)) {
if (!shouldLoadLibrary(libraryName, libraryFsrl, provider, desiredLoadSpec, log)) {
return null;
}
LoadSpec libLoadSpec = matchSupportedLoadSpec(desiredLoadSpec, provider);
if (libLoadSpec == null) {

View File

@ -20,6 +20,7 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import generic.jar.ResourceFile;
import ghidra.app.util.Option;
import ghidra.app.util.OptionUtils;
import ghidra.app.util.bin.ByteProvider;
@ -31,7 +32,6 @@ import ghidra.framework.options.Options;
import ghidra.program.model.listing.Function;
import ghidra.program.model.listing.Program;
import ghidra.program.model.symbol.*;
import ghidra.util.Msg;
import ghidra.util.exception.*;
import ghidra.util.task.TaskMonitor;
@ -75,47 +75,33 @@ public abstract class AbstractOrdinalSupportLoader extends AbstractLibrarySuppor
return shouldPerformOrdinalLookup(options);
}
@Override
protected boolean shouldLoadLibrary(String libName, FSRL libFsrl, ByteProvider provider,
LoadSpec loadSpec, MessageLog log) throws IOException {
if (!super.shouldLoadLibrary(libName, libFsrl, provider, loadSpec, log)) {
return false;
}
int size = loadSpec.getLanguageCompilerSpec().getLanguageDescription().getSize();
File localLibFile = getLocalFile(libFsrl);
if (localLibFile == null ||
!LibraryLookupTable.hasFileAndPathAndTimeStampMatch(localLibFile, size) &&
LibraryLookupTable.libraryLookupTableFileExists(libName, size)) {
log.appendMsg("WARNING! Using existing exports file for " + libName +
" which may not be an exact match");
}
return true;
}
@Override
protected void processLibrary(Program lib, String libName, FSRL libFsrl, ByteProvider provider,
LoadSpec loadSpec, List<Option> options, MessageLog log, TaskMonitor monitor)
throws IOException, CancelledException {
int size = loadSpec.getLanguageCompilerSpec().getLanguageDescription().getSize();
File localLibFile = getLocalFile(libFsrl);
ResourceFile existingExportsFile = LibraryLookupTable.getExistingExportsFile(libName, size);
// Create exports file
if (localLibFile == null ||
!LibraryLookupTable.libraryLookupTableFileExists(libName, size) ||
!LibraryLookupTable.hasFileAndPathAndTimeStampMatch(localLibFile, size)) {
log.appendMsg("Examining ordinal info in %s...".formatted(libFsrl));
if (!shouldPerformOrdinalLookup(options)) {
return;
}
// Create exports file if necessary
if (existingExportsFile == null) {
try {
// Need to write correct library exports file (LibrarySymbolTable)
// for use with related imports
LibraryLookupTable.createFile(lib, true, monitor);
ResourceFile newExportsFile = LibraryLookupTable.createFile(lib, true, monitor);
log.appendMsg("Created exports file: " + newExportsFile);
}
catch (IOException e) {
log.appendMsg("Unable to create exports file for " + libFsrl);
Msg.error(this, "Unable to create exports file for " + libFsrl, e);
}
}
else {
log.appendMsg("Using existing exports file: " + existingExportsFile);
File localLibFile = getLocalFile(libFsrl);
if (localLibFile != null &&
!LibraryLookupTable.hasFileAndPathAndTimeStampMatch(localLibFile, size)) {
log.appendMsg("WARNING: Existing exports file may not be an exact match.");
}
}
}

View File

@ -220,6 +220,7 @@ public class LibraryLookupTable {
String cacheKey = LibrarySymbolTable.getCacheKey(dllName, size);
LibrarySymbolTable symTab = cacheMap.get(cacheKey);
if (symTab != null) {
log.appendMsg("Applying cached symbols from " + dllName);
return symTab;
}

View File

@ -32,9 +32,6 @@ import ghidra.graph.viewer.vertex.VisualVertexRenderer;
*/
public class FcgComponent extends GraphComponent<FcgVertex, FcgEdge, FunctionCallGraph> {
// our parent stores a reference to this graph, but we do it here to maintain its type
private FunctionCallGraph fcGraph;
private FcgVertexPaintTransformer vertexPaintTransformer =
new FcgVertexPaintTransformer(FcgVertex.DEFAULT_VERTEX_SHAPE_COLOR);
@ -55,7 +52,7 @@ public class FcgComponent extends GraphComponent<FcgVertex, FcgEdge, FunctionCal
@Override
protected FcgVertex getInitialVertex() {
return fcGraph.getSource();
return graph.getSource();
}
@Override
@ -91,13 +88,6 @@ public class FcgComponent extends GraphComponent<FcgVertex, FcgEdge, FunctionCal
edgeRenderer.setDrawColorTransformer(satelliteEdgePaintTransformer);
}
@Override
public void dispose() {
fcGraph = null;
super.dispose();
}
@Override // open access for testing
public VisualGraphViewUpdater<FcgVertex, FcgEdge> getViewUpdater() {
return super.getViewUpdater();