mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-21 21:15:25 +08:00
Merge remote-tracking branch 'origin/patch'
This commit is contained in:
+28
-7
@@ -669,10 +669,12 @@ public class CreateThunkFunctionCmd extends BackgroundCommand<Program> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle conversion of label within reserved EXTERNAL block to a real
|
||||
* external function which can be thunked. This may be necessary when a
|
||||
* loaded symbol failed to identify itself as a function. This will
|
||||
* only handle single symbols contained within the global namespace.
|
||||
* Facilitates conversion of a global label within the reserved EXTERNAL block to an
|
||||
* external function which can be thunked. This may be necessary when a loaded symbol
|
||||
* failed to identify itself as a function.
|
||||
* <p>
|
||||
* NOTE: If a suitable External symbol is found or created the original symbol for the
|
||||
* thunk function will be removed.
|
||||
*
|
||||
* @param program the program
|
||||
* @param entry function being created
|
||||
@@ -696,10 +698,29 @@ public class CreateThunkFunctionCmd extends BackgroundCommand<Program> {
|
||||
}
|
||||
try {
|
||||
ExternalManager extMgr = program.getExternalManager();
|
||||
ExternalLocation extLoc =
|
||||
extMgr.addExtFunction(Library.UNKNOWN, s.getName(), null, s.getSource());
|
||||
|
||||
Symbol externalSymbol = null;
|
||||
for (Symbol symbol : symbolTable.getSymbols(s.getName())) {
|
||||
// Only consider external symbols directly in a Library root Namespace
|
||||
if (!symbol.isExternal() || !symbol.getParentNamespace().isLibrary()) {
|
||||
continue;
|
||||
}
|
||||
if (externalSymbol != null) {
|
||||
// multiple ambiguous external symbols - can't decide
|
||||
return null;
|
||||
}
|
||||
externalSymbol = symbol;
|
||||
}
|
||||
|
||||
if (externalSymbol == null) {
|
||||
ExternalLocation extLoc =
|
||||
extMgr.addExtFunction(Library.UNKNOWN, s.getName(), null, s.getSource());
|
||||
externalSymbol = extLoc.getSymbol();
|
||||
}
|
||||
|
||||
s.delete(); // remove original symbol from EXTERNAL block
|
||||
return extLoc.getExternalSpaceAddress();
|
||||
|
||||
return externalSymbol.getAddress();
|
||||
}
|
||||
catch (DuplicateNameException | InvalidInputException e) {
|
||||
// ignore - unexpected
|
||||
|
||||
Reference in New Issue
Block a user