mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-27 23:17:03 +08:00
GP-2838 - PDB Fix primary symbol override logic for functions, affecting
function sigs from mangled.
This commit is contained in:
+15
@@ -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
|
||||||
|
|||||||
+25
-14
@@ -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,23 +318,24 @@ 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)) {
|
||||||
FunctionDefinition def = (FunctionDefinition) dataType;
|
return false;
|
||||||
ApplyFunctionSignatureCmd sigCmd =
|
}
|
||||||
new ApplyFunctionSignatureCmd(address, def, SourceType.IMPORTED);
|
FunctionDefinition def = (FunctionDefinition) dataType;
|
||||||
if (!sigCmd.applyTo(applicator.getProgram(), monitor)) {
|
ApplyFunctionSignatureCmd sigCmd =
|
||||||
applicator.appendLogMsg(
|
new ApplyFunctionSignatureCmd(address, def, SourceType.IMPORTED);
|
||||||
"PDB Warning: Failed to apply signature to function at address " + address +
|
if (!sigCmd.applyTo(applicator.getProgram(), monitor)) {
|
||||||
" due to " + sigCmd.getStatusMsg() + "; dataType: " + def.getName());
|
applicator.appendLogMsg(
|
||||||
return false;
|
"PDB Warning: Failed to apply signature to function at address " + address +
|
||||||
}
|
" due to " + sigCmd.getStatusMsg() + "; dataType: " + def.getName());
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user