Merge remote-tracking branch 'origin/patch'

This commit is contained in:
Ryan Kurtz 2022-11-15 00:45:13 -05:00
commit 81fd59389d
5 changed files with 46 additions and 25 deletions

View file

@ -272,6 +272,21 @@ public class DefaultPdbApplicator implements PdbApplicator {
// return; // return;
// } // }
// WANTED TO put the following block in place of the one beneath it, but it would require
// that we visit all appliers to make sure they have the requisite logic to override
// primary mangled symbols with the appropriate global symbols that have the data types.
// See FunctionSymbolApplier for logic used in the "if" case below.
// // Processing public (mangled) symbols first, but global symbol processing can change
// // which symbol is marked primary to the global one if that global symbol provided a rich
// // function definition data type. Doing this will prevent the mangled symbol from applying
// // the function signature (unless there is an option set to force the mangled symbol to be
// // the primary symbol).
// processPublicSymbols();
// processGlobalSymbolsNoTypedefs();
// WANTED TO replace the following block with the one above. See comment above.
// Doing globals before publics, as publics are those that can have mangled names. By // Doing globals before publics, as publics are those that can have mangled names. By
// applying the non-mangled symbols first, we can get full type information from the // applying the non-mangled symbols first, we can get full type information from the
// underlying type. Then we can apply the mangled symbols and demangle them without // underlying type. Then we can apply the mangled symbols and demangle them without

View file

@ -252,17 +252,22 @@ public class FunctionSymbolApplier extends MsSymbolApplier {
} }
private boolean applyFunction(TaskMonitor monitor) { private boolean applyFunction(TaskMonitor monitor) {
applicator.createSymbol(address, getName(), true);
function = createFunction(monitor); function = createFunction(monitor);
if (function == null) { if (function == null) {
return false; return false;
} }
boolean succeededSetFunctionSignature = false;
if (!function.isThunk() && if (!function.isThunk() &&
function.getSignatureSource().isLowerPriorityThan(SourceType.IMPORTED)) { function.getSignatureSource().isLowerPriorityThan(SourceType.IMPORTED)) {
setFunctionDefinition(monitor); succeededSetFunctionSignature = setFunctionDefinition(monitor);
function.setNoReturn(isNonReturning); function.setNoReturn(isNonReturning);
} }
// If signature was set, then override existing primary mangled symbol with
// the global symbol that provided this signature so that Demangler does not overwrite
// the richer data type we get with global symbols.
applicator.createSymbol(address, getName(), succeededSetFunctionSignature);
currentFrameSize = 0; currentFrameSize = 0;
return true; return true;
} }
@ -289,11 +294,16 @@ public class FunctionSymbolApplier extends MsSymbolApplier {
return myFunction; return myFunction;
} }
/**
* returns true only if we set a function signature
* @param monitor monitor
* @return true if function signature was set
*/
private boolean setFunctionDefinition(TaskMonitor monitor) { private boolean setFunctionDefinition(TaskMonitor monitor) {
if (procedureSymbol == null) { if (procedureSymbol == null) {
// TODO: is there anything we can do with thunkSymbol? // TODO: is there anything we can do with thunkSymbol?
// long x = thunkSymbol.getParentPointer(); // long x = thunkSymbol.getParentPointer();
return true; return false;
} }
// Rest presumes procedureSymbol. // Rest presumes procedureSymbol.
RecordNumber typeRecordNumber = procedureSymbol.getTypeRecordNumber(); RecordNumber typeRecordNumber = procedureSymbol.getTypeRecordNumber();
@ -308,14 +318,16 @@ public class FunctionSymbolApplier extends MsSymbolApplier {
((PrimitiveTypeApplier) applier).isNoType())) { ((PrimitiveTypeApplier) applier).isNoType())) {
applicator.appendLogMsg("Error: Failed to resolve datatype RecordNumber " + applicator.appendLogMsg("Error: Failed to resolve datatype RecordNumber " +
typeRecordNumber + " at " + address); typeRecordNumber + " at " + address);
return false;
} }
return false;
} }
DataType dataType = applier.getDataType(); DataType dataType = applier.getDataType();
// Since we know the applier is an AbstractionFunctionTypeApplier, then dataType is either // Since we know the applier is an AbstractionFunctionTypeApplier, then dataType is either
// FunctionDefinition or no type (typedef). // FunctionDefinition or no type (typedef).
if (dataType instanceof FunctionDefinition) { if (!(dataType instanceof FunctionDefinition)) {
return false;
}
FunctionDefinition def = (FunctionDefinition) dataType; FunctionDefinition def = (FunctionDefinition) dataType;
ApplyFunctionSignatureCmd sigCmd = ApplyFunctionSignatureCmd sigCmd =
new ApplyFunctionSignatureCmd(address, def, SourceType.IMPORTED); new ApplyFunctionSignatureCmd(address, def, SourceType.IMPORTED);
@ -325,7 +337,6 @@ public class FunctionSymbolApplier extends MsSymbolApplier {
" due to " + sigCmd.getStatusMsg() + "; dataType: " + def.getName()); " due to " + sigCmd.getStatusMsg() + "; dataType: " + def.getName());
return false; return false;
} }
}
return true; return true;
} }

