mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-05 19:42:36 +02:00
Merge remote-tracking branch
'origin/GP-2838_ghizard_fix_PDB_primary_symbol_override_logic_for_functions' into patch (Closes #4735)
This commit is contained in:
commit
7fb60e9ac7
2 changed files with 40 additions and 14 deletions
|
@ -272,6 +272,21 @@ public class DefaultPdbApplicator implements PdbApplicator {
|
|||
// 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
|
||||
// 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
|
||||
|
|
|
@ -252,17 +252,22 @@ public class FunctionSymbolApplier extends MsSymbolApplier {
|
|||
}
|
||||
|
||||
private boolean applyFunction(TaskMonitor monitor) {
|
||||
applicator.createSymbol(address, getName(), true);
|
||||
function = createFunction(monitor);
|
||||
if (function == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean succeededSetFunctionSignature = false;
|
||||
if (!function.isThunk() &&
|
||||
function.getSignatureSource().isLowerPriorityThan(SourceType.IMPORTED)) {
|
||||
setFunctionDefinition(monitor);
|
||||
succeededSetFunctionSignature = setFunctionDefinition(monitor);
|
||||
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;
|
||||
return true;
|
||||
}
|
||||
|
@ -289,11 +294,16 @@ public class FunctionSymbolApplier extends MsSymbolApplier {
|
|||
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) {
|
||||
if (procedureSymbol == null) {
|
||||
// TODO: is there anything we can do with thunkSymbol?
|
||||
// long x = thunkSymbol.getParentPointer();
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
// Rest presumes procedureSymbol.
|
||||
RecordNumber typeRecordNumber = procedureSymbol.getTypeRecordNumber();
|
||||
|
@ -308,14 +318,16 @@ public class FunctionSymbolApplier extends MsSymbolApplier {
|
|||
((PrimitiveTypeApplier) applier).isNoType())) {
|
||||
applicator.appendLogMsg("Error: Failed to resolve datatype RecordNumber " +
|
||||
typeRecordNumber + " at " + address);
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DataType dataType = applier.getDataType();
|
||||
// Since we know the applier is an AbstractionFunctionTypeApplier, then dataType is either
|
||||
// FunctionDefinition or no type (typedef).
|
||||
if (dataType instanceof FunctionDefinition) {
|
||||
if (!(dataType instanceof FunctionDefinition)) {
|
||||
return false;
|
||||
}
|
||||
FunctionDefinition def = (FunctionDefinition) dataType;
|
||||
ApplyFunctionSignatureCmd sigCmd =
|
||||
new ApplyFunctionSignatureCmd(address, def, SourceType.IMPORTED);
|
||||
|
@ -325,7 +337,6 @@ public class FunctionSymbolApplier extends MsSymbolApplier {
|
|||
" due to " + sigCmd.getStatusMsg() + "; dataType: " + def.getName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue