mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2026-05-30 07:09:41 +08:00
Merge remote-tracking branch 'origin/GP-6465_ExternalThunkFunction' into 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
|
* 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
|
* external function which can be thunked. This may be necessary when a loaded symbol
|
||||||
* loaded symbol failed to identify itself as a function. This will
|
* failed to identify itself as a function.
|
||||||
* only handle single symbols contained within the global namespace.
|
* <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 program the program
|
||||||
* @param entry function being created
|
* @param entry function being created
|
||||||
@@ -696,10 +698,29 @@ public class CreateThunkFunctionCmd extends BackgroundCommand<Program> {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
ExternalManager extMgr = program.getExternalManager();
|
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
|
s.delete(); // remove original symbol from EXTERNAL block
|
||||||
return extLoc.getExternalSpaceAddress();
|
|
||||||
|
return externalSymbol.getAddress();
|
||||||
}
|
}
|
||||||
catch (DuplicateNameException | InvalidInputException e) {
|
catch (DuplicateNameException | InvalidInputException e) {
|
||||||
// ignore - unexpected
|
// ignore - unexpected
|
||||||
|
|||||||
Reference in New Issue
Block a user