View file

@ -23,10 +23,6 @@ import java.util.concurrent.CopyOnWriteArrayList;
import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener; import javax.swing.event.ChangeListener;
import org.apache.commons.text.StringEscapeUtils;
import com.google.common.base.Splitter;
import docking.Tool; import docking.Tool;
import docking.options.editor.*; import docking.options.editor.*;
import ghidra.framework.options.*; import ghidra.framework.options.*;
@ -250,11 +246,6 @@ public class GraphDisplayOptions implements OptionsChangeListener {
if (vertexLabel == null) { if (vertexLabel == null) {
vertexLabel = vertex.getName(); vertexLabel = vertex.getName();
} }
if (vertexLabel.contains("\n")) {
vertexLabel = StringEscapeUtils.escapeHtml4(vertexLabel);
return "<html>" + String.join("<p>", Splitter.on('\n').split(vertexLabel));
}
return vertexLabel; return vertexLabel;
} }

View file

@ -664,6 +664,10 @@ public abstract class PcodeEmit {
AddressSpace spc = vn.getSpace().fixSpace(walker); AddressSpace spc = vn.getSpace().fixSpace(walker);
Address addr = spc.getTruncatedAddress(vn.getOffset().fix(walker), false); Address addr = spc.getTruncatedAddress(vn.getOffset().fix(walker), false);
// translate the address into the overlayspace if we have an overlayspace. // translate the address into the overlayspace if we have an overlayspace.
if (startAddress.getAddressSpace().isOverlaySpace()) {
OverlayAddressSpace overSpace = (OverlayAddressSpace) startAddress.getAddressSpace();
addr = overSpace.getOverlayAddress(addr);
}
ParserWalker oldwalker = walker; ParserWalker oldwalker = walker;
long olduniqueoffset = uniqueoffset; long olduniqueoffset = uniqueoffset;
setUniqueOffset(addr); setUniqueOffset(addr);

View file

@ -40,7 +40,7 @@ public class TypedefDataType extends GenericDataType implements TypeDef {
* @param dt data type that is being typedef'ed (may not be null) * @param dt data type that is being typedef'ed (may not be null)
*/ */
public TypedefDataType(String name, DataType dt) { public TypedefDataType(String name, DataType dt) {
this(CategoryPath.ROOT, name, dt, null); this(CategoryPath.ROOT, name, dt, dt.getDataTypeManager());
} }
/** /**
@ -50,7 +50,7 @@ public class TypedefDataType extends GenericDataType implements TypeDef {
* @param dt data type that is being typedef'ed (may not be null) * @param dt data type that is being typedef'ed (may not be null)
*/ */
public TypedefDataType(CategoryPath path, String name, DataType dt) { public TypedefDataType(CategoryPath path, String name, DataType dt) {
this(path, name, dt, null); this(path, name, dt, dt.getDataTypeManager());
} }
/** /